<!--
  @description: CA管理-CA缴费确认审核
  @Modifier:肖文龙
  @routerPath:/caManage/paymentAudit
  @date:2019-12-6 18:03:42
-->
<template>
  <div class="p0-16">
    <!-- 返回 -->
    <section class="title">
      <router-link to="/caManage/confirmPaymentList">
        <i class="iconfont icon-fanhui pointer" />
      </router-link>
      CA财务详情
    </section>
    <!--信息-->
    <table class="tableData">
      <tr>
        <td>单位名称</td>
        <td>{{ tableData.title }}</td>
        <td>CA类型</td>
        <td>{{ tableData.caType=='00'?'单位身份证书':'个人数字证书' }}</td>
      </tr>
      <tr>
        <td>缴费金额（元）</td>
        <td>{{ tableData.buyersLinkerTel }}</td>
        <td>缴费时间</td>
        <td>{{ tableData.PayData }}</td>
      </tr>
      <tr>
        <td>服务类型</td>
        <td>{{ tableData.serviceType=='00'?'证书办理':'证书延期' }}</td>
        <td>审核状态</td>
        <td>{{ tableData.auditStatus=='00'?'审核通过':'审核不通过' }}</td>
      </tr>
      <tr>
        <td>审核意见</td>
        <td>
          <el-form ref="batch" :model="batch" :rules="rules">
            <el-form-item ref="auditOpinion" prop="auditOpinion" class="auditOpinion">
              <el-input v-model="batch.auditOpinion" type="textarea" placeholder="请输入审核意见" />
            </el-form-item>
          </el-form>
        </td>
        <td>支付凭证</td>
        <td>
          <img src="http://pic1.nipic.com/2008-08-14/2008814183939909_2.jpg" class="paymentVoucher">
        </td>
      </tr>
    </table>
    <div class="page-bottom-btn" style="padding: 20px;">
      <el-button type="primary" @click="verified('batch')">
        审核通过
      </el-button>
      <el-button @click="auditFail('batch')">
        审核不通过
      </el-button>
    </div>
  </div>
</template>

<script>
import { getSublist } from '@/api/purchase/purchaseMain'
export default {
  name: 'PaymentAuditDetail',
  components: {},
  data() {
    return {
      title: '',
      // 发票信息
      tableData: {
        serialNumber: '', // 流水号
        applicantUnit: '', // 申请单位
        applicationData: '', // 申请时间
        AuditData: '', // 审核时间
        caType: '', // CA类型
        serviceType: '', // 服务类型
        paymentMode: '', // 支付方式
        PayData: '', // 缴费时间
        billingStatus: '', // 开票状态
        specialTicket: '', // 是否专票
        mobilePhone: '', // 移动电话
        refund: '', // 退款
        invoice: '', // 发票号码
        invoiceCode: '', // 发票代码
        invoiceVerificationCode: '', // 发票验证码
        electronicsMail: '', // 电子邮箱
        region: '', // 地区
        invoiceMethod: '', // 开票方式
        operation: '', // 操作
        id: '', //
        paymenAamount: '', // 缴费金额
        unitMin: '', // 单位名称
        paymentVoucher: '', // 支付凭证
        auditStatus: '' // 审核状态
      },
      // 物料信息分页
      totalPage: 0, // 长度
      pageNo: 1, // 页数
      pageSize: 10, // 每条页数
      bottom: 0, // padding值
      rules: {
        auditOpinion: [
          {
            required: true,
            message: '请输入审核意见',
            trigger: 'blur'
          }
        ]
      },
      batch: {
        auditFlag: '', // 01-审核通过 ||02-审核不通过
        auditOpinion: '', // 审核意见
        ids: []
      }
    }
  },
  mounted() {
    const projectId = this.$route.query.id
    // 初始化项目信息
    getSublist(projectId).then(response => {
      // ==============初始化===================
      // 采购项目信息
      this.tableData = response.data.tbpurchaseMainEntityVO
      // 物料类型
      if (response.data.tbpurchaseMainEntityVO.materialType === '00') {
        this.tableData.materialType = '现货/标准品'
      } else if (response.data.tbpurchaseMainEntityVO.materialType === '01') {
        this.tableData.materialType = '加工/定制品'
      } else {
        this.tableData.materialType = '服务'
      }
      // 订单类型
      if (response.data.tbpurchaseMainEntityVO.orderType === '00') {
        this.tableData.orderType = '标准订单(单次采购)'
      } else {
        this.tableData.orderType = '价格协议(长期采购)'
      }
      // 组织形式
      if (response.data.tbpurchaseMainEntityVO.orgMethod === '00') {
        this.tableData.orgMethod = '自行采购'
      } else {
        this.tableData.orgMethod = '委托代理机构采购'
      }
      // 采购方式
      if (response.data.tbpurchaseMainEntityVO.purchaseType === '00') {
        this.tableData.purchaseType = '一次询价'
      } else if (response.data.tbpurchaseMainEntityVO.purchaseType === '01') {
        this.tableData.purchaseType = '竞价'
      } else {
        this.tableData.purchaseType = '二次询价'
      }
    })
  },
  methods: {
    // 审核通过
    verified(batch) {
      this.batch.auditFlag = '01'
      this.$message({
        type: 'success',
        message: '审核成功'
      })
      this.is_batch = false
    },
    // 审核不通过
    auditFail(batch) {
      this.$refs[batch].validate((valid, field) => {
        if (valid) {
          this.batch.auditFlag = '02'
          // 						this.$message({
          // 							type: 'success',
          // 							message: '审核成功'
          // 						});
          // 						auditTBPurchaseMain(this.batch).then(reponse => {
          //
          // 							this.reload();
          // 						}).catch(res => {
          //
          // 						});
          this.is_batch = false
        } else {
          this.$message({
            type: 'warning',
            message: '请输入审核意见'
          })
          if (this.$refs[batch].$el.getElementsByTagName('input').length > 0) {
            this.is_batch = true
          }
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
