FlatQuickShipmentDetailModel.vue
4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭"
>
<a-spin :spinning="confirmLoading">
<a-table
ref="table"
rowKey="id"
size="middle"
:columns="columns"
:scroll="{y: 600}"
:dataSource="dataSource"
:pagination="false">
<span slot="shipQty" slot-scope="text, record">
<a-input-number :max="record.availableQty" :min="0" placeholder="请输入出库数量" v-model="record.shipQty" :value="text"/>
</span>
<span slot="zoneCode" slot-scope="zoneCode">
<a-tag :key="zoneCode" color=blue>
{{ solutionZoneCode(zoneCode) }}
</a-tag>
</span>
<span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
<a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
{{ inventoryStatus_dictText }}
</a-tag>
</span>
</a-table>
</a-spin>
</j-modal>
</template>
<script>
import {flatShipmentInventoryDetail} from '@/api/api'
import inputNumber from "ant-design-vue/lib/input-number";
export default {
name: 'flatQuickShipmentDetailModel',
computed: {
inputNumber() {
return inputNumber
}
},
components: {},
data() {
return {
title: '操作',
width: 1200,
columns: [
{
title: '#', dataIndex: '', key: 'rowIndex', width: 60, align: "center",
customRender: function (t, r, index) {
return parseInt(index) + 1;
}
},
{title: '库区', dataIndex: 'zoneCode', align: 'center', scopedSlots: {customRender: 'zoneCode'}},
{title: '库位', dataIndex: 'locationCode', align: 'center'},
{title: '容器', dataIndex: 'containerCode', align: 'center'},
{title: '物料编码', dataIndex: 'materialCode', align: 'center'},
{title: '物料名称', dataIndex: 'materialName', align: 'center'},
{title: '物料规格', dataIndex: 'materialSpec', align: 'center'},
{title: '物料单位', dataIndex: 'materialUnit', align: 'center'},
{title: '批次', dataIndex: 'batch', align: 'center'},
{title: '库存状态', dataIndex: 'inventoryStatus_dictText', align: 'center', scopedSlots: {customRender: 'inventoryStatus_dictText'}},
{title: '可出数量', dataIndex: 'availableQty', key: 'availableQty', align: 'center'},
{title: '出库数量', dataIndex: 'shipQty', align: 'center', key: 'shipQty', scopedSlots: {customRender: 'shipQty'}}
],
dataSource: [],
zoneList: [],
querySource: {},
visible: false,
labelCol: {
xs: {span: 24},
sm: {span: 5}
},
wrapperCol: {
xs: {span: 24},
sm: {span: 16}
},
confirmLoading: false,
validatorRules: {}
}
},
created() {
},
methods: {
open(recordList) {
this.visible = true;
this.dataSource = recordList;
},
close() {
this.$emit('close')
this.visible = false
},
handleOk() {
let dataSource = this.dataSource.filter(data => data.shipQty);
if (dataSource) {
try {
dataSource.forEach(data => {
if (data.shipQty < 0) {
throw new Error(`第 ${data.index} 行出库数量异常`);
}
})
} catch (e) {
this.$message.warning(e);
return;
}
}
let params = dataSource.map(data => {
return {inventoryDetailId: data.id, shipQty: data.shipQty}
})
flatShipmentInventoryDetail(params).then((res) => {
if (res.success) {
this.$message.success(res.message);
this.$emit("ok");
} else {
this.$message.error(res.message);
}
}).finally(() => {
this.close()
});
},
handleCancel() {
this.close()
},
solutionZoneCode(value) {
let actions = []
Object.keys(this.zoneList).some((key) => {
if (this.zoneList[key].code === ('' + value)) {
actions.push(this.zoneList[key].name)
return true
}
})
return actions.join('')
},
getStatusColor(status) {
const colors = {
'良品': 'green',
'报废品': 'purple',
'待确认 ': 'grey',
'次品': 'red',
'锁定': 'red',
default: 'blue'
};
return colors[status] || colors.default;
},
}
}
</script>