<!--
  @description: 采购计划-采购计划查询退回表格数据
  @author: lxl
  @date： 2020-10-30 09:52
-->
<template>
  <el-table
    ref="smallTable"
    v-loading="loading"
    :data="tableData"
    :row-class-name="fileIsClass"
    :stripe="stripeFlag"
    @sort-change="sortChange"
  >
    <el-table-column
      type="index"
      label="序号"
      width="60px"
      align="center"
      fixed="left"
    />
    <!-- <el-table-column key="3" min-width="150" prop="tenderNo" label="采购单编号" align="center" fixed="left" /> -->
    <el-table-column sortable="custom" min-width="150" prop="purchaseNo" label="行项目编号" header-align="center" align="left" fixed="left" />
    <el-table-column sortable="custom" min-width="100" label="是否集采" fixed="left" prop="collectionType" align="center">
      <template slot-scope="scope">
        {{ filterDictText(collectionTypeList,scope.row.collectionType) }}
      </template>
    </el-table-column>
    <el-table-column sortable="custom" min-width="150" prop="businessNo" label="业务编号" fixed="left" header-align="center" align="left" />
    <el-table-column sortable="custom" min-width="150" prop="" label="处理状态" align="center">
      <template slot-scope="scope">
        {{ filterDictText(businessReturnCodeList, scope.row.bizCode ) }}
      </template>
    </el-table-column>

    <el-table-column sortable="custom" min-width="100" prop="purchaseCode" label="物资编码" header-align="center" align="left" />
    <el-table-column sortable="custom" min-width="150" prop="purchaseName" label="物资名称" header-align="center" />
    <!-- <el-table-column sortable="custom" min-width="150" label="采购方式" align="center">
      <template slot-scope="scope">
        {{ filterDictText(tender_methodList,scope.row.tenderMethod) }}
      </template>
    </el-table-column> -->
    <!-- <el-table-column
      sortable="custom"
      min-width="150"
      label="审核状态"
      align="center"
    >
      <template slot-scope="scope">
        {{ filterDictText(planAuditStatusList, scope.row.bizAuditStatus) }}
      </template>
    </el-table-column> -->
    <!-- <el-table-column sortable="custom" min-width="150" prop="suppliersName" label="供货厂商" header-align="center" /> -->
    <el-table-column sortable="custom" min-width="150" prop="purchaseBrand" label="品牌" header-align="center" />
    <el-table-column prop="purchaseClassificationParent" width="150" label="一级专业分类" header-align="center" />
    <el-table-column sortable="custom" min-width="150" prop="purchaseClassification" label="二级专业分类" header-align="center" />
    <el-table-column sortable="custom" min-width="200" prop="purchaseSpecification" label="物资描述" header-align="center" />
    <el-table-column sortable="custom" min-width="150" prop="resultExeNo" label="结果执行编号" header-align="center" align="left" />

    <el-table-column sortable="custom" min-width="120" prop="purchaseNum" label="数量" header-align="center" align="right" />
    <el-table-column sortable="custom" min-width="120" label="计量单位" prop="purchaseUnit" align="center">
      <template slot-scope="scope">
        {{ filterDictText(purchaseUnitList,scope.row.purchaseUnit) }}
      </template>
    </el-table-column>
    <el-table-column sortable="custom" min-width="150" prop="purchaseBudget" label="预算净单价(元)" header-align="center" align="right">
      <template slot-scope="scope">
        {{ scope.row.purchaseBudget && numFilter(scope.row.purchaseBudget) }}
      </template>
    </el-table-column>
    <el-table-column sortable="custom" min-width="150" prop="purchaseTotalBudget" label="预算净总价(元)" header-align="center" align="right">
      <template slot-scope="scope">
        {{ scope.row.purchaseTotalBudget && numFilter(scope.row.purchaseTotalBudget) }}
      </template>
    </el-table-column>
    <!-- 成交总价 -->
    <!-- <el-table-column
      min-width="170"
      sortable="custom"
      prop="distributionTotalMoney"
      label="成交总价(元)"
      header-align="center"
      align="right"
    >
      <template slot-scope="scope">
        {{ scope.row.distributionTotalMoney && numFilter(scope.row.distributionTotalMoney) }}
      </template>
    </el-table-column> -->
    <el-table-column sortable="custom" min-width="100" label="税率(%)" prop="purchaseTaxRate" header-align="center" align="left">
      <template slot-scope="scope">
        {{ filterDictText(taxRateList,scope.row.purchaseTaxRate) }}
      </template>
    </el-table-column>
    <el-table-column sortable="custom" prop="deliveryTime" min-width="110" label="交货日期" align="center">
      <template slot-scope="scope">
        {{ scope.row.deliveryTime && $Moment(scope.row.deliveryTime).format(momentDate) }}
      </template>
    </el-table-column>
    <el-table-column sortable="custom" min-width="200" prop="deliveryAddress" label="交货地点" header-align="center" />
    <el-table-column sortable="custom" min-width="150" prop="purchaseDepartName" label="采购单位" header-align="center" />
    <el-table-column sortable="custom" min-width="150" prop="purchaseUserRealName" label="上报人" header-align="center" />
    <el-table-column sortable="custom" min-width="150" prop="planManagerName" label="技术联系人/电话" align="center" />
    <el-table-column sortable="custom" min-width="200" prop="remark" label="备注" header-align="center" />
    <!-- <el-table-column sortable="custom" min-width="150" prop="purchaseBuyer" label="采购员" header-align="center" /> -->
    <el-table-column sortable="custom" min-width="150" prop="purchasePlanNo" label="采购计划编号" header-align="center" align="left" />
    <!-- 预算编号 -->
    <el-table-column
      min-width="160"
      prop="ykNo"
      label="预算编号"
      header-align="center"
      align="left"
    />
    <!-- 预算年度 -->
    <el-table-column
      min-width="180"
      prop="ykYear"
      label="预算年度"
      header-align="center"
      align="left"
    />
    <!-- 计划编号 -->
    <el-table-column
      min-width="180"
      prop="ykPlanno"
      label="计划编号"
      header-align="center"
      align="left"
    />
    <!-- Book ID -->
