ShipmentPickManualCombineModal.vue
17.2 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
<template>
<j-modal
:title="title"
:width="1400"
:visible="visible"
:maskClosable="false"
switchFullscreen
@ok="handleOk"
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
@cancel="handleCancel">
<a-row :gutter="24">
<a-col :span="24">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" class="j-inline-form" @keyup.enter.native="search()">
<a-row :gutter="24">
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<a-form-item label="物料编码">
<a-input placeholder="请输入物料编码" v-model="queryParam.materialCode"></a-input>
</a-form-item>
</a-col>
<a-col :xl="8" :lg="7" :md="8" :sm="24">
<a-button type="primary" @click="search()" icon="search">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</a-col>
</a-row>
</a-form>
</div>
<div style="height: 340px">
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:scroll="{ x: true }"
:customRow="clickThenSelect"
:rowSelection="{selectedRowKeys, onChange: onSelectChange, type: 'radio'}"
class="j-table-force-nowrap"
@change="handleTableChange">
<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>-->
<span slot="companyCode" slot-scope="companyCode">
<a-tag :key="companyCode" color=blue>
{{ solutionCompany(companyCode) }}
</a-tag>
</span>
<span slot="inventoryStatus" slot-scope="inventoryStatus">
<a-tag :key="inventoryStatus" :color="getStatusColor(inventoryStatus)">
{{ solutionInvStatus(inventoryStatus) }}
</a-tag>
</span>
<span slot="action" slot-scope="text, record">
<a-input-number placeholder="" v-model="record.shipQty" :value="text"/>
</span>
<span slot="action2" slot-scope="text, record">
<a-button @click="combine(record)" type="primary">配盘</a-button>
</span>
</a-table>
</div>
</a-col>
</a-row>
<!-- 底部表格 start -->
<!-- <div>-->
<!-- <a-table-->
<!-- ref="table"-->
<!-- size="middle"-->
<!-- bordered-->
<!-- rowKey="id"-->
<!-- :columns="detailColumns"-->
<!-- :dataSource="detailDataSource"-->
<!-- :pagination="detailIpagination"-->
<!-- :loading="loading"-->
<!-- class="j-table-force-nowrap"-->
<!-- @change="handleDetailTableChange">-->
<!-- <span slot="companyCode" slot-scope="companyCode">-->
<!-- <a-tag :key="companyCode" color=blue>-->
<!-- {{ solutionCompany(companyCode) }}-->
<!-- </a-tag>-->
<!-- </span>-->
<!-- <span slot="inventoryStatus" slot-scope="inventoryStatus">-->
<!-- <a-tag :key="inventoryStatus" :color="getStatusColor(inventoryStatus)">-->
<!-- {{ solutionInvStatus(inventoryStatus) }}-->
<!-- </a-tag>-->
<!-- </span>-->
<!-- <span slot="action" slot-scope="text, record">-->
<!-- <a-input-number placeholder="" v-model="record.shipQty" :value="text"/>-->
<!-- </span>-->
<!-- <span slot="action2" slot-scope="text, record">-->
<!-- <a-button @click="combine(record)" type="primary">配盘</a-button>-->
<!-- </span>-->
<!-- </a-table>-->
<!-- </div>-->
<!-- 底部表格 end -->
</j-modal>
</template>
<script>
// import CycleCountDetailForm from './CycleCountDetailForm'
import JSelectBizQueryItem from "@comp/jeecgbiz/JButtonBizComponent/JSelectBizQueryItem";
import {JeecgListMixin} from "@/mixins/JeecgListMixin";
import {
getCompanyList,
getZoneList,
getInventoryFromShipmentPickDetail,
ajaxGetDictItems, shipmentPickCombination
} from "@api/api";
import {getAction} from "@api/manage";
export default {
name: 'shipmentPickManualCombineModal',
mixins: [JeecgListMixin],
components: {
JSelectBizQueryItem,
// CycleCountDetailForm
},
data() {
return {
title: '',
loading: true,
visible: false,
disableSubmit: false,
cycleCountHeader: {},
shipmentHeaderId: {},
combineParam: {},
invStatus:[],
queryParam: {},
shipQty: {},
rowKey: 'id',
selectedRowKeys: [],
selectedRows: [],
selectedRowIds: [],
columns: [
{title: '货主', align: "center", dataIndex: 'companyCode', scopedSlots: {customRender: 'companyCode'}},
// {title: '单据详情ID', align: 'center', dataIndex: 'id'},
{title: '物料编码', align: 'center', dataIndex: 'materialCode'},
{title: '物料名称', align: 'center', dataIndex: 'materialName'},
{title: '容器编码', align: "center", dataIndex: 'containerCode'},
{title: '检验批次', align: 'center', dataIndex: 'batch'},
{title: '物料规格', align: 'center', dataIndex: 'materialSpec'},
{title: '物料单位', align: 'center', dataIndex: 'materialUnit'},
{title: '库存数量', align: 'center', dataIndex: 'qty'},
{title: '任务数量', align: 'center', dataIndex: 'taskQty'},
{title: '可出数量', align: 'center', dataIndex: 'availableQty'},
{title: '出库数量',dataIndex: 'action',align: 'center',key: 'action',scopedSlots: {customRender: 'action'}},
{title: '入库日期', align: "center", dataIndex: 'receiptDate'}
],
selectedTable: {
pagination: false,
scroll: {y: 235},
columns: [
{title: '库位编码', align: 'center', width: '70%', dataIndex: 'locationCode'},
{title: '操作', dataIndex: 'action', align: 'center', width: 60, scopedSlots: {customRender: 'action'},}
],
dataSource: [],
},
dataSource: [],
detailDataSource: [],
url: {
list: '/shipment/pick/header/listShipmentPickDetailByPickId',
pageByMainIds: "/inventory/inventoryDetail/pageByMainIds",
checkQty: '/shipment/pick/header/getShipmentPickDetailById'
},
zoneList: [],
companyList: [],
ipagination: {
current: 1,
pageSize: 5,
pageSizeOptions: ['5', '10', '100'],
showTotal: (total, range) => {
return range[0] + "-" + range[1] + " 共" + total + "条"
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
detailIpagination: {
current: 1,
pageSize: 5,
pageSizeOptions: ['5', '10', '100'],
showTotal: (total, range) => {
return range[0] + "-" + range[1] + " 共" + total + "条"
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
}
}
},
methods: {
searchReset() {
Object.keys(this.queryParam).forEach(key => {
this.queryParam[key] = ''
})
this.selectedRowKeys = []
this.selectedRows = []
this.selectedRowIds = []
this.selectedTable.dataSource = []
this.detailDataSource = []
this.detailIpagination.total = 0
this.dataSearch(this.shipmentHeaderId);
},
validateAction() {
for (const item of this.dataSource) {
if (!item.shipQty || item.shipQty <= 0) {
return false; // 如果发现出库数量不合法,返回false
}
}
return true; // 校验通过
},
// calculateTotalShipQty() {
// return this.dataSource.reduce((total, item) => {
// return total + (item.shipQty || 0); // 累加 shipQty,忽略为null的情况
// }, 0);
// },
submitForm() {
const params = {
shipmentDetails: this.dataSource,
shipmentPickDetailId: this.shipmentHeaderId
};
// send post
return shipmentPickCombination(params);
},
edit(record) {
this.shipmentHeaderId = record;
this.search();
},
search() {
this.dataSearch();
// 点击查询清空列表选中行
// https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
this.selectedRowKeys = []
this.selectionRows = []
},
dataSearch(arg){
//加载数据 若传入参数1则加载第一页的内容
if (!this.url.list) {
this.$message.error("请设置url.list属性!")
return
}
this.selectedRowKeys = []
this.selectionRows = []
this.detailDataSource = []
this.queryParam.shipmentPickDetailId = this.shipmentHeaderId;
var params = this.getQueryParams();
this.loading = true;
getAction(this.url.list, params).then((res) => {
if (res.success) {
this.dataSource = res.result.records || res.result;
if (res.result.total) {
this.ipagination.total = res.result.total;
} else {
this.ipagination.total = 0;
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
refreshHeader(){
this.queryParam.shipmentPickDetailId = this.shipmentHeaderId;
var params = this.getQueryParams();//查询条件
this.loading = true;
getAction(this.url.list, params).then((res) => {
if (res.success) {
this.dataSource = res.result.records || res.result;
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
solutionInvStatus(value) {
var actions = []
Object.keys(this.invStatus).some(key => {
if (this.invStatus[key].value == '' + value) {
actions.push(this.invStatus[key].text)
return true
}
})
return actions.join('')
},
handleOk() {
// if (!this.validateAction()) {
// this.$message.error("请检查出库数量!");
// return;
// }
// const totalShipQty = this.calculateTotalShipQty();
// console.log("totalShipQty : ", totalShipQty)
const params = { shipmentPickDetailId: this.shipmentHeaderId };
// getAction(this.url.checkQty, params)
// .then((res =>{
// if (res.success) {
// console.info("params" + res.result)
// // 假设返回的数据结构中包含一个 qty 字段
// const qtyFromResult = res.result.bdmng || 0; // 获取返回的 qty
// // 比较 qtyFromResult 和 totalShipQty
// if (qtyFromResult < totalShipQty) {
// this.$message.error("发料数量大于领料单数量,请检查!");
// return; // 比较失败时直接退出
// }
// }
// })
// )
// this.submitForm().then(response => {
// if (response.success) {
// this.$message.success("提交成功!");
// this.$emit('ok'); // 通知父组件
// this.close(); // 关闭模态框
// } else {
// this.$message.error(response.message || "提交失败!");
// }
// }).catch(error => {
// this.$message.error("接口请求失败,请重试!");
// });
getAction(this.url.checkQty, params)
.then(res => {
if (!res.success) {
this.$message.error(res.message || "请求失败,请重试!");
return; // 请求失败,退出处理
}
console.info("Response data:", res.result);
const qtyFromResult = res.result.bdmng || 0; // 获取返回的 qty
// 比较 qtyFromResult 和 totalShipQty
// if (qtyFromResult < totalShipQty) {
// this.$message.error("发料数量大于领料单数量,1请检查!");
// return; // 发料数量不合法,退出处理
// }
// 如果通过所有检查,继续处理提交表单
this.submitForm()
.then(response => {
if (response.success) {
this.$message.success("提交成功!");
this.$emit('ok'); // 通知父组件
this.close(); // 关闭模态框
} else {
this.$message.error(response.message || "提交失败!");
}
})
.catch(error => {
this.$message.error("接口请求失败,请重试!");
});
})
.catch(error => {
console.error("请求出错:", error);
this.$message.error("请求失败,请检查网络或稍后重试!");
});
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys;
// 解决翻页后 selectionRows 没记录上一页的问题
if (selectedRowKeys.length === selectionRows.length) {
this.selectionRows = selectionRows;
} else {
this.selectionRows = selectedRowKeys.map(key => (
this.selectionRows.find(row => row.id === key) || selectionRows.find(row => row.id === key)
))
}
this.selectedTable.dataSource = this.selectionRows;
this.selectedRowIds = this.selectionRows.map(x => x.id)
this.searchShipment();
},
clickThenSelect(record,index) {
return {
on: {
click: () => {
this.selectIndex=index
this.onSelectChange(record.id.toString().split(','), [record]);
}
}
}
},
combine(record) {
const that = this
that.querySource = record
this.combineParam.shipmentDetailID = this.selectionRows[0].id
this.combineParam.inventoryDetailID = record.id
this.combineParam.shipQty = record.shipQty
shipmentPickCombination(this.combineParam).then(res => {
if (res.success) {
// this.model = res.result;
this.$message.success(res.message)
this.searchShipment()
this.refreshHeader();
} else {
this.$message.warning(res.message)
}
})
},
handleDetailTableChange(pagination, filters, sorter) {
if (Object.keys(sorter).length > 0) {
this.isorter.column = sorter.field;
this.isorter.order = "ascend" === sorter.order ? "asc" : "desc"
}
this.detailIpagination = pagination;
this.searchShipment();
},
searchShipment() {
let id = this.selectionRows[0].id;
let params = {
id: id
}
getInventoryFromShipmentPickDetail(params).then(res => {
if (res.success) {
this.detailDataSource = res.result;
} else {
this.$message.warning(res.message)
}
})
},
loadDetailDataSource(pageCurrent) {
if (pageCurrent && typeof pageCurrent == 'number') {
this.detailIpagination.current = pageCurrent;
}
this.loading = true;
let params = {
inventoryHeaderIds: this.selectedRowIds.join(","),
pageNo: this.detailIpagination.current,
pageSize: this.detailIpagination.pageSize
}
getAction(this.url.pageByMainIds, params).then((res) => {
if (res.success) {
this.detailDataSource = res.result ? res.result.records : null;
if (res.result && res.result.total) {
this.detailIpagination.total = res.result.total;
} else {
this.detailIpagination.total = 0;
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
close() {
this.searchReset()
this.visible = false
},
handleCancel() {
this.close()
},
loadForm() {
getZoneList().then(res => {
if (res.success) {
this.zoneList = res.result
}
})
getCompanyList().then(res => {
if (res.success) {
this.companyList = res.result
}
})
ajaxGetDictItems('inventory_status').then((res) => {
if (res.success) {
this.invStatus = res.result
}
})
},
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('')
},
solutionCompany(value) {
let actions = []
Object.keys(this.companyList).some(key => {
if (this.companyList[key].code === '' + value) {
actions.push(this.companyList[key].name)
return true
}
})
return actions.join('')
},
getStatusColor(status) {
return 'blue';
},
},
created() {
this.loadForm();
}
}
</script>
<style lang="less" scoped>
</style>