<!--
  @description: 采购计划-集采计划分配全部列表
  @author: lxl/hdk
  @routerPath:/procurement/procurementPlanAllocationList
  @date： 2020-10-30 14:52
-->
<template>
  <div>
    <el-table
      v-loading="loading"
      :data="tableData"
      :row-key="getRowKey"
      @sort-change="sortChange"
    >
      <el-table-column key="o912a" type="index" label="序号" align="center" min-width="60" fixed="left" />
      <el-table-column key="a3v6" sortable="custom" prop="tenderNo" label="采购单编号" min-width="150" align="center" fixed="left" />
      <el-table-column
        key="s9f4"
        min-width="150"
        sortable="custom"
        prop="tenderMethod"
        label="采购方式"
        align="center"
        fixed="left"
      >
        <template slot-scope="scope">
          {{ filterDictText(tenderMethodList, scope.row.tenderMethod) }}
        </template>
      </el-table-column>
      <el-table-column
        key="5xrw1"
        prop="tenderType"
        sortable="custom"
        min-width="150"
        label="公开/邀请"
        align="center"
      >
        <template slot-scope="scope">
          {{ filterDictText(tenderTypeList, scope.row.tenderType) }}
        </template>
      </el-table-column>
      <el-table-column key="35" prop="tenderManager" min-width="150" label="采购员" header-align="center" />
      <el-table-column key="l309x" sortable="custom" prop="planType" label="是否框架" min-width="100" align="center">
        <template slot-scope="scope">
          {{ filterDictText(isFramePlanList, scope.row.planType) }}
        </template>
      </el-table-column>
      <el-table-column key="k1092" label="供应商属性" prop="supplierAttribute" sortable="custom" min-width="180" align="center">
        <template slot-scope="scope">
          {{ filterDictText(supplierAttributeList, scope.row.supplierAttribute) }}
        </template>
      </el-table-column>
      <el-table-column key="x121d" label="供应商分类" sortable="custom" prop="supplierCategory" min-width="180" align="center">
        <template slot-scope="scope">
          {{ filterDictText(supplierCategoryList, scope.row.supplierCategory) }}
        </template>
      </el-table-column>
      <el-table-column key="1212" label="评审办法" sortable="custom" prop="reviewMethod" min-width="180" align="center">
        <template slot-scope="scope">
          {{ filterDictText(reviewMethodList, scope.row.reviewMethod) }}
        </template>
      </el-table-column>
      <el-table-column key="a4012" prop="purchaseNo" sortable="custom" label="行项目编号" min-width="180" align="center" />
      <el-table-column key="s6102" prop="purchaseCode" sortable="custom" label="物资编码" min-width="150" align="center" />
      <el-table-column key="sd703" prop="purchaseName" sortable="custom" label="物资名称" min-width="100" align="center" />
      <!-- <el-table-column key="sg10" prop="suppliersName" label="供货厂商" min-width="100" align="center" /> -->
      <el-table-column key="bt11" prop="purchaseBrand" sortable="custom" label="品牌" min-width="150" align="center" />
      <el-table-column key="dr101" prop="purchaseClassificationParent" sortable="custom" min-width="150" label="一级专业分类" header-align="center" />
      <el-table-column key="gh12" prop="purchaseClassification" sortable="custom" min-width="150" label="二级专业分类" align="center" />
      <el-table-column key="nj13" prop="purchaseSpecification" sortable="custom" label="物资描述" min-width="100" align="center" />
      <!-- 结果执行编号-暂时隐藏 -->
      <!-- <el-table-column key="mr14" prop="resultExeNo" label="结果执行编号" min-width="100" align="center" /> -->
      <!-- 是否集采-暂时隐藏 -->
      <!-- <el-table-column
        key="sg215"
        prop="collectionType"
        label="是否集采"
        min-width="150"
        align="center"
      >
        <template slot-scope="scope">
          {{ filterDictText(collectionTypeList, scope.row.collectionType) }}
        </template>
      </el-table-column> -->
      <el-table-column key="ae416" min-width="150" prop="purchaseNum" sortable="custom" label="数量" header-align="center" align="right" />
      <el-table-column
        key="ujk17"
        sortable="custom"
        prop="purchaseUnit"
        label="计量单位"
        min-width="150"
        align="center"
      >
        <template slot-scope="scope">
          {{ filterDictText(purchaseUnitList, scope.row.purchaseUnit) }}
        </template>
      </el-table-column>
      <el-table-column key="ft418" label="预算净单价(元)" sortable="custom" prop="purchaseBudget" min-width="150" header-align="center" align="right">
        <template slot-scope="scope">
          {{ scope.row.purchaseBudget && numFilter(scope.row.purchaseBudget) }}
        </template>
      </el-table-column>
      <el-table-column key="gt19" label="预算净总价(元)" sortable="custom" prop="purchaseTotalBudget" min-width="150" header-align="center" align="right">
        <template slot-scope="scope">
          {{ scope.row.purchaseTotalBudget && numFilter(scope.row.purchaseTotalBudget) }}
        </template>
      </el-table-column>
      <el-table-column key="gt320" label="税率(%)" sortable="custom" prop="purchaseTaxRate" min-width="150" header-align="center" align="left">
        <template slot-scope="scope">
          {{ filterDictText(taxRateList,scope.row.purchaseTaxRate) }}
        </template>
      </el-table-column>
      <el-table-column key="jku21" prop="deliveryTime" label="交货日期" sortable="custom" min-width="150" align="center">
        <template slot-scope="scope">
          {{ scope.row.planType === '01' ? '以实际项目情况为准' : scope.row.deliveryTime && $Moment(scope.row.deliveryTime).format(momentDate) }}
        </template>
      </el-table-column>
      <el-table-column key="ft3522" prop="deliveryAddress" header-align="center" sortable="custom" label="交货地点" min-width="180" align="left" />
      <el-table-column key="gy2323" prop="purchaseDepartName" header-align="center" sortable="custom" label="采购单位" min-width="180" align="left" />
      <el-table-column key="hhy2564" prop="purchaseUserRealName" min-width="150" sortable="custom" header-align="center" label="上报人" align="left" />
      <el-table-column key="gyj2126" prop="remark" header-align="center" label="备注" min-width="180" align="left" />
      <!-- <el-table-column key="jki27" prop="purchaseBuyer" header-align="center" label="采购员" min-width="150" align="left" /> -->
      <!-- 计划管理员 -->
      <el-table-column key="jki28" prop="createUserRealName" label="计划管理员" header-align="center" min-width="150" align="left" />
      <el-table-column key="ghy67428" prop="purchasePlanNo" label="采购计划编号" sortable="custom" min-width="180" align="center" />
      <el-table-column key="sr1229" label="创建日期" min-width="110" prop="createTime" sortable="custom" align="center">
        <template slot-scope="scope">
          {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDate) }}
        </template>
      </el-table-column>
      <el-table-column key="ji430" label="批准日期" prop="approvalTime" min-width="110" sortable="custom" align="center">
        <template slot-scope="scope">
          {{ scope.row.approvalTime && $Moment(scope.row.approvalTime).format(momentDate) }}
        </template>
      </el-table-column>
      <el-table-column key="fte32" min-width="150" label="行项目状态" prop="dataStatus" sortable="custom" align="center">
        <template slot-scope="scope">
          {{ filterDictText(plan_data_statusList, scope.row.dataStatus) }}
        </template>
      </el-table-column>
      <el-table-column key="qw3f15" label="附件" fixed="right" min-width="150" align="center">
        <template slot-scope="scope">
          <el-link v-if="scope.row.isContainAttachment==='1'" type="primary" @click.stop="checkAccessory(scope.row)">
            查看
          </el-link>
        </template>
      </el-table-column>
      <!-- 操作 -->
      <el-table-column key="34" label="操作" width="150" align="center" fixed="right">
        <template slot-scope="scope">
          <el-link type="primary" @click="viewPackInfo(scope.row)">
            打包信息
          </el-link>
          <!-- 查看邀请的供应商  tenderType 00 公开 01邀请  邀请类的项目可查看供应商-->
          <el-link
            v-if="scope.row.tenderType==='01'"
            type="primary"
            @click="inviteSupDetail(scope.row)"
          >
            [查看供应商]
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <purPlanBaleDetailDialog ref="purPlanBaleDetail" />
  </div>
