<!--
  @description: 标书费审核弹框
  @Modifier: haofengxian
  @routerPath:
  @date: 2020-9-1-16:41
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="docPayVisible"
    :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>
          <td class="page-title" colspan="4">
            缴纳基本信息
          </td>
        </tr>
        <tr>
          <td>缴费的项目/标段（包）</td>
          <td colspan="3">
            {{ rowOrderInfo.tenderName }}
          </td>
        </tr>
        <tr>
          <td>缴费金额（元）</td>
          <td>{{ orderDetailVo.payPrice }}</td>
          <td>缴费时间</td>
          <td>{{ orderDetailVo.createTime }}</td>
        </tr>
        <tr>
          <td>缴费方式</td>
          <td colspan="3">
            {{ filterDictText(payTypeList, orderDetailVo.payType) }}
          </td>
        </tr>
        <tr>
          <td>审核状态</td>
          <td colspan="3">
            {{ filterDictText(auditStatusOptions, rowOrderInfo.auditStatus) }}
          </td>
        </tr>
        <tr>
          <td>缴费凭证</td>
          <td colspan="3">
            <downloadFile ref="downloadFile" :data="upLoadData" />
          </td>
        </tr>
        <tr>
          <td class="page-title" colspan="4">
            开票信息
          </td>
        </tr>
        <tr>
          <td>发票抬头</td>
          <td colspan="3">
            {{ orderDetailVo.invoiceInfo.invoiceTitle }}
          </td>
        </tr>
        <tr>
          <td>发票类型</td>
          <td>
            {{ filterDictText(invoiceTypeList, orderDetailVo.invoiceInfo.invoiceType) }}
          </td>
          <td>纳税人识别号</td>
          <td>{{ orderDetailVo.invoiceInfo.taxpayerIdentificationNumber }}</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 { getOrderDetail, auditDocfee } from '@api/fee/docfee'
import { TenderFeeGroupMixin } from '../mixins/tenderFeeGroupMixin'
import downloadFile from '@comp/common/updownload/downloadFile'
export default {
  name: 'DocPayAuditDialog',
  components: {
    downloadFile// 文件下载
  },
  mixins: [TenderFeeGroupMixin],
  data() {
    return {
      confirmLoading: false,
      docPayVisible: false, // 是否打开弹框
      rowOrderInfo: {}, // 订单信息
      auditReason: '', // 审批意见
      // 订单详情
      orderDetailVo: {
        invoiceInfo: {
          invoiceTitle: '', // 发票类型(00:普票,01:专票)
          invoiceType: '' // 发票抬头
        },
        payPrice: '', // 订单支付金额
        payTime: '', // 支付时间(完成支付时间)
        payType: '' // 缴纳方式 01线上支付 02线下支付
      },
      // 获取缴纳凭证参数
      upLoadData: {
        bizId: '', // 业务主键Id
        fileType: 'docfeePayFile'// 文件类型
      }
    }
  },
  methods: {
    // 打开弹框
    openDocPayAuditDialog(rowOrderInfo) {
      this.docPayVisible = true // 打开弹框
      this.rowOrderInfo = rowOrderInfo // 订单信息
      this.upLoadData.bizId = rowOrderInfo.orderId // 订单id
      this.auditGetOrderDetail() // 获取订单详情
    },
    // 获取订单详情
    auditGetOrderDetail() {
      getOrderDetail({ orderNo: this.rowOrderInfo.orderNo }).then(res => {
        this.orderDetailVo = res.data
      }).catch(() => {
      })
    },
    // 审核通过/不通过
    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通过
          orderId: this.rowOrderInfo.orderId // 订单id
        }
        auditDocfee(params).then(res => {
          this.$message.success(res.header.msg)
          this.docPayVisible = false // 关闭弹框
          this.$emit('loadData', {
            pageNo: 1,
            pageSize: 10
          })
        }).catch(() => {
        })
      }).catch(() => {})
    }
  }
}
</script>

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