ReceiptModal.vue
13.6 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
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭"
>
<a-row :gutter="24">
<a-col :span="9">
<a-spin :spinning="confirmLoading">
<a-form-model ref="form" :model="model" :rules="validatorRules">
<a-row>
<a-col :span="12">
<a-form-model-item label="容器编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="containerCode">
<a-input ref="containerCode" v-model="model.containerCode" placeholder="请输入容器编码"/>
</a-form-model-item>
</a-col>
<a-col :span="6">
<a-button type="default" style="margin-top: 3px" @click="selectSomeContainer()">选取未满容器</a-button>
</a-col>
<a-col :span="4">
<a-button type="default" style="margin-top: 3px" @click="selectEmptyContainer()">选取空容器</a-button>
</a-col>
</a-row>
</a-form-model>
</a-spin>
<a-table ref="table"
rowKey="id"
size="middle"
bordered
:columns="columns"
:dataSource="dataSource"
:pagination="false"
:customRow="customRowFn"
:rowSelection="{selectedRowKeys: this.selectedRowKeys, onChange: this.onSelectChange, type: 'checkbox'}">
<span slot="action" slot-scope="text, record">
<a-input-number placeholder="请输入组盘数量" readonly v-model="record.taskQty" :value="text"/>
</span>
<!-- <span slot="action2" slot-scope="text, record">
<a-button type="primary" @click="selectContainer(record)">选取容器</a-button>
</span>-->
<span slot="inventoryStatus" slot-scope="inventoryStatus">
<a-tag :key="inventoryStatus" color="blue" :color="getStatusColor(inventoryStatus)">
{{ solutionInvStatus(inventoryStatus) }}
</a-tag>
</span>
</a-table>
</a-col>
<a-col :span="15">
<a-card title="库存交易" :bordered="false" :head-style="{padding:0}" :body-style="{padding:0}">
<a-table
size="middle"
rowKey="id"
bordered
:scroll="{ x:true }"
ref="invTransaction"
:columns="invTransactionColumns"
:dataSource="invTransactionDataSource"
:pagination="invTransactionPage"
@change="handleTableChange"
>
<span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
<a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
{{ inventoryStatus_dictText }}
</a-tag>
</span>
<span slot="zoneCode" slot-scope="zoneCode">
<a-tag :key="zoneCode" color="blue">
{{ solutionZoneCode(zoneCode) }}
</a-tag>
</span>
</a-table>
</a-card>
</a-col>
</a-row>
<select-inv-container-header ref="selectContainerForm"
v-on:getContainer="getContainerCode"></select-inv-container-header>
<select-empty-container ref="selectEmptyContainerForm"
v-on:getContainer="getContainerCode"></select-empty-container>
</j-modal>
</template>
<script>
import { getAction, httpAction } from '@/api/manage'
import { ajaxGetDictItems, getZoneList, listReceiveByReceiptId } from '@/api/api'
import SelectInvContainerHeader from './SelectInvContainerHeader'
import SelectEmptyContainer from '@views/system/receipt/modules/SelectEmptyContainer.vue'
import { mixinDevice } from '@/utils/mixin'
export default {
name: 'ReceiptModal',
components: { SelectEmptyContainer, SelectInvContainerHeader },
mixins: [mixinDevice],
props: {
mainId: {
type: String,
required: false,
default: ''
}
},
data() {
return {
title: '操作',
width: '90%',
visible: false,
materialList: {},
querySource: {},
dataSource: [],
invTransactionDataSource: [],
invTransactionPage: {
current: 1,
pageSize: 5,
pageSizeOptions: ['5', '10', '50'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' 共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
selectedRowKeys: [],
selectionRows: [],
materialCode: null,
invStatus: [],
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 8 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 14 }
},
columns: [
{
title: '物料编码',
dataIndex: 'materialCode',
align: 'center',
width: 160,
hideCheckbox: false
},
{
title: '物料名称',
dataIndex: 'materialName',
align: 'center',
width: 160
},
{
title: '库存状态',
dataIndex: 'inventoryStatus',
align: 'center',
width: 96,
scopedSlots: { customRender: 'inventoryStatus' }
},
/* {
title: '批次',
dataIndex: 'batch',
align: 'center'
}, */
{
title: '可收数量',
dataIndex: 'qty',
align: 'center',
width: 80
},
/* {
title: '组盘数量',
dataIndex: 'action',
align: 'center',
key: 'action',
hidden: true,
scopedSlots: { customRender: 'action' }
} *//* ,
{
title: '操作',
dataIndex: 'action2',
align: "center",
width: 147,
scopedSlots: {customRender: 'action2'}
} */
],
invTransactionColumns: [
{
title: '库区',
align: 'center',
dataIndex: 'zoneCode',
key: 'zoneCode',
scopedSlots: { customRender: 'zoneCode' }
},
{
title: '容器编码',
align: 'center',
dataIndex: 'containerCode'
},
{
title: '起始库位',
align: 'center',
dataIndex: 'fromLocationCode'
},
{
title: '目标库位',
align: 'center',
dataIndex: 'toLocationCode'
},
{
title: '交易类型',
align: 'center',
dataIndex: 'type_dictText'
},
{
title: '物料编码',
dataIndex: 'materialCode',
align: 'center',
width: 160,
},
/* {
title: '物料名称',
dataIndex: 'materialName',
width: 160,
align: 'center',
}, */
{
title: '交易数量',
align: 'center',
dataIndex: 'qty'
},
{
title: '库存状态',
dataIndex: 'inventoryStatus_dictText',
align: 'center',
width: 96,
scopedSlots: { customRender: 'inventoryStatus_dictText' }
},
{
title: '交易日期',
align: 'center',
dataIndex: 'createTime'
},
],
confirmLoading: false,
validatorRules: {
containerCode: [{ required: true, message: '请输入容器编码!' }]
},
dictOptions: {},
superFieldList: [],
zoneList: [],
zoneOptions: [],
url: {
add: '/receipt/receiveHeader/receiving',
edit: '/receipt/receiptHeader/editReceiptDetail',
inventoryTransactionList: '/inventory/inventoryTransaction/list'
},
}
},
created() {
//备份model原始值
// this.searchReceive()
this.getSuperFieldList()
// this.modelDefault = JSON.parse(JSON.stringify(this.model))
this.loadFrom()
},
computed: {},
methods: {
loadFrom() {
getZoneList().then((res) => {
if (res.success) {
this.zoneList = res.result
//延迟半秒执行,避免组件未加载完,数据已经加载完
setTimeout(() => {
//slice可以在数组的任何位置进行删除/添加操作
this.zoneOptions.splice(0, 1)
for (let i = 0; i < res.result.length; i++) {
this.zoneOptions.push({ value: res.result[i].code, text: res.result[i].name })
}
}, 500)
}
})
ajaxGetDictItems('inventory_status').then((res) => {
if (res.success) {
this.invStatus = res.result
}
})
},
solutionZoneCode(value) {
var 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 = {
'good ': 'green',
'良品 ': 'green',
'defective': 'red',
'次品': 'red',
'discussed': 'grey',
'待确认': 'grey',
'scrap': 'purple',
'报废品': 'purple',
default: 'blue'
}
return colors[status] || colors.default
},
handleTableChange(pagination, filters, sorter) {
this.invTransactionPage = pagination;
this.loadInvTransaction();
},
getContainerCode(e) {
this.$nextTick(function () {
let record = { containerCode: e }
this.model = Object.assign({}, record)
})
},
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('')
},
edit(record) {
this.model = Object.assign({}, record)
this.visible = true
this.searchReceive()
},
/* selectContainer(record) {
this.$refs.selectContainerForm.edit(record);
}, */
selectSomeContainer() {
this.$refs.selectContainerForm.edit()
},
selectEmptyContainer() {
this.$refs.selectEmptyContainerForm.edit()
},
close() {
this.$emit('close')
this.visible = false
this.$refs.form.clearValidate()
this.selectionRows = []
this.selectedRowKeys = []
this.materialCode = null
this.invTransactionDataSource = []
},
searchReceive() {
const that = this
that.querySource.receiptCode = that.model.code
listReceiveByReceiptId(that.querySource).then(res => {
that.dataSource = res.result
that.dataSource.forEach(item => {
if (item.qty === 0) {
item.taskQty = 0
} else {
item.taskQty = 1
}
})
})
},
initDictConfig() {
},
getSuperFieldList() {
let fieldList = []
fieldList.push({ type: 'string', value: 'inventoryStatus', text: '库存状态', dictCode: 'inventory_status' })
this.superFieldList = fieldList
},
handleOk() {
const that = this
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true
let httpurl = ''
let method = ''
httpurl += this.url.add
method = 'post'
if (this.dataSource[0] == null) {
that.confirmLoading = false
that.$message.warning('入库单没有详情!')
return
}
if (this.selectionRows.length <= 0) {
that.confirmLoading = false
that.$message.warning('没有勾选组盘物料信息')
return
}
//this.dataSource[0].containerCode = this.model.containerCode
this.selectionRows.forEach(data => {
data.containerCode = this.model.containerCode
})
// 过滤掉可收数量为0的
let params = this.selectionRows.filter(x => x.qty > 0 || x.taskQty > 0)
httpAction(httpurl, params, method)
.then(res => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
that.close()
} else {
that.$message.warning(res.message)
}
})
.finally(() => {
that.confirmLoading = false
})
} else {
return false
}
})
},
handleCancel() {
this.close()
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys
this.selectionRows = selectionRows
},
onClearSelected() {
this.selectedRowKeys = []
this.selectionRows = []
},
customRowFn(record) {
return {
on: {
click: () => {
this.materialCode = record.materialCode;
this.loadInvTransaction();
}
}
}
},
loadInvTransaction() {
let params = { materialCode: this.materialCode, type: 20 }
params.pageNo = this.invTransactionPage.current;
params.pageSize = this.invTransactionPage.pageSize;
getAction(this.url.inventoryTransactionList, params).then(res => {
if (res.success) {
this.invTransactionDataSource = res.result.records
this.invTransactionPage.total = res.result.total
} else {
this.$message.warning(res.message)
}
}
)
}
}
}
</script>