1414 <el-input size =" medium" clearable v-model =" form.username" :disabled =" isEdited" ></el-input >
1515 </el-form-item >
1616 <el-form-item label =" 邮箱" prop =" email" >
17- <el-input size =" medium" clearable v-model =" form.email" auto-complete =" new-password" ></el-input >
17+ <el-input
18+ size =" medium"
19+ clearable
20+ v-model =" form.email"
21+ :disabled =" isEdited"
22+ auto-complete =" new-password"
23+ ></el-input >
1824 </el-form-item >
1925 <el-form-item v-if =" pageType === 'add'" label =" 密码" prop =" password" >
2026 <el-input
3137 <el-form-item v-if =" pageType !== 'password'" label =" 选择分组" >
3238 <el-select
3339 size =" medium"
34- filterable
35- v-model =" form.group_id "
40+ multiple
41+ v-model =" form.group_ids "
3642 :disabled =" groups.length === 0"
3743 placeholder =" 请选择分组"
3844 >
@@ -124,7 +130,7 @@ export default {
124130 password: ' ' ,
125131 confirm_password: ' ' ,
126132 email: ' ' ,
127- group_id : ' 请先创建分组 ' ,
133+ group_ids : [] ,
128134 },
129135 // 验证规则
130136 rules: {
@@ -172,13 +178,16 @@ export default {
172178 }
173179 } else {
174180 // 更新用户信息
175- if (this .form .email === this .info .email && this .form .group_id === this .info .group_id ) {
181+ if (
182+ this .form .email === this .info .email
183+ && this .form .group_ids .sort ().toString () === this .info .group_ids .sort ().toString ()
184+ ) {
176185 this .$emit (' handleInfoResult' , false )
177186 return
178187 }
179188 try {
180189 this .loading = true
181- res = await Admin .updateOneUser (this .form .email , this .form .group_id , this .id )
190+ res = await Admin .updateOneUser (this .form .email , this .form .group_ids , this .id )
182191 } catch (e) {
183192 this .loading = false
184193 console .log (e)
@@ -203,22 +212,26 @@ export default {
203212 if (this .pageType === ' edit' ) {
204213 this .setInfo ()
205214 } else {
206- this .form .group_id = this .groups [0 ].id
215+ this .form .group_ids = [ this .groups [0 ].id ]
207216 this .$refs [formName].resetFields ()
208217 }
209218 },
210219 setInfo () {
211220 this .form .username = this .info .username
212221 this .form .email = this .info .email
213- this .form .group_id = this .info .group_id
222+ const temp = []
223+ this .info .group_ids .forEach (item => {
224+ temp .push (item .id )
225+ })
226+ this .form .group_ids = temp
214227 },
215228 },
216229 watch: {
217230 groups: {
218231 // 默认选中管理员组
219232 handler () {
220233 if (this .groups && this .groups [0 ] && this .groups [0 ].id ) {
221- this .form .group_id = this .groups [0 ].id
234+ this .form .group_ids = [ this .groups [0 ].id ]
222235 }
223236 },
224237 immediate: true ,
0 commit comments