couseAllocation.vue
11.8 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
<!-- 课程配置 -->
<template>
<div class="couseAllocation">
<div class="header">AI导师建议</div>
<div class="ai-suggest">
{{ staffDetailInfo.aiJy ? staffDetailInfo.aiJy : "暂无AI导师建议" }}
</div>
<div class="header">课程配置</div>
<!-- 已配置 -->
<template v-if="staffItem.courseConfigFlag == 1">
<el-form class="edit-sub-block" label-width="138px">
<el-form-item label="学习完成时间:">本周内 </el-form-item>
<el-form-item label="处罚方式:">
{{ alreadyConfig.punishTypeText }}
</el-form-item>
<el-form-item label="配置课程:">
<div class="right">
<div class="title-type">
<div class="select">已选课程</div>
<div class="time">
共{{ selectObj.count }}节 {{ selectObj.courseTotalDuration }}min
</div>
</div>
<div class="select-list">
<div
class="select-item"
v-for="selectCourse in staffTagCourseList"
:key="selectCourse.courseId"
>
<div class="item-content">
{{ selectCourse.courseName
}}<span class="item-time"
>{{ selectCourse.courseTotalDuration || 0 }}min</span
>
</div>
</div>
</div>
</div>
</el-form-item>
<el-form-item label="学习任务标题:"
>{{ alreadyConfig.title }}
</el-form-item>
</el-form>
</template>
<!-- 未配置 -->
<template v-else>
<div class="allocation">
<glsx-combi-form
ref="editFormRef"
:isBlock="isBlock"
class="form-container"
label-width="138px"
default-width="400px"
:form-ref="handleFormRef"
:form-obj="extendConfig"
:form-data="allocationFormData"
:form-rules="formRules"
>
<!-- 配置课程 -->
<div slot="allocationHtml" slot-scope="scope">
<curricula-variable
ref="curriculaVariable"
:courseList="courseAllocationData"
@handleCourse="handleCourse"
></curricula-variable>
</div>
</glsx-combi-form>
</div>
<div class="foot-btns">
<div class="btn reset" @click="handleReset">重置</div>
<div class="btn multiple" @click="handleMultiple">多人配置</div>
<div class="btn submit" @click="handleSubmit">提交本员工配置</div>
</div>
</template>
<!-- 多人配置 -->
<multipleDialog
ref="multipleDialog"
:multipleVisible="multipleVisible"
v-if="multipleVisible"
@dialogClose="handleCloseDialog"
:staffList="staffListData"
@handleMultiple="handleConfirmMultiple"
></multipleDialog>
</div>
</template>
<script>
import curriculaVariable from "./allocation"
import multipleDialog from "./multiple"
import { insertOrUpdate, staffCourse, getByTaskId } from "@/api/serviceCentre"
export default {
components: {
curriculaVariable,
multipleDialog
},
data() {
return {
isBlock: true,
handleFormRef: "handleFormRef",
multipleVisible: false,
extendConfig: {
punishType: 1, //惩罚方式:0无 1禁止录单
deadline: "",
title: "",
studyType: 1,
courseList: []
},
alreadyConfig: {},
handleFormRef: "handleFormRef",
formRules: {
punishType: [
{ required: true, message: "请选择处罚方式", trigger: "change" }
],
studyType: [
{ required: true, message: "请选择学习完成时间:", trigger: "change" }
],
courseList: [
{ required: true, message: "请选择配置课程", trigger: "change" }
],
title: [{ required: true, message: "请输入标题", trigger: "blur" }]
},
allocationFormData: [
{
label: "学习完成时间:",
name: "studyType",
type: "radio",
optionList: [
{
confLabel: "本周内",
confId: 1
}
],
optionId: "confId",
optionLabel: "confLabel",
handleRadioChange: (val) => {}
},
{
label: "处罚方式:",
name: "punishType",
type: "radio",
optionList: [
{
confLabel: "不处罚",
confId: 1
},
{
confLabel: "限制录单",
confId: 2
}
],
optionId: "confId",
optionLabel: "confLabel",
handleRadioChange: (val) => {}
},
{
label: "配置课程:",
name: "courseList",
type: "slot",
addHtml: "allocationHtml"
},
{
label: "学习任务标题:",
name: "title",
type: "input",
isClear: true,
maxlength: 20
}
],
courseAllocationData: [],
staffListData: [],
staffTagCourseList: [], //已配置的课程列表
selectObj: {
courseTotalDuration: 0,
count: 0
}
}
},
props: {
staffDetailInfo: {
type: Object,
default: () => {}
},
courseList: {
type: Array,
default: () => []
},
staffItem: {
type: Object,
default: () => {}
},
staffList: {
type: Array,
default: () => []
}
},
watch: {
courseList: {
handler(val) {
console.log(val, "val")
this.courseAllocationData = val
this.handleReset()
},
deep: true
},
staffList: {
handler(val) {
console.log(val, "我是员工我是员工我是员工")
this.staffListData = val.map((record) => ({
...record,
active: false // 初始化为 false
}))
},
deep: true,
immediate: true
},
staffItem: {
handler(val) {
console.log(val, "我是员工详情")
if (val.courseConfigFlag == 1) {
//查询员工已配置课程
this.getStaffTagCourseList()
//查询员工已配置详情
this.getByTaskId()
}
},
deep: true,
immediate: true
}
},
methods: {
//查询员工已配置课程
getStaffTagCourseList() {
staffCourse({
taskId: this.staffItem.taskId
}).then((res) => {
console.log("获取到已配课", res)
this.staffTagCourseList = res.list
})
},
//查询员工已配置详情
getByTaskId() {
getByTaskId({ id: this.staffItem.taskId }).then((res) => {
console.log("获取到已配课详情", res)
this.alreadyConfig = {
title: res.title,
punishTypeText:
res.extendConfig.punishType == 1 ? "不处罚" : "限制录单"
}
})
},
//获取配置课程列表
handleCourse(data) {
this.extendConfig.courseList = data.map((item) => {
return {
courseId: item.courseId,
courseTitle: item.courseName
}
})
if (data.length > 0) {
this.$refs.editFormRef.$refs[this.handleFormRef].clearValidate(
`courseList`
)
}
},
//重置
handleReset() {
this.extendConfig = {
punishType: 1, //惩罚方式:0无 1禁止录单
deadline: "",
title: "",
studyType: 1,
courseList: []
}
this.$refs.curriculaVariable && this.$refs.curriculaVariable.reset()
},
handleMultiple() {
this.$refs.editFormRef.$refs[this.handleFormRef].validate((valid) => {
console.log(valid)
if (valid) {
this.multipleVisible = true
}
})
},
handleCloseDialog() {
this.multipleVisible = false
},
getThisSundayWithTime() {
const now = new Date()
const today = now.getDay()
const diffToSunday = (0 - today + 7) % 7
const sunday = new Date(now)
sunday.setDate(now.getDate() + diffToSunday)
sunday.setHours(23, 59, 59, 999)
return sunday
},
formatDateTime(date) {
const y = date.getFullYear()
const m = String(date.getMonth() + 1).padStart(2, "0")
const d = String(date.getDate()).padStart(2, "0")
const h = String(date.getHours()).padStart(2, "0")
const i = String(date.getMinutes()).padStart(2, "0")
const s = String(date.getSeconds()).padStart(2, "0")
return `${y}-${m}-${d} ${h}:${i}:${s}`
},
handleParams() {
const deadlineStr = this.formatDateTime(this.getThisSundayWithTime())
let params = {
content: JSON.stringify(this.extendConfig.courseList),
contentType: 5,
extendConfig: {
deadline: deadlineStr,
finishCriteria: 1, //(写死)
punishType: this.extendConfig.punishType
},
readType: 1, //(写死)
sendChannelType: 2, //(写死)
saveDraft: false, //(写死)
sendType: 1, //(写死)
staffPhoneList: [
// 多人就传多个,单人就传单个人手机号
this.staffItem.phone
],
title: this.extendConfig.title
}
return params
},
handleConfirmMultiple(selectStaffList) {
let staffPhoneList = selectStaffList.map((item) => item.phone)
let params = this.handleParams()
params.staffPhoneList = staffPhoneList
this.submit(params)
},
submit(params) {
insertOrUpdate(params).then((res) => {
this.notice.okTips("操作成功")
this.$emit("handleConfigureCourse")
})
},
handleSubmit() {
this.$refs.editFormRef.$refs[this.handleFormRef].validate((valid) => {
console.log(valid)
if (valid) {
let params = this.handleParams()
// this.visible = false
this.submit(params)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.couseAllocation {
background: #fff;
height: calc(100% - 45px);
overflow-y: auto;
overflow-x: hidden;
.header {
color: #111111;
font-size: 16px;
font-weight: 500;
padding: 8px 20px;
border-bottom: 1px solid #e5e5e5;
}
.ai-suggest {
margin: 20px 40px;
padding: 12px 20px;
background: #f5f6fa;
border-radius: 2px;
}
.allocation {
background: #fff;
padding: 20px 20px 0;
}
.foot-btns {
display: flex;
align-items: center;
margin: 0 auto;
justify-content: center;
padding: 20px 0;
.btn {
padding: 6px 28px;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
}
.reset {
background: #e8e8e8;
color: #666666;
}
.multiple {
background: #dfe6f3;
color: #2a58ad;
margin: 0 16px;
}
.submit {
background: #2a58ad;
color: #ffffff;
}
}
.right {
width: 580px;
border: 1px solid #e5e5e5;
}
.right {
.title-type {
display: flex;
align-items: center;
justify-content: space-between;
height: 40px;
box-sizing: border-box;
padding: 10px 16px;
border-bottom: 1px solid #e5e5e5;
background: #f5f6fa;
.select {
color: #333333;
font-size: 14px;
}
.time {
color: #666666;
font-size: 14px;
}
}
.select-list {
height: 365px;
overflow-y: auto;
overflow-x: hidden;
.select-item {
display: flex;
align-items: center;
border-bottom: 1px solid #e5e5e5;
.item-content {
color: #333333;
font-size: 14px;
line-height: 20px;
padding: 14px 16px;
white-space: wrap;
}
.item-time {
font-size: 12px;
color: #666666;
margin-left: 4px;
}
}
}
}
}
</style>