pointsRecord.vue
16.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
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
559
560
561
562
563
564
565
566
567
568
569
<!-- 积分记录 -->
<template>
<d2-container class="points-record">
<div class="header"
slot="header">
<d2-search ref="showSearch"
class="show-search"
:search-form="searchForm"
:form-data="showFormData"
label-width="100px" />
<div class="up-btns">
<el-button :id="tableParams.btnId"
size="small"
type="primary">
查询
</el-button>
<el-button size="small"
@click="handleReset">
重置
</el-button>
</div>
</div>
<div class="d2-container-content">
<d2-table-header>
<auth-button category="Button"
:show-btn-ids="['9121301', '9121302', '9121303',]" />
</d2-table-header>
<d2-table ref="detailListTable"
:search-form="searchFormSearch"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn">
<div slot="merchantBrandHtml"
slot-scope="scope">
<template v-if="
scope.scope.merchantBrand && scope.scope.merchantBrand.split(',').length > 1
">
<span>{{ scope.scope.merchantBrand.split(',').slice(0, 1).join("") }}</span>
<el-popover placement="top"
width="fit-content"
trigger="hover">
<div :class="{ scrollHeight: scope.scope.merchantBrand.split(',').length >= 10 }">
<div v-for="(item, index) in scope.scope.merchantBrand.split(',')"
:key="index">
{{ item }}
</div>
</div>
<span class="more-info"
slot="reference">...({{ scope.scope.merchantBrand.split(',').length }})</span>
</el-popover>
</template>
<template v-else>
<span v-if="
!scope.scope.merchantBrand || !scope.scope.merchantBrand.split(',').length
">--</span>
<span v-else>{{ scope.scope.merchantBrand.split(',').join("") }}</span>
</template>
</div>
</d2-table>
</div>
<d2-dialog :title="'上传文件'"
:is-visible="fileVisible"
@closeDialog="handleBatchImport"
@confirmDialog="handleConfirmImport">
<slot>
<el-form :model="fileForm"
ref="fileRuleForm"
:rules="fileRules"
label-width="120px">
<el-form-item label="导入文件:"
prop="fileName">
<el-col :span="16">
<el-input readonly
v-model="fileForm.fileName" />
</el-col>
<el-col :span="4"
class="m-l-md">
<el-button class="import-btn">
导入文件
<input type="file"
id="fileUpload"
class="import-input"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
@change="importFile($event)">
<el-link type="primary"
class="import-template"
icon="el-icon-link"
@click="exportTemplate">
模版下载
</el-link>
</el-button>
</el-col>
</el-form-item>
</el-form>
</slot>
</d2-dialog>
<!-- 新增积分记录 -->
<add-dialog :add-visible="addVisible"
v-if="addVisible"
@dialogClose="addDialogClose" />
</d2-container>
</template>
<script>
import { mapActions, mapState } from 'vuex'
import { Util, deepClone, downLoadFile } from '@/common/util'
import addDialog from './components/addDialog'
import { pointPage, pointRule, pointExport, pointImport } from '@api/inStorePoints'
import { getBrandList } from "@/api/shopConfig.js"
import { getParkStore } from "@api/editCustomer"
import { getServiceStore } from "@api/order"
import { priorityShowText, filterOpt, pointValueSignOpt } from '@/common/constants.js'
export default {
name: 'PointsRecord',
props: {
},
data() {
return {
searchForm: {
staffName: '',
staffPhone: '',
serviceMerchantId: '',
merchantId: '',
brandIdList: [],
pointClassification: '',
pointType: '',
createTime: '',
pointValueSign: ''
},
searchFormSearch: {},
showFormData: [{
label: '员工姓名',
name: 'staffName',
type: 'input',
maxlength: '20',
isClear: true
}, {
label: '电话号码',
name: 'staffPhone',
type: 'input',
inputType: "number",
maxlength: '11',
isClear: true
}, {
label: '归属商户',
name: 'merchantId',
type: 'select',
isClear: true,
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
optionsName: "storeIdList",
changeAttr: (value, targetItem) => {
if (value) {
// 获取流量方
this.getServiceStore(value)
} else {
this.baseData.parkServiceList = []
}
this.searchForm.serviceMerchantId = ""
this.getOptionsList()
}
}, {
label: '服务门店',
name: 'serviceMerchantId',
type: 'select',
isClear: true,
noDataText: "请先选择归属商户",
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
optionsName: "parkServiceList"
}, {
label: '门店品牌',
name: 'brandIdList',
type: 'select',
isClear: true,
multiple: true,
multipleLimit: 5,
collapseTags: true,
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "brandList"
}, {
label: "创建时间",
name: "createTime",
type: "datePicker",
isClear: true,
pickerOptions: "rangePickerOptions"
}, {
label: '积分分类',
name: 'pointClassification',
type: 'select',
isClear: true,
optionList: [],
optionId: 'categoryCode',
optionLabel: 'categoryName',
optionsName: 'pointClassificationOpt',
changeAttr: (value, targetItem) => {
this.baseData.pointTypeOpt = []
if (value) {
this.baseData.pointTypeOpt = this.baseData.pointClassificationOpt.find(item => item.categoryCode == value).typeList
}
this.searchForm.pointType = ""
this.getOptionsList()
}
}, {
label: '积分类型',
name: 'pointType',
type: 'select',
isClear: true,
noDataText: "请先选择积分分类",
optionList: [],
optionId: 'typeCode',
optionLabel: 'typeName',
optionsName: 'pointTypeOpt'
}, {
label: '积分增减',
name: 'pointValueSign',
type: 'select',
isClear: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confValue',
optionsName: 'pointValueSignOpt'
}],
getListApi: pointPage,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '姓名',
prop: 'staffName',
width: '150'
}, {
label: '电话号码',
prop: 'staffPhone',
width: '120'
}, {
label: '服务门店',
prop: "serviceMerchantName",
width: '150'
}, {
label: '门店品牌',
prop: 'merchantBrand',
addHtml: "merchantBrandHtml",
width: '180'
}, {
label: '角色',
prop: 'roleName',
width: '100'
}, {
label: "归属商户",
prop: "merchantName",
width: '150'
}, {
label: '积分分类',
prop: 'pointClassificationStr',
width: '120'
}, {
label: '积分类型',
prop: 'pointTypeStr',
width: '120'
}, {
label: '积分描述',
prop: 'pointDescription'
}, {
label: '积分值',
prop: 'pointValue',
width: '100'
}, {
label: '创建时间',
prop: 'createdDate',
width: '150',
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss')
}
}
]
},
baseData: {
filterOpt: deepClone(filterOpt),
supervisorOpt: [],
saleOpt: [],
categoryList: [],
priorityShowText: deepClone(priorityShowText),
pointValueSignOpt: deepClone(pointValueSignOpt),
brandList: [],
pointClassificationOpt: [],
pointTypeOpt: [],
parkServiceList: [],
storeIdList: []
},
detailVisible: false,
handleVisible: false,
recordInfo: {},
params_obj: {},
fileRules: {
fileName: [{ required: true, message: '请上传文件', trigger: 'change' }]
},
fileForm: {},
fileVisible: false,
addVisible: false
}
},
components: {
addDialog
// handleDialog
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList
})
},
mounted() {
this.getBaseData()
},
methods: {
...mapActions({
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
...mapActions('d2admin/user', ['actionSetDownloadList']),
async getBaseData() {
this.getBrandList()
this.getParkStore()
this.pointRule()
this.getOptionsList()
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchFormSearch = deepClone(this.searchForm)
if (this.searchFormSearch.createTime) {
this.searchFormSearch.createdTimeBegin = Util.dateFormate(this.searchFormSearch.createTime[0], 'YYYY-MM-DD HH:mm:ss')
this.searchFormSearch.createdTimeEnd = Util.dateFormate(this.searchFormSearch.createTime[1], 'YYYY-MM-DD') + ' 23:59:59'
// delete this.searchForm.warnCycle
} else {
delete this.searchFormSearch.createdTimeBegin
delete this.searchFormSearch.createdTimeEnd
}
resolve()
})
},
getBrandList() {
getBrandList({}).then((res) => {
this.baseData.brandList = res
this.getOptionsList()
})
},
pointRule() {
pointRule({}).then((res) => {
this.baseData.pointClassificationOpt = res
this.getOptionsList()
})
},
getParkStore() {
getParkStore({}).then((res) => {
res.forEach((item) => {
item.merchantId = item.merchantNo
})
this.baseData.storeIdList = res
this.getOptionsList()
})
},
getServiceStore(merchantIds) {
getServiceStore({
// yqMerchantId: merchantId
yqMerchantIds: merchantIds,
scene: 1
}).then((res) => {
this.baseData.parkServiceList = res || []
this.getOptionsList()
})
},
handleReset() {
this.searchForm = {
staffName: '',
staffPhone: '',
serviceMerchantId: '',
merchantId: '',
brandIdList: [],
pointClassification: '',
pointType: '',
createTime: '',
pointValueSign: ''
}
this.$refs.detailListTable.refreshTable()
},
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] !== '全部' && item.label != '门店品牌'
) {
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]
)
}
})
},
// 模板下载
exportTemplate() {
var params = {}
params.method = 'dj.api.smartcarlife.resident.point.import.template.export.async'
const list = [
...this.dowloadList,
{
name: '驻店积分记录模板',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
handleBatchImport() {
this.fileVisible = !this.fileVisible
this.$refs.fileRuleForm && this.$refs.fileRuleForm.resetFields()
},
// 上传文件,转码为base64
importFile(e) {
const size = e.target.files[0].size / 1024 / 1024
if (size < 9) {
this.$set(this.fileForm, 'fileName', e.target.files[0].name)
// // 转码base64
const reader = new FileReader()
reader.readAsDataURL(e.target.files[0])
reader.onload = event => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(',')
this.fileInfo = e.target.files[0].name.split('.')[e.target.files[0].name.split('.')?.length - 1] + '@' + arrBase64[1]
document.getElementById('fileUpload').value = ''
}
} else {
this.notice.errorTips('上传文件不可超过9M')
}
},
handleConfirmImport() {
this.$refs.fileRuleForm.validate(valid => {
if (valid) {
var params = {
file: this.fileInfo
}
pointImport(params).then(res => {
if (res) {
// 异步处理文件上传 把id传入处理轮询
// const list = [...this.updateList, {
// name: this.fileForm.fileName,
// ifSuccess: false,
// uuid: res,
// type: 'upload'
// }]
// this.actionSetDownloadList({ list, type: 'updateList' })
this.notice.okTips(res)
this.handleBatchImport()
this.$refs.detailListTable.refreshTable()
}
})
}
})
},
findAllPersonRelations(sourceType) {
const params = { sourceType: sourceType }
findAllPersonRelations(params).then((res) => {
if (sourceType == 1) { // 督导
this.baseData.supervisorOpt = res
} else if (sourceType == 2) { // 销售
this.baseData.saleOpt = res
}
this.getOptionsList()
})
},
handleExport() {
var params = this.searchForm
// if (params.statuses.length > 0) {
// const statuses = `statuses[0]`
// params[statuses] = params.statuses[0]
// delete params.statuses
// }
// 去除为null的值
// for (const key in params) {
// if (params[key] === null || params[key] === '') {
// delete params[key]
// }
// }
// params.method = 'dj.api.smartcarlife.warningmsg.warningMsgDetailListWithPageExport'
// const list = [
// ...this.dowloadList,
// {
// name: '员工预警明细',
// exportParam: JSON.stringify(params),
// status: 'waiting',
// timeid: new Date().getTime()
// }
// ]
// this.actionSetDownloadList({ list, type: 'dowloadList' })
pointExport(params).then((res) => {
res && downLoadFile(res)
})
},
handleAdd() {
this.addVisible = !this.addVisible
},
addDialogClose(flag) {
this.addVisible = !this.addVisible
if (flag) {
this.$refs.detailListTable.refreshTable()
}
}
}
}
</script>
<style lang="scss" scoped>
.points-record {
margin-top: 40px;
.m-l-md {
margin-left: 20px;
}
.import-btn {
position: relative;
}
.import-input {
opacity: 0;
position: absolute;
right: 0;
top: 0;
width: 98px;
height: 36px;
cursor: pointer;
font-size: 0;
}
.import-template {
position: absolute;
height: 20px;
top: 50px;
left: 0;
}
}
.more-info {
white-space: nowrap;
color: #5850ff;
cursor: pointer;
}
</style>