mentorForm.vue
23.3 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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
<template>
<div class="mentor-content">
<glsx-combi-form class="mentor-form-container"
ref="edit_monterFormRef"
label-width="154px"
default-width="432px"
:is-block="true"
form-ref="editChildRef"
:form-obj="configInfo"
:form-data="mentorFormData">
<div slot="titleText">
<el-input type="text" style="width: 432px;" disabled :value="configInfo.titleText" />
<el-button type="text" :disabled="pageDisabled" @click="showTitleDialog" class="setting-btn">职级晋升</el-button>
</div>
<div slot="student">
<div class="dis-inlne-b" v-for="item in configInfo['studentStaffs']" :key="item.staffUuid">
<span v-if="item.staffUuid" class="staff_name_span">{{ item.staffName + ' ' + (item.refTime || '') }}</span>
</div>
<el-button type="text" :disabled="pageDisabled" @click="showTitleDialog">修改关联</el-button>
</div>
<div slot="mentorCommission">
<el-tabs type="card" :before-leave="beforeLeave" v-model="configInfo.defaultMerchant" edit @tab-remove="removeTab">
<el-tab-pane v-for="(subItem, subIndex) in configInfo.merchantArr" :key="subItem.shopMerchantId" :closable="configInfo.merchantArr.length > 0" :name="subItem.shopMerchantId">
<span slot="label"><i v-if="subItem.validateErrFlag" class="el-icon-warning car-error-txt"></i>{{ subItem.shopMerchantName }}</span>
<el-form class="commission-box" :ref="`mentor_commission${subItem.shopMerchantId}`" :model="subItem" :rules="formRules">
<div class="title_text">
<span class="tips-block"
slot="label">
<span class="tips-label">导师附加提成</span>
<el-tooltip popper-class="tooltip-class"
effect="dark"
content="导师附加提成按不同个业务下关联学员的月份提成比例发放"
placement="top">
<span class="tips-icon" />
</el-tooltip>
</span>
<span class="explain" @click="handleExplain('tutorBonusConfigs')">示例说明</span>
</div>
<d2-table ref="orderRef" class="award-wrap" :table-data="subItem['tutorBonusConfigs']"
:table-params="montorTableParams" :has-page="false">
<template slot="startMonth" slot-scope="scope">
<span v-if="scope.scope.isStartEdit">{{ scope.scope.startMonth }}</span>
<el-form-item v-else style="margin-bottom: 0px;margin-right: 0;">
<el-input class="input-w-136" v-model="scope.scope.startMonth" placeholder="请输入" disabled></el-input>
</el-form-item>
</template>
<template slot="endMonth" slot-scope="scope">
<span v-if="scope.scope.isEndEdit">--</span>
<el-form-item v-else style="margin-bottom: 0px;margin-right: 0;" :prop="`tutorBonusConfigs.${scope.index}.endMonth`"
:rules="checkEndValue(scope.scope)">
<el-input class="input-w-136" :disabled="pageDisabled" v-model="scope.scope.endMonth" placeholder="请输入"
@blur="handleCalculate('tutorBonusConfigs', 'endMonth', scope.index, subIndex)"></el-input>
</el-form-item>
</template>
<template slot="calculateValue" slot-scope="scope">
<el-form-item style="margin-bottom: 0px;margin-right: 0;" :prop="`tutorBonusConfigs.${scope.index}.calculateValue`"
:rules="formRules.calculateValue">
<el-input class="input-w-136" :disabled="pageDisabled" v-model="scope.scope.calculateValue" placeholder="请输入"
@blur="handleCalculate('tutorBonusConfigs', 'calculateValue', scope.index, subIndex)"></el-input>
</el-form-item>
</template>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<el-button :disabled="pageDisabled" @click="handleDelete(`tutorBonusConfigs`, scope.index, subIndex)" type="text" size="small">删除</el-button>
</div>
</d2-table>
<div class="add-txt">
<el-button icon="el-icon-plus" :disabled="pageDisabled" @click="addLine('tutorBonusConfigs', subIndex)">新增一行</el-button>
</div>
</el-form>
</el-tab-pane>
<el-tab-pane key="add" @tab-add="addSceneMerchant" name="add" :disabled="pageDisabled">
<!-- //这是增加的按钮 -->
<span slot="label" style="padding: 8px;font-size:20px;font-weight:bold;">+</span>
</el-tab-pane>
</el-tabs>
</div>
</glsx-combi-form>
<d2-dialog title="职级晋升/降级"
:is-visible="titleDialogVisible"
width="1000px"
@closeDialog="handleTitleClose"
@confirmDialog="handleTitleConfirm">
<el-form ref="title-dialog-form"
:model="titleForm"
inline
label-width="120px">
<el-form-item label="调整职级:"
class="mar_b_20"
prop="setTitle">
<el-select class="input-w-432" v-model="titleForm.setTitle"
placeholder="请选择调整的职级">
<el-option v-for="(item, index) in titleList" :key="index" :label="item.confValue" :value="item.confId">{{ item.confValue }}</el-option>
</el-select>
</el-form-item>
<el-form-item label="关联学员:" v-if="titleForm.setTitle > 0 || (configInfo.lastSetTitle > 0)">
<d2-table class="award-wrap" :table-data="titleForm['studentStaffs']"
:table-params="relateTableParams" :has-page="false">
<template slot="staffUuid" slot-scope="scope">
<el-form-item :rules="titleDialogRules.staffUuid" style="margin-bottom: 0px;margin-right: 0;" :prop="'studentStaffs.' + scope.index + '.staffUuid'">
<span v-if="scope.scope.staffUuid">{{ scope.scope.staffName }}</span>
<el-select v-else v-model="scope.scope.staffUuid"
class="student_width"
placeholder="请选择"
filterable
@change="handleChangeStaff($event, scope.index)">
<el-option v-for="item in mentorStaffList"
:key="item.staffUuid"
:label="item.staffName"
:value="item.staffUuid"
:disabled="selectedRelateOptions.includes(item.staffUuid)" />
</el-select>
</el-form-item>
</template>
<template slot="phoneNumber" slot-scope="scope">
<span>{{ scope.scope.phoneNumber || '--' }}</span>
</template>
<template slot="refTime" slot-scope="scope">
<span>{{ scope.scope.refTime || '--' }}</span>
</template>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<el-button @click="handleRelateDelete(scope.index)" type="text" size="small">删除</el-button>
</div>
</d2-table>
<div class="add-txt">
<el-button icon="el-icon-plus" @click="addRelateLine()">新增一行</el-button>
</div>
</el-form-item>
</el-form>
</d2-dialog>
<d2-dialog title="选择门店"
:is-visible="storeDialogVisible"
@closeDialog="handleStoreClose"
@confirmDialog="handleStroeConfirm">
<el-form :model="storeForm"
ref="store-dialog-form"
:rules="storeDialogRules"
label-width="120px">
<el-form-item label="门店:"
prop="merchantId">
<el-select v-model="storeForm.merchantId"
placeholder="请选择门店" @change="handleStoreChange">
<el-option v-for="(item, index) in dialogMerchantList" :disabled="disabledMerchantArr.includes(`${item.merchantId}`)" :key="index" :label="item.merchantName" :value="item.merchantId">{{ item.merchantName }}</el-option>
</el-select>
</el-form-item>
</el-form>
</d2-dialog>
<explain-dialog :is-explain="isExplain" :diff-explain="diffExplain" @handleClose="handleDialogClose"></explain-dialog>
</div>
</template>
<script>
import BigNumber from 'bignumber.js'
import explainDialog from './explainDialog.vue'
import { deepClone } from '@/common/util'
export default {
name: 'MentorForm',
components: {
explainDialog
},
props: {
mentorConfigInfo: Object,
mentorStaffList: Array,
dialogMerchantList: Array
},
data() {
var checkInput = (rule, value, callback) => {
if (isNaN(+value)) {
callback(new Error('请输入数字值'))
} else {
callback()
}
}
return {
configInfo: {},
mentorFormData: [{
label: '当前职级',
name: 'titleText',
addHtml: 'titleText'
}, {
label: '关联学员',
name: 'student',
addHtml: 'student',
isHide: true
}, {
label: '所属园区店',
name: 'merchantName',
type: 'input',
isDisabled: true
}, {
label: '设置导师提成',
name: 'mentorCommission',
addHtml: 'mentorCommission',
isHide: true
}],
formRules: {
calculateValue: [
{ required: true, message: '请输入', trigger: 'blur' },
{ validator: checkInput, trigger: 'blur' }
]
},
titleForm: {
studentStaffs: []
},
titleDialogRules: {
staffUuid: [{ required: true, message: '请选择', trigger: 'change' }]
},
titleDialogVisible: false,
titleList: [{
confId: '0',
confValue: '初级驻店零售'
}, {
confId: '1',
confValue: '中级导师'
}, {
confId: '2',
confValue: '高级导师'
}],
relateTableParams: {
tableOption: {
width: '80px'
},
tableColumns: [{
label: `姓名`,
prop: 'staffName',
addHtml: 'staffUuid',
minWidth: 200
},
{
label: '手机号',
prop: 'phoneNumber',
addHtml: 'phoneNumber',
minWidth: 200
}, {
label: '关联时间',
prop: 'refTime',
addHtml: 'refTime',
minWidth: 200
}]
},
montorTableParams: {
tableOption: {
width: '80px'
},
tableColumns: [{
label: `区间开始值/月`,
prop: 'startMonth',
addHtml: 'startMonth',
minWidth: 200
},
{
label: '区间结束值/月',
prop: 'endMonth',
addHtml: 'endMonth',
minWidth: 200
},
{
label: '提成比例/%',
prop: 'calculateValue',
addHtml: 'calculateValue',
minWidth: 200
}]
},
storeDialogVisible: false, // 添加门店弹窗
storeForm: {}, // 添加门店弹窗Form
storeDialogRules: {
merchantId: [{ required: true, message: '请选择门店', trigger: 'change' }]
},
selectedRelateOptions: [],
disabledMerchantArr: [],
diffExplain: '',
isExplain: false, // 示例说明
pageDisabled: false, // 根据绩效配置开关控制是否可编辑
defaultMerchant: ''
}
},
watch: {
// 当前职级
'configInfo.lastSetTitle': {
handler(val) {
if (val > 0) { // 编辑进入
this.initformData(false)
}
},
deep: true
},
// 晋升/降级
'configInfo.setTitle': {
handler(val, oldVal) {
this.oldSetTitle = oldVal
if (val && val == 0 && (this.configInfo?.lastSetTitle > 0)) {
this.$confirm('将导师降级为初级驻店时,清空所有学员关联关系及附加提成,是否确定继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.initformData(true)
this.clearData()
this.$nextTick(() => {
// 触发下拉框失去焦点
this.$refs.editFormRef?.$refs.editChildRef?.$children[3]?.$children[1]?.blur()
})
this.configInfo.lastSetTitle = val
}).catch(() => {
this.configInfo.setTitle = this.oldSetTitle
this.$nextTick(() => {
this.$refs.editFormRef?.$refs.editChildRef?.$children[3]?.$children[1]?.blur()
})
})
} else if (val > 0) {
this.initformData(false)
this.configInfo.lastSetTitle = val
}
},
deep: true
},
'titleForm.studentStaffs': {
handler(val) {
this.selectedRelateOptions = []
val?.forEach(v => {
// 已选的初级员工
this.selectedRelateOptions.push(v.staffUuid)
})
},
deep: true
},
'configInfo.merchantArr': {
handler(val) {
this.disabledMerchantArr = []
val?.forEach(v => {
// 已选的门店
this.disabledMerchantArr.push(v.shopMerchantId)
})
},
deep: true
},
'configInfo.performanceFlag': {
handler(val) {
this.pageDisabled = !val
},
deep: true
}
},
created() {
this.configInfo = deepClone(this.mentorConfigInfo)
},
methods: {
// 切换场景默认选中的门店tab
updateData(val) {
this.configInfo.defaultMerchant = val
this.$forceUpdate()
},
// 控制form表单显示隐藏
initformData(flag) {
this.changeFormAttr('mentorFormData', 'isHide', ['mentorCommission'], flag)
this.changeFormAttr('mentorFormData', 'isHide', ['student'], flag)
},
changeFormAttr(formName, attrName, labelList, attrValue) {
labelList.forEach(item => {
const idx = this[formName].findIndex(k => k.name == item)
this[formName][idx][attrName] = attrValue
})
},
beforeLeave(currentName) { // 通过tab标签的切换事件触发增加的函数
// 如果name是add,则调用增加tab的函数
if (currentName == "add") {
this.addSceneMerchant()
return false
}
},
// 职级调整
showTitleDialog() {
const configInfo = deepClone(this.configInfo)
this.titleDialogVisible = true
this.titleForm = {
setTitle: configInfo?.setTitle || `${configInfo?.title}`,
studentStaffs: configInfo?.studentStaffs || []
}
},
// 调整职级弹窗关闭
handleTitleClose() {
this.titleDialogVisible = false
},
// 调整职级弹窗确认
handleTitleConfirm() {
this.$refs['title-dialog-form']?.validate(valid => {
if (valid) {
this.configInfo = {
...this.configInfo,
...this.titleForm,
titleText: ['初级驻店零售', '中级导师', '高级导师'][this.titleForm?.setTitle]
}
this.handleTitleClose()
}
})
},
// 删除门店
removeTab(targetName) {
if (this.pageDisabled) return
const merchantArr = this.configInfo?.merchantArr
const defaultMerchant = this.configInfo?.defaultMerchant
if (targetName == defaultMerchant) this.$set(this.configInfo, 'defaultMerchant', merchantArr[0]?.shopMerchantId)
const index = merchantArr?.findIndex(val => val.shopMerchantId == targetName)
merchantArr.splice(index, 1)
},
// 删除关联的初级驻店销售
handleRelateDelete(index) {
const list = this.titleForm.studentStaffs
this.$confirm('删除学员后,后续订单不再计入导师提成,是否确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
list.splice(index, 1)
}).catch(() => { })
},
// 关联员工新增一行
addRelateLine() {
const list = this.titleForm.studentStaffs
if (list.length > 9) return
list.push({
staffName: '',
staffUuid: '',
phoneNumber: ''
})
},
// 选择关联员工
handleChangeStaff(e, index) {
const list = this.titleForm.studentStaffs
const idx = this.mentorStaffList.findIndex(k => k.staffUuid == e)
list[index].phoneNumber = this.mentorStaffList[idx]?.phoneNumber
list[index].staffName = this.mentorStaffList[idx]?.staffName
this.$nextTick(() => {
this.$refs['title-dialog-form'].clearValidate(`studentStaffs.${index}.staffUuid`)
})
},
// 示例说明
handleExplain(item) {
this.diffExplain = item
this.isExplain = true
},
// 关闭示例弹窗
handleDialogClose() {
this.isExplain = false
},
// 添加门店
addSceneMerchant() {
this.storeDialogVisible = true
this.$refs['store-dialog-form'] && this.$refs['store-dialog-form'].resetFields()
},
// 选择门店弹窗
handleStoreChange(e) {
const index = this.dialogMerchantList?.findIndex(val => val.merchantId == e)
if (index > -1) this.storeForm.merchantName = this.dialogMerchantList[index]?.merchantName
},
handleStoreClose() {
this.storeDialogVisible = false
},
handleStroeConfirm() {
this.$refs['store-dialog-form'].validate(valid => {
if (valid) {
const tabListData = this.configInfo?.merchantArr
tabListData.push({
shopMerchantId: `${this.storeForm?.merchantId}`,
shopMerchantName: this.storeForm?.merchantName
})
this.configInfo.defaultMerchant = `${this.storeForm?.merchantId}`
this.handleStoreClose()
}
})
},
// 导师附加提成新增一行
addLine(item, index) {
!this.configInfo.merchantArr[index][item] ? (this.configInfo.merchantArr[index][item] = []) : ''
const formData = this.configInfo.merchantArr[index][item]
const line = formData?.length + 1
formData.push({
startMonth: line >= 2 ? '' : 0,
endMonth: 99,
calculateValue: '',
isStartEdit: line == 1,
isEndEdit: true
})
if (line >= 2) {
// 上一行区间结束值/元 设为可编辑
formData[formData.length - 2].isEndEdit = false
if (formData[formData.length - 2].endMonth && formData[formData.length - 2].endMonth < 99) {
formData[formData.length - 1].startMonth = new BigNumber(formData[formData.length - 2].endMonth).plus(1).toNumber()
} else {
formData[formData.length - 2].endMonth = ''
}
}
this.$forceUpdate()
},
// 职级晋升/降级 清除数据
clearData() {
this.configInfo.studentStaffs = []
this.configInfo.merchantArr = []
},
// 区间值/提成比例 失去焦点
handleCalculate(item, key, index, idx) {
const formData = this.configInfo.merchantArr[idx][item]
let max = 98
if (key == 'calculateValue') {
max = 100
}
formData[index][key] = formData[index][key] > max ? max : formData[index][key]
formData[index][key] = formData[index][key] ? new BigNumber(formData[index][key]).dp(key == 'calculateValue' ? 2 : 0).toNumber() : ''
// 下一行区间开始值自动在上一行的区间结束值的基础上+1
if (formData[index + 1] && key == 'endMonth' && formData[index][key]) formData[index + 1].startMonth = new BigNumber(formData[index][key]).plus(1).toNumber()
if (!formData[index][key] && key != 'calculateValue') formData[index][key] = ''
},
// 自定义校验区间结束值
checkEndValue(row) {
return [{
required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error("请输入"))
} else if (+value <= row.startMonth) {
callback(new Error('结束值需大于开始值'))
} else if (+value <= 0) {
callback(new Error('不能小于等于0'))
} else {
callback()
}
},
trigger: 'blur'
}]
},
// 导师附加提成奖励项删除
handleDelete(item, index, idx) {
const list = this.configInfo.merchantArr
list[idx][item]?.splice(index, 1)
},
// 保存校验
submitValide() {
const configInfo = this.configInfo
return new Promise(async (resolve, reject) => {
const valideResult = [] // 精品升级配置
for (var j = 0; j < configInfo.merchantArr?.length; j++) {
const subVal = configInfo.merchantArr[j]
const node = this.$refs[`mentor_commission${subVal?.shopMerchantId}`]?.[0]
node?.validate(valid => {
if (valid) {
subVal.validateErrFlag = false
valideResult.push(subVal)
} else {
valideResult.push('error')
subVal.validateErrFlag = true
}
})
}
this.$forceUpdate()
resolve({ merchantValid: valideResult, ...this.configInfo })
})
}
}
}
</script>
<style scoped lang="scss">
.mentor-content{
margin-top: -20px;
padding: 15px 0;
.mentor-form-container{
.dis-inlne-b{
display: inline-block;
.staff_name_span{
color: #666666;
padding: 3px 8px;
background: #FAFBFE;
border: 1px solid #E8E8EA;
border-radius: 4px;
margin-right: 8px;
}
}
.title_text{
font-weight: 600;
color: #333333;
margin: 0 -20px 20px -20px;
padding-left: 20px;
border-bottom: 1px solid #E8E8EA;
.tips-block{
position: relative;
.tips-label{
margin-right: 20px;
}
.tips-icon {
position: absolute;
display: inline-block;
width: 12px;
height: 12px;
top: 1px;
right: 4px;
margin-right: 4px;
cursor: pointer;
border: 1px solid #7f7f7f;
border-radius: 50%;
}
.tips-icon::before {
content: "?";
position: absolute;
width: 8px;
height: 8px;
top: -10px;
left: 3px;
font-size: 10px;
}
}
.explain{
margin: 0 8px;
color: #2a58ad;
cursor: pointer;
}
.grap_text{
font-weight: 500;
color: #999;
}
}
.commission-box{
background: #FAFAFA;
border-radius: 4px;
padding: 12px 20px;
}
}
.setting-btn{
margin-left: 10px;
}
}
.award-wrap{
width: 750px;
::v-deep td{
height: 64px;
}
::v-deep .el-form-item__error {
padding-top: 2px;
z-index: 9999999;
position: static;
text-align: left;
}
.input-w-136{
width: 136px;
}
}
.mar_b_20{
margin-bottom: 20px;
}
.student_width{
width: 150px;
}
.input-w-432{
width: 432px
}
::v-deep .el-tabs__header{
margin-bottom: 8px;
}
::v-deep .el-tabs__item{
background: #F8F8F8;
}
::v-deep .el-tabs__item.is-active{
background: #FFFFFF;
font-weight: 600;
}
::v-deep #mentorCommission > .el-form-item__content{
width: calc(100% - 154px);
}
</style>