<!--    <el-table-column
      min-width="180"
      prop="ykBookid"
      label="Book ID"
      header-align="center"
      align="left"
    />-->
    <!-- 计划名称 -->
    <el-table-column
      min-width="180"
      prop="ykPlannoT"
      label="计划名称"
      header-align="center"
      align="left"
    />
    <!-- 预算编号描述 -->
    <el-table-column
      min-width="230"
      prop="post1"
      label="预算编号描述"
      header-align="center"
      align="left"
    />
    <el-table-column
      sortable="custom"
      prop="createTime"
      min-width="110"
      label="创建日期"
      align="center"
    >
      <template slot-scope="scope">
        {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDate) }}
      </template>
    </el-table-column>
    <el-table-column
      sortable="custom"
      prop="approvalTime"
      min-width="110"
      label="批准日期"
      align="center"
    >
      <template slot-scope="scope">
        {{ scope.row.approvalTime && $Moment(scope.row.approvalTime).format(momentDate) }}
      </template>
    </el-table-column>
    <el-table-column min-width="200" prop="bizReason" label="退回原因" header-align="center" />
    <el-table-column sortable="custom" min-width="150" prop="bizApplication" label="退回操作人" header-align="center" />
    <el-table-column min-width="150" label="退回时间" align="center">
      <template slot-scope="scope">
        {{ scope.row.bizApplicationTime && $Moment(scope.row.bizApplicationTime).format(momentDateTime) }}
      </template>
    </el-table-column>
    <el-table-column min-width="80" label="附件" fixed="right" 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>
</template>
<script>
/* 公共方法*/
/* 公共方法*/
import { filterDictText, numFilter } from '@/assets/js/utils' // 字典方法
// import { procurementPlanGrounpMixins } from '@views/procurement/procurementPlan/mixins/procurementPlanGroupMixins' // 字典信息
export default {
  name: 'BackTableComp',
  // mixins: [procurementPlanGrounpMixins],
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      stripeFlag: true,
      /* --------------字典----------------*/
      tender_methodList: [], // 采购方式
      collectionTypeList: [], // 是否集采
      purchaseUnitList: [], // 计量单位
      taxRateList: [], // 税率
      businessReturnCodeList: [], // 处理状态
      dictionaryType: ['tender_method', 'collectionType', 'purchaseUnit', 'taxRate', 'businessReturnCode'] // 字典请求参数
      /* ------------------------------*/
    }
  },
  created() {
    this.getGroupType() // 字典请求初始化
  },
  methods: {
    filterDictText, // 字典
    numFilter, // 金额
    // 字典请求
    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]
          }
        }
      })
    },
    // 附件查看
    checkAccessory(row) {
      this.$emit('checkFile', row)
    },
    // 排序
    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 })
    },
    // 判断附件动态添加类名
    fileIsClass({ row }) {
      if (row.isContainAttachment === '1') {
        this.stripeFlag = false
        return 'rowRed'
      }
      return ''
    }
  }
}
</script>
<style lang="less" scoped>
@import "~@assets/style/procurement/procurement.rewrite.element";
</style>
