<!--
  @description: 采购员-框架计划-框架计划编辑-查看
  @author: lxl
  @routerPath:/procurement/ProcurementPlanEntry-detail
  @date： 2020-11-03 10:24:19
-->
<template>
  <div class="p0-16">
    <!--标题-->
    <section v-if="isPBackIcon" class="title">
      <i
        class="iconfont icon-fanhui pointer"
        @click="back()"
      />
      查看框架计划详情
    </section>
    <section>
      <p class="page-title">
        1.框架计划基本信息
      </p>
      <table class="tableData">
        <tr>
          <!-- <td>
            采购单位
          </td>
          <td>
            {{ formData.belongOrgName }}
          </td> -->
          <td>
            采购计划名称
          </td>
          <td colspan="3">
            {{ formData.purchasePlanName }}
          </td>
        </tr>
        <tr>
          <td>
            采购计划编号
          </td>
          <td>
            {{ formData.purchasePlanNo }}
          </td>
          <td>
            采购单编号
          </td>
          <td>
            {{ formData.tenderNo }}
          </td>
        </tr>
        <tr>
          <td>
            采购方式
          </td>
          <td colspan="3">
            {{ filterDictText(tenderMethodList,formData.tenderMethod) }}
          </td>
        </tr>
        <tr>
          <td>
            采购单净预算(元)
          </td>
          <td>
            {{ formData.budgetTotalMoney && numFilter(formData.budgetTotalMoney) }}
          </td>
          <td>
            采购单含税总预算(元)
          </td>
          <td>
            {{ formData.budgetTotalTaxMoney && numFilter(formData.budgetTotalTaxMoney) }}
          </td>
        </tr>
        <tr>
          <td>
            公开/邀请
          </td>
          <td>
            {{ filterDictText(tenderTypeList,formData.tenderType) }}
          </td>
          <td>
            评审办法
          </td>
          <td>
            {{ filterDictText(reviewMethodList,formData.reviewMethod) }}
          </td>
        </tr>
        <tr>
          <td>
            供应商属性
          </td>
          <td>
            {{ filterDictText(supplierAttributeList,formData.supplierAttribute) }}
          </td>
          <td>
            供应商分类
          </td>
          <td>
            {{ filterDictText(supplierCategoryList,formData.supplierCategory) }}
          </td>
        </tr>
        <tr>
          <td>内部附件({{ formData.insideTenderFile }})</td>
          <td>
            <el-link
              v-if="formData.insideTenderFile+'' !== '0'"
              :underline="false"
              size="mini"
              plain
              type="primary"
              @click="checkAccessory('01')"
            >
              查看
            </el-link>
          </td>
          <td>公开附件({{ formData.openTenderFile }})</td>
          <td>
            <el-link
              v-if="formData.openTenderFile+'' !== '0'"
              :underline="false"
              size="mini"
              plain
              type="primary"
              @click="checkAccessory('02')"
            >
              查看
            </el-link>
          </td>
        </tr>
        <tr>
          <td>
            采购方式说明
          </td>
          <td colspan="3">
            {{ formData.tendermethodRemarks }}
          </td>
        </tr>
      </table>
    </section>
    <section v-if="formData.tenderType==='01'">
      <p class="page-title">
        2.供应商信息
      </p>
      <el-table
        ref="multipleTable"
        style="marginTop:10px"
        :data="formData.supplierList"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="50"
        />
        <el-table-column
          prop="supplierName"
          header-align="center"
          label="供应商"
        />
        <el-table-column
          prop="businesslicence"
          label="统一社会信用代码"
          min-width="110"
          header-align="center"
        />
        <el-table-column
          prop="linkerName"
          header-align="center"
          label="联系人"
        />
        <el-table-column
          prop="linkerTel"
          align="center"
          label="联系方式"
        />
      </el-table>
    </section>
    <section>
      <p class="page-title">
        {{ `${formData.tenderType==='01'?3:2}.行项目信息` }}
      </p>
      <template>
        <!-- 行项目 -->
        <procurementPlanLineItemComp :line-item-data="lineItemData" :line-item-other-data="lineItemOtherData" @checkFile="onCheckFile" />
        <!-- 分页 -->
        <pagination :pagination-data="paginationData" :loading="loading" @change="loadData" />
      </template>
    </section>
    <template>
      <!-- 查看附件 -->
      <checkFIleCompDialog :dialog-file-data="dialogFileData" />
    </template>
  </div>
