InventorySnQuery.vue
17.4 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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<template>
<a-card :bordered='false'>
<!-- 操作按钮区域 -->
<div class='table-operator'>
<a-button v-has="'inventoryDetail:export'" type='primary' icon='download' @click="handleExportXls('库存详情')">
导出
</a-button>
<a-button type='primary' icon='download' @click="downloadFile('queryInventoryByUniqueList.xls')">序列号查询详细模板下载
</a-button>
<a-upload name='file' :showUploadList='false' :multiple='false'
:headers='tokenHeader' :action='queryInventoryByUniqueListUrl'
@change='handleImportUniqueList'>
<a-button type='primary' icon='import'>导入序列号查询详细</a-button>
</a-upload>
<a-button v-has="'inventoryDetail:quickShipment'" @click='quickShipment()' type='primary' icon='logout'>快速出库
</a-button>
<a-button v-has="'inventoryDetail:redCard'" @click='batchLock()' type='danger' icon='lock'>红牌</a-button>
<a-button v-has="'inventoryDetail:batchGood'" @click='batchGood()' type='danger' icon='unlock'>释放红牌</a-button>
<a-button v-has="'inventoryDetail:controller'" @click='controlledOrRelease(true)' type='danger' :ghost="true"
icon='lock'>受控
</a-button>
<a-button v-has="'inventoryDetail:releaseController'" @click='controlledOrRelease(false)' type='danger'
:ghost="true" icon='unlock'>释放受控
</a-button>
<a-button v-has="'inventoryDetail:scrap'" @click='scrap()' type='danger' icon='delete'>红牌报废</a-button>
<a-button v-has="'inventoryDetail:returnLabel'" @click='returnLabel()' type='danger' icon='tool'>退标签
</a-button>
</div>
<!-- table区域-begin -->
<div>
<a-table
ref='table'
size='middle'
:scroll='{x:true}'
bordered
rowKey='id'
:columns='columns'
:dataSource='dataSource'
:loading='loading'
:pagination="false"
:rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, fixed: true}'
class='j-table-force-nowrap'>
<template slot="title" slot-scope="currentPageData">
{{ `共 ${collectInv(currentPageData).snSize} 个序列号, ${collectInv(currentPageData).sumQty} 根` }}
</template>
<span slot='companyCode' slot-scope='companyCode'>
<a-tag :key='companyCode' color='blue'>
{{ solutionCompany(companyCode) }}
</a-tag>
</span>
<span slot='zoneCode' slot-scope='zoneCode'>
<a-tag :key='zoneCode' color='blue'>
{{ solutionZoneCode(zoneCode) }}
</a-tag>
</span>
</a-table>
</div>
<quick-shipment-model ref='QuickShipmentModel' @ok='quickShipmentModalFormOk'></quick-shipment-model>
<lock-material-model ref='LockMaterialModel' @ok='lockMaterialModelFormOk'></lock-material-model>
<return-label-model ref='returnLabelModel' @ok='returnLabelModelFormOk'></return-label-model>
<controlled-or-release ref='controlledOrReleaseModel' @ok='controlledOrReleaseFormOk'></controlled-or-release>
</a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import SimpleInventoryDetailModal from './modules/SimpleInventoryDetailModal'
import {getCompanyList, getZoneList} from '@api/api'
import QuickShipmentModel from '../shipment/modules/QuickShipment.vue'
import {getAction, postAction} from '@/api/manage'
import ReturnLabelModel from "@views/system/shipment/modules/ReturnLabelModel.vue";
import LockMaterialModel from "@views/system/shipment/modules/LockMaterialModel.vue";
import ControlledOrRelease from "@views/system/inventory/modules/ControlledOrReleaseModal.vue";
import QuickSortShipmentModel from "@views/system/shipment/modules/QuickSortShipment.vue";
export default {
name: 'InventorySnQuery',
mixins: [JeecgListMixin, mixinDevice],
components: {
ReturnLabelModel,
LockMaterialModel,
ControlledOrRelease,
QuickShipmentModel,
QuickSortShipmentModel,
SimpleInventoryDetailModal,
},
data() {
return {
description: '序列号查询库存页面',
companyList: [],
zoneList: [],
// 表头
columns: [
{
title: '#',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '库存详情ID',
align: 'center',
dataIndex: 'id',
},
{
title: '库区',
align: 'center',
dataIndex: 'zoneCode',
key: 'zoneCode',
scopedSlots: {customRender: 'zoneCode'}
},
{
title: '库存状态',
align: 'center',
dataIndex: 'inventoryStatus_dictText'
},
{
title: '容器编码',
align: 'center',
dataIndex: 'containerCode'
},
{
title: '库位编码',
align: 'center',
dataIndex: 'locationCode'
},
{
title: '序列号',
align: 'center',
dataIndex: 'uniqueCode'
},
{
title: '是否使用',
align: 'center',
dataIndex: 'isUse_dictText'
},
{
title: 'pin码',
align: 'center',
dataIndex: 'boxPin'
},
{
title: '收货日期',
align: 'center',
dataIndex: 'receiveDate'
},
{
title: '物料编码',
align: 'center',
dataIndex: 'materialCode'
},
{
title: '物料名称',
align: 'center',
dataIndex: 'materialName'
},
// {
// title:'物料规格',
// align:"center",
// dataIndex: 'materialSpec'
// },
{
title: '物料单位',
align: 'center',
dataIndex: 'materialUnit'
},
{
title: '数量',
align: 'center',
dataIndex: 'qty'
},
{
title: '任务数量',
align: 'center',
dataIndex: 'taskQty'
},
{
title: '明细数量',
align: 'center',
dataIndex: 'childQty'
},
{
title: '红牌单号',
align: 'center',
dataIndex: 'lockBillCode'
},
{
title: '红牌原因',
align: 'center',
dataIndex: 'lockReason'
},
{
title: '容器状态',
align: 'center',
dataIndex: 'containerStatus_dictText'
},
{
title: '箱型号',
align: 'center',
dataIndex: 'boxTypeCode_dictText'
},
{
title: '纸箱规格',
align: 'center',
dataIndex: 'boxName_dictText'
},
{
title: '客户料号',
align: 'center',
dataIndex: 'customMaterialCode'
},
{
title: '库龄(天)',
align: 'center',
dataIndex: 'inventoryAge'
},
{
title: '创建人',
align: 'center',
dataIndex: 'createBy'
},
{
title: '创建日期',
align: 'center',
dataIndex: 'createTime'
},
{
title: '更新人',
align: 'center',
dataIndex: 'updateBy'
},
{
title: '更新日期',
align: 'center',
dataIndex: 'updateTime'
},
],
url: {
getInventoryDetailBySnList: '/inventory/inventoryDetail/getInventoryDetailBySnList',
exportXlsUrl: '/inventory/inventoryDetail/exportXls',
importExcelUrl: 'inventory/inventoryDetail/importExcel',
quickShipment: 'inventory/inventoryDetail/quickShipment',
batchLock: 'inventory/inventoryDetail/batchLock',
batchGood: 'inventory/inventoryDetail/batchGood',
scrap: 'inventory/inventoryDetail/scrap',
returnLabel: 'inventory/inventoryDetail/returnLabel',
queryInventoryByUniqueList: 'inventory/inventoryDetail/queryInventoryByUniqueList'
},
dictOptions: {},
selectRecord: [],
}
},
created() {
this.loadFrom()
},
computed: {
importExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
},
queryInventoryByUniqueListUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.queryInventoryByUniqueList}`
}
},
methods: {
collectInv(data) {
if (data === null || data === undefined || data.length === 0) {
return {
snSize: 0,
sumQty: 0,
}
} else {
return {
snSize: data.length,
sumQty: data.map(x => x.qty).reduce((prev, curr) => {
return prev + curr
}),
}
}
},
loadData() {
},
refreshData() {
let snList = this.dataSource.map(t => t.uniqueCode);
postAction(this.url.getInventoryDetailBySnList, snList).then((res) => {
if (res.success) {
this.dataSource = res.result.records || res.result;
} else {
this.$message.warning(res.message)
}
}).finally(() => {
})
},
loadFrom() {
getCompanyList().then((res) => {
if (res.success) {
this.companyList = res.result
}
})
getZoneList().then((res) => {
if (res.success) {
this.zoneList = 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('')
},
onSelectChange(selectedRowKeys, record) {
this.selectedRowKeys = selectedRowKeys
this.selectRecord = record
},
quickShipment() {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
let zoneCodes = this.selectRecord.map(row => row.zoneCode)
if (new Set(zoneCodes).size !== 1) {
this.$message.warning('所选数据非同库区')
return
}
if ('D' !== this.selectRecord[0].zoneCode) {
this.$refs.QuickShipmentModel.model.containerCode = this.selectRecord[0].containerCode
this.$refs.QuickShipmentModel.edit()
this.$refs.QuickShipmentModel.title = '选择出库口'
} else {
this.quickShipmentModalFormOk(null)
}
}
},
quickShipmentModalFormOk(params) {
let that = this
if (params !== '') {
that.loading = true
postAction(that.url.quickShipment, {ids: that.selectedRowKeys, outPortCode: params}).then((res) => {
that.$message.warning(res.message)
that.onClearSelected()
that.refreshData();
}).finally(() => {
that.loading = false
})
}
},
handleImportUniqueList(info) {
this.loading = false
if (info.file.status === 'done') {
if (info.file.response.success) {
let res = info.file.response
this.dataSource = res.result.records || res.result
this.$message.success(info.file.response.message)
} else {
this.$message.error(`${info.file.name} ${info.file.response.message}.`)
}
}
},
batchLock: function () {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
this.$refs.LockMaterialModel.edit()
this.$refs.LockMaterialModel.isLock = true
}
},
lockMaterialModelFormOk(isLock, lockBillCode, lockReason) {
let that = this
that.loading = true
let url = isLock ? this.url.batchLock : this.url.batchGood
postAction(url, {
lockBillCode: lockBillCode,
lockReason: lockReason,
inventoryDetailIds: this.selectedRowKeys
}).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.onClearSelected()
this.refreshData();
} else {
that.$message.warning(res.message)
this.selectedRowKeys = []
}
}).finally(() => {
that.loading = false;
})
},
batchGood() {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
this.$refs.LockMaterialModel.edit()
this.$refs.LockMaterialModel.isLock = false
}
}
},
scrap() {
let record = this.selectRecord
if (record.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
try {
record.forEach((x) => {
if (x.zoneCode !== 'F') {
throw new Error('报废失败,只能报废成品地面库的库存!')
}
if (x.inventoryStatus !== 'lock') {
throw new Error('报废失败,只能报废红牌状态的库存!')
}
})
} catch (e) {
this.$message.warning(e.message)
return;
}
let that = this
this.$confirm({
title: '确认报废',
content: '是否报废选中数据?',
onOk: function () {
that.loading = true
postAction(that.url.scrap, that.selectedRowKeys).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.onClearSelected()
that.refreshData();
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.loading = false
})
}
})
}
},
returnLabel() {
let record = this.selectRecord
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
try {
record.forEach((x) => {
if (x.zoneCode !== 'F') {
throw new Error('退标签失败,只能退掉成品地面库的库存!')
}
})
} catch (e) {
this.$message.warning(e.message)
return;
}
this.$refs.returnLabelModel.edit()
}
},
returnLabelModelFormOk(returnLabelReason) {
let that = this
that.loading = true
postAction(that.url.returnLabel, {
inventoryDetailIds: that.selectedRowKeys,
returnLabelReason: returnLabelReason
}).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.onClearSelected()
that.refreshData();
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.loading = false
})
},
controlledOrRelease: function (isControlled) {
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
} else {
let that = this
this.$confirm({
title: isControlled ? '确认受控' : '确认释放',
content: '是否' + (isControlled ? '受控' : '释放') + '选中数据?',
onOk: function () {
that.loading = true
let url = isControlled ? that.url.controller : that.url.releaseController
console.log(that.selectedRowKeys)
postAction(url, that.selectedRowKeys).then((res) => {
if (res.success) {
//重新计算分页问题
that.reCalculatePage(that.selectedRowKeys.length)
that.$message.success(res.message)
that.loadData()
that.onClearSelected()
} else {
that.$message.warning(res.message)
that.selectedRowKeys = []
}
}).finally(() => {
that.loading = false
})
}
})
}
},
controlledOrReleaseFormOk(param1, param2, param3, param4) {
let url = param4 ? this.url.controller : this.url.releaseController
let that = this
if (param1 !== '' && param1 !== undefined
&& param2 !== '' && param2 !== undefined
&& param3 !== '' && param3 !== undefined) {
that.loading = true
getAction(url, {
companyCode: param1,
zoneCode: param2,
materialCode: param3
}).then((res) => {
if (res.success) {
//重新计算分页问题
that.reCalculatePage(that.selectedRowKeys.length)
that.$message.success(res.message)
that.loadData()
that.onClearSelected()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.loading = false
})
}
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>