<!--
  @description: 采购员-结果执行管理-新增采购执行结果
  @author: hdk
  @routerPath:/procurement/rstMgmtAdd
  @date： 2020-11-03 10:24:19
-->
<template>
  <div>
    <!--标题-->
    <section class="title title_border p0-16">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      查看执行结果
    </section>
    <div class="p0-16">
      <!-- 执行结果基本信息 -->
      <div class="mb16">
        <p class="page-title">
          1.执行结果基本信息
        </p>
        <el-form ref="form" :model="formData" :inline-message="true">
          <table class="tableData">
            <tr>
              <td>
                执行编号
              </td>
              <td>
                {{ formData.executeNo }}
              </td>
              <td>
                来源编号
              </td>
              <td>
                {{ formData.belongTenderNo }}
              </td>
              <!-- <td>
            物资编号
          </td>
          <td>
            {{ formData.purchaseCode }}
          </td> -->
            </tr>
            <!-- <tr> -->
            <!-- <td>
            物资信息
          </td>
          <td>
            {{ formData.purchaseName }}
          </td> -->
            <!-- 采购单位暂时隐藏 -->
            <!-- <td>
                采购单位
              </td>
              <td colspan="3">
                {{ formData.belongOrgName }}
              </td>
            </tr> -->
            <!-- </tr> -->
            <tr>
              <td>
                成交供应商
              </td>
              <td colspan="3">
                {{ formData.suppliersName }}
              </td>
            </tr>
            <tr>
              <td>
                执行方式
              </td>
              <td>
                <!-- 00-一次谈判一次采购;01-一次谈判多次采购; -->
                {{ filterDictText(executeTypeList, formData.executeType) }}
              </td>
              <td>
                来源
              </td>
              <td>
                {{ filterDictText(tenderMethodList, formData.tenderMethod) }}
              </td>
            </tr>
            <tr>
              <td>
                付款方式
              </td>
              <td colspan="3">
                {{ filterDictText(paymentTypeList, formData.paymentType) }}
              </td>
            </tr>
            <tr>
              <td>
                采购单不含税总金额（元）
              </td>
              <td colspan="3">
                {{ formData.purchaseTotalBudget && numFilter(formData.purchaseTotalBudget) }}
              </td>
            </tr>
            <tr>
              <td>
                执行日期
              </td>
              <td>
                {{ formData.executeTime && $Moment(formData.executeTime).format(momentDate) }}
              </td>
              <td>
                有效期至
              </td>
              <td>
                {{ formData.validityPeriod }}
              </td>
            </tr>
            <tr>
              <td>
                创建人
              </td>
              <td>
                {{ formData.exeCreateUserRealName }}
              </td>
              <td>
                创建日期
              </td>
              <td>
                {{ formData.createTime && $Moment(formData.createTime).format(momentDate) }}
              </td>
            </tr>
          </table>
        </el-form>
      </div>
      <!-- 采购计划基本信息 -->
      <div class="mb16">
        <p class="page-title">
          2.采购计划基本信息
        </p>
        <!-- 行项目信息组件 -->
        <lineItemInfoTable :is-edit="false" :line-project-data="formData.detailsList" />
      </div>
    </div>
  </div>
</template>

<script>
/* 接口*/
import { goPurchasePlanResultExecutePage } from '@/api/procurement/purchasplan.js' // 获取角色信息
import { queryProcurementProjectRuleInitInfo } from '@/api/procurement/procurementProject' // 付款方式字典 queryProcurementProjectRuleInitInfo

/* 公共混入*/
import { rstMgmtMixins } from './mixins/rstMgmtMixins'
/* 公共方法*/
import { filterDictText, numFilter } from '@/assets/js/utils'// 常用方法
/* 组件*/
import lineItemInfoTable from './rstMgmtAdd/lineItemInfoTable' // 行项目信息组件
export default {
  name: 'PurPlanRstMgmtDetail',
  components: {
    lineItemInfoTable // 行项目信息组件
  },
  mixins: [rstMgmtMixins],
  data() {
    return {
      backPath: '', // 回退路径
      paymentTypeList: [], // 付款方式字典
      formData: {} // 数据对象
    }
  },
  created() {
    this.getDetails()
    // 付款方式字典请求
    this.queryRuleInitInfo()
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      vm.backPath = from.path
    })
  },
  methods: {
    // 字典检索
    filterDictText,
    numFilter, // 金额
    // 付款方式字典请求
    queryRuleInitInfo() {
      queryProcurementProjectRuleInitInfo().then((res) => {
        this.paymentTypeList = res.data.protproject_payType.typeList // 支付方式
      })
    },
    // 获取执行单详情
    getDetails() {
      const params = {
        executeId: this.$route.params.executeId // 执行单ID
      }
      // 生成执行单id（获取执行单详情）
      goPurchasePlanResultExecutePage(params)
        .then(response => {
          this.formData = response.data
        })
        .catch(() => {
        })
    },
    // 返回按钮
    back() {
      const pathOf = this.backPath.lastIndexOf('/') + 1
      const path = this.backPath.substr(pathOf)
      this.$router.push({
        path
      })
    }
  }
}
</script>

<style scoped>

</style>
