multiple.vue
3.75 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
<!-- 多人配置 -->
<template>
<div class="multiple-dialog">
<baseDialog
:dialog-config="dialogConfig"
:is-show.sync="visible"
class="accountDailog"
:config="config"
@handleClick="handleConfirm"
@closeDialog="handleClose"
>
<glsx-combi-form
label-width="160px"
default-width="400px"
:form-obj="multipleForm"
:form-data="multipleFormData"
:form-rules="infoRules"
>
<template slot="multiple" slot-scope="scope">
<el-checkbox v-model="checkAll" @change="handleCheckAllChange"
>全选</el-checkbox
>
<div class="staff-list">
<div
:class="['staff-item', item.active ? 'active' : '']"
v-for="(item, index) in selectStaffList"
:key="index"
@click="handleChooseStaff(index)"
>
{{ item.employeeName }}
</div>
</div>
</template>
</glsx-combi-form>
</baseDialog>
</div>
</template>
<script>
import { Util, deepClone } from "@/common/util"
export default {
props: {
multipleVisible: {
type: Boolean,
default: false
},
staffList: {
type: Array,
default: () => []
}
},
watch: {
staffList: {
handler(val) {
console.log(val, "🚀🚀🚀🚀🚀🚀🚀🚀🚀")
this.filterStaffList(deepClone(val))
},
deep: true,
immediate: true
}
},
computed: {
visible: {
get() {
return this.multipleVisible
},
set(newVal) {
this.$emit("dialogClose", {
flag: newVal,
attrName: "multipleVisible"
})
}
}
},
data() {
return {
dialogConfig: {
title: "多人配置",
width: "720px"
},
config: {
showClose: true,
appendToBody: false, // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
isShowFooter: true,
cancel_name: "取 消",
confirm_name: "确定配置"
},
checkAll: false,
infoRules: {
refundType: [
{
required: true,
message: "请选择退款类型",
trigger: "blur"
}
]
},
multipleForm: {},
multipleFormData: [
{
label: "本次课程配置同步给:",
name: "multiple",
addHtml: "multiple"
}
],
selectStaffList: []
}
},
methods: {
reset() {
this.checkAll = []
this.selectStaffList = []
},
handleChooseStaff(index) {
this.selectStaffList[index].active = !this.selectStaffList[index].active
this.checkAll = this.selectStaffList.every((item) => item.active)
},
filterStaffList(val) {
this.selectStaffList = []
val.forEach((item) => {
if (item.courseConfigFlag != 1) {
this.selectStaffList.push(item)
}
})
},
handleCheckAllChange() {
this.staffList.forEach((item) => {
item.active = this.checkAll
})
},
handleClose() {
this.visible = false
},
handleConfirm() {
this.$emit("handleMultiple", this.selectStaffList)
// this.$emit("handleMultiple")
this.visible = false
}
}
}
</script>
<style scoped lang="scss">
.staff-list {
display: flex;
align-items: center;
margin-top: 5px;
flex-wrap: wrap;
width: 480px;
.staff-item {
padding: 6px 12px;
border-radius: 2px;
color: #333333;
font-size: 14px;
font-weight: 400;
background: #f2f3f5;
margin-right: 8px;
margin-bottom: 8px;
box-sizing: border-box;
line-height: 20px;
}
.active {
color: #2a58ad;
font-weight: 500;
background: #2a58ad26;
}
}
</style>