mentorConfig.vue
12.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
<template>
<d2-container class="montor-config" :loading="$store.state.d2admin.loading.value" v-if="showPage">
<div class="container-content">
<div class="title">
<span>导师配置</span>
<div class="sub-title" v-if="routerQuery.partnerMerchantArr.length">服务商:
<span v-for="(subV, subIdx) in routerQuery.partnerMerchantArr" :key="subIdx">{{ subV }}</span>
</div>
</div>
<div class="content">
<glsx-combi-form class="edit-form-container"
ref="editFormRef"
label-width="154px"
default-width="432px"
:is-block="true"
form-ref="editChildRef"
:form-obj="configInfo"
:form-data="editFormData">
<template>
<div slot="sceneSelect">
<el-tabs v-model="configInfo.deploymentScene">
<el-tab-pane v-for="item in openedSceneList" :key="item.scene" :label="item.label" :name="item.scene"></el-tab-pane>
</el-tabs>
</div>
</template>
</glsx-combi-form>
<div class="scene_config_box">
<mentorForm ref="mentor-form-ref1" :mentor-config-info="configInfo.upgradeConfigInfo" :mentor-staff-list="upgradeStaffList" :dialog-merchant-list="upgradeMerchantList" v-show="configInfo.deploymentScene == '1'"></mentorForm>
<mentorForm ref="mentor-form-ref0" :mentor-config-info="configInfo.equityConfigInfo" :mentor-staff-list="equityStaffList" :dialog-merchant-list="equityMerchantList" v-show="configInfo.deploymentScene == '0'"></mentorForm>
</div>
</div>
</div>
<div class="footer">
<el-button @click="submit" type="primary">保存</el-button>
<el-button @click="navBack">取消</el-button>
</div>
</d2-container>
</template>
<script>
import mentorForm from './mentorForm.vue'
import { setMentorApi, getMentorInfoApi, getNoRelateStaffListApi, getMerchantStoreByServiceApi } from '@api/businessSchool'
import { mapActions } from 'vuex'
import _ from 'lodash'
export default {
name: 'MentorConfig',
components: {
mentorForm
},
data() {
return {
showPage: false,
configInfo: {
staffName: '',
phoneNumber: '',
deploymentScene: '',
equityConfigInfo: {
titleText: '初级驻店零售',
merchantArr: [],
studentStaffs: []
},
upgradeConfigInfo: {
titleText: '初级驻店零售',
merchantArr: [],
studentStaffs: []
}
},
editFormData: [{
label: '员工姓名',
name: 'staffName',
type: 'input',
isHide: false,
isDisabled: true
}, {
label: '手机号',
name: 'phoneNumber',
type: 'input',
isHide: false,
isDisabled: true
}, {
label: '选择业务',
name: 'sceneSelect',
isHide: false,
style: "width: calc(100% - 432px)",
addHtml: 'sceneSelect'
}],
selectedRelateOptions: [], // 关联员工已选的
upgradeStaffList: [], // 1.1场景所有初级驻店
equityStaffList: [], // 2.1场景 所有初级驻店
upgradeMerchantList: [], // 1.1场景所有门店
equityMerchantList: [], // 2.1场景所有门店
routerQuery: {
yqMerchantObj: {},
partnerMerchantArr: []
},
openedSceneList: []
}
},
watch: {
'configInfo.deploymentScene': {
handler(val) {
const customerConfigInfo = val == '1' ? this.configInfo.upgradeConfigInfo : this.configInfo.equityConfigInfo
const customerMerchantArr = val == '1' ? this.configInfo.upgradeConfigInfo?.merchantArr : this.configInfo.equityConfigInfo?.merchantArr
if (!customerConfigInfo?.defaultMerchant || customerConfigInfo?.defaultMerchant == '0') {
customerConfigInfo.defaultMerchant = customerMerchantArr[0]?.shopMerchantId
}
this.$nextTick(() => {
this.$refs['mentor-form-ref' + val]?.updateData(customerConfigInfo.defaultMerchant)
})
},
deep: true
}
},
mounted() {
this.routerQuery = {
...this.$route.query,
yqMerchantObj: JSON.parse(this.$route.query?.yqMerchantObj),
partnerMerchantArr: JSON.parse(this.$route.query?.partnerMerchantArr),
sceneTypeList: JSON.parse(this.$route.query?.sceneTypeList)
}
// 获取配置详情
this.getConfigInfo()
},
methods: {
...mapActions({
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
getNoRelateStaffList(sceneType) {
const routerQuery = this.routerQuery
getNoRelateStaffListApi({ sceneType, merchantId: routerQuery?.yqMerchantObj?.merchantId, currentPage: 1, pageSize: 9999 }).then(res => {
// 需过滤当前员工
const index = res?.list.findIndex(val => val.staffUuid == routerQuery?.staffUuid)
if (index > -1) res.list?.splice(index, 1)
sceneType == 1 ? this.upgradeStaffList = res?.list || [] : this.equityStaffList = res?.list || []
})
},
// 获取可添加配置的门店数据 (当前园区店关联的服务商下的所有4s店)
getStoreList(sceneType) {
const routerQuery = this.routerQuery
getMerchantStoreByServiceApi({ sceneType, yqMerchantId: routerQuery?.yqMerchantObj?.merchantId }).then(res => {
sceneType == 1 ? this.upgradeMerchantList = res || [] : this.equityMerchantList = res || []
})
},
initConfigInfo(v) {
if (v == 0) {
this.configInfo.equityConfigInfo = {
merchantArr: [],
studentStaffs: [],
titleText: ['初级驻店零售', '中级导师', '高级导师'][0],
title: 0,
sceneType: 0,
merchantName: JSON.parse(this.$route.query?.yqMerchantObj)?.merchantName,
performanceFlag: this.routerQuery?.performanceFlag == 'Y' // 绩效开关
}
} else if (v == 1) {
this.configInfo.upgradeConfigInfo = {
merchantArr: [],
studentStaffs: [],
titleText: ['初级驻店零售', '中级导师', '高级导师'][0],
title: 0,
sceneType: 1,
merchantName: JSON.parse(this.$route.query?.yqMerchantObj)?.merchantName,
performanceFlag: this.routerQuery?.performanceFlag == 'Y' // 绩效开关
}
}
},
// 获取配置详情
getConfigInfo() {
const routerQuery = this.routerQuery
getMentorInfoApi({ staffUuid: routerQuery?.staffUuid }).then(res => {
routerQuery?.sceneTypeList?.map(v => {
// 获取未关联导师的初级驻店数据
this.getNoRelateStaffList(v)
// 获取场景下园区店关联的4s店
this.getStoreList(v)
this.openedSceneList.push({
scene: `${v}`,
label: ['2.1', '1.1'][v]
})
// 初始化数据
this.initConfigInfo(v)
})
const configInfo = {
...this.configInfo,
staffUuid: routerQuery?.staffUuid,
staffName: routerQuery?.staffName, // 员工姓名
phoneNumber: routerQuery?.phoneNumber, // 员工手机号
deploymentScene: `${routerQuery?.sceneTypeList?.[0]}` // 选择业务
}
Array.isArray(res) && res?.forEach(val => {
val.tutorBonusConfigs?.forEach(v => {
v.startMonth == '0' ? (v.isStartEdit = true) : ''
v.endMonth == '99' ? (v.isEndEdit = true) : ''
})
if (val.sceneType == 0) { // 会员权益场景
val.shopMerchantId = `${val.shopMerchantId}`
if (val.shopMerchantId && val.shopMerchantId != 'null') configInfo.equityConfigInfo.merchantArr.push(val) // 门店配置
configInfo.equityConfigInfo.performanceFlag = routerQuery?.performanceFlag == 'Y', // 绩效开关
configInfo.equityConfigInfo.studentStaffs = configInfo.equityConfigInfo.studentStaffs.concat(val.studentStaffs || []) // 学员
configInfo.equityConfigInfo.titleText = ['初级驻店零售', '中级导师', '高级导师'][val.title || 0], // 当前职级
configInfo.equityConfigInfo.title = val.title // 当前职级
configInfo.equityConfigInfo.lastSetTitle = val.title // 最新配置的职级
configInfo.equityConfigInfo.merchantName = routerQuery?.yqMerchantObj?.merchantName // 园区店
} else if (val.sceneType == 1) { // 精品升级场景
val.shopMerchantId = `${val.shopMerchantId}` // 门店
if (val.shopMerchantId && val.shopMerchantId != 'null') configInfo.upgradeConfigInfo.merchantArr.push(val) // 门店配置
configInfo.upgradeConfigInfo.performanceFlag = routerQuery?.performanceFlag == 'Y', // 绩效开关
configInfo.upgradeConfigInfo.studentStaffs = configInfo.upgradeConfigInfo.studentStaffs.concat(val.studentStaffs || []) // 学员
configInfo.upgradeConfigInfo.titleText = ['初级驻店零售', '中级导师', '高级导师'][val.title || 0], // 当前职级
configInfo.upgradeConfigInfo.title = val.title // 当前职级
configInfo.upgradeConfigInfo.lastSetTitle = val.title, // 最新设置的职级
configInfo.upgradeConfigInfo.merchantName = routerQuery?.yqMerchantObj?.merchantName // 园区店
}
})
// 学员数据去重
configInfo.equityConfigInfo.studentStaffs = _.uniqBy(configInfo.equityConfigInfo.studentStaffs, 'staffUuid')
configInfo.upgradeConfigInfo.studentStaffs = _.uniqBy(configInfo.upgradeConfigInfo.studentStaffs, 'staffUuid')
this.configInfo = configInfo
this.showPage = true
}).catch(() => { this.showPage = true })
},
// 保存
async submit() {
const sceneConfigData = []
const configInfo = this.configInfo
for (var i = 1; i > -1; i--) {
const formValide = await this.$refs[`mentor-form-ref${i}`]?.submitValide(i)
if (formValide?.merchantValid?.includes('error')) {
// 有校验不通过的 切换到当前场景
if (i == 1) this.configInfo.deploymentScene = '1'
if (i == 0) this.configInfo.deploymentScene = '0'
return this.$message.error('请检查导师配置是否正确')
}
sceneConfigData.push(formValide) // 组件tab数据
}
const list = []
sceneConfigData.map(v => {
if (v.sceneType >= 0) {
if (v?.merchantArr?.length) { // 有配置门店
v?.merchantArr?.map(subV => {
list.push({
staffUuid: configInfo?.staffUuid,
sceneType: v?.sceneType,
title: v?.setTitle || v?.title,
studentStaffUuids: v?.studentStaffs?.map(v => { return v.staffUuid }),
shopMerchantId: subV?.shopMerchantId,
shopMerchantName: subV?.shopMerchantName,
tutorBonusConfigs: subV?.tutorBonusConfigs
})
})
} else { // 无门店默认是初级驻店
list.push({
staffUuid: configInfo?.staffUuid,
sceneType: v?.sceneType,
title: v.setTitle || v.title,
studentStaffUuids: v?.studentStaffs?.map(v => { return v.staffUuid })
})
}
}
})
setMentorApi({ list }).then(res => {
this.notice.okTips()
this.navBack()
})
},
// 返回
navBack() {
this.close({ tagName: '/staffManage' })
this.$router.push({ name: 'staffManage' })
this.close({ tagName: '/mentorConfig' })
}
}
}
</script>
<style lang="scss" scoped>
.montor-config{
.container-content{
background: #fff;
.title{
font-size: 18px;
color: #333333;
font-weight: 500;
border-bottom: 1px solid #E8E8EA;
padding: 12px 16px 12px 24px;
&::before{
position: absolute;
display: inline-block;
content: "";
height: 18px;
width: 4px;
top: 16px;
left: 16px;
background-color: #0947c6;
}
.sub-title{
display: inline-block;
margin-left: 8px;
font-size: 14px;
color: #666666;
font-weight: 400;
}
.sub-title:last-child{
max-width: 1300px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: bottom;
span{
margin-right: 10px;
}
}
}
.content{
padding: 16px 80px;
}
}
.footer{
display: flex;
align-items: center;
justify-content: center;
margin-top: 16px;
}
}
::v-deep .glsx-combi-form-block #sceneSelect .el-form-item__content{
width: calc(100% - 154px);
}
</style>