<!--
  @description: 保证金凭证审核-弹框
  @Modifier: 肖文龙
  @routerPath:
  @date: 2021-01-04
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialog"
    :close-on-click-modal="false"
    title="确认保证金凭证"
    append-to-body
    width="960px"
    custom-class="el-dialog__body-p0"
  >
    <!--查询列表-->
    <div class="main mb10">
      <table class="tableData">
        <tr class="singleRow">
          <td class="page-title" colspan="4">
            缴纳基本信息
          </td>
        </tr>
        <tr>
          <td>招标项目编号</td>
          <td colspan="3">
            {{ fromData.tenderNo }}
          </td>
        </tr>
        <tr>
          <td>招标项目名称</td>
          <td colspan="3">
            {{ fromData.tenderName }}
          </td>
        </tr>
        <tr>
          <td>标段（包）编号</td>
          <td colspan="3">
            {{ fromData.packNo }}
          </td>
        </tr>
        <tr>
          <td>标段（包）名称</td>
          <td colspan="3">
            {{ fromData.packName }}
          </td>
        </tr>
        <tr>
          <td>投标人名称</td>
          <td colspan="3">
            {{ fromData.supplierName }}
          </td>
        </tr>
        <tr>
          <td>凭证附件</td>
          <td colspan="3">
            <downloadFile ref="downloadFile" :data="bailfeeVoucherData" />
          </td>
        </tr>
        <tr class="singleRow">
          <td class="page-title" colspan="4">
            审核意见
          </td>
        </tr>
        <tr>
          <td>审核意见</td>
          <td colspan="3">
            <el-input
              v-model="auditReason"
              :autosize="{ minRows: 4, maxRows: 4 }"
              type="textarea"
            />
          </td>
        </tr>
      </table>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button :loading="confirmLoading" type="primary" @click="handleAudit('01')">
        审核通过
      </el-button>
      <el-button :loading="confirmLoading" @click="handleAudit('02')">
        审核不通过
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
/* 接口*/
import { auditBailFeeInfo } from '@api/fee/bailfee'
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
/* 混入 */
import { cashDepositMixin } from '../mixins/cashDepositMixin.js'// 附件类型
/* 组件 */
import downloadFile from '@comp/common/updownload/downloadFile'
export default {
  name: 'BailfeeVoucherAuditDialog',
  components: {
    downloadFile// 文件下载
  },
  mixins: [cashDepositMixin],
  data() {
    return {
      confirmLoading: false,
      dialog: false, // 是否打开弹框
      auditReason: '', // 审批意见
      // 保证金凭证信息
      fromData: {
        fileId: '', // 附件业务主键id
        guaranteeId: '', // 保证金凭证id
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        packNo: '', // 标段编号
        packName: '', // 标段名称
        supplierName: '' // 投标人名称
      }
    }
  },
  methods: {
    filterDictText,
    // 打开弹框
    open(fromData) {
      this.dialog = true // 打开弹框
      this.fromData = fromData // 保证金凭证信息
      this.bailfeeVoucherData.bizId = fromData.fileId // 附件业务主键id
    },
    // 审核通过/不通过
    handleAudit(auditStatus) {
      const auditText = auditStatus === '01' ? '通过' : '不通过'
      this.$confirm(`确定${auditText}吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        const params = {
          auditReason: this.auditReason, // 审批意见
          auditStatus: auditStatus, // 审批状态 02驳回,01通过
          guaranteeId: this.fromData.guaranteeId // 保证金凭证id
        }
        auditBailFeeInfo(params).then(res => {
          this.$message.success(res.header.msg)
          this.auditReason = ''// 审批意见
          this.dialog = false // 关闭弹框
          this.$emit('loadData', {
            pageNo: 1,
            pageSize: 10
          })
        }).catch(() => {
        })
      }).catch(() => {})
    }
  }
}
</script>

<style scoped lang="less">
  .tableData tr td:nth-child(odd){
    width: 10%;
  }
</style>
