addTeachingTask.vue
12.4 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
<template>
<d2-container class="editTeachingTask">
<div class="storeConfig con">
<p class="titleClass">选择要指派的督导</p>
<div class="itemCon">
<el-form ref="supervisorFormRef"
:model="infoForm"
:rules="formRules"
:label-width="formDefaultObj.labelWidth">
<el-form-item label="督导:"
prop="flightSupervisorId">
<el-button icon="el-icon-plus"
@click="handleSelectSupervisor">选择督导</el-button>
</el-form-item>
<el-form-item v-if="supervisorTableData.length > 0">
<el-table :data="supervisorTableData"
border
style="width: 100%">
<el-table-column type="index"
label="序号"
align="center"
width="60">
</el-table-column>
<el-table-column prop="staffName"
label="督导名称"
align="center">
</el-table-column>
<el-table-column prop="staffPhone"
label="手机号"
align="center">
</el-table-column>
<el-table-column label="操作"
align="center"
width="80">
<template slot-scope="scope">
<el-button type="text"
@click="handleDeleteSupervisor(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
</div>
<p class="titleClass">选择要带教的门店</p>
<div class="itemCon">
<el-form ref="merchantFormRef"
:model="infoForm"
:rules="formRules"
:label-width="formDefaultObj.labelWidth">
<el-form-item label="门店:"
prop="merchantId">
<el-button icon="el-icon-plus"
@click="handleStoreMerchant">选择门店</el-button>
</el-form-item>
<el-form-item v-if="storeTableData.length > 0">
<el-table :data="storeTableData"
border
style="width: 100%">
<el-table-column type="index"
label="序号"
align="center"
width="60">
</el-table-column>
<el-table-column prop="merchantName"
label="门店名称"
align="center">
</el-table-column>
<el-table-column label="区域运营"
align="center">
<div slot-scope="scope">
<template v-if="
scope.row.areaOperatorList && scope.row.areaOperatorList.length > 1
">
<span>{{ scope.row.areaOperatorList[0].areaOperatorName + ' ' + scope.row.areaOperatorList[0].areaOperatorPhone }}</span>
<el-popover placement="top"
width="fit-content"
trigger="hover">
<div :class="{ scrollHeight: scope.row.areaOperatorList.length >= 10 }">
<div v-for="(item, index) in scope.row.areaOperatorList"
:key="index">
{{ item.areaOperatorName + ' ' + item.areaOperatorPhone }}
</div>
</div>
<span class="more-info"
slot="reference">...({{ scope.row.areaOperatorList.length }})</span>
</el-popover>
</template>
<template v-else>
<span>--</span>
</template>
</div>
</el-table-column>
<el-table-column label="操作"
align="center"
width="80">
<template slot-scope="scope">
<el-button type="text"
@click="handleDeleteStore(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
</div>
<p class="titleClass">其他信息</p>
<div class="itemCon">
<el-form ref="otherFormRef"
:model="infoForm"
:rules="formRules"
:label-width="formDefaultObj.labelWidth">
<el-form-item label="支援类型:"
prop="supportType">
<el-select v-model="infoForm.supportType"
style="width: 310px"
placeholder="请选择">
<el-option v-for="(item, index) in supportTypeOpt"
:key="index"
:label="item.confValue"
:value="item.confId" />
</el-select>
</el-form-item>
<el-form-item label="情况描述:"
prop="situationDescription">
<el-input v-model="infoForm.situationDescription"
type="textarea"
:rows="4"
placeholder="请输入情况描述"
maxlength="200"
style="width: 500px"
clearable
show-word-limit />
</el-form-item>
</el-form>
</div>
<div class="footer">
<el-button @click="submitForm"
type="primary"
:loading="$store.state.d2admin.loading.value">提交</el-button>
<el-button @click="routerBack">取消</el-button>
</div>
</div>
<!-- 选择督导弹窗 -->
<select-supervisor-dialog v-if="selectSupervisorVisible"
:select-supervisor-visible="selectSupervisorVisible"
@handleSelectSupervisorConfirm="handleSelectSupervisorConfirm"
@handleSelectSupervisorClose="handleSelectSupervisorClose"></select-supervisor-dialog>
<!-- 选择门店弹窗 -->
<select-store-dialog v-if="selectStoreVisible"
:select-store-visible="selectStoreVisible"
:supervisor-uuid="supervisorTableData[0].uuid"
@handleSelectStoreConfirm="handleSelectStoreConfirm"
@handleSelectStoreClose="handleSelectStoreClose"></select-store-dialog>
</d2-container>
</template>
<script>
import { mapActions, mapState } from "vuex"
import { deepClone } from "@/common/util"
import selectSupervisorDialog from "./components/selectSupervisorDialog"
import selectStoreDialog from "./components/selectStoreDialog"
import { teaching_supportTypeOpt } from '@/common/constants.js'
import { teachTaskCreate } from '@api/teachingManage'
export default {
name: "EditTeachingTask",
components: {
selectSupervisorDialog,
selectStoreDialog
},
data() {
return {
formDefaultObj: {
labelWidth: "150px",
defaultWidth: "530px"
},
infoForm: {
flightSupervisorId: "", // 督导
merchantId: "", // 门店
supportType: "", // 支援类型
situationDescription: "" // 情况描述
},
formRules: {
flightSupervisorId: [
{ required: true, message: "请选择督导", trigger: "change" }
],
merchantId: [
{ required: true, message: "请选择门店", trigger: "change" }
],
supportType: [
{ required: true, message: "请选择支援类型", trigger: "change" }
],
situationDescription: [
{ required: true, message: "请输入情况描述", trigger: "blur" }
]
},
baseData: {},
selectSupervisorVisible: false,
supervisorTableData: [],
selectStoreVisible: false,
storeTableData: [],
supportTypeOpt: deepClone(teaching_supportTypeOpt)
}
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList,
updateList: (state) => state.d2admin.user.updateList
})
},
mounted() {
// this.loading = true
// this.loadItem()
},
methods: {
...mapActions({ close: "d2admin/page/close" }),
routerBack() {
this.$router.go(-1)
},
// 选择督导
handleSelectSupervisor() {
this.selectSupervisorVisible = true
},
// 选择门店
handleStoreMerchant() {
if (this.infoForm.flightSupervisorId) {
this.selectStoreVisible = true
} else {
this.$message.warning('请先选择督导')
}
},
handleSelectSupervisorConfirm(selectedData) {
const _valueObj = deepClone(selectedData)
console.log("_valueObj", _valueObj)
this.infoForm.flightSupervisorId = _valueObj.id
this.supervisorTableData = []
this.storeTableData = [] // 选择督导后,门店清空
this.supervisorTableData.push(_valueObj)
this.$refs.supervisorFormRef.clearValidate()
this.handleSelectSupervisorClose()
},
handleSelectSupervisorClose() {
this.selectSupervisorVisible = false
},
handleSelectStoreConfirm(selectedData) {
const _valueObj = deepClone(selectedData)
console.log("_valueObj", _valueObj)
this.infoForm.merchantId = _valueObj.merchantId
this.storeTableData = []
this.storeTableData.push(_valueObj)
this.$refs.merchantFormRef.clearValidate()
this.handleSelectStoreClose()
},
handleSelectStoreClose() {
this.selectStoreVisible = false
},
// 删除督导
handleDeleteSupervisor(subIndex) {
this.infoForm.flightSupervisorId = null
this.supervisorTableData.splice(subIndex, 1)
// 删除督导后,门店清空
this.handleDeleteStore(0)
},
// 删除门店
handleDeleteStore(subIndex) {
this.infoForm.merchantId = null
this.storeTableData.splice(subIndex, 1)
},
validateForm() {
let supervisorForm_flag = false
let merchantForm_flag = false
let otherForm_flag = false
this.$refs.supervisorFormRef.validate((valid) => {
supervisorForm_flag = valid
})
this.$refs.merchantFormRef.validate((valid) => {
merchantForm_flag = valid
})
this.$refs.otherFormRef.validate((valid) => {
otherForm_flag = valid
})
return supervisorForm_flag && merchantForm_flag && otherForm_flag
},
submitForm() {
const flag = this.validateForm()
if (flag) {
const params = deepClone(this.infoForm)
const supervisor = this.supervisorTableData[0]
params.flightSupervisorName = supervisor.staffName
params.flightSupervisorPhone = supervisor.staffPhone
params.flightSupervisorUuid = supervisor.uuid
const store = this.storeTableData[0]
params.merchantName = store.merchantName
if (store.areaOperatorList && store.areaOperatorList.length > 0) {
params.areaOperatorList = store.areaOperatorList.map(item => {
return {
areaOperatorPhone: item.areaOperatorPhone,
areaOperatorName: item.areaOperatorName
}
})
}
delete params.flightSupervisorId
// return console.log('params', params)
teachTaskCreate(params)
.then((res) => {
console.log(res)
this.$notify({
type: "success",
title: "保存成功"
})
this.close({ tagName: "/addTeachingTask" })
this.$router.push({ name: "teachingManage" })
})
.catch((err) => {
console.log(err)
})
}
}
}
}
</script>
<style lang="scss" scoped>
.titleClass {
height: 50px;
line-height: 50px;
padding: 0 20px;
border-bottom: 1px solid #e5e5e5;
font-size: 16px;
font-weight: 600;
color: #333333;
margin: 0 !important;
}
.storeConfig {
margin-bottom: 20px;
}
.itemCon {
width: 800px;
box-sizing: border-box;
padding: 20px 0 1px;
}
.con {
// border-radius: ;
background-color: #fff;
}
.footer {
text-align: center;
padding-bottom: 30px;
}
.more-info {
white-space: nowrap;
color: #5850ff;
cursor: pointer;
}
</style>