<!--
  @description: 代理机构-项目管理-确定资审结果通知书
  @author: 肖文龙/haoFx
  @routerPath:/bidding/projectDrive/calibration/confirmQualifiedResult
  @date:2019-11-21 10:35:27
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <div class="main">
    <section v-if="tenderBase.isCanOperate" class="clearfix mb16">
      <div class="fr">
        <el-button
          :disabled="isSendData.isWinBiddingNoticeStatus==='01'"
          type="primary"
          @click="sendZsNotice('01')"
        >
          发送资格预审合格通知书
        </el-button>
        <el-button
          :disabled="isSendData.resultNoticeStatus==='01'"
          type="primary"
          @click="sendZsNotice('00')"
        >
          发送资格预审结果通知书
        </el-button>
      </div>
    </section>
    <!--供应商列表-->
    <section>
      <el-table
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="60"
        />
        <el-table-column
          header-align="center"
          prop="supplierName"
          label="投标供应商"
          min-width="210"
        />
        <el-table-column
          prop="linknNme"
          label="联系人"
          align="center"
          width="80"
        />
        <el-table-column
          prop="linkerTel"
          label="联系电话"
          align="center"
        />
        <el-table-column
          prop="isWinBiding"
          label="是否合格"
          align="center"
          width="90"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.isWinBiding === '00'" class="status2">否</span>
            <span v-else-if="scope.row.isWinBiding === '01'" class="status1">是</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="sendTime"
          label="发送时间"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.sendTime && $Moment(scope.row.sendTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="receiveTime"
          label="查看通知书时间"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.receiveTime && $Moment(scope.row.receiveTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="auditStatus"
          label="审核状态"
          align="center"
        >
          <template slot-scope="scope">
            {{ filterDictText(auditStatusOptions,scope.row.auditStatus) }}
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          width="230"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              v-if="scope.row.isWinBiding === '00' && isSendData.resultNoticeStatus === '01'"
              type="primary"
              @click="see(scope.row,'00')"
            >
              [查看资格预审结果通知书]
            </el-link>
            <el-link
              v-if="scope.row.isWinBiding === '01' && isSendData.isWinBiddingNoticeStatus === '01'"
              type="primary"
              @click="see(scope.row,'01')"
            >
              [查看资格预审合格通知书]
            </el-link>
            <template v-if="letterAcceptanceConfigType">
              <el-link
                v-if="scope.row.auditStatus"
                type="primary"
                @click="handleDetail(scope.row.id)"
              >
                [流程追踪]
              </el-link>
            </template>
          </template>
        </el-table-column>
      </el-table>
    </section>
    <!--流程追踪查看弹框-->
    <flow-detail-dialog ref="tracingFlow" />
  </div>
</template>

<script>
/* api*/
import { queryZsNoticePages, getZsNoticeStatus } from '@/api/bidding/bidCalibration'
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
import { initGroupMixin } from '@/mixins/initGroupMixin' // 公共审核状态字典数据
import { filterDictText } from '@/assets/js/utils' // 匹配字典值
export default {
  name: 'ConfirmQualifiedResult',
  components: {
    flowDetailDialog
  },
  mixins: [initGroupMixin],
  data() {
    return {
      letterAcceptanceConfigType: false, // true启动工作流 false普通审核
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      loading: true,
      packInfo: this.$store.getters.packInfo, // 标包信息-当前
      isSendData: {
        resultNoticeStatus: '00', // 是否发送了资格预审结果通知书  00:未发送 01:已发送
        isWinBiddingNoticeStatus: '00'// 是否发送了资格预审合格通知书  00:未发送 01:已发送
      },
      tableData: []
    }
  },
  created() {
    // 根据键获取正式配置
    this.$store.dispatch('getSystemConfigValue', 'zsNotice-audit-config').then(() => {
      this.letterAcceptanceConfigType = this.$store.getters.systemConfigVo.configType // true启动工作流 false普通审核
    }).catch(() => {
    })
    this.isSend()
    this.getZsNoticeSupplierList()
  },
  methods: {
    filterDictText,
    // 初始化供应商信息
    getZsNoticeSupplierList() {
      const data = {
        stageId: this.packInfo.stageId
      }
      queryZsNoticePages(data).then(res => {
        this.tableData = res.data
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    // 是否已发送 入围通知书-是否已发送结果通知书
    isSend() {
      const stageId = this.packInfo.stageId
      getZsNoticeStatus(stageId).then(res => {
        this.isSendData = res.data
      }).catch(() => {

      })
    },
    // 发送资审合格通知书或资审结果通知书
    sendZsNotice(type) {
      let path = ''
      if (type === '01') { // 合格通知书
        path = '/bidding/projectDrive/calibration/prequalificationNoticeDetail'
      } else { // 00 结果通知书
        path = '/bidding/projectDrive/calibration/prequalificationResultNoticeDetail'
      }
      this.$router.push({
        path: path,
        query: {
          ...this.$route.query
        }
      })
    },
    // 资审通知书查看
    see(row, type) {
      // 00 否 结果通知书 01 是合格通知书
      if (type === '00') {
        this.$router.push({
          path: '/bidding/projectDrive/calibration/zsNotificationResultsPdfDetail',
          query: {
            ...this.$route.query,
            noticeId: row.id
          }
        })
      } else {
        // 01 是合格通知书
        this.$router.push({
          path: '/bidding/projectDrive/calibration/zsNotificationConformityPdfDetail',
          query: {
            ...this.$route.query,
            noticeId: row.id
          }
        })
      }
    },
    // 流程追踪详情
    handleDetail(id) {
      this.$refs.tracingFlow.openDialogInitData(id)
    }
  }
}
</script>

<style scoped lang="less">

</style>