</template>

<script>
/* 接口*/
import {
  purchasePlanFramePackPage, // 基本信息
  getPurchasePlanFrameDetailsList // 行项目
} from '@/api/procurement/purchasplan'
/* 公用组件*/
import { ListMixin } from '@/mixins/ListMixin' // 分页公用方法
import pagination from '@comp/common/pagination/pagination' // 分页组件
import { filterDictText, numFilter } from '@/assets/js/utils' // 公用方法
import procurementPlanLineItemComp from '@/views/procurement/procurementPlan/components/procurementPlanLineItemComp.vue' // 行项目信息
import checkFIleCompDialog from '@/views/procurement/procurementPlan/components/checkFIleComp-dialog.vue'// 查看附件
export default {
  name: 'PurPlanFrameDetail',
  components: {
    pagination, // 分页
    procurementPlanLineItemComp, // 行项目信息
    checkFIleCompDialog // 查看附件
  },
  mixins: [ListMixin],
  data() {
    return {
      /* -----------数据字典start-------------*/
      tenderMethodList: [], // 采购方式
      tenderTypeList: [], // 公开/邀请
      supplierAttributeList: [], // 供应商属性
      supplierCategoryList: [], // 供应商分类
      reviewMethodList: [], // 评审办法
      dictionaryType: ['tenderMethod', 'tenderType', 'supplierAttribute', 'supplierCategory', 'reviewMethod'],
      /* -----------数据字典end-------------*/
      formData: {}, // 采购计划基本信息
      loading: true,
      organizaTionFlag: false, // 自采集采展示状态
      lineItemData: [], // 行项目数据
      // 行项目其他数据
      lineItemOtherData: {
        isShowpurcDepart: false // 是否显示采购人字段 框架计划的审批及详情页面，隐藏行项目处的采购人 布尔值 默认显示
      },
      tenderId: this.$route.params.tenderId || this.$route.query.id, // 采购计划id
      planMainId: '', // 项目id
      // 查看附件弹框数据
      dialogFileData: {
        checkFileVisible: false, // 查看附件弹框状态
        bizId: '', // 附件主键id
        fileType: '' // 附件类型
      },
      isPBackIcon: this.$route.params.isShowBack // 是否显示返回 布尔值
    }
  },
  created() {
    // 字典请求初始化
    this.getGroupType()
    this.getFramePackPage() // 基本信息
  },
  methods: {
    filterDictText, // 字典
    getGroupType() {
      this.$store.dispatch('getGroupType', this.dictionaryType).then((data) => {
        // 遍历key存储相应的数据
        for (const key in data.bidTypeData) {
          /* 是否有数据*/
          if (data.bidTypeData[key]) {
            this[key] = data.bidTypeData[key]
          }
        }
      })
    },
    numFilter, // 金额千位符
    // 返回按钮
    back() {
      this.$router.push('procurementPlanFrameList')
    },
    // 行项目信息
    loadData() {
      const params = {
        planMainId: this.planMainId, // 项目id
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      getPurchasePlanFrameDetailsList(params).then((res) => {
        this.lineItemData = res.data.records
        // 获取条数
        this.paginationData.total = res.data.total
      })
    },
    // 基本信息
    getFramePackPage() {
      // 采购计划基本信息
      const data = {
        tenderId: this.tenderId
      }
      purchasePlanFramePackPage(data)
        .then(response => {
          this.formData = {
            ...response.data,
            ...response.data.planMainInfo
          }
          this.planMainId = this.formData.id // 项目id
          this.loadData() // 行项目信息
        })
        .catch(() => {
        })
    },
    // 公开/内部：附件
    checkAccessory(val) {
      this.dialogFileData.bizId = this.formData.tenderId
      if (val === '01') {
        this.dialogFileData.fileType = 'inside_tender_plan_file' // 内部
      } else {
        this.dialogFileData.fileType = 'open_tender_project_file' // 公开
      }
      this.dialogFileData.checkFileVisible = true
    },
    // 查看附件
    onCheckFile(row) {
      this.dialogFileData.checkFileVisible = true
      this.dialogFileData.bizId = row.planDetailId
    }
  }
}
</script>

<style scoped>

</style>
