<!--
  @description: 联系人信息-报名情况-审核
  @Modifier: sxm/wxy
  @routerPath:supplierResponse/contactInfoAdd
  @date: 2020-6-3 15:24:31
-->
<template>
  <div class="p0-16">
    <p class="page-title">
      1、参与项目情况
    </p>
    <table class="tableData">
      <tr>
        <td>参与家数</td>
        <td>
          {{ signUpCountVo.totalCount }}
        </td>
        <td>待审核</td>
        <td>{{ signUpCountVo.pendingAuditsCount }}</td>
      </tr>
      <tr>
        <td>审核通过</td>
        <td>{{ signUpCountVo.auditPassCount }}</td>
        <td>审核不通过</td>
        <td>{{ signUpCountVo.auditNoPassCount }}</td>
      </tr>
    </table>
    <p class="page-title">
      2、参与供应商列表
    </p>
    <div style="padding:10px 0">
      <el-button type="primary" @click="patchAuditIs">
        批量审核
      </el-button>
      <el-button @click="exportSignUpList">
        导出名单
      </el-button>
    </div>
    <section>
      <el-table
        ref="smallTable"
        :data="tableData"
        @selection-change="patchAudit"
      >
        <el-table-column
          :selectable="checkboxT"
          type="selection"
          width="55"
        />
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="60"
        />
        <el-table-column
          align="left"
          label="单位名称"
          header-align="center"
          prop="supplierName"
        />
        <el-table-column
          align="center"
          width="160"
          label="联系人"
          header-align="center"
          prop="linker"
        />
        <el-table-column
          align="center"
          label="联系电话"
          header-align="center"
          prop="linkerTel"
        />
        <el-table-column
          align="center"
          label="邮箱"
          header-align="center"
          prop="linkerEmail"
        />
        <el-table-column
          align="center"
          label="报名时间"
          header-align="center"
          prop="applyTime"
        />
        <el-table-column
          align="center"
          prop="auditStatus"
          label="审核状态"
          header-align="center"
        >
          <template slot-scope="scope">
            <!-- 判断审核状态 00未审核  01审核通过  02审核未通过 -->
            <span v-if="scope.row.auditStatus === '00'">未审核</span>
            <span v-else-if="scope.row.auditStatus === '01'">审核通过</span>
            <span v-else>审核不通过</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="操作"
          header-align="center"
        >
          <template slot-scope="scope">
            <el-link v-if="scope.row.auditStatus!=='00'" type="primary" @click.stop="view(scope.row)">
              [查看]
            </el-link>
            <el-link v-else type="primary" @click.stop="audit(scope.row)">
              [审核]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </section>
    <!--分页组件-->
    <pagination :pagination-data="paginationData" />
  </div>
</template>

<script>
/* 接口*/
import { connectionSignUpMessage, exportSignUpList } from '@/api/procurement/procurementSignup'// 获取联系人信息
/* 公共方法 */
import { download } from '@/assets/js/utils/index'
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'ContactInfoAdd',
  inject: ['getTenderBase'],
  components: {
    pagination // 分页
  },
  filters: {
    filterStatus(val) {
      let text = ''
      switch (val) {
        case '00':
          text = '待审核'
          break
        case '01':
          text = '审核通过'
          break
        case '02':
          text = '不通过'
          break
      }
      return text
    }
  },
  mixins: [],
  props: {

  },
  data() {
    return {
      tableData: [], // 邀请供应商列表
      signUpCountVo: {},
      serchForm: {
        pageNo: 1,
        pageSize: 10,
        packId: ''
      },
      paginationData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      },
      multipleSelection: [], // 批量审核 选中记录存放数组
      dialogData: { // 批量审核-弹框
        dialog: false
      },
      signUpIds: '', // 多个报名id以,隔开拼接的字符串
      tenderBase: this.getTenderBase() // 获取项目信息
    }
  },
  created() {
    this.serchForm.packId = this.tenderBase.packId
    this.initData(this.serchForm)// 查询联系人信息
  },
  methods: {
    // 查询联系人信息
    initData(serchForm) {
      connectionSignUpMessage(serchForm).then(response => {
        if (response.header.ret === '0') {
          this.signUpCountVo = { ...response.data.signUpCountVo }
          this.tableData = [...response.data.signUpList.records]
        }
      }).catch(() => {
      })
    },
    // 批量审核选择
    patchAudit(val) {
      this.multipleSelection = val
    },
    // 批量审核弹框
    patchAuditIs() {
      if (!this.multipleSelection.length) {
        this.$message({
          type: 'warning',
          message: '请选择需要审核的数据'
        })
      } else {
        const arr = []
        this.dialogData.dialog = true
        this.multipleSelection.forEach(val => {
          arr.push(val.id)
        })
        if (arr.length > 1) {
          this.signUpIds = arr.join(',')
        } else {
          this.signUpIds = arr[0]
        }
        this.initData(this.serchForm)
      }
    },
    // 审核
    audit(val) {
      this.$router.push({
        path: '/procurement/procurementDrive/supplierResponse/contactInfoAudit',
        query: { data: val }
      })
    },
    // 查看
    view(val) {
      this.$router.push({
        path: '/procurement/procurementDrive/supplierResponse/contactInfoAuditList',
        query: { data: val }
      })
    },
    // 只有待审核状态的复选框才可以勾选
    checkboxT(row, index) {
      if (row.auditStatus === '00') {
        return 1
      } else {
        return 0
      }
    },
    // 导出名单
    exportSignUpList() {
      exportSignUpList(this.$route.query.packId).then(res => {
        download(res, '名单.xlsx')
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
