addInStoreConfig.vue
15.7 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
<template>
<d2-container class="storeConfigCon">
<!-- <div > -->
<el-form ref="storeConfigCon" :model="storeConfigConObj" :rules="rules" label-suffix=":" label-width="180px">
<div class="storeConfig con">
<!-- <p class=" "> -->
<div class="storeConfigCon_title">
<div class="edit-sub-title title">新增配置</div>
</div>
<div class="itemCon">
<el-form-item label="选择门店" prop="merchantId" required>
<el-select :disabled="routerParams.idEdit == 'true' || routerForView" style="width: 300px;" width="300px"
v-model="storeConfigConObj.merchantId" filterable placeholder="请选择门店" @change="restData">
<el-option v-for="item in baseData.merchantList " :key="item.merchantId" :label="item.merchantName"
:value="item.merchantId" />
</el-select>
</el-form-item>
<el-form-item label="场景名称" prop="sceneType" required>
<el-checkbox-group :disabled="routerParams.idEdit == 'true' || routerForView"
v-model="storeConfigConObj.sceneType" @change="restData">
<el-checkbox false-label="null" :true-label="1" name="state">精品升级</el-checkbox>
<el-checkbox false-label="null" :true-label="0" name="state">会员权益/升级</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="驻店员工">
<div v-if="storeConfigConObj.merchantId && storeConfigConObj.sceneType">
<el-table style="width: 600px;" v-if="merchantTargetConfigGetStaffList.length"
:data="merchantTargetConfigGetStaffList" border stripe :header-cell-style="rowClass">
<el-table-column label="员工" prop="staffName" align="center">
</el-table-column>
<el-table-column label="联系方式" prop="phoneNumber" align="center">
</el-table-column>
<el-table-column label="账号创建时间" prop="registerTime" align="center">
</el-table-column>
</el-table>
<div v-else class="nothingTips">
<div>未配置</div>
<el-alert title="为不影响员工查看驻店目标,请尽快配置员工账号。" type="warning" show-icon>
</el-alert>
</div>
</div>
<!-- <el-table>
</el-table> -->
</el-form-item>
</div>
<!-- </p> -->
</div>
<div class="targetCon con">
<div class="storeConfigCon_title">
<div class="edit-sub-title title">驻店目标</div>
</div>
<el-form-item label="考核周期">
<span>3个月</span>
</el-form-item>
<el-form-item label="考核频次">
<span>半个月1次</span>
</el-form-item>
<el-form-item label="考核方案" prop="periodList">
<!-- <span>半个月1次</span> style="width: 60%" 'text-align': 'center', -->
<el-button v-if="!routerForView" type="primary" @click="addLine">新增方案</el-button>
<el-table :data="tableData" border stripe :header-cell-style="rowClass">
<el-table-column label="月度" align="center">
<template slot-scope="scope">
{{ checkMonthObj[scope.row.checkMonth] }}
</template>
</el-table-column>
<el-table-column label="季度" align="center">
<template slot-scope="scope">
{{ checkPeriodObj[scope.row.checkPeriod] }}
</template>
</el-table-column>
<el-table-column label="车主类型" align="center">
<template slot-scope="scope">
{{ selectCarTypeObj[scope.row.selectCarType] }}
</template>
</el-table-column>
<el-table-column label="商品分类" align="center">
<template slot-scope="scope">
{{ selectGoodsTypeObj[scope.row.selectGoodsType] }}
</template>
</el-table-column>
<el-table-column label="主推产品套餐" align="center">
<template slot-scope="scope">
</template>
</el-table-column>
<el-table-column label="目标转化率" align="center">
<template slot-scope="scope">
{{ scope.row.conversionRate | fitterFormat }}
</template>
</el-table-column>
<el-table-column label="提成系数" align="center">
<template slot-scope="scope">
{{ scope.row.conversionRatePercentage | fitterFormat }}
</template>
</el-table-column>
<el-table-column label="目标客单价" align="center">
<template slot-scope="scope">
{{ scope.row.customerUnitPrice }}
</template>
</el-table-column>
<el-table-column label="提成系数" align="center">
<template slot-scope="scope">
{{ scope.row.customerUnitPricePercentage | fitterFormat }}
</template>
</el-table-column>
<!-- <el-table-column label="子类目名称" align="center" width="400">
<template slot-scope="scope">
<div class="inputCol">
<el-form-item :prop="'tableData.' + scope.$index + '.feeCategoryName'"
:rules="[{ required: true, message: '请输入子类目名称', trigger: 'change' }]">
<el-input v-model="scope.row.feeCategoryName" placeholder="请输入子类目名称" maxlength="20"
style="width: 300px" clearable />
</el-form-item>
</div>
</template>
</el-table-column> -->
<el-table-column label="操作" v-if="!routerForView" align="center">
<template slot-scope="scope">
<span>
<!-- v-if="scope.$index != (form.tableData.length - 1)" form.tableData, -->
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
<!-- form.tableData, -->
<el-button type="text" v-if="scope.row.defaultFlag == 'N'"
@click="handleMove(scope, 'top')">删除</el-button>
</span>
</template>
</el-table-column>
</el-table>
</el-form-item>
<div class="footer" v-if="!routerForView">
<el-button @click="saveDraft" type="primary">存草稿</el-button>
<el-button @click="submitForm" type="primary">保存</el-button>
<el-button @click="routerBack">取消</el-button>
</div>
<div class="footer" v-if="routerForView">
<el-button @click="routerBack" type="primary">返回</el-button>
</div>
</div>
</el-form>
<drawerPeriodItemEdit :visible.sync="drawerShow" :mode="mode" :period-item="editPeriodObj"
@submitPeriodItem="submitPeriodItem" :store-config-con-obj-search-obj="storeConfigConObjSearchObj">
</drawerPeriodItemEdit>
<!-- </div> -->
</d2-container>
</template>
<script>
import { deepClone } from '@/common/util'
import drawerPeriodItemEdit from './components/drawerPeriodItemEdit.vue'
import { getList } from '@api/merchant.js'
import { merchantTargetConfigUpdate, merchantTargetConfigGetStaffList, merchantTargetConfigDetail } from '@api/inStoreTargetConfig.js'
const periodList = [
{
checkMonth: '1',
checkPeriod: '1',
taskList: [{
defaultFlag: 'Y',
selectCarType: '0',
selectGoodsType: '0',
selectPackageType: '0',
conversionRate: '1',
conversionRatePercentage: '1',
customerUnitPrice: '1',
customerUnitPricePercentage: '1'
}]
},
{
checkMonth: '1',
checkPeriod: '2',
taskList: [{
defaultFlag: 'Y',
selectCarType: '0',
selectGoodsType: '0',
selectPackageType: '0',
conversionRate: '1',
conversionRatePercentage: '1',
customerUnitPrice: '1',
customerUnitPricePercentage: '1'
}]
},
{
checkMonth: '2',
checkPeriod: '1',
taskList: [{
defaultFlag: 'Y',
selectCarType: '0',
selectGoodsType: '0',
selectPackageType: '0',
conversionRate: '1',
conversionRatePercentage: '1',
customerUnitPrice: '1',
customerUnitPricePercentage: '1'
}]
},
{
checkMonth: '2',
checkPeriod: '2',
taskList: [{
defaultFlag: 'Y',
selectCarType: '0',
selectGoodsType: '0',
selectPackageType: '0',
conversionRate: '1',
conversionRatePercentage: '1',
customerUnitPrice: '1',
customerUnitPricePercentage: '1'
}]
},
{
checkMonth: '3',
checkPeriod: '1',
taskList: [{
defaultFlag: 'Y',
selectCarType: '0',
selectGoodsType: '0',
selectPackageType: '0',
conversionRate: '1',
conversionRatePercentage: '1',
customerUnitPrice: '1',
customerUnitPricePercentage: '1'
}]
},
{
checkMonth: '3',
checkPeriod: '2',
taskList: [{
defaultFlag: 'Y',
selectCarType: '0',
selectGoodsType: '0',
selectPackageType: '0',
conversionRate: '1',
conversionRatePercentage: '1',
customerUnitPrice: '1',
customerUnitPricePercentage: '1'
}]
}
]
export default {
name: 'AddInStoreConfig',
components: {
drawerPeriodItemEdit
},
filters: {
fitterFormat(value) {
return value ? value + '%' : ''
}
},
data() {
return {
merchantTargetConfigGetStaffList: [],
// drawerShow: true,
drawerShow: false,
checkMonthObj: {
1: '首月',
2: '次月',
3: '第三月'
},
checkPeriodObj: {
1: '上半月',
2: '下半月'
},
selectCarTypeObj: {
0: '无',
1: '车辆价格',
2: '车辆类型'
},
selectGoodsTypeObj: {
0: '无',
1: '商品分类'
},
baseData: {
merchantList: []
},
storeConfigConObj: {
merchantId: '',
sceneType: '',
periodList: periodList
},
mode: 'add',
editPeriodObj: {},
// editIndex: 0,
rules: {
merchantId: [{ required: true, message: '请选择门店', trigger: 'change' }],
// realityShopMerchantId: [{ required: true, message: '请选择流量方', trigger: 'change' }]
sceneType: [{ required: true, message: '请选择场景', trigger: 'change' }]
}
}
},
computed: {
tableData: {
get() {
const tableData = this.storeConfigConObj.periodList.reduce((pre, item, periodIndex) => {
item.taskList.map((el, elIndex) => {
pre.push({ ...el, periodIndex, elIndex, checkMonth: item.checkMonth, checkPeriod: item.checkPeriod })
})
return pre
}, [])
return tableData
}
// set(newVal) {
// this.$emit('dialogClose', { flag: newVal, attrName: 'addVisible' })
// }
},
routerParams() {
return this.$route.query
},
routerForView() {
return this.$route.name == 'inStoreConfigView'
},
storeConfigConObjSearchObj() {
return {
merchantIds: [this.storeConfigConObj.merchantId],
sceneType: this.storeConfigConObj.sceneType
}
}
},
mounted() {
this.getMerchantList()
if (this.routerParams.merchantId) {
this.getDetail()
}
},
methods: {
routerBack() {
this.$router.go(-1)
},
getDetail() {
const { merchantId, sceneType } = this.routerParams
merchantTargetConfigDetail({ merchantId, sceneType }).then(res => {
console.log(res)
this.storeConfigConObj = deepClone(res)
this.getStaff()
}).catch((err) => {
console.log(err)
})
},
restData() {
// this. = periodList
this.storeConfigConObj = deepClone({ ...this.storeConfigConObj, periodList })
this.getStaff()
},
saveDraft() {
},
getStaff() {
const { merchantId, sceneType } = this.storeConfigConObj
if (merchantId && sceneType) {
merchantTargetConfigGetStaffList({
merchantId, sceneType
}).then(res => {
this.merchantTargetConfigGetStaffList = res || []
console.log(res, 'merchantTargetConfigGetStaffList')
// this
}).catch((err) => {
console.log(err)
})
}
},
handleEdit(item) {
this.drawerShow = true
this.mode = 'edit'
this.editPeriodObj = deepClone(item)
},
submitPeriodItem(item) {
// updatePeriodItem
console.log(item, 'submitPeriodItem')
if (this.mode === 'add') {
this.storeConfigConObj.periodList = this.storeConfigConObj.periodList.map((el) => {
console.log(el.checkMonth == item.checkMonth && el.checkPeriod == item.checkPeriod)
if (el.checkMonth == item.checkMonth && el.checkPeriod == item.checkPeriod) {
el.taskList.push(item)
}
// item.taskList
return el
})
// this.storeConfigConObj.periodList.push(item)
} else {
this.storeConfigConObj.periodList[item.periodIndex].taskList[item.elIndex] = item
// this.storeConfigConObj.periodList.map((el) => {
// // if (el.checkMonth === item.checkMonth && el.checkPeriod === item.checkPeriod) {
// // el.taskList.push(item)
// // }
// // item.taskList
// return el
// })
}
// this.storeConfigConObj.periodList[this.editIndex] = item
this.storeConfigConObj = deepClone(this.storeConfigConObj)
console.log(this.storeConfigConObj, ' this.storeConfigConObj')
// this.$forceUpdate()
},
addLine() {
this.drawerShow = true
this.mode = 'add'
this.editPeriodObj = {
defaultFlag: 'N',
checkMonth: '2',
checkPeriod: '1',
selectCarType: 0,
selectGoodsType: 0,
selectPackageType: 1,
conversionRate: 1,
conversionRatePercentage: 1,
customerUnitPrice: 1,
customerUnitPricePercentage: 1
}
},
handleMove() {
},
submitForm() {
// console.log('submitForm')
this.$refs.storeConfigCon.validate((valid) => {
if (valid) {
console.log('submitForm')
const params = deepClone(this.storeConfigConObj)
merchantTargetConfigUpdate(params).then(res => {
console.log(res, 'merchantTargetConfigUpdate')
this.$notify({
type: 'success',
title: '保存成功'
})
this.$router.push('/inStoreGoalsConfig')
}).catch((err) => {
console.log(err)
})
} else {
console.log('error submit!!')
return false
}
})
},
// 设置表头的颜色
rowClass({ row, rowIndex }) {
// console.log(rowIndex) // 表头行标号为0
return 'background:#F4F6FC'
},
getMerchantList() {
getList({ currentPage: 1, pageSize: 99999 }).then(res => {
console.log(res, 'getMerchantList')
this.baseData.merchantList = res.list
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style lang="scss" scoped>
// .storeConfigCon {
// // padding: ;
// }
.storeConfigCon_title {
box-sizing: border-box;
// height: 50px;
// line-height: 50px;
padding: 10px 20px;
border-bottom: 1px solid #e5e5e5;
.title {
margin: 0 !important;
}
// font-size: 16px;
// font-weight: 600;
// color: #333;
}
.storeConfig {
margin-bottom: 20px;
}
.itemCon {
box-sizing: border-box;
padding: 20px 0 1px;
}
.con {
// border-radius: ;
background-color: #fff;
}
.footer {
text-align: center;
padding-bottom: 30px;
}
</style>