add.vue
16.8 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
<template>
<div class="addWrap">
<div class="d2-container-content gl-form-min"
style="padding: 10px 20px">
<el-form :inline="true"
size="small"
:model="editAllocationForm"
ref="editAllocationFormRef"
:rules="formRules"
class="demo-form-inline">
<el-form-item label="调出仓库:"
prop="callOutYqMerchantId">
<el-select v-model="editAllocationForm.callOutYqMerchantId"
style="width: 300px">
<el-option v-for="item in callOutYqMerchantList"
:key="item.merchantNo"
:label="item.merchantName"
:value="item.merchantNo" />
</el-select>
</el-form-item>
<el-form-item label="调出门店:"
prop="callOutMerchantId">
<el-select v-model="editAllocationForm.callOutMerchantId"
style="width: 300px">
<el-option v-for="item in callOutMerchantList"
:key="item.merchantId"
:label="item.merchantName"
:value="item.merchantId" />
</el-select>
</el-form-item>
<br />
<el-form-item label="调入仓库:"
prop="callInYqMerchantId">
<el-select v-model="editAllocationForm.callInYqMerchantId"
@change="changeCallInYqMerchant(editAllocationForm.callInYqMerchantId)"
style="width: 300px">
<el-option v-for="item in callInYqMerchantList"
:key="item.merchantNo"
:label="item.merchantName"
:value="item.merchantNo" />
</el-select>
</el-form-item>
<el-form-item label="调入门店:"
prop="callInMerchantId">
<el-select v-model="editAllocationForm.callInMerchantId"
style="width: 300px">
<el-option v-for="item in callInMerchantList"
:key="item.merchantId"
:label="item.merchantName"
:value="item.merchantId" />
</el-select>
</el-form-item>
</el-form>
</div>
<div class="d2-container-content">
<div style="padding: 15px 0">
<div class="gl-form-min">
<el-form :inline="true"
size="small"
:model="editAllocationForm">
<el-form-item label="">
<el-input v-model="searchForm.upgradeGoodsNameOrSeries"
style="width: 200px"
placeholder="请输入商品名称/系列"
maxlength="20"
clearable />
</el-form-item>
<el-button @click="handleSearch"
size="small"
type="primary"
style="marginleft: 15px">查询</el-button>
</el-form>
</div>
</div>
<GLTable ref="allocationTable"
:getListApi="getListApi"
:pageConf="pageConf"
:searchForm="searchFormSearch"
:tableParams="tableParams"
:beforeSearchFn="beforeSearchFn">
<div slot="auth-button"
slot-scope="scope">
<el-button type="text"
@click="allocation(scope.scope)"
:disabled="setDisabled(scope.scope)">选择</el-button>
</div>
</GLTable>
</div>
<div class="d2-container-content">
<p class="title">调拨确认单</p>
<GLTable ref="allocationTable2"
:tableData="chooseDataList"
:tableParams="tableParams2"
:hasPage="false">
<div slot="auth-button"
slot-scope="scope">
<el-button type="text"
@click="cancelAllocation(scope.row, scope.$index)">取消</el-button>
</div>
</GLTable>
</div>
<glsx-form ref="allocationForm"
:origin-data="editData"
:form-list="editForm"
form-ref="inveFormRef"
@handleAddConfirm="handleAddConfirm"
@handleClose="handleAddClose"></glsx-form>
<!-- 盘点 -->
<allocation-num-dialog :allocation-num-visible="allocationNumVisible"
:allocation-info="allocationInfo"
v-if="allocationNumVisible"
@dialogClose="dialogClose" />
</div>
</template>
<script>
import allocationNumDialog from './allocationNumDialog'
import { membraneTypeList } from '@/utils/constants.js'
export default {
name: 'allocationList',
components: {
allocationNumDialog
},
data() {
return {
callOutYqMerchantList: [],
callInYqMerchantList: [],
callOutMerchantList: [],
callInMerchantList: [],
membraneTypeList: membraneTypeList,
searchForm: {
upgradeGoodsNameOrSeries: '',
stockFlag: true
},
searchFormSearch: {},
searchSelectObj: {},
showFormData: [
{
// label: '商品名称/系列',
placeholder: '请输入商品名称/系列',
name: 'upgradeGoodsNameOrSeries',
type: 'input',
maxlength: '20',
isClear: true
}
],
getListApi: this.$apis.stockManage.stockRemainPage,
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品名称',
prop: 'upgradeGoodsName'
},
{
label: '商品编码',
prop: 'productCode',
width: '250px'
},
{
label: '系列',
prop: 'goodsSeries'
},
{
label: '所属分类',
prop: 'goodsTypeName'
},
{
label: '库存',
prop: 'stock',
formatter: cellValue => {
return cellValue.stock || cellValue.stock == 0 ? parseFloat(cellValue.stock).toFixed(2) + (this.membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
}
},
{
label: '所属门店',
prop: 'yqMerchantName'
}
]
},
tableParams2: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '商品编码',
prop: 'productCode',
width: '250px'
},
{
label: '系列',
prop: 'sourceMaterialName'
},
{
label: '所属分类',
prop: 'goodsTypeName'
},
{
label: '库存',
prop: 'stock',
formatter: cellValue => {
return cellValue.stock || cellValue.stock == 0 ? parseFloat(cellValue.stock).toFixed(2) + (this.membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
}
},
{
label: '调拨库存',
prop: 'allocateNumber ',
formatter: cellValue => {
return cellValue.allocateNumber || cellValue.allocateNumber == 0 ? parseFloat(cellValue.allocateNumber).toFixed(2) + (this.membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
}
}
]
},
editData: {
// thumbUrlList: [],
},
editForm: [
{
formBlock: [
{
name: 'deliveryNumber',
label: '承运单号',
type: 'input',
maxlength: 50,
width: '300px'
},
{
name: 'deliveryCompany',
label: '承运公司',
type: 'input',
maxlength: 20,
width: '300px'
},
{
name: 'remark',
label: '备注说明',
type: 'textarea',
maxlength: 100
},
]
}
],
editAllocationForm: {
callOutYqMerchantId: '',//调出仓库
callOutMerchantId: '',//调出门店
callInYqMerchantId: '',//调入仓库
callInMerchantId: '',//调入门店
},
allocationNumVisible: false,
allocationInfo: null,
chooseDataList: [],
formRules: {
callOutYqMerchantId: [
{
required: true,
message: '请选择调出仓库',
trigger: 'change'
}
],
callOutMerchantId: [
{
required: true,
message: '请选择调出门店',
trigger: 'change'
}
],
callInYqMerchantId: [
{
required: true,
message: '请选择调入仓库',
trigger: 'change'
}
],
callInMerchantId: [
{
required: true,
message: '请选择调入门店',
trigger: 'change'
}
]
},
oldyqMerchantId: '',//之前选择的调出仓库
oldMerchantId: '',//之前选择的调出门店
}
},
created() {
// if (window.__POWERED_BY_QIANKUN__) {
// this.callOutYqMerchantList = [{ merchantNo: this.$globalState.session.merchantId + '', merchantName: this.$globalState.session.merchantName }]
// }
},
watch: {
'editAllocationForm.callOutYqMerchantId'(val, oldval) {
console.log(val, oldval, "监听callOutYqMerchantId");
// if (this.callOutYqMerchantList.length > 1) {//选项大于1个
if (val != this.oldyqMerchantId) {//与之前的选项不一样
this.editAllocationForm.callOutMerchantId = ''
this.switchData(val, oldval, 'yqMerchant')
}
// }
},
'editAllocationForm.callOutMerchantId'(val, oldval) {
console.log(val, oldval, "监听callOutMerchantId");
if (val != this.oldMerchantId) {//与之前的选项不一样
this.switchData(val, oldval, 'merchant')
}
}
},
mounted() {
// this.editAllocationForm.callOutYqMerchantId = this.callOutYqMerchantList[0].merchantNo
// 调出仓库
this.$apis.stockManage.getyqMerchantList({ mainPartnerMerchant: true }).then(res => {
this.callOutYqMerchantList = res
this.callInYqMerchantList = res
// if (this.callOutYqMerchantList && this.callOutYqMerchantList.length == 1) {
// this.editAllocationForm.callOutYqMerchantId = this.callOutYqMerchantList[0].merchantNo
// this.getServicemerchantrefList(this.editAllocationForm.callOutYqMerchantId, 'out')
// }
})
//调入仓库
// this.$apis.stockManage.yqRelatedList({ includeSelf: false }).then(res => {
// this.callInYqMerchantList = res
// if (this.callInYqMerchantList && this.callInYqMerchantList.length == 1) {
// this.editAllocationForm.callInYqMerchantId = this.callInYqMerchantList[0].merchantId
// this.getServicemerchantrefList(this.editAllocationForm.callInYqMerchantId, 'in')
// }
// })
},
methods: {
beforeSearchFn() {
return new Promise(resolve => {
let _form = {
...this.searchForm,
...this.editAllocationForm
}
this.searchFormSearch = this.$common.utils.deepClone(_form)
resolve()
})
},
handleSearch() {
this.$refs.allocationTable.refreshTable()
},
// 获取仓库门店
getServicemerchantrefList(merchantId, type) {
this.$apis.stockManage.getServicemerchantrefList({
yqMerchantId: merchantId
}).then(res => {
if (type == 'out') {
this.callOutMerchantList = res || []
//总店
let _headOffice = this.callOutYqMerchantList.find(item => item.merchantNo === merchantId)
_headOffice.merchantId = _headOffice.merchantNo
//门店选项中加入总店
this.callOutMerchantList.push(_headOffice)
// if (this.callOutMerchantList && this.callOutMerchantList.length == 1) {
// this.editAllocationForm.callOutMerchantId = this.callOutMerchantList[0].merchantId
// }
} else if (type == 'in') {
this.callInMerchantList = res || []
//总店
let _headOffice = this.callInYqMerchantList.find(item => item.merchantNo === merchantId)
_headOffice.merchantId = _headOffice.merchantNo
//门店选项中加入总店
this.callInMerchantList.push(_headOffice)
// if (this.callInMerchantList && this.callInMerchantList.length == 1) {
// this.editAllocationForm.callInMerchantId = this.callOutMerchantList[0].merchantId
// }
console.log(this.callInMerchantList);
}
})
},
switchData(val, oldval, type) {
this.$confirm('切换调出仓库和调出门店,自动重置已调拨内容;是否确定切换?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
if (type == 'yqMerchant') {
this.getServicemerchantrefList(val, 'out')
}
//更新调拨数据以及清空调拨确认单数据
this.$refs.allocationTable.refreshTable()
this.chooseDataList = []
})
.catch(err => {
console.log(err)
if (type == 'yqMerchant') {//调出仓库
this.editAllocationForm.callOutYqMerchantId = oldval
this.oldyqMerchantId = oldval
} else if (type == 'merchant') {//调出门店
this.editAllocationForm.callOutMerchantId = oldval
this.oldMerchantId = oldval
}
})
},
changeCallInYqMerchant(merchantId) {
this.editAllocationForm.callInMerchantId = ''
this.getServicemerchantrefList(merchantId, 'in')
},
// 调拨
allocation(row) {
this.allocationInfo = row
this.allocationNumVisible = true
},
//设置禁选
setDisabled(row) {
const index = this.chooseDataList.findIndex(item => item.id == row.id)
if (index == -1) {
return false
} else {
return true
}
},
dialogClose(chooseData) {
this.allocationNumVisible = !this.allocationNumVisible
console.log(chooseData)
if (chooseData) {
chooseData = this.fieldConvert(chooseData)
this.chooseDataList.push(chooseData)
}
},
//选择的数据与提交数据之间的字段转换
fieldConvert(obj) {
obj.goodsId = obj.upgradeGoodsId
obj.goodsName = obj.upgradeGoodsName
obj.sourceMaterialName = obj.goodsSeries
return obj
},
// 取消
cancelAllocation(row, index) {
this.chooseDataList.splice(index, 1)
},
handleAddConfirm(data) {
// return console.log(data);
this.$refs.editAllocationFormRef.validate(valid => {
if (valid) {
if (this.chooseDataList.length == 0) {
this.$notify({
type: 'warning',
title: '请选择调拨商品'
})
return
}
var params = {}
params.stockCheckDetailList = this.chooseDataList
if (data.remark) {
params.remark = data.remark
}
params.deliveryNumber = data.deliveryNumber
params.deliveryCompany = data.deliveryCompany
params = {
...params,
...this.editAllocationForm
}
this.$confirm('调拨单保存后,系统自动按照调拨数量对调出和调入门店进行库存更新;是否确定保存?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$apis.stockManage.saveStockAllocate(params).then(res => {
this.$notify({
type: 'success',
title: res.message || '操作成功'
})
this.handleAddClose()
})
})
.catch(err => {
console.log(err)
})
}
})
},
handleAddClose(isRefresh = false) {
this.$router.go(-1)
}
}
}
</script>
<style scoped>
.d2-container-content {
background: #fff;
padding: 20px;
margin-bottom: 20px;
}
.count-txt {
font-weight: 700;
color: #2a58ad;
margin: 0 2px;
}
.title {
font-weight: 600;
font-size: 16px;
color: #333333;
padding: 17px 0;
}
.leftSpan {
display: inline-block;
box-sizing: border-box;
margin-right: 10px;
}
</style>