index.vue
13.9 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
<template>
<div class="purchase">
<div class="container">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="table-header">
<h2>退货列表</h2>
<div>
<GLButton type="primary" plain size="small" @click="handleAdd" fn="创建退货">创建退货</GLButton>
<el-button size="small" @click="exportExcel">导出</el-button>
</div>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="checkRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
<template slot="refundStatus" slot-scope="scope">
<div>
<span :class="tableParams.tableColumns[refundStatusIdx].className(scope.scope)" />
<span>{{ tableParams.tableColumns[refundStatusIdx].formatter(scope.scope) }}</span>
</div>
</template>
<div slot="img" slot-scope="scope" v-if="scope.scope.voucherPic">
<img class="img-36" :src="scope.scope.voucherPic" @click="handleEnlargeImg(scope.scope.voucherPic)" />
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<!-- <el-button type="text" @click="handleDetail(scope.scope)">查看</el-button> -->
<GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope"></GLTableButton>
</div>
</GLTable>
<!-- 表格区域 end -->
</div>
<!-- 预览图片 -->
<el-dialog :visible="imgVisible" :before-close="handleCloseImg">
<img width="100%" :src="previewImgUrl" alt="图片" />
</el-dialog>
<!-- 查看 -->
<detailDialog :detail-visible="detailVisible" :recordInfo="recordInfo" v-if="detailVisible" @dialogClose="dialogClose" />
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
// import { membraneTypeList } from '@/utils/constants.js'
import constData from './constant/data.js'
import detailDialog from './detailDialog'
export default {
name: 'warehousing',
components: {
detailDialog
},
data() {
return {
// membraneTypeList: membraneTypeList,
size: 'small',
url: url,
searchForm: {
refundTime: '',
refundCode: '',
yqMerchantId: '',
merchantId: '',
refundStatus: ''
},
tableSearchForm: {},
recordInfo: {},
detailVisible: false,
showFormData: [
{
label: '退货单号',
name: 'refundCode',
type: 'input',
maxlength: '20',
isClear: true
},
{
label: '退货时间',
name: 'refundTime',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
},
{
label: '退货仓库',
name: 'yqMerchantId',
type: 'select',
optionList: [],
optionId: 'merchantNo',
optionLabel: 'merchantName',
optionsName: 'yqMerchantList',
changeAttr: (value, targetItem) => {
value ? this.getServicemerchantrefList(value) : (this.baseData.merchantIdList = [])
this.searchForm.merchantId = ''
this.getOptionsList('showFormData')
}
},
{
label: '退货门店',
name: 'merchantId',
type: 'select',
noDataText: '请先选择盘点仓库',
optionList: [],
optionId: 'merchantId',
optionLabel: 'merchantName',
optionsName: 'merchantIdList'
},
{
label: '单据状态',
name: 'refundStatus',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'refundStatusList'
}
],
// 表格
getListApi: this.$apis.stockManage.refundPage,
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '退货单号',
prop: 'refundCode',
width: 180
},
{
label: '退货时间',
prop: 'refundTime',
width: 180,
formatter: cellValue => {
return dayjs(cellValue.refundTime).format('YYYY-MM-DD HH:mm:ss')
}
},
{
label: '退货人',
prop: 'createdBy'
},
{
label: '退货类型',
prop: 'refundType',
formatter: cellValue => {
return this.baseData.refundTypeList.find(item => item.confId === cellValue.refundType)?.confLabel
}
},
{
label: '退货仓库',
prop: 'yqMerchantName'
},
{
label: '退货门店',
prop: 'merchantName'
},
{
label: '单据状态',
prop: 'refundStatus',
width: 150,
addHtml: 'refundStatus',
formatter: cellValue => {
let item = this.baseData.refundStatusList.find(item => item.confId === cellValue.refundStatus)
return item ? item.confLabel : '-'
},
className: cellValue => {
return {
1: 'yellowSpot',
2: 'yellowSpot',
3: 'redSpot',
4: 'greenSpot',
5: 'ashSpot'
}[cellValue.refundStatus]
}
},
{
label: '备注',
prop: 'remark',
width: 200,
line: 1
},
{
label: '凭证',
prop: 'voucherPic',
addHtml: 'img'
}
]
},
refundStatusIdx: 6,
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
// 表格按钮
tableButtonList: [
{
type: 'el-button',
name: '查看',
attrs: {
type: 'text'
},
listeners: {
click: row => this.handleDetail(row)
}
},
{
type: 'GLButton',
name: '提交审核',
attrs: {
type: 'text',
fn: '提交审核'
},
condition: row => {
return [1, 3].includes(row.refundStatus)
},
listeners: {
click: row => {
this.$confirm('退货申请单,确认提交申请?', '提交确定', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
console.log(row)
this.updateStatus(row, 2, '提交审核成功')
})
.catch(() => {})
}
}
},
{
type: 'GLButton',
name: '编辑',
attrs: {
type: 'text',
fn: '编辑'
},
condition: row => {
return [1, 3].includes(row.refundStatus)
},
listeners: {
click: row => this.handleEdit(row)
}
},
{
type: 'GLButton',
name: '作废',
attrs: {
type: 'text',
fn: '作废'
},
condition: row => {
return [1, 3].includes(row.refundStatus)
},
listeners: {
click: row => {
this.$confirm('作废后无法恢复退货单,是否确认作废?', '退货申请作废确定', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
console.log(row)
this.updateStatus(row, 5, '作废成功')
})
.catch(() => {})
}
}
}
],
// 基本数据
baseData: {
yqMerchantList: [],
merchantIdList: [],
refundTypeList: [
{
confId: 1,
confLabel: '不良退货'
},
{
confId: 2,
confLabel: '呆滞退货'
}
],
refundStatusList: constData.refundStatusList
},
imgVisible: false,
previewImgUrl: ''
}
},
created() {
this.refundStatusIdx = this.tableParams.tableColumns.findIndex(item => item.prop === 'refundStatus')
},
mounted() {
// 获取当前登录账号可见的园区店列表
this.$apis.stockManage.getyqMerchantList({ mainPartnerMerchant: true }).then(res => {
this.baseData.yqMerchantList = res
this.getOptionsList('showFormData')
})
},
methods: {
getParams() {
var params = JSON.parse(JSON.stringify(this.searchForm))
console.log(params)
if (this.searchForm.refundTime) {
params.refundTimeStart = new Date(this.searchForm.refundTime[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.refundTimeEnd = new Date(this.searchForm.refundTime[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
delete params.refundTime
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
// 获取仓库门店
getServicemerchantrefList(merchantId) {
this.$apis.stockManage
.getServicemerchantrefList({
yqMerchantId: merchantId
})
.then(res => {
this.baseData.merchantIdList = res || []
//总店
let _headOffice = this.baseData.yqMerchantList.find(item => item.merchantNo === merchantId)
_headOffice.merchantId = _headOffice.merchantNo
//门店选项中加入总店
this.baseData.merchantIdList.push(_headOffice)
this.getOptionsList('showFormData')
})
},
// 查看详情
handleDetail(row) {
this.recordInfo = row
this.detailVisible = true
},
updateStatus(row, refundStatus, okMessage = '提交成功') {
this.$apis.stockManage
.refundUpdateStatus({
id: row.id,
refundStatus
})
.then(res => {
this.$notify({
message: res.code == '0' ? okMessage : res.message,
type: res.code == '0' ? 'success' : 'error'
})
this.$refs.checkRef.refreshTable()
})
},
handleAdd() {
this.$router.push({
path: '/sendBack/add',
query: {
$title: '创建退货'
}
})
},
handleEdit(row) {
this.$router.push({
path: '/sendBack/add',
query: {
$title: '编辑退货',
row: row
}
})
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
var index = this[formName].findIndex(k => k.name == refreshSigle)
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
}
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.checkRef.data.length ? (this.$refs.checkRef.tableHeightValues = '') : this.$refs.checkRef.setTableHeightFun()
},
exportExcel() {
var params = this.getParams()
this.$apis.stockManage.refundExport(params).then(res => {
window.location.href = res
})
},
handleSearch() {
this.$refs.checkRef.refreshTable()
},
handleReset() {
this.searchForm = {
refundTime: '',
refundCode: '',
yqMerchantId: '',
merchantId: '',
refundStatus: ''
}
this.showFormData[this.findFormIdx('merchantId')].optionList = []
this.handleSearch()
},
findFormIdx(name) {
return this.showFormData.findIndex(item => item.name === name)
},
handleEnlargeImg(url) {
if (url) {
this.previewImgUrl = url
this.imgVisible = !this.imgVisible
}
},
handleCloseImg() {
this.imgVisible = !this.imgVisible
},
dialogClose() {
this.detailVisible = !this.detailVisible
}
}
}
</script>
<style scoped lang="scss">
@import '@/assets/css/mixin.scss';
.purchase {
.table-header {
@include space-between_center;
margin-bottom: 10px;
h2 {
font-weight: 600;
font-size: 16px;
color: #333;
}
}
}
@mixin spotBase {
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 5px;
display: inline-block;
}
.ashSpot {
@include spotBase();
background: #c6c8cc;
}
.greenSpot {
@include spotBase();
background: #2cca74;
}
.yellowSpot {
@include spotBase();
background: #fdb757;
}
.redSpot {
@include spotBase();
background: #eb4e4e;
}
</style>