<!--
  @description: 审核中服务费
  @Modifier: haofengxian
  @routerPath:
  @date: 2021-3-10-9:58
-->
<template>
  <div>
    <el-table
      ref="smallTable"
      v-loading="loading"
      :data="tableData"
    >
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="60"
      />
      <el-table-column
        prop="orderCode"
        label="单号"
        header-align="center"
        align="center"
        width="180"
      />
      <el-table-column
        :formatter="formatterOrderTotalMoney"
        prop="money"
        label="服务费收取金额(元)"
        min-width="180"
        header-align="center"
        align="right"
      />
      <el-table-column
        prop="supplierName"
        label="供应商名称"
        header-align="center"
        align="left"
        min-width="220"
      />
      <el-table-column
        :formatter="formatterSkType"
        prop="skType"
        label="类型"
        min-width="120"
        header-align="center"
        align="left"
      />
      <!--00 待审核、01 审核通过 02 审核不通过-->
      <el-table-column
        :formatter="formatterAuditStatus"
        prop="auditStatus"
        label="状态"
        min-width="120"
        header-align="center"
        align="center"
      />
      <el-table-column
        label="操作"
        width="180"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          <template v-if="isShowBtn">
            <el-link
              v-if="scope.row.auditStatus==='02' && (!scope.row.isRemove || scope.row.isRemove==='0')"
              type="primary"
              @click.stop="cancel(scope.row)"
            >
              [取消]
            </el-link>
          </template>
          <el-link type="primary" @click.stop="particulars(scope.row)">
            [详情]
          </el-link>
          <el-link
            v-if="scope.row.auditStatus!=='02' && scope.row.isRemove"
            type="primary"
            @click="handleDetail(scope.row.bizId)"
          >
            [流程追踪]
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <!--详情-->
    <serviceChargeDetailDialog ref="serviceChargeDetail" />
    <!--流程追踪查看弹框-->
    <flow-detail-dialog ref="tracingFlow" />
  </div>
</template>

<script>
/* api*/
import { cancelPayeeSingle, cancelPayeeSingleExcep } from '@/api/procurement/procurementOrder'
import { orderServeFeeMixins } from '../../mixins/orderServeFeeMixins'
import serviceChargeDetailDialog from '../procurementOrderServeFeeReceive/serviceChargeDetail-dialog'
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
export default {
  name: 'ServiceFeeProcessAuditTableComp',
  components: {
    flowDetailDialog, // 流程追踪组件
    serviceChargeDetailDialog // 查看详情弹框
  },
  mixins: [orderServeFeeMixins],
  props: {
    loading: {
      type: Boolean,
      default: function() {
        return {}
      }
    },
    tableData: {
      type: Array,
      default: function() {}
    },
    // 是否显示操作列按钮
    isShowBtn: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
    }
  },
  methods: {
    // 取消
    cancel(row) {
      // 收款单类型(00:收款单 01:减免收款单 02: 异常缴纳管理订单 03:异常缴纳处理)
      this.$confirm('确定取消？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        if (row.skType === '00' || row.skType === '01' || row.skType === '02') {
          this.handleCancelPayeeSingle(row)
        }
        if (row.skType === '03') {
          this.handleCancelPayeeSingleExcep(row)
        }
      }).catch(() => {
      })
    },
    // 审核不通过取消收款单 并释放该 收款单下的 服务单
    handleCancelPayeeSingle(row) {
      const params = {
        recordId: row.id, // 异常缴纳ID(收款单类型为 异常 的情况下需要传)
        skType: row.skType, // 收款单类型(00:收款单 01:减免收款单 02: 异常缴纳管理订单 03:异常缴纳处理)
        voucherId: row.bizId // 收款单ID
      }
      cancelPayeeSingle(params).then(res => {
        this.$emit('close')
        this.$message.success('操作成功')
      }).catch(() => {
      })
    },
    // 审核不通过取消 业务类型：异常缴纳处理
    handleCancelPayeeSingleExcep(row) {
      const params = {
        recordId: row.bizId, // 异常缴纳ID(收款单类型为 异常 的情况下需要传)
        skType: row.skType, // 收款单类型(00:收款单 01:减免收款单 02: 异常缴纳管理订单 03:异常缴纳处理)
        voucherId: '' // 收款单ID
      }
      cancelPayeeSingleExcep(params).then(res => {
        this.$emit('close')
        this.$message.success('操作成功')
      }).catch(() => {
      })
    },
    // 详情
    particulars(row) {
      this.$refs.serviceChargeDetail.openDialogDetail(row, '00')
    },
    // 流程追踪详情
    handleDetail(id) {
      this.$refs.tracingFlow.openDialogInitData(id)
    }
  }
}
</script>

<style scoped>

</style>
