recordList.vue
15.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
<!-- 预录客户列表 -->
<template>
<d2-container class="record-list">
<div class="header" slot="header">
<d2-search ref="showSearch" class="show-search" :search-form="searchForm" :form-data="showFormData">
<!-- <p class="custom-input">
<el-input
size="small"
v-model="searchForm.standNoOrCustomerName"
placeholder="客户姓名或车架号或钥匙号"
suffix-icon="el-icon-search"
></el-input>
</p> -->
</d2-search>
<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>
<span slot="left">
<!-- 2024/9 独立版本 -->
<!-- <auth-button category="Button" style="{display: inline-block}" :show-btn-ids="['9020201']" /> -->
<span style="margin-left: 0;" class="table-header-left-txt">已预录客户列表{{ total }}条记录。</span>
</span>
<span>
<span class="btn-tips"><img src="../../assets/icon-warn.png">预录信息只能导入1.1场景的客户档案</span>
<auth-button category="Button" :show-btn-ids="['9020202']" />
</span>
</d2-table-header>
<d2-table ref="recordTable" :search-form="tableSearchForm" :table-params="tableParams" :get-list-api="getListApi"
:before-search-fn="beforeSearchFn">
<span slot="baseGoodsStr" slot-scope="scope">
<p v-for="(item, index) in scope.scope.baseGoodsStr ? scope.scope.baseGoodsStr.split(',') : []" :key="index">{{
item }}</p>
</span>
<auth-button slot="auth-button" slot-scope="scope" :data="scope.scope" />
</d2-table>
</div>
<d2-dialog :title="'上传文件'" :is-visible="fileVisible" @closeDialog="handleImport" @confirmDialog="handleConfirmImport">
<slot>
<el-form :model="fileForm" ref="fileRuleForm" :rules="fileRules" label-width="120px">
<!-- <el-form-item v-if="userInfo.beSuper" label="园区店:" prop="yqMerchantId">
<el-select v-model="fileForm.yqMerchantId">
<el-option v-for="item in baseData.parkServiceList.filter(i => i.merchantName !== '全部')"
:key="item.merchantId" :value="item.merchantId" :label="item.merchantName" />
</el-select>
</el-form-item> -->
<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 href="http://img01.glsx.com.cn/upload/salesexcel/预录订单导入模板.xlsx" type="primary"
class="import-template" icon="el-icon-link">
模版下载
</el-link> -->
<el-link type="primary"
class="import-template"
icon="el-icon-link"
@click="exportTemplate">
模版下载
</el-link>
</el-button>
</el-col>
</el-form-item>
<el-form-item v-show="showNum">
<span>导入成功{{ importNum.succNum }}条,导入失败{{ importNum.failNum }}条</span>
</el-form-item>
</el-form>
</slot>
</d2-dialog>
</d2-container>
</template>
<script>
// import _ from 'lodash'
import { deepClone, Util } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { getList, getOrderDetail, recordUpload, getOrderTotal } from '@api/recordList'
import { getServiceStore, getParkStore, getStaff, getGoods } from '@api/editCustomer'
import { exportJsonToExcel } from '@/common/Export2Excel.js'
export default {
name: 'RecordList',
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
hideVisible: false,
fileVisible: false,
fileForm: {},
total: 0,
showNum: false,
importNum: {
succNum: 0,
failNum: 0
},
fileRules: {
yqMerchantId: [{ required: true, message: '请选择园区店', trigger: 'change' }],
fileName: [{ required: true, message: '请上传文件', trigger: 'change' }]
},
tableSearchForm: {},
searchForm: {
shopOrYqMerchantId: '',
yqMerchantId: '',
merchantId: '',
employeeName: '',
carSeriesTypeNameSearch: '',
entryTime: '',
customerName: ''
},
showFormData: [{
label: '园区店',
name: 'yqMerchantId',
type: 'select',
optionList: [],
optionId: 'merchantId',
optionLabel: 'merchantName',
optionsName: 'parkServiceList',
changeAttr: (value, targetItem) => {
if (value) {
this.getServiceStore(value)
} else {
this.baseData.storeIdList = []
}
this.searchForm.merchantId = ''
this.getOptionsList()
}
}, {
label: '4s店',
name: 'merchantId',
type: 'select',
optionList: [],
optionId: 'merchantId',
optionLabel: 'merchantName',
optionsName: 'storeIdList',
noDataText: '请先选择园区店',
changeAttr: (value, targetItem) => {
}
}, {
label: '商户号',
name: 'shopOrYqMerchantId',
type: 'input',
keyFn: this.keyDowmGetList,
isClear: true
}, {
label: '销售顾问',
name: 'employeeName',
type: 'input',
keyFn: this.keyDowmGetList,
isClear: true
}, {
label: '车型',
name: 'carSeriesTypeNameSearch',
type: 'input',
keyFn: this.keyDowmGetList,
isClear: true
}, {
label: '导入日期',
name: 'entryTime',
type: 'datePicker',
isClear: true,
pickerOptions: 'rangePickerOptions'
}, {
label: '客户姓名',
name: 'customerName',
type: 'input',
keyFn: this.keyDowmGetList,
isClear: true
}],
getListApi: getList,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
// tableOption: true, 2024/9 独立版本
tableOption: false,
tableColumns: [{
label: '4s店名称',
prop: 'merchantName',
width: '150px'
}, {
label: '4s店商户号',
prop: 'merchantId',
width: '100px'
}, {
label: '园区店名称',
prop: 'yqMerchantName',
width: '150px'
},
{
label: '园区店店商户号',
prop: 'yqMerchantId',
width: '150px'
},
{
label: '导入日期',
prop: 'orderTime',
formatter: (cellValue) => {
return cellValue.orderTime ? Util.dateFormate(cellValue.orderTime, 'YYYY-MM-DD HH:mm:ss') : '--'
}
}, {
label: '销售顾问',
prop: 'employeeName',
width: '120px'
}, {
label: '客户来源',
prop: 'salesType',
formatter: (cellValue) => {
return {
0: '售前',
1: '售后'
}[cellValue.salesType]
}
}, {
label: '客户姓名',
prop: 'customerName'
}, {
label: '性别',
prop: 'customerSex',
formatter: (cellValue) => {
return {
1: '男',
2: '女'
}[cellValue.customerSex]
},
with: '60px'
}, {
label: '手机号码',
prop: 'customerPhone',
width: '120px'
}, {
label: '车架号',
prop: 'standNo',
width: '170px'
}, {
label: '车型',
prop: 'carTypeStr',
width: '170px'
},{
label: '操作员',
prop: 'createdBy',
width: '100px'
}]
},
// 基本数据
baseData: {
parkServiceList: [],
storeIdList: [],
adviserList: [],
goodList: []
}
}
},
mounted() {
var params = this.userInfo.beSuper ? {} : { yqMerchantId: this.userInfo.detail.merchantId }
getOrderTotal(params).then(res => {
this.total = res
})
getParkStore({}).then(res => {
res.forEach(item => {
item.merchantId = item.merchantNo
})
this.baseData.parkServiceList = res
this.getOptionsList()
})
// if (!this.userInfo.beSuper) {
// this.showFormData = this.showFormData.filter(item => item.name !== 'yqMerchantId')
// this.getServiceStore(this.userInfo.detail.merchantId)
// }
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList,
})
},
methods: {
...mapActions({ close: 'd2admin/page/close' }),
...mapActions('d2admin/user', ['actionSetDownloadList']),
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = deepClone(this.searchForm)
// !this.userInfo.beSuper && (this.tableSearchForm.yqMerchantId = this.userInfo.detail.merchantId)
if (this.tableSearchForm.entryTime) {
this.tableSearchForm.startDate = new Date(this.tableSearchForm.entryTime[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
this.tableSearchForm.endDate = new Date(this.tableSearchForm.entryTime[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
delete this.tableSearchForm.entryTime
}
resolve()
})
},
keyDowmGetList() {
this.$refs.recordTable.refreshTable()
},
handleReset() {
this.searchForm = {
shopOrYqMerchantId: '',
yqMerchantId: '',
merchantId: '',
employeeName: '',
carSeriesTypeNameSearch: '',
entryTime: '',
customerName: ''
}
// this.userInfo.beSuper && (this.baseData.storeIdList = [])
this.baseData.storeIdList = []
this.baseData.adviserList = []
this.baseData.goodList = []
this.getOptionsList()
},
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])
}
})
},
getServiceStore(merchantId) {
getServiceStore({
yqMerchantId: merchantId
}).then(res => {
this.baseData.storeIdList = res || []
this.getOptionsList()
})
},
// 模板下载
exportTemplate() {
var params = {}
params.method = 'dj.smartcarlife.api.advanceOrder.template.export'
const list = [
...this.dowloadList,
{
name: '预录订单导入模板',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
handleShowHide() {
this.hideVisible = !this.hideVisible
},
// 上传文件,转码为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')
}
},
handleImport() {
this.fileForm = {
fileName: ''
}
this.$refs.fileRuleForm && this.$refs.fileRuleForm.resetFields()
this.fileVisible = !this.fileVisible
},
exportFailList(list) {
const tHeader = ['流量来源', '推荐人', '客户姓名', '性别', '手机号码', '客户类型', '客户职业', '车架号', '交车日期', '新车首购', '基础商品(填商品id,多个用英文,分隔)', '客户备注', '错误信息']
const fieldVal = ['merchantName', 'userName', 'customerName', 'customerSexStr', 'customerPhone', 'customerTypeStr', 'customerProfession', 'standNo', 'buyTimeStr', 'newCarFlagStr', 'baseGoodsStr', 'remark', 'errorMsg']
require.ensure([], () => {
const data = this.formatJson(fieldVal, list)
exportJsonToExcel(tHeader, data, '失败原因')
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
handleConfirmImport() {
this.$refs.fileRuleForm.validate(valid => {
if (valid) {
var params = {
file: this.fileInfo
}
recordUpload(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('上传成功')
this.handleImport()
}
})
}
})
},
handleAdd() {
this.close({ tagName: '/editCustomer' })
this.$router.push({
name: 'editCustomer',
params: {
addOrEdit: 'add'
}
})
},
handleEdit(data) {
getOrderDetail({
orderCode: data.orderCode
}).then(res => {
this.close({ tagName: '/editCustomer' })
this.$router.push({
name: 'editCustomer',
params: {
addOrEdit: 'edit',
form: res
}
})
})
}
}
}
</script>
<style>
.record-list {
position: relative;
}
.record-list .custom-input {
display: inline-block;
width: 220px;
}
.record-list .btn-tips img {
width: 18px;
height: 15px;
margin-right: 9px;
vertical-align: bottom;
}
.record-list .btn-tips {
display: inline-block;
font-size: 12px;
height: 14px;
line-height: 14px;
background-color: #fff2e5;
color: #999999;
margin-right: 24px;
padding: 6.5px 10px;
}
.record-list .custom-input {
margin: 0 0;
}
.record-list .m-l-md {
margin-left: 20px;
}
.record-list .import-btn {
position: relative;
}
.record-list .import-input {
opacity: 0;
position: absolute;
right: 0;
top: 0;
width: 98px;
height: 36px;
cursor: pointer;
font-size: 0;
}
.record-list .import-template {
position: absolute;
height: 20px;
top: 50px;
left: 0;
}
</style>