recordList.vue
11.1 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
<!-- 预录客户列表 -->
<template>
<d2-container class="record-list">
<div slot="header" class="header">
<d2-search ref="showSearch"
class="show-search"
:form-data="showFormData"
:search-form="searchForm">
<!-- <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">
<span class="table-header-left-txt" style="margin-left: 0;">已预录客户列表{{ 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"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="tableSearchForm"
:table-params="tableParams">
<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-file-import-dialog title="上传文件"
:is-visible="fileVisible"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
@downloadTemplate="exportTemplate" />
</d2-container>
</template>
<script>
import { getGoods, getParkStore, getServiceStore, getStaff } from "@api/editCustomer";
import { getList, getOrderDetail, getOrderTotal, recordUpload } from "@api/recordList";
import { mapActions, mapState } from "vuex";
import { exportJsonToExcel } from "@/common/Export2Excel.js";
// import _ from 'lodash'
import { deepClone, Util } from "@/common/util";
export default {
name: "RecordList",
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
hideVisible: false,
fileVisible: false,
total: 0,
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() + Number.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() {
let 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() {
let 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;
},
handleImport() {
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({ fileName, fileData }) {
let params = {
file: fileData,
};
recordUpload(params).then((res) => {
if (res) {
const list = [...this.updateList, {
name: fileName,
ifSuccess: false,
uuid: res,
type: "upload",
}];
this.actionSetDownloadList({ list, type: "updateList" });
this.notice.okTips("上传成功");
this.handleImport();
}
});
},
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;
}
</style>