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
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
557
558
<!-- 创建盘点 -->
<template>
<div class="addWrap">
<div class="d2-container-content gl-form-min"
style="padding: 10px 20px">
<el-form :inline="true"
size="small"
:model="editCheckForm"
ref="editCheckFormRef"
:rules="formRules"
class="demo-form-inline">
<el-form-item label="盘点仓库:"
prop="yqMerchantId">
<el-select v-model="editCheckForm.yqMerchantId"
@change="changeYqMerchant(editCheckForm.yqMerchantId)"
style="width: 300px">
<el-option v-for="item in yqMerchantIdList"
:key="item.merchantNo"
:label="item.merchantName"
:value="item.merchantNo" />
</el-select>
</el-form-item>
<el-form-item label="盘点门店:"
prop="merchantId">
<el-select v-model="editCheckForm.merchantId"
@change="changeMerchant(editCheckForm.merchantId)"
style="width: 300px">
<el-option v-for="item in merchantList"
:key="item.merchantId"
:label="item.merchantName"
:value="item.merchantId" />
</el-select>
</el-form-item>
</el-form>
</div>
<div class="d2-container-content">
<p class="title">盘存</p>
<div style="padding: 15px 0">
<div class="gl-form-min">
<el-form ref="ruleForm"
:model="searchForm"
size="small"
inline="true">
<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">查询</el-button>
</el-form>
</div>
</div>
<p class="title">盘存</p>
<GLTable ref="recordTable"
:getListApi="getListApi"
:searchForm="searchFormSearch"
:tableParams="tableParams"
:beforeSearchFn="beforeSearchFn"
:pageConf="pageConf">
<div slot="auth-button"
slot-scope="scope">
<el-button type="text"
@click="inventory(scope.scope)"
:disabled="setDisabled(scope.scope)">盘点</el-button>
</div>
</GLTable>
</div>
<div class="d2-container-content">
<p class="title">盘存确认单</p>
<GLTable ref="recordTable2"
:tableData="chooseDataList"
:tableParams="tableParams2"
:hasPage="false">
<template slot="profitAndLoss"
slot-scope="scope">
<span v-if="scope.scope.profitAndLoss || scope.scope.profitAndLoss == 0">
<span v-if="parseFloat(scope.scope.profitAndLoss) > 0"
style="color: blue">{{ '+' + parseFloat(scope.scope.profitAndLoss).toFixed(2) + (membraneTypeList.includes(scope.scope.goodsType) ? '米' : '件') }}</span>
<span v-else-if="parseFloat(scope.scope.profitAndLoss) < 0"
style="color: red">{{ parseFloat(scope.scope.profitAndLoss).toFixed(2) + (membraneTypeList.includes(scope.scope.goodsType) ? '米' : '件') }}</span>
<span
v-else>{{ parseFloat(scope.scope.profitAndLoss).toFixed(2) + (membraneTypeList.includes(scope.scope.goodsType) ? '米' : '件') }}</span>
</span>
<span v-else>-</span>
</template>
<div slot="auth-button"
slot-scope="scope">
<el-button type="text"
@click="cancelInventory(scope.row, scope.$index)">取消</el-button>
</div>
</GLTable>
</div>
<glsx-form ref="addInventoryForm"
:origin-data="editData"
:form-list="editForm"
form-ref="inveFormRef"
@handleAddConfirm="handleAddConfirm"
@handleClose="handleAddClose"></glsx-form>
<!-- 盘点 -->
<inventory-num-dialog :inventory-num-visible="inventoryNumVisible"
:record-info="recordInfo"
v-if="inventoryNumVisible"
@dialogClose="dialogClose" />
</div>
</template>
<script>
import inventoryNumDialog from './inventoryNumDialog'
// import { membraneTypeList } from '@/utils/constants.js'
export default {
name: 'InventoryList',
components: {
inventoryNumDialog
},
data() {
return {
membraneTypeList: this.$membraneTypeList,
searchForm: {
upgradeGoodsNameOrSeries: ''
},
searchFormSearch: {},
searchSelectObj: {},
// getListApi: this.$apis.stockManage.stockRemainPage,
getListApi: null,
tableData: [],
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: 'specificationData',
width: 180,
line: 1
},
{
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'
},
{
label: '所属门店',
prop: 'merchantName'
},
{
label: '膜卷号',
prop: 'filmRollNo'
}
]
},
tableParams2: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '规格',
prop: 'specificationData',
width: 180,
line: 1
},
{
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: 'checkStock',
formatter: cellValue => {
return cellValue.checkStock || cellValue.checkStock == 0 ? parseFloat(cellValue.checkStock).toFixed(2) + (this.$membraneTypeList.includes(cellValue.goodsType) ? '米' : '件') : '-'
}
},
{
label: '盘盈盘亏',
prop: 'profitAndLoss',
addHtml: 'profitAndLoss'
},
{
label: '所属仓库',
prop: 'yqMerchantName'
},
{
label: '所属门店',
prop: 'merchantName'
},
{
label: '膜卷号',
prop: 'filmRollNo'
}
]
},
baseData: {
// productTypeList: [],
// yqMerchantList: []
},
editData: {
thumbUrlList: []
},
editForm: [
{
formBlock: [
{
name: 'thumbUrlList',
label: '凭证图片',
type: 'photo',
tips: ['请上传小于2M的图片'],
maxPhotoNum: 1
},
{
name: 'remark',
label: '备注说明',
type: 'textarea',
maxlength: 100
}
]
}
],
inventoryNumVisible: false,
recordInfo: null,
chooseDataList: [],
editCheckForm: {
yqMerchantId: '',
merchantId: ''
},
formRules: {
yqMerchantId: [
{
required: true,
message: '请选择盘点仓库',
trigger: 'change'
}
],
merchantId: [
{
required: true,
message: '请选择盘点门店',
trigger: 'change'
}
]
},
yqMerchantIdList: [], //盘点仓库
merchantList: [], //盘点门店
oldyqMerchantId: '', //之前选择的仓库
oldMerchantId: '' //之前选择的门店
}
},
watch: {
'editCheckForm.yqMerchantId'(val, oldval) {
console.log(val, oldval, '监听yqMerchantId')
// this.getListApi = this.$apis.stockManage.stockRemainPage
if (this.yqMerchantIdList.length == 1) {
//当只有一个选项时不弹提示框
// this.$refs.recordTable.refreshTable()
} else {
if (val != this.oldyqMerchantId) {
//与之前的选项不一样
this.editCheckForm.merchantId = ''
this.switchData(val, oldval, 'yqMerchant')
}
}
},
'editCheckForm.merchantId'(val, oldval2) {
console.log(val, oldval2, '监听merchantId')
this.getListApi = this.$apis.stockManage.stockRemainPage
if (this.merchantList.length == 1) {
this.$refs.recordTable.refreshTable()
} else {
if (val != this.oldMerchantId) {
//与之前的选项不一样
this.switchData(val, oldval2, 'merchant')
}
}
}
},
mounted() {
// 获取当前登录账号可见的园区店列表
this.$apis.stockManage.getyqMerchantList({ mainPartnerMerchant: true }).then(res => {
this.yqMerchantIdList = res
if (this.yqMerchantIdList && this.yqMerchantIdList.length == 1) {
this.editCheckForm.yqMerchantId = this.yqMerchantIdList[0].merchantNo
this.getServicemerchantrefList(this.editCheckForm.yqMerchantId)
}
})
},
methods: {
changeYqMerchant(merchantId) {
// this.switchData(merchantId, 'yqMerchant')
},
changeMerchant(merchantId) {
// this.switchData(merchantId, 'merchant')
},
// 获取仓库门店
getServicemerchantrefList(merchantId) {
this.$apis.stockManage
.getServicemerchantrefList({
yqMerchantId: merchantId
})
.then(res => {
this.merchantList = res || []
//总店
let _headOffice = this.yqMerchantIdList.find(item => item.merchantNo === merchantId)
_headOffice.merchantId = _headOffice.merchantNo
//门店选项中加入总店
this.merchantList.push(_headOffice)
if (this.merchantList && this.merchantList.length == 1) {
this.editCheckForm.merchantId = this.merchantList[0].merchantId
}
})
},
switchData(val, oldval, type) {
if (this.chooseDataList && this.chooseDataList.length > 0) {
//当盘存确认单有数据时提示
this.$confirm('切换盘点仓库和盘点门店,自动重置已盘点内容;是否确定切换?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
if (type == 'yqMerchant') {
this.getServicemerchantrefList(val)
} else {
//选择门店以后才更新盘存数据
this.$refs.recordTable.refreshTable()
}
//清空盘存确认单数据
this.chooseDataList = []
})
.catch(err => {
console.log(err)
if (type == 'yqMerchant') {
this.editCheckForm.yqMerchantId = oldval
this.oldyqMerchantId = oldval
} else if (type == 'merchant') {
this.editCheckForm.merchantId = oldval
this.oldMerchantId = oldval
}
})
} else {
if (type == 'yqMerchant') {
this.getServicemerchantrefList(val)
} else {
//选择门店以后才更新盘存数据
this.$refs.recordTable.refreshTable()
}
}
},
beforeSearchFn() {
return new Promise(resolve => {
let _form = {
...this.searchForm,
...this.editCheckForm
}
this.searchFormSearch = this.$common.utils.deepClone(_form)
resolve()
})
},
getOptionsList() {
this.showFormData.forEach((item, index) => {
if (item.type === 'select') {
if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
const temp = {}
temp[this.showFormData[index].optionId] = ''
temp[this.showFormData[index].optionLabel] = '全部'
this.baseData[item.optionsName].unshift(temp)
}
this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
}
})
},
handleSearch() {
console.log(this.searchFormSearch)
if (this.searchFormSearch.yqMerchantId && this.searchFormSearch.merchantId) {
this.getListApi = this.$apis.stockManage.stockRemainPage
this.$refs.recordTable.refreshTable()
} else {
this.$message({
type: 'error',
message: '请选择仓库和门店再查询数据'
})
}
},
// 盘点
inventory(row) {
this.recordInfo = row
this.inventoryNumVisible = true
},
// 设置禁选
setDisabled(row) {
const index = this.chooseDataList.findIndex(item => item.id == row.id)
if (index == -1) {
return false
} else {
return true
}
},
dialogClose(chooseData) {
this.inventoryNumVisible = !this.inventoryNumVisible
console.log('chooseData', 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
},
// 取消
cancelInventory(row, index) {
this.chooseDataList.splice(index, 1)
},
handleAddConfirm(data) {
this.$refs.editCheckFormRef.validate(valid => {
if (valid) {
if (this.chooseDataList.length == 0) {
this.$notify({
type: 'warning',
title: '请选择盘存商品'
})
return
}
var params = {}
params.stockCheckDetailList = this.chooseDataList
if (data.thumbUrlList.length > 0) {
params.voucherPic = data.thumbUrlList[0].content
}
if (data.remark) {
params.remark = data.remark
}
params = {
...params,
...this.editCheckForm
}
this.$confirm('盘点单保存后,系统自动按照盘点实际库存进行库存更新;是否确定保存?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$apis.stockManage.saveStockCheck(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>