|
@@ -1,13 +1,28 @@
|
|
|
<template>
|
|
|
<el-table size="mini" :data="data" style="width: 100%" border :header-cell-style="rowStyle">
|
|
|
<el-table-column type="index" label="序号" align="center" width="50px" />
|
|
|
- <el-table-column prop="matterP.matterTypeName" label="材料类型" align="center" />
|
|
|
- <el-table-column prop="matterP.matterName" label="材料名称" align="center" />
|
|
|
- <el-table-column prop="matterP.standards" label="规格" align="center" />
|
|
|
- <el-table-column prop="matterP.unit" label="单位" align="center" />
|
|
|
- <el-table-column prop="matterP.matterPrice.price" label="售价(元)" align="center" />
|
|
|
- <el-table-column prop="matterP.matterPrice.installPrice" label="人工单价(元)" align="center" />
|
|
|
- <el-table-column prop="quantity" :label="quantityName" align="center" />
|
|
|
+ <template v-for="{ max, align, ...col } in cols">
|
|
|
+ <el-table-column
|
|
|
+ :key="col.prop"
|
|
|
+ v-bind="col"
|
|
|
+ :align="align || 'center'"
|
|
|
+ :header-align="align || 'center'"
|
|
|
+ :show-overflow-tooltip="!inputKeys.includes(col.prop) || isDetail"
|
|
|
+ >
|
|
|
+ <template v-if="!isDetail && inputKeys.includes(col.prop)" v-slot:default="{ row }">
|
|
|
+ <el-input-number
|
|
|
+ v-if="col.prop === 'quantity'"
|
|
|
+ v-model="row.quantity"
|
|
|
+ size="small"
|
|
|
+ :min="1"
|
|
|
+ :max="max && max(row)"
|
|
|
+ style="width:100%"
|
|
|
+ />
|
|
|
+ <el-input v-else v-model="row.remark" size="small" style="width:100%" maxlength="255" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+
|
|
|
<template v-slot:empty>
|
|
|
<el-empty :image="nullPng" />
|
|
|
</template>
|
|
@@ -18,11 +33,96 @@
|
|
|
import nullPng from '@/assets/icon/null.png'
|
|
|
export default {
|
|
|
name: 'MaterialTable',
|
|
|
- props: { data: { type: Array, default: () => ({}) }, quantityName: { type: String, default: '预算量' } },
|
|
|
+ props: {
|
|
|
+ data: { type: Array, default: () => ({}) },
|
|
|
+ /** 物资类型 1预算;2开工;3领料;4补料;5退料;6其它;7验收申请 */
|
|
|
+ type: { type: Number, default: 0 },
|
|
|
+ isDetail: { type: Boolean, default: false }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
nullPng,
|
|
|
- rowStyle: { background: 'rgba(250,250,250)', color: 'rgb(50,59,65)', height: '39px', textAlign: 'center' }
|
|
|
+ rowStyle: { background: 'rgba(250,250,250)', color: 'rgb(50,59,65)', height: '39px' },
|
|
|
+ inputKeys: ['quantity', 'remark'],
|
|
|
+ tableData: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ cols() {
|
|
|
+ const dynamicCols = (() => {
|
|
|
+ // quantityAll 预算量+补料量
|
|
|
+ // receivedNum 已领量
|
|
|
+ // supplyNum 补充量
|
|
|
+ // returnNums 退料量
|
|
|
+ switch (this.type) {
|
|
|
+ // 领料
|
|
|
+ case 3: {
|
|
|
+ return [
|
|
|
+ { prop: 'receivedNum', label: '已领取', width: '80px' },
|
|
|
+ {
|
|
|
+ prop: 'quantity',
|
|
|
+ label: '本次领取',
|
|
|
+ width: '150px',
|
|
|
+ max: ({ quantityAll, receivedNum, returnNums }) => +quantityAll - +receivedNum + +returnNums
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ // 补料
|
|
|
+ case 4: {
|
|
|
+ return [
|
|
|
+ { prop: 'receivedNum', label: '已领取', width: '80px' },
|
|
|
+ { prop: 'quantity', label: '本次增加预算', max: () => 99999, width: '150px' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ // 退料
|
|
|
+ case 5: {
|
|
|
+ return [
|
|
|
+ { prop: 'receivedNum', label: '已领取', width: '80px' },
|
|
|
+ {
|
|
|
+ prop: 'quantity',
|
|
|
+ label: '退料量',
|
|
|
+ width: '150px',
|
|
|
+ max: ({ receivedNum, returnNums }) => +receivedNum - +returnNums
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'actual',
|
|
|
+ label: '实际使用量',
|
|
|
+ formater: ({ receivedNum, returnNums, quantity }) => +receivedNum - +returnNums - +quantity
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ default: {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })()
|
|
|
+ return [
|
|
|
+ { prop: 'categoryName', label: '材料类别', width: '90px' },
|
|
|
+ { prop: 'matterTypeName', label: '材料类型', width: '90px' },
|
|
|
+ { prop: 'matterName', label: '材料名称', minWidth: '120px', align: 'left' },
|
|
|
+ { prop: 'standards', label: '规格', width: '90px' },
|
|
|
+ { prop: 'unit', label: '单位', width: '90px' },
|
|
|
+ { prop: 'price', label: '售价(元)', width: '80px' },
|
|
|
+ { prop: 'installPrice', label: '人工单价(元)', width: '90px' },
|
|
|
+ { prop: 'quantityAll', label: '预算量', width: '80px' },
|
|
|
+ ...dynamicCols,
|
|
|
+ { prop: 'remark', label: '备注', width: '130px' }
|
|
|
+ ].filter((item) => {
|
|
|
+ if (item.prop === 'quantity') {
|
|
|
+ return !this.isDetail
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ data: {
|
|
|
+ handler(val) {
|
|
|
+ if (val) {
|
|
|
+ this.tableData = [...val]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|