allocationDialog.vue
2.91 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
<template>
<d2-dialog title="新增课程"
:is-visible.sync="isVisible"
width="1120px"
btn-ok-label="确定"
@confirmDialog="handleConfirm"
@closeDialog="handleClose">
<CurriculaVariable ref="curriculaVariable"
:course-list="courseList"
:course-total="courseTotal"
:selected-rows="selectedDialogRows"
@handleCourse="handleCourse"
@fromAllocation="fromAllocation">
</CurriculaVariable>
</d2-dialog>
</template>
<script>
import { getStaffTagCourseList } from "@/api/serviceCentre";
import curriculaVariable from "./allocation";
export default {
components: {
CurriculaVariable: curriculaVariable,
},
props: {
isVisible: {
type: Boolean,
default: false,
},
selectedRows: {
type: Array,
default: () => [],
},
staffItem: {
type: Object,
default: () => {},
},
},
data() {
return {
selectData: [],
courseList: [],
courseTotal: 0,
};
},
computed: {
selectedDialogRows() {
return this.selectedRows.map((item) => {
return item;
});
},
},
watch: {
isVisible: {
handler(val) {
if (val) {
// 弹框每次 v-if 重建后 selectData 为空,需从 props 同步已选数据
this.selectData = Array.isArray(this.selectedRows)
? [...this.selectedRows]
: [];
this.getStaffTagCourseList();
}
},
immediate: true,
},
},
methods: {
getStaffTagCourseList(courseForm = {}) {
let params = {
staffPhone: this.staffItem.phone,
currentPage: 1,
pageSize: 5,
queryAll: false,
...courseForm,
};
getStaffTagCourseList(params).then((res) => {
this.courseList = res ? res.list : [];
this.courseTotal = res ? res.total : 0;
});
},
handleCourse(data) {
this.selectData = data;
},
fromAllocation(val) {
this.getStaffTagCourseList(val);
},
// 确认仅返回整条数据数组
handleConfirm() {
const curriculaRef = this.$refs.curriculaVariable;
const data
= curriculaRef && Array.isArray(curriculaRef.selectCourseList)
? [...curriculaRef.selectCourseList]
: [...this.selectData];
this.$emit("handleConfirm", data);
},
handleClose() {
this.$emit("handleClose");
},
},
};
</script>
<style lang="scss" scoped>
.relateEmp {
::v-deep .el-dialog__header {
border-bottom: 1px solid #e5e5e5;
}
::v-deep .d2-search .d2-search-block {
padding: 0px !important;
}
::v-deep .el-dialog__header {
font-size: 20px;
line-height: 24px;
}
.select-text {
color: #333333;
font-size: 14px;
position: relative;
right: 65%;
margin-bottom: 8px;
}
.online-status {
display: flex;
justify-content: center;
align-items: center;
.dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
}
}
</style>