</template>
<script>
import { filterDictText, numFilter } from '@/assets/js/utils' // 字典方法
import { planAllocationMixins } from './mixins/planAllocationMixins'
import purPlanBaleDetailDialog from './purPlanBaleDetail-dialog'
export default {
  name: 'AlreadyAllocationTable',
  components: {
    purPlanBaleDetailDialog // 打包信息
  },
  mixins: [planAllocationMixins],
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {}
  },
  methods: {
    filterDictText,
    numFilter,
    // 指定一个key标识这一行的数据
    getRowKey(row) {
      return row.purchaseNo
    },
    checkAccessory(row) {
      this.$emit('checkFile', row)
    },
    // 查看 邀请类的项目才显示查看 查看邀请的供应商
    inviteSupDetail(row) {
      this.$emit('inviteSupDetail', row)
    },
    // 查看打包信息
    viewPackInfo(row) {
      this.$refs.purPlanBaleDetail.openDialogPurPlanBaleDetail(row.tenderId)
    },
    // 排序
    sortChange: function(column, prop, order) {
      let orderType = ''
      switch (column.order) {
        case 'ascending':
          orderType = 'ASC'
          break
        case 'descending':
          orderType = 'DESC'
          break
      }
      this.$emit('orderData', { column: column.prop, orderSort: orderType })
    }
  }
}
</script>
