<!--
  @description:招标项目/采购项目-合同供应内容/价格-行项目信息
  @Modifier:郝定康
  @routerPath:
  @date:2021-10-21 09:30:46
-->
<template>
  <div>
    <el-table
      ref="smallTable"
      v-loading="loading"
      :data="tableData"
      highlight-current-row
    >
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="50"
      />
      <el-table-column
        prop="orderCode"
        label="订单编号"
        align="center"
      />
      <el-table-column
        prop="productNo"
        label="行项目编号"
        align="center"
      />
      <el-table-column
        prop="productName"
        label="产品名称"
        align="center"
      />
      <!-- <el-table-column
        prop="supplyDepartName"
        label="产品描述"
            align="center"
      /> -->
      <el-table-column
        prop="unit"
        label="计量单位"
        align="center"
      >
        <template slot-scope="scope">
          <span>{{ filterDictText(purchaseUnitList,scope.row.unit ) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="quantity"
        label="成交数量"
        align="center"
      />
      <el-table-column
        prop="taxRate"
        label="税率"
        align="center"
      >
        <template slot-scope="scope">
          {{ filterDictText(taxRateList,scope.row.taxRate) }}
        </template>
      </el-table-column>
      <el-table-column
        prop="price"
        label="含税单价（元）"
        align="center"
      />
      <!-- <el-table-column
        prop="supplyDepartName"
        label="不含税单价（元）"
            align="center"
      /> -->
      <el-table-column
        prop="fastestDeliveryDate"
        label="发货日期"
        align="center"
      />
      <!-- <el-table-column
        prop="supplyDepartName"
        label="交货地点"
            align="center"
      /> -->
      <!-- 操作 -->
      <el-table-column
        label="操作"
        width="100"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          <el-link
            type="primary"
            @click.stop="delContractDetailInfo(scope.row.id)"
          >
            移除
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <pagination :pagination-data="paginationData" @change="loadData" />
  </div>
</template>

<script>
/*   公共方法*/
import { filterDictText } from '@/assets/js/utils'
/* api */
import { listContractDetailInfoPage, delContractDetailInfo } from '@/api/contractManagement/index'
/* 公共混入 */
import { ListMixin } from '@/mixins/ListMixin'
import { planAllocationMixins } from '@/views/procurement/procurementPlan/purPlanAllocation/mixins/planAllocationMixins'
/* 组件 */
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'ContractLineItemInfo',
  components: {
    pagination
  },
  mixins: [ListMixin, planAllocationMixins],
  props: {
    dataInfo: {
      type: Object,
      default: () => {
        return {}
      }
    },
    contractData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    contractId: {
      type: String,
      default: ''
    },
    order: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      tableData: []
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    filterDictText,
    loadData() {
      this.loading = true
      const params = {
        contractId: this.contractId,
        supplierId: this.dataInfo.departId,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize,
        orderIds: this.$route.query.order
      }
      listContractDetailInfoPage(params).then(res => {
        this.loading = false
        this.tableData = res.data.records
        this.paginationData.total = res.data.total
      })
    },
    delContractDetailInfo(id) {
      if (this.tableData.length <= 1) {
        this.$confirm('行项目不能全部删除！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        })
      } else {
        delContractDetailInfo(id).then(response => {
          this.loadData()
        }).catch(() => {
          this.loading = false
        })
      }
    }
  }
}
</script>

<style>
</style>
