<!--
  @description:招标项目/采购项目-合同签订详情
  @Modifier:zyy
  @routerPath:bidding/calibration/bidContractSigning
  @date:2021/4/21-17:52
-->
<template>
  <div :key="contractSource">
    <section v-if="$route.meta.type !== 'audit'" class="title p0-16 clearfix">
      <template>
        <div class="title-back pointer" @click="back">
          <i class="iconfont icon-fanhui mr10" />合同签订
        </div>
      </template>
    </section>
    <div class="p0-16">
      <table class="tableData">
        <tr>
          <td colspan="4" style="background: #fff;border:none">
            <div class="page-title" style="display: inline-block">
              1.采购单信息
            </div>
          </td>
        </tr>
      </table>
      <div>
        <el-table
          ref="singleTable"
          :data="formData.orderSaveDtoList"
          class="pointer"
          highlight-current-row
          size="mini"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            align="center"
            prop="orderNo"
            label="订单编号"
            min-width="50px"
          />
          <el-table-column
            align="center"
            prop="tenderNo"
            label="采购单编号"
            min-width="50px"
          />
          <el-table-column
            align="center"
            prop="tenderName"
            label="采购单名称"
            min-width="50px"
          />
          <el-table-column
            align="center"
            prop="tenderMethod"
            label="采购方式"
            min-width="50px"
          >
            <template slot-scope="scope">
              {{ filterDictText(tender_methodList, scope.row.tenderMethod) }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderTotalTaxMoney"
            label="订单含税总额"
            min-width="50px"
          />
        </el-table>
      </div>
      <table class="tableData">
        <!--        <tr>-->
        <!--          <td>-->
        <!--            项目编号-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            {{ formData.tenderNo }}-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            {{ contractSource == '00' ? '采购单名称' : '项目名称' }}-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            {{ formData.tenderName }}-->
        <!--          </td>-->
        <!--        </tr>-->
        <!--        &lt;!&ndash;采购才显示项目名称&ndash;&gt;-->
        <!--        <tr v-if="contractSource == '00'">-->
        <!--          <td>-->
        <!--            项目名称-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            {{ formData.purchaseProjectName }}-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            采购方式-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            <template>-->
        <!--              {{ filterDictText(tender_methodList, formData.tenderMethod) }}-->
        <!--            </template>-->
        <!--          </td>-->
        <!--        </tr>-->
        <!--        &lt;!&ndash;采购才显示采购方式&ndash;&gt;-->
        <!--        &lt;!&ndash;<tr v-if="contractSource == '00'">-->
        <!--          <td>-->
        <!--            采购方式-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            <template>-->
        <!--              {{ filterDictText(tender_methodList, formData.tenderMethod) }}-->
        <!--            </template>-->
        <!--          </td>-->
        <!--          <td />-->
        <!--          <td />-->
        <!--        </tr>&ndash;&gt;-->
        <!--        &lt;!&ndash;招标才显示标段信息&ndash;&gt;-->
        <!--        <tr v-if="contractSource == '01'">-->
        <!--          <td>-->
        <!--            标段编号-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            {{ formData.packNo }}-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            标段名称-->
        <!--          </td>-->
        <!--          <td>-->
        <!--            {{ formData.packName }}-->
        <!--          </td>-->
        <!--        </tr>-->
        <tr>
          <td colspan="4" style="background: #fff;border:none">
            <div class="page-title">
              2.合同基本信息
            </div>
          </td>
        </tr>
        <tr>
          <td>
            合同编号
          </td>
          <td>
            {{ formData.contractNo }}
          </td>
          <td>
            合同名称
          </td>
          <td>
            {{ formData.contractName }}
          </td>
        </tr>
        <tr>
          <td>
            合同类型
          </td>
          <td>
            {{ formData.isFocus=='01' ? '框架合同' : '采购合同' }}
          </td>
          <td>
            <span v-if="formData.isFocus!='01'">合同金额(元)</span>
          </td>
          <td>
            <span v-if="formData.isFocus!='01'">{{ formData.contractTotalMoney }}</span>
          </td>
        </tr>
        <!--走集中采购-->
        <tr v-if="formData.isFocus=='01'">
          <td>
            供货期限
          </td>
          <td>
            {{ formData.contractStartTime }} 至 {{ formData.contractEndTime }}
          </td>
          <td>
            交货地址
          </td>
          <td>
            {{ formData.deliveryAddress }}
          </td>
        </tr>
        <tr>
          <td colspan="4" style="background: #fff;border:none">
            <div class="page-title">
              3.合同供方
            </div>
          </td>
        </tr>
        <template v-for="(item, index) in formData.supplyContractPartyVo">
          <tr :key="index+'departName'">
            <td>
              单位名称
            </td>
            <td>
              {{ item.departName }}
            </td>
            <td>
              社会统一信用代码
            </td>
            <td>
              {{ item.unified }}
            </td>
          </tr>
          <tr :key="index+'corporation'">
            <td>
              法定代表人
            </td>
            <td>
              {{ item.corporation }}
            </td>
            <td>
              税号
            </td>
            <td>
              {{ item.taxNo }}
            </td>
          </tr>
          <tr :key="index+'bankName'">
            <td>
              开户行
            </td>
            <td>
              {{ item.bankName }}
            </td>
            <td>
              账号
            </td>
            <td>
              {{ item.bankNo }}
            </td>
          </tr>
          <tr :key="index+'address'">
            <td>
              单位地址
            </td>
            <td colspan="3">
              {{ item.address }}
            </td>
          </tr>
          <tr :key="index+'agent'">
            <td>
              委托代理人
            </td>
            <td>
              {{ item.agent }}
            </td>
            <td>
              电话
            </td>
            <td>
              {{ item.tel }}
            </td>
          </tr>
          <tr :key="index+'bankNo'">
            <td>
              传真
            </td>
            <td>
              {{ item.fax }}
            </td>
            <td>
              邮箱
            </td>
            <td>
              {{ item.mail }}
            </td>
          </tr>
        </template>
        <tr>
          <td colspan="4" style="background: #fff;border:none">
            <div class="page-title">
              4.合同需方
            </div>
          </td>
        </tr>
        <template v-for="(item, index) in formData.demandContractPartyVo">
          <tr :key="index+'demandDepartName'">
            <td>
              单位名称
            </td>
            <td>
              {{ item.departName }}
            </td>
            <td>
              社会统一信用代码
            </td>
            <td>
              {{ item.unified }}
            </td>
          </tr>
          <tr :key="index+'demandCorporation'">
            <td>
              法定代表人
            </td>
            <td>
              {{ item.corporation }}
            </td>
            <td>
              税号
            </td>
            <td>
              {{ item.taxNo }}
            </td>
          </tr>
          <tr :key="index+'demandBankName'">
            <td>
              开户行
            </td>
            <td>
              {{ item.bankName }}
            </td>
            <td>
              账号
            </td>
            <td>
              {{ item.bankNo }}
            </td>
          </tr>
          <tr :key="index+'demandAddress'">
            <td>
              单位地址
            </td>
            <td colspan="3">
              {{ item.address }}
            </td>
          </tr>
          <tr :key="index+'demandAgent'">
            <td>
              委托代理人
            </td>
            <td>
              {{ item.agent }}
            </td>
            <td>
              电话
            </td>
            <td>
              {{ item.tel }}
            </td>
          </tr>
          <tr :key="index+'demandBankNo'">
            <td>
              传真
            </td>
            <td>
              {{ item.fax }}
            </td>
            <td>
              邮箱
            </td>
            <td>
              {{ item.mail }}
            </td>
          </tr>
        </template>
      </table>
      <div class="page-title mt10 mb10">
        5.合同付款条款
      </div>
      <contractPaymentProvisionDetail />
      <div class="page-title mt10 mb10">
        6.合同文件列表
      </div>
      <contractDocumentsDetail />
    </div>
    <!-- 审核状态图片 -->
    <div class="supper_auditStatus">
      <!-- 待审核 -->
      <img v-if="formData.auditStatus==='00'" src="@assets/img/common/audit/auditWait.png" alt="">
      <!-- 审核通过 -->
      <img v-if="formData.auditStatus==='01'" src="@assets/img/common/audit/auditOk.png" alt="">
      <!-- 审核不通过 -->
      <img v-if="formData.auditStatus==='02'" src="@assets/img/common/audit/auditNo.png" alt="">
    </div>
    <!-- <div>
      <div class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <el-button :loading="confirmLoading" @click="next">
              下一页，查看附件
            </el-button>
          </div>
        </div>
      </div>
    </div> -->
    <div v-if="roleCode=='12' && formData.contractStatus=='02'" class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button :loading="confirmLoading" @click="confirm">
            确 认
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
/* 接口*/
import { getBidtCalibrationTenderContractData, confirmContract } from '@/api/contractManagement/index'// 招标项目-编辑初始化数据 招标项目-签订保存
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { procurementGroupMixins } from '@/views/procurement/mixins/procurementGrounpMixins'
/* 组件 */
import contractPaymentProvisionDetail from '../contractPaymentProvision/contractPaymentProvisionSingle-detail.vue' // 合同付款条款
import contractDocumentsDetail from '../contractDocuments/contractDocuments-detail.vue' // 合同文件列表
export default {
  name: 'ContractSigningDetail',
  components: {
    contractPaymentProvisionDetail,
    contractDocumentsDetail
  },
  mixins: [procurementGroupMixins],
  data() {
    return {
      confirmLoading: false,
      contractSource: '', // 合同来源00采购01招标
      id: '', // 合同详情id
      roleCode: '',
      formData: {
        contractStatus: '', // 合同状态
        auditStatus: '', // 合同审批状态
        noticeId: '', // 通知书id
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        tenderId: '', // 项目id
        tenderMethod: '', // 采购方式
        packNo: '', // 标段编号
        packName: '', // 标段名称
        contractNo: '', // 合同编号
        contractName: '', // 合同名称
        contractTotalMoney: '', // 合同金额
        contractPartyVo: {
          /* 供方 */
          supplyDepartName: '', // 中标人名称/供方单位
          supplyDepartId: '', // 供方人id
          supplyUnified: '', // 供方统一社会信用代码
          supplyTel: '', // 供方电话
          supplyCorporation: '', // 供方法人
          supplyBankName: '', // 供方开户行
          supplyMail: '', // 供方邮箱
          supplyAddress: '', // 供方地址
          supplyAgent: '', // 供方代理人
          supplyFax: '', // 供方传真
          supplyBankNo: '', // 供方银行账号
          supplyTaxNo: '', // 供方税号
          /* 需方 */
          demandDepartId: '', // 需方机构id
          demandDepartName: '', // 需方机构名称
          demandUnified: '', // 需方统一社会信用代码
          demandCorporation: '', // 需方法人
          demandTel: '', // 需方电话
          demandBankName: '', // 需方开户行
          demandMail: '', // 需方邮箱
          demandAddress: '', // 需方地址
          demandAgent: '', // 需方代理人
          demandFax: '', // 需方传真
          demandBankNo: '', // 需方银行账号
          demandTaxNo: '' // 需方税号
        }
      }
    }
  },
  created() {
    // 字典信息
    this.initWebTypeGroup() // 采购方式
    this.initData(this.$route.params.id ? this.$route.params.id : this.$route.query.id)
    this.contractSource = this.$route.params.contractSource
    this.roleCode = this.$store.getters.info.currentRol.roleCode // 角色code
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 编辑初始化数据
    initData(id) {
      const data = {
        id: id
      }
      getBidtCalibrationTenderContractData(data).then(response => {
        this.formData = response.data
      }).catch(() => {
        this.loading = false
      })
    },
    // 返回
    back() {
      let path = this.$route.meta.path
      if (path === 'leaderContractSigning-list') {
        path = '/leaderContractManagement/leaderContractSigning-list'
      } else {
        path = '/contractManagement/contractSigning-list'
      }
      this.$router.push({
        path
      })
    },
    next() {
      let path = this.$route.meta.path
      if (path === 'leaderContractSigning-list') {
        path = '/leaderContractManagement/leaderContractPdfDetail'
      } else {
        path = '/contractManagement/contractPdfDetail'
      }
      this.$router.push({
        path,
        query: {
          contractSource: this.contractSource,
          id: this.$route.params.id // 合同id
        }
      })
    },
    confirm() {
      this.$confirm('确定确认吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoading = true
        const param = this.$route.params.id
        confirmContract(param).then(res => {
          this.$message({
            message: '已确认',
            type: 'success'
          })
          this.$router.push({ path: '/contractManagement/contractConfirm-list' })
          this.confirmLoading = false
        })
      }).catch(() => {
        this.confirmLoading = false
      })
    }
  }
}
</script>
<style lang="less" scoped>
// 审核图片
.supper_auditStatus{
  position: absolute;
  top: 10px;
  right:100px;
  z-index: 9;
}
</style>
