From cace6971fbdb31ade5c5ae2cdca781ff50f9510c Mon Sep 17 00:00:00 2001 From: wjt <1797368093@qq.com> Date: 星期一, 24 六月 2024 21:00:26 +0800 Subject: [PATCH] 添加分管机构 --- src/views/system/user/index.vue | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index acf78c3..7172b37 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -86,7 +86,7 @@ <span>{{ parseTime(scope.row.createTime) }}</span> </template> </el-table-column> - <el-table-column label="鎿嶄綔" align="center" width="280" class-name="small-padding fixed-width"> + <el-table-column label="鎿嶄綔" align="center" width="380" class-name="small-padding fixed-width"> <template #default="scope"> <!-- <el-tooltip content="淇敼" placement="top" v-if="scope.row.userId !== 1"> --> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">淇敼</el-button> @@ -103,6 +103,7 @@ <!-- <el-tooltip content="閲嶇疆鏀粯瀵嗙爜" placement="top" v-if="scope.row.userId !== 1"> <el-button link type="danger" icon="Key" @click="handlePayPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"></el-button> </el-tooltip> --> + <el-button link type="success" icon="Key" @click="handlerDept(scope.row)" v-hasPermi="['system:user:resetPwd']">鍒嗙鏈烘瀯</el-button> </template> </el-table-column> </el-table> @@ -235,13 +236,25 @@ </div> </template> </el-dialog> + <!-- 澶氭満鏋勭粦瀹� --> + <el-dialog title="鍒嗙鏈烘瀯" v-model="openDialog" width="400px" append-to-body> + <el-tree :data="treeData" ref="depttree" :default-expanded-keys="defaultKeys" :props="{label: 'deptName', value: 'deptId', children: 'child' }" node-key="deptId" :default-checked-keys="defaultKeys" show-checkbox> + + </el-tree> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitFileFormSave">纭� 瀹�</el-button> + <el-button @click="openDialog = false">鍙� 娑�</el-button> + </div> + </template> + </el-dialog> </div> </template> <script setup name="User"> import { getToken } from "@/utils/auth"; import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect, resetPayPwd,updateUserProfile } from "@/api/system/user"; - +import { batchUserDeptView,batchUserDeptTree,batchUserDeptSave } from '@/api/system/company/company' const router = useRouter(); const { proxy } = getCurrentInstance(); const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex"); @@ -570,4 +583,42 @@ getDeptTree(); // getList(); +const openDialog = ref(false) +const userInfo = reactive({ + userId: "", + +}) +const treeData = ref([]) +const defaultKeys = ref([]) +const depttree = ref() +function handlerDept(item) { + userInfo.userId = item.userId + openDialog.value = true + batchUserDeptTreeHttp(item.deptId) + batchUserDeptViewHttp(userInfo.userId) +} +function batchUserDeptViewHttp(userId) { + batchUserDeptView({userId}).then(val => { + defaultKeys.value = val.data.deptIds + }) +} +function batchUserDeptTreeHttp(deptId) { + batchUserDeptTree({deptId}).then(val => { + val.data.child.forEach(item => { + // item.disabled = true + if(item.deptId == deptId) { + item.disabled = true + } + }) + treeData.value = [val.data] + }) +} +function submitFileFormSave() { + userInfo.deptIds = depttree.value.getCheckedKeys() + batchUserDeptSave(userInfo).then(val => { + if(val.code == 200){ + openDialog.value = false + } + }) +} </script> -- Gitblit v1.9.1