<!--
  @description:不合格供应商加入/移除审核
  @Modifier:齐若帆
  @routerPath:
  @date:2020/9/17-14:27
-->
<template>
  <div>
    <el-dialog
      v-dialogDrag
      :visible.sync="dialog"
      :close-on-click-modal="false"
      :title="headTitle"
      width="960px"
      custom-class="el-dialog__body-p0"
    >
      <section class="p0-16">
        <div class="crud_menu_title clearfix">
          <table class="tableData mb10 main">
            <tr>
              <td>供应商名称</td>
              <td>{{ rowReviewInfo.supplierName }}</td>
              <td>{{ statusOrOpinion }}</td>
              <td>{{ rowReviewInfo.punishIdea }}</td>
            </tr>
            <tr>
              <td>淘汰原因</td>
              <!-- 不合格供应商淘汰原因-->
              <td colspan="3">
                {{ rowReviewInfo.freezingReasons }}
              </td>
            </tr>
            <tr>
              <td>处罚时间期限（月）</td>
              <td colspan="3">
                {{ rowReviewInfo.punishTime }}
              </td>
            </tr>
            <tr>
              <td>事件说明</td>
              <td colspan="3">
                {{ rowReviewInfo.remarks }}
              </td>
            </tr>
            <tr>
              <td>附件</td>
              <td colspan="3">
                <downloadFile />
              </td>
            </tr>
            <tr>
              <td>审核意见</td>
              <td colspan="3">
                <el-input
                  v-model="formData.auditReason"
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  type="textarea"
                />
              </td>
            </tr>
          </table>
          <!--操作按钮-->
          <div class="but_footer">
            <div class="but_footer-h">
              <div class="but_footer-but">
                <el-button :loading="confirmLoading" type="primary" @click="handleAudit('01')">
                  审批通过
                </el-button>
                <el-button :loading="confirmLoading" @click="handleAudit('02')">
                  审批不通过
                </el-button>
              </div>
            </div>
          </div>
        </div>
      </section>
    </el-dialog>
  </div>
</template>
<script>
/* api*/
import { queryBlacklistAuditInfo, updateAuditBlacklistInfo } from '@/api/supplier/supplierUnqualified.js'
import downloadFile from '@comp/common/updownload/downloadFile' // 获取附件信息 下载组件
import {
  filterDictText
} from '@/assets/js/utils'

export default {
  name: 'ReviewUnqualifiedDetail',
  components: {
    downloadFile // 文件下载
  },
  props: {
    headTitle: {
      type: String,
      default() {
      }
    }
  },
  data() {
    return {
      title: '',
      statusOrOpinion: '', // 加入：处罚意见（ 01:暂停合格供应商资格 02:取消合格供应商资格）；移除：当前状态
      TimeOrRemarks: '', // 加入：处罚时间期限；移除：移除原因
      confirmLoading: false,
      dialog: false, // 弹窗状态 false 关闭 true 打开
      formData: {
        auditReason: ''
      },
      uploadData: {
        bizId: ''
      },
      rowReviewInfo: {}
    }
  },
  methods: {
    filterDictText,
    // 打开弹框
    openDialog(rowData) {
      this.dialog = true // 打开弹框
      this.auditGetOrderDetail(rowData.bizId) // 获取订单详情
      if (this.title === '不合格供应商(加入)') {
        this.statusOrOpinion = '处罚意见'
      } else {
        this.statusOrOpinion = '当前状态'
      }
    },
    // 获取订单详情
    auditGetOrderDetail(id) {
      queryBlacklistAuditInfo(id).then(res => {
        this.rowReviewInfo = res.data.data
        console.log(this.rowReviewInfo)
      }).catch(() => {
      })
    },
    // 审核通过/不通过
    handleAudit(auditStatus) {
      const params = {
        auditReason: this.auditReason, // 审批意见
        auditStatus: auditStatus, // 审批状态 02驳回,01通过
        orderId: this.rowOrderInfo.orderId // 订单id
      }
      updateAuditBlacklistInfo(params).then(res => {
        this.$message.success(res.header.msg)
        this.dialog = false // 关闭弹框
        this.$emit('loadData', {
          pageNo: 1,
          pageSize: 10
        })
      }).catch(() => {
      })
    }
  }
}
</script>
<style lang="less" scoped>
</style>
