index.vue
19 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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
<!-- 个人交付成交率 -->
<template>
<d2-container class="m-t-40">
<div class="header"
slot="header"
style="padding-bottom: 20px;">
<d2-search ref="showSearch"
class="show-search"
:search-form="searchForm"
:form-data="showFormData"
label-width="120px">
<div slot="4sHtml">
<el-select v-model="searchForm.storeId"
remote
reserve-keyword
placeholder="请选择4S门店"
@visible-change="visibleChange"
:remote-method="remoteMethod"
v-el-select-loadmore="interestsLoadmore"
style="width: 100%;"
filterable>
<el-option v-for="subItem in baseData.merchantList"
:key="subItem.merchantId"
:label="`${subItem.merchantName}(${subItem.merchantId})`"
:value="subItem.merchantId">
</el-option>
</el-select>
</div>
<div slot="dealMonthHtml">
<el-date-picker v-model="searchForm.monthYear"
type="month"
value-format="yyyy-MM"
format="yyyy-MM"
placeholder="选择月"
:picker-options="monthPickerOptions"
style="width: 100%;">
</el-date-picker>
</div>
</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> -->
<div class="d2-container-content">
<d2-table-header>
<span>
<auth-button category="Button"
:show-btn-ids="['9061937','9061938','9061939']" /></span>
</d2-table-header>
<d2-table ref="personalTable"
:search-form="searchFormSearch"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn">
<template slot="typeHtml"
slot-scope="scope">
<span :class="baseData.businessOptShowClass[scope.scope.businessType]">
{{ baseData.businessNameShow[scope.scope.businessType] }}
</span>
</template>
<div slot="auth-button"
slot-scope="scope">
<!-- 详情 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope"
:show-btn-ids="['9061940']" />
</span>
<!-- 修改 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope"
:show-btn-ids="['9061941']" />
</span>
<!-- 删除 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope"
:show-btn-ids="['9061942']" />
</span>
</div>
</d2-table>
</div>
<d2-file-import-dialog :is-visible="fileVisible"
title="毛利导入"
form-item-label="毛利信息表:"
:max-size="10"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport"
@downloadTemplate="exportTemplate">
<template #tip>
<p class="tips">请选择需要导入的毛利信息表格</p>
</template>
</d2-file-import-dialog>
<!-- 新增&修改&详情 -->
<edit-dialog :visible.sync="editVisible"
v-if="editVisible"
:params-obj="recordInfo"
:operation-type="operationType"
@dialogClose="closeEditDialog" />
</d2-container>
</template>
<script>
import { mapActions, mapState, mapMutations } from "vuex"
import { Util, deepClone } from "@/common/util"
import inputRange from './components/inputRange'
import editDialog from "./components/editDialog"
import { listProfitPage, importProfit, deleteProfit } from '@api/shopConfig'
import { getList } from "@api/merchant"
import reportTrackFunMixin from '@/mixins/reportTrackFunMixin'
export default {
name: "DeliveryQuantity",
mixins: [reportTrackFunMixin], // 导入混入
directives: {
'el-select-loadmore': {
bind(el, binding) {
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector(
'.el-select-dropdown .el-select-dropdown__wrap'
)
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition =
this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) {
binding.value()
}
})
}, 100)
}
}
},
data() {
return {
searchForm: {
storeId: [],
monthYear: "",
profitAmount: [],
businessType: ""
},
searchFormSearch: {},
showFormData: [
{
label: "4S门店",
name: "merchantIds",
addHtml: "4sHtml"
},
{
label: "业务类型",
name: "businessType",
type: "select",
isClear: true,
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "businessTypeList"
},
{
label: '所属月份',
name: 'dealMonth',
addHtml: "dealMonthHtml"
},
{
label: '导入时间',
name: 'createTime',
type: 'datePicker',
isClear: true,
pickerOptions: 'rangePickerOptions'
}
],
getListApi: listProfitPage,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
tableOption: { width: "150px" },
tableColumns: [
{
label: "4S门店",
prop: "storeName",
formatter: (cellValue) => {
return (cellValue.storeName) ? cellValue.storeName+'('+cellValue.storeId+')' : "-"
}
},
{
label: "业务类型",
addHtml: "typeHtml"
},
{
label: "所属月份",
prop: "monthYear",
width: "150"
},
{
label: "毛利额",
prop: "profitAmount",
width: "200",
formatter: (cellValue) => {
return (cellValue.profitAmount || cellValue.profitAmount == 0) ? cellValue.profitAmount : "-"
}
},
{
label: "导入时间",
prop: "createdAt",
width: "180",
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdAt, "YYYY-MM-DD HH:mm:ss")
}
}
]
},
baseData: {
merchantList: [],
brandList: [],
businessTypeList: [{
confId: 1,
confValue: '延保'
}, {
confId: 2,
confValue: '轻改'
}, {
confId: 3,
confValue: '权益'
}, {
confId: 4,
confValue: '二手车'
}],
businessOptShowClass: {
1: "type-green",
2: "type-yellow",
3: "type-purple",
4: "type-blue"
},
businessNameShow: {
1: "延保",
2: "轻改",
3: "权益",
4: "二手车"
},
},
recordInfo: null,
operationType: "add",
currentPage: 1,
pageSize: 20,
fileVisible: false,
editVisible: false,
// 保存编辑前的分页状态
savedPageState: null,
track_event_code: 'shopConfig_personalConversion_list',
track_businessParam_key: 'searchForm',
// 月份选择器配置:仅允许选择当前月份及之前的月份
monthPickerOptions: {
disabledDate(time) {
const now = new Date()
const currentYear = now.getFullYear()
const currentMonth = now.getMonth()
const timeYear = time.getFullYear()
const timeMonth = time.getMonth()
// 禁用未来的月份
return timeYear > currentYear || (timeYear === currentYear && timeMonth > currentMonth)
}
}
}
},
components: {
inputRange,
editDialog
},
watch: {
updateRefesh(val) {
if (val == true) {
this.$refs.personalTable.refreshTable()
this.setUpdateRefesh('false')
}
},
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList,
updateRefesh: (state) => state.d2admin.user.updateRefesh
})
},
mounted() {
this.onPageShow() // 用于页面浏览埋点追踪-来源于mixins
this.getBaseData()
},
methods: {
...mapActions({
get: "d2admin/base/get",
close: "d2admin/page/close"
}),
...mapActions("d2admin/user", ["actionSetDownloadList"]),
...mapMutations('d2admin/user', ['setUpdateRefesh']),
async getBaseData() {
this.getOptionsList() // 为所有下拉选择框统一添加“全部”选项
this.getSelectingList() // 获取下拉选择4s门店列表接口
},
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch = deepClone(this.searchForm)
if (this.searchFormSearch.createTime) {
this.searchFormSearch.startDate = Util.dateFormate(this.searchFormSearch.createTime[0], 'YYYY-MM-DD HH:mm:ss')
this.searchFormSearch.endDate = Util.dateFormate(this.searchFormSearch.createTime[1], 'YYYY-MM-DD') + ' 23:59:59'
delete this.searchFormSearch.createTime
} else {
delete this.searchFormSearch.startDate
delete this.searchFormSearch.endDate
}
if (this.searchFormSearch.dealRate && this.searchFormSearch.dealRate.length > 0) {
this.searchFormSearch.dealRateStart = this.searchFormSearch.dealRate[0]
this.searchFormSearch.dealRateEnd = this.searchFormSearch.dealRate[1]
} else {
delete this.searchFormSearch.dealRateStart
delete this.searchFormSearch.dealRateEnd
}
if (this.searchFormSearch.brandId) {
this.searchFormSearch.brandChildIds.push(this.searchFormSearch.brandId)
delete this.searchFormSearch.brandId
} else {
this.searchFormSearch.brandChildIds = []
}
resolve()
})
},
// 获取商品数据
remoteMethod(query) {
this.merchantName = query
this.currentPage = 1
this.baseData.merchantList = []
this.getSelectingList() // 请求接口
},
// 获取4S门店列表
getSelectingList(defaultSelect) {
getList({
merchantName: this.merchantName,
currentPage: this.currentPage,
pageSize: this.pageSize
}).then(res => {
console.log("getSelectingList",res);
this.allPages = res.pages
const resArr = [...res.list]
const arr = this.baseData.merchantList.concat(resArr)
this.baseData.merchantList = arr
this.getOptionsList()
}).catch(() => {
})
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.merchantName) {
this.merchantName = ''
this.currentPage = 1
this.baseData.merchantList = []
this.getSelectingList()
}
}
},
// 获取更多4S店
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages
return
}
this.getSelectingList()
}, 10)
},
handleReset() {
this.searchForm = {
storeId: [],
monthYear: "",
dealRate: [],
createTime: "",
businessType: ""
}
this.$refs.personalTable.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] !== '全部') {
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])
}
})
},
handleAdd() {
this.recordInfo = null
this.operationType = 'add'
this.editVisible = true
},
handleDetail(row) {
this.recordInfo = row
this.operationType = 'detail'
this.editVisible = true
},
handleEdit(row) {
// 保存当前分页状态
if (this.$refs.personalTable && this.$refs.personalTable.page) {
this.savedPageState = {
currentPage: this.$refs.personalTable.page.currentPage,
pageSize: this.$refs.personalTable.page.pageSize
}
}
this.recordInfo = row
this.operationType = 'edit'
this.editVisible = true
},
closeEditDialog(obj) {
this.editVisible = !this.editVisible
if (obj.flag) {
// 如果是编辑状态,恢复分页状态
if (this.operationType === 'edit' && this.savedPageState) {
// 先恢复分页状态
if (this.$refs.personalTable && this.$refs.personalTable.page) {
this.$refs.personalTable.page.currentPage = this.savedPageState.currentPage
this.$refs.personalTable.page.pageSize = this.savedPageState.pageSize
}
// 刷新表格,不重置分页
this.$refs.personalTable.refreshTable(false, false)
// 清空保存的分页状态
this.savedPageState = null
} else {
// 新增状态,正常刷新并重置分页
this.$refs.personalTable.refreshTable(false, true)
}
}
},
handleExport() {
var params = this.searchFormSearch
console.log("CS1220", this.searchFormSearch);
// if (params.merchantIds.length > 0) {
// params.merchantIds.forEach((item, index) => {
// const merchantId = `merchantIds[${index}]`
// params[merchantId] = item
// })
// delete params.merchantIds
// }
// if (params.brandChildIds.length > 0) {
// params.brandChildIds.forEach((item, index) => {
// const brandChildId = `brandChildIds[${index}]`
// params[brandChildId] = item
// })
// delete params.brandChildIds
// }
// 去除为null的值
for (const key in params) {
if (params[key] === null || params[key] === '' || params[key].length == 0) {
delete params[key]
}
}
params.method = 'dj.api.script.merchant.profit.record.async.export'
params.moduleName = 'script'
if (this.searchForm.businessType) {
params.businessType = this.searchForm.businessType
}
delete params.createTime
const list = [
...this.dowloadList,
{
name: '毛利额导出模板',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
// 门店毛利额导入模版下载
exportTemplate() {
var params = {}
params.method = 'dj.api.script.common.template.async.export.async.export'
params.moduleName = 'script'
params.templateCode = 'merchant_profit_record_temp'
const list = [
...this.dowloadList,
{
name: '毛利额导入模版',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
handleImport() {
this.fileVisible = !this.fileVisible
},
handleConfirmImport({ fileName, fileData }) {
var params = {
file: fileData
}
importProfit(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()
}
})
},
// 删除
handleDelete(row) {
this.$confirm('请确认是否要执行当前操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
closeOnClickModal: false
}).then(() => {
deleteProfit({ recordId : row.recordId }).then(res => {
this.notice.okTips()
this.$refs.personalTable.refreshTable()
})
}).catch(err => {
console.log(err)
})
}
},
beforeDestroy() {
this.onPageHide()
}
}
</script>
<style lang="scss" scoped>
.m-t-40 {
margin-top: 40px;
}
@mixin typeBase {
width: 52px;
border-radius: 239px;
opacity: 1;
font-size: 14px;
text-align: center;
line-height: 24px;
display: inline-block;
}
.type-yellow {
@include typeBase();
background: #FF8D1A1A;
color: #FF8D1AFF;
}
.type-blue {
@include typeBase();
background: #2A58AD1A;
color: #2A58ADFF;
}
.type-green {
@include typeBase();
background: #43CF7C1A;
color: #43CF7CFF;
}
.type-purple {
@include typeBase();
background: #5850FF1A;
color: #5850FFFF;
}
.tips {
color: #999999ff;
font-size: 14px;
margin-top: 0px;
}
</style>