<!--
 * @Description: 结果执行管理-行项目信息组件
 * @Author:hdk
 * @Date: 2020-11-03 14:19:56
-->
<template>
  <div>
    <el-table :data="lineProjectData">
      <el-table-column
        type="index"
        label="序号"
        width="60"
        align="center"
        fixed
      />
      <el-table-column
        header-align="center"
        min-width="150"
        align="center"
        prop="purchaseCode"
        label="物资编号"
        fixed
      />
      <el-table-column
        header-align="center"
        min-width="110"
        align="center"
        prop="purchaseName"
        label="物资名称"
        fixed
      />
      <el-table-column
        header-align="center"
        min-width="220"
        prop="belongOrgName"
        label="采购单位"
      />
      <!-- 物料描述 -->
      <el-table-column
        header-align="center"
        align="left"
        prop="purchaseSpecification"
        min-width="230"
        label="物料描述"
      />
      <el-table-column prop="purchaseClassificationParent" width="150" label="一级专业分类" header-align="center" />
      <el-table-column
        header-align="center"
        align="left"
        min-width="150"
        label="二级专业分类"
      >
        <template slot-scope="scope">
          <p>
            {{ scope.row.purchaseClassification }}
          </p>
        </template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="left"
        prop="purchaseBrand"
        min-width="160"
        label="品牌"
      />
      <!-- 代理单位 暂时隐藏 -->
      <!-- <el-table-column
        header-align="center"
        align="left"
        prop="purchaseDepartName"
        min-width="180"
        label="代理单位"
      /> -->
      <!-- 供货供应商 暂时隐藏 -->
      <!-- <el-table-column
        header-align="center"
        align="left"
        prop="suppliersName"
        min-width="110"
        label="供货供应商"
      /> -->
      <el-table-column
        header-align="center"
        align="right"
        width="80"
        prop="purchaseNum"
        label="采购数量"
      />
      <el-table-column
        header-align="center"
        align="left"
        width="110"
        label="单位"
      >
        <template slot-scope="scope">
          <p>
            {{ filterDictText(purchaseUnitList, scope.row.purchaseUnit) }}
          </p>
        </template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="right"
        min-width="120"
        label="不含税单价（元）"
      >
        <template slot-scope="scope">
          <p>{{ scope.row.purchaseBudget && numFilter(scope.row.purchaseBudget) }}</p>
        </template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="right"
        min-width="140"
        prop="purchaseTotalBudget"
        label="不含税总价（元）"
      >
        <template slot-scope="scope">
          <p>{{ scope.row.purchaseTotalBudget && numFilter(scope.row.purchaseTotalBudget) }}</p>
        </template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="right"
        min-width="150"
        label="税率（%）"
      >
        <template slot-scope="scope">
          {{ filterDictText(taxRateList,scope.row.purchaseTaxRate) }}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        min-width="150"
        label="到货日期"
      >
        <template slot-scope="scope">
          {{ scope.row.deliveryTime }}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        min-width="150"
        label="到货地点"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.deliveryAddress.replace(/,/g,'') }}</span>
          <!-- <span>{{ scope.row.deliveryAddress }}</span> -->
        </template>
      </el-table-column>
      <!-- <el-table-column
        header-align="center"
        align="left"
        prop="deliveryTime"
        label="已采数量"
      /> -->
      <!-- <el-table-column
        v-if="!isEdit"
        header-align="center"
        label="已采计划"
        align="center"
        width="140"
      >
        <template slot-scope="scope">
          <el-link
            :underline="false"
            size="mini"
            plain
            type="primary"
            @click="editRow(scope.row)"
          >
            查看
          </el-link>
        </template>
      </el-table-column>
      <el-table-column
        v-if="!isEdit"
        header-align="center"
        label="关联订单"
        align="center"
        width="140"
      >
        <template slot-scope="scope">
          <el-link
            :underline="false"
            size="mini"
            plain
            type="primary"
            @click="editRow(scope.row)"
          >
            查看
          </el-link>
        </template>
      </el-table-column> -->
      <el-table-column
        v-if="isEdit"
        header-align="center"
        label="操作"
        align="center"
        width="140"
      >
        <template slot-scope="scope">
          <!-- isEdit 编辑状态 布尔值  true显示编辑 false不显示 查看审核时不显示编辑按钮 -->
          <el-link
            :underline="false"
            size="mini"
            plain
            type="primary"
            @click="editRow(scope.row)"
          >
            [编辑]
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <!-- <pagination :pagination-data="paginationData" @change="getOrderListData" /> -->
    <!-- 编辑行项目信息 -->
    <entryProjectInfoDialog :dialog-data="dialogData" :project-info="projectInfo" @lineItemEditClose="lineItemEditClose" />
  </div>
</template>

<script>
/* 公共混入*/
// import { ListMixin } from '@/mixins/ListMixin' // 分页
import { rstMgmtMixins } from '../mixins/rstMgmtMixins'
/* 公共方法*/
import { numFilter, filterDictText } from '@/assets/js/utils' // 金额转换千分位
/* 组件*/
import pagination from '@comp/common/pagination/pagination' // 分页组件
import entryProjectInfoDialog from './lineItemEdit-dialog' // 编辑行项目信息
export default {
  name: 'LineItemInfoTable',
  components: {
    pagination, // 分页组件
    entryProjectInfoDialog // 编辑行项目信息
  },
  mixins: [rstMgmtMixins],
  props: {
    lineProjectData: { // 行项目数据
      type: Array,
      default: function() {
        return []
      }
    },
    isEdit: { // 行项目编辑状态
      type: Boolean,
      default: false
    },
    executeId: { // 执行表ID
      type: String,
      default: ''
    },
    executeNo: { // 执行编号
      type: String,
      default: ''
    }
  },
  data() {
    return {
      projectInfo: {}, // 要编辑的行项目
      dialogData: { // 编辑行项目信息数据
        consignContractVisible: false, // 编辑行项目信息状态
        executeId: '', // 执行表ID
        executeNo: '' // 执行单编号
      }
    }
  },
  watch: {
    'dialogData.consignContractVisible': {
      handler(val) {
        if (val) {
          this.dialogData.executeId = this.executeId // 执行表ID
          this.dialogData.executeNo = this.executeNo // 执行单编号
        }
      },
      deep: true
    }
  },
  created() {
  },
  methods: {
    filterDictText, // 数据字典
    numFilter, // 金额补零
    // 编辑行项目信息
    editRow(row) {
      this.dialogData.consignContractVisible = true
      this.projectInfo = row
    },
    lineItemEditClose() { // 关闭行项目信息编辑
      if (this.dialogData.consignContractVisible) {
        this.$emit('updateData') // 页面数据更新
      }
      this.dialogData.consignContractVisible = false
    }
  }
}
</script>

<style lang='less'>

</style>
