From c9a0b7481ac2b142548cbbb43502067e30fc5609 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 6 Jan 2026 08:55:04 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=9F=E4=B8=80=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=85=A5=E5=8F=A3=E4=B8=BA=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 UserEditModal 组件,整合昵称、电话、职位、邮箱、密码、部门、个人简介、个性标签编辑 - 签到模式下支持编辑人脸图片和 MAC 地址,并高亮显示相关字段 - TeamManagement 移除分散的编辑入口(快捷修改、修改邮箱/密码/部门/人脸/MAC 等菜单) - 简化 operationUser 方法,移除冗余的 data/watch/methods --- .../manage/components/TeamManagement.vue | 373 ++----------- .../pages/manage/components/UserEditModal.vue | 525 ++++++++++++++++++ 2 files changed, 556 insertions(+), 342 deletions(-) create mode 100644 resources/assets/js/pages/manage/components/UserEditModal.vue diff --git a/resources/assets/js/pages/manage/components/TeamManagement.vue b/resources/assets/js/pages/manage/components/TeamManagement.vue index 5a0a20794..d90565882 100644 --- a/resources/assets/js/pages/manage/components/TeamManagement.vue +++ b/resources/assets/js/pages/manage/components/TeamManagement.vue @@ -241,89 +241,13 @@ - - - -
- {{$L(`正在进行帐号【ID:${checkinMacEditData.userid}, ${checkinMacEditData.nickname}】MAC地址修改。`)}} - - {{$L('设备MAC地址')}} - {{$L('备注')}} - - - - - - - - - - -
-
- - -
-
- - - - -
- {{$L(`正在进行帐号【ID:${checkinFaceEditData.userid}, ${checkinFaceEditData.nickname}】人脸图片修改。`)}} - - {{$L('人脸图片')}} - - - - -
{{$L('建议尺寸:500x500')}}
- -
-
-
- - -
-
- - - -
- {{$L(`正在进行帐号【ID:${departmentEditData.userid}, ${departmentEditData.nickname}】部门修改。`)}} - - - -
-
- - -
-
+ + import UserSelect from "../../../components/UserSelect.vue"; import UserAvatarTip from "../../../components/UserAvatar/tip.vue"; -import ImgUpload from "../../../components/ImgUpload"; import ResizeLine from "../../../components/ResizeLine.vue"; import SearchButton from "../../../components/SearchButton.vue"; +import UserEditModal from "./UserEditModal.vue"; import {mapState} from "vuex"; export default { name: "TeamManagement", - components: {SearchButton, ResizeLine, UserAvatarTip, UserSelect, ImgUpload}, + components: {SearchButton, ResizeLine, UserAvatarTip, UserSelect, UserEditModal}, props: { checkinMode: { type: Boolean, @@ -480,21 +404,7 @@ export default { key: 'tel', minWidth: 80, render: (h, {row}) => { - return h('QuickEdit', { - props: { - value: row.tel, - }, - on: { - 'on-update': (val, cb) => { - this.operationUser({ - userid: row.userid, - tel: val - }, true).finally(cb); - } - } - }, [ - h('AutoTip', row.tel || '-') - ]); + return h('AutoTip', row.tel || '-'); } }, { @@ -502,21 +412,7 @@ export default { key: 'nickname', minWidth: 80, render: (h, {row}) => { - return h('QuickEdit', { - props: { - value: row.nickname_original, - }, - on: { - 'on-update': (val, cb) => { - this.operationUser({ - userid: row.userid, - nickname: val - }, true).finally(cb); - } - } - }, [ - h('AutoTip', row.nickname_original || '-') - ]); + return h('AutoTip', row.nickname_original || '-'); } }, { @@ -524,21 +420,7 @@ export default { key: 'profession', minWidth: 80, render: (h, {row}) => { - return h('QuickEdit', { - props: { - value: row.profession, - }, - on: { - 'on-update': (val, cb) => { - this.operationUser({ - userid: row.userid, - profession: val - }, true).finally(cb); - } - } - }, [ - h('AutoTip', row.profession || '-') - ]); + return h('AutoTip', row.profession || '-'); }, }, { @@ -629,32 +511,9 @@ export default { render: (h, params) => { const identity = params.row.identity; const dropdownItems = []; - if (this.checkinMode) { - dropdownItems.push(...[ - h('EDropdownItem', { - props: { - command: 'checkin_face', - }, - style: { - color: '#f90', - fontWeight: 'bold' - } - }, [h('div', this.$L('修改人脸图片'))]), - h('EDropdownItem', { - props: { - command: 'checkin_mac', - }, - style: { - color: '#f90', - fontWeight: 'bold' - } - }, [h('div', this.$L('修改MAC地址'))]) - ]) - } dropdownItems.push(h('EDropdownItem', { props: { command: 'openDialog', - divided: this.checkinMode }, }, [h('div', this.$L('打开会话窗口'))])); if (identity.includes('admin')) { @@ -685,24 +544,13 @@ export default { }, }, [h('div', this.$L('设为临时帐号'))])); } - dropdownItems.push(...[ - h('EDropdownItem', { - props: { - command: 'email', - divided: true - }, - }, [h('div', this.$L('修改邮箱'))]), - h('EDropdownItem', { - props: { - command: 'password', - }, - }, [h('div', this.$L('修改密码'))]), - h('EDropdownItem', { - props: { - command: 'department', - }, - }, [h('div', this.$L('修改部门'))]) - ]) + // 编辑用户信息 + dropdownItems.push(h('EDropdownItem', { + props: { + command: 'edit_user_info', + divided: true + }, + }, [h('div', this.$L('编辑用户信息'))])); if (identity.includes('disable')) { dropdownItems.push(h('EDropdownItem', { props: { @@ -773,17 +621,9 @@ export default { total: 0, noText: '', - checkinMacEditShow: false, - checkinMacEditLoading: 0, - checkinMacEditData: {}, + userEditShow: false, + userEditData: {}, - checkinFaceEditShow: false, - checkinFaceEditLoading: 0, - checkinFaceEditData: {}, - - departmentEditShow: false, - departmentEditLoading: 0, - departmentEditData: {}, departmentWidth: $A.getStorageInt('management.departmentWidth', 239), disableShow: false, @@ -858,11 +698,6 @@ export default { dialogLoad: false, dialogList: [], - - nullCheckinDatum: { - 'mac': '', - 'remark': '', - }, } }, created() { @@ -962,46 +797,6 @@ export default { }); }, immediate: true - }, - 'departmentEditData.department': { - handler(value, oldValue = []) { - if (!Array.isArray(value) || value.length === 0 || this.departmentList.length === 0) { - return; - } - - const previous = Array.isArray(oldValue) ? new Set(oldValue) : new Set(); - const selected = new Set(value); - - const hasNewSelection = Array.from(selected).some(id => !previous.has(id)); - if (!hasNewSelection) { - return; - } - - const departmentMap = this.departmentList.reduce((acc, item) => { - acc[item.id] = item; - return acc; - }, {}); - - const needAdd = new Set(); - - value.forEach((id) => { - let cursor = departmentMap[id]; - while (cursor && cursor.parent_id && cursor.parent_id > 0) { - if (!selected.has(cursor.parent_id)) { - needAdd.add(cursor.parent_id); - } - cursor = departmentMap[cursor.parent_id]; - } - }); - - if (needAdd.size > 0) { - const merged = Array.from(new Set([...value, ...needAdd])).sort((a, b) => a - b); - if (merged.length !== value.length || merged.some((id, index) => id !== value[index])) { - this.$set(this.departmentEditData, 'department', merged); - } - } - }, - deep: true } }, computed: { @@ -1064,26 +859,9 @@ export default { dropUser(name, row) { switch (name) { - case 'checkin_mac': - this.checkinMacEditData = { - type: 'checkin_macs', - userid: row.userid, - nickname: row.nickname, - checkin_macs: row.checkin_macs, - }; - if (this.checkinMacEditData.checkin_macs.length === 0) { - this.addCheckinDatum(); - } - this.checkinMacEditShow = true; - break; - case 'checkin_face': - this.checkinFaceEditData = { - type: 'checkin_face', - userid: row.userid, - nickname: row.nickname, - faceimg: row.checkin_face - }; - this.checkinFaceEditShow = true; + case 'edit_user_info': + this.userEditData = $A.cloneJSON(row); + this.userEditShow = true; break; case 'openDialog': @@ -1144,55 +922,6 @@ export default { }); break; - case 'email': - $A.modalInput({ - title: "修改邮箱", - placeholder: `请输入新的邮箱(${row.email})`, - onOk: (value) => { - if (!value) { - return '请输入新的邮箱地址' - } - return this.operationUser({ - userid: row.userid, - email: value - }); - } - }); - break; - - case 'password': - $A.modalInput({ - title: "修改密码", - placeholder: "请输入新的密码", - onOk: (value) => { - if (!value) { - return '请输入新的密码' - } - return this.operationUser({ - userid: row.userid, - password: value - }); - } - }); - break; - - case 'department': - let departments = [] - row.department.some(did => { - const data = this.departmentList.find(d => d.id == did) - if (data) { - departments.push(data.owner_userid === row.userid ? `${data.name} (${this.$L('负责人')})` : data.name) - } - }) - this.departmentEditData = { - type: 'department', - userid: row.userid, - nickname: row.nickname, - department: row.department.map(id => parseInt(id)), - }; - this.departmentEditShow = true; - break; - case 'setdisable': this.disableData = { type: 'setdisable', @@ -1247,19 +976,7 @@ export default { operationUser(data, tipErr) { return new Promise((resolve, reject) => { let submitData = data; - if (data.type == 'checkin_macs') { - this.checkinMacEditLoading++; - } else if (data.type == 'checkin_face') { - this.checkinFaceEditLoading++; - submitData = { - type: data.type, - userid: data.userid, - nickname: data.nickname, - checkin_face: $A.arrayLength(data.faceimg) > 0 ? data.faceimg[0].url : '' - } - } else if (data.type == 'department') { - this.departmentEditLoading++; - } else if (data.type == 'setdisable') { + if (data.type == 'setdisable') { this.disableLoading++; submitData = Object.assign({}, data); if (Array.isArray(submitData.transfer_userid)) { @@ -1280,14 +997,8 @@ export default { }).then(({msg}) => { $A.messageSuccess(msg); this.getLists(); - resolve() - if (data.type == 'checkin_macs') { - this.checkinMacEditShow = false; - } else if (data.type == 'checkin_face') { - this.checkinFaceEditShow = false; - } else if (data.type == 'department') { - this.departmentEditShow = false; - } else if (data.type == 'setdisable') { + resolve(); + if (data.type == 'setdisable') { this.disableShow = false; } }).catch(({msg}) => { @@ -1295,21 +1006,15 @@ export default { $A.modalError(msg); } this.getLists(); - reject(msg) + reject(msg); }).finally(_ => { - if (data.type == 'checkin_macs') { - this.checkinMacEditLoading--; - } else if (data.type == 'checkin_face') { - this.checkinFaceEditLoading--; - } else if (data.type == 'department') { - this.departmentEditLoading--; - } else if (data.type == 'setdisable') { + if (data.type == 'setdisable') { this.disableLoading--; } else { this.loadIng--; } - }) - }) + }); + }); }, getDepartmentLists() { @@ -1321,11 +1026,6 @@ export default { }) }, - onMultipleMaxBefore(num) { - $A.messageError(`最多选择${num}个部门`) - return false - }, - onShowDepartment(data) { this.departmentData = Object.assign({ id: 0, @@ -1481,17 +1181,6 @@ export default { this.dialogList = []; } }, - - addCheckinDatum() { - this.checkinMacEditData.checkin_macs.push($A.cloneJSON(this.nullCheckinDatum)); - }, - - delCheckinDatum(key) { - this.checkinMacEditData.checkin_macs.splice(key, 1); - if (this.checkinMacEditData.checkin_macs.length === 0) { - this.addCheckinDatum(); - } - }, } } diff --git a/resources/assets/js/pages/manage/components/UserEditModal.vue b/resources/assets/js/pages/manage/components/UserEditModal.vue new file mode 100644 index 000000000..ee86bcc90 --- /dev/null +++ b/resources/assets/js/pages/manage/components/UserEditModal.vue @@ -0,0 +1,525 @@ + + + + + +