From 0d9c8915b4c9deef17459f886ef136ad3d3b9440 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期四, 04 七月 2024 16:50:04 +0800 Subject: [PATCH] 成员管理 分配部门 部门搜索 添加 修改 导入人员 下载导入模板 --- Source/plt-web/plt-web-ui/src/views/system/user/index.vue | 258 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 247 insertions(+), 11 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/views/system/user/index.vue b/Source/plt-web/plt-web-ui/src/views/system/user/index.vue index f584d62..1970aa3 100644 --- a/Source/plt-web/plt-web-ui/src/views/system/user/index.vue +++ b/Source/plt-web/plt-web-ui/src/views/system/user/index.vue @@ -2,6 +2,7 @@ <basic-container> <avue-crud ref="userCrud" + :before-open="beforeOpen" :data="tableData" :option="option" :page.sync="page" @@ -16,8 +17,27 @@ @row-click="rowClickHandler" @row-save="rowSaveHandler" @row-update="rowUpdateHandler" - @row-del="rowDelHandler" > + <!-- 閮ㄩ棬澶撮儴鎼滅储鎻掓Ы --> + <template slot-scope="{disabled,size}" slot="pkDepartmentNameSearch"> + <div style="display: flex;gap: 5px"> + <el-select v-model="departSearchValue" clearable placeholder="璇烽�夋嫨閮ㄩ棬"> + <el-option :label="departSearchObj.name" :value="departSearchObj.oid"></el-option> + </el-select> + <el-button size="small" type="success" @click="dialogDepartSearchHandler">閫夋嫨閮ㄩ棬</el-button> + </div> + </template> + + <!-- 瀵硅瘽妗嗛儴闂ㄦ彃妲� --> + <template slot="pkDepartmentNameForm" slot-scope="scope"> + <div style="display: flex;gap: 5px"> + <el-select v-model="departValue" clearable placeholder="璇烽�夋嫨閮ㄩ棬"> + <el-option :label="departObj.name" :value="departObj.oid"></el-option> + </el-select> + <el-button size="small" type="success" @click="dialogDepartHandler">閫夋嫨閮ㄩ棬</el-button> + </div> + </template> + <template slot="status" slot-scope="{row}"> <el-tag v-if="row.status === 0" type="success">鍚敤</el-tag> <el-tag v-if="row.status === 1" type="danger">鍋滅敤</el-tag> @@ -29,7 +49,9 @@ </template> <template #menu="{row,index,size}"> - <el-button size="small" type="text" @click="stopUserHandler(row)"> + <el-button icon="el-icon-edit" size="small" type="text" @click.stop="rowEditHandler(row,index)">缂栬緫</el-button> + <el-button icon="el-icon-delete" size="small" type="text" @click.stop="rowDeleteHandler(row)">鍒犻櫎</el-button> + <el-button size="small" type="text" @click.stop="stopUserHandler(row)"> <span v-if="row.status === 0" style="color: #fa3434"><i class="el-icon-video-pause"></i> 鍋滅敤</span> <span v-if="row.status === 1" style="color: #55b61d"><i class="el-icon-video-pause"></i> 鍚敤</span> </el-button> @@ -38,12 +60,13 @@ <template slot="menuLeft" slot-scope="scope"> <el-button icon="el-icon-delete" plain size="small" type="danger" @click="allDelHandler">鍒犻櫎</el-button> <el-button icon="el-icon-user" plain size="small" type="primary" @click="roleHandler">鍒嗛厤瑙掕壊</el-button> - <el-button icon="el-icon-school" plain size="small" type="primary">鍒嗛厤閮ㄩ棬</el-button> + <el-button icon="el-icon-school" plain size="small" type="primary" @click="departmentHandler">鍒嗛厤閮ㄩ棬</el-button> <el-button icon="el-icon-key" plain size="small" type="success" @click="setPwsHandler">璁剧疆瀵嗙爜绛栫暐</el-button> - <el-button icon="el-icon-upload2" plain size="small" type="primary">瀵煎叆浜哄憳</el-button> - <el-button icon="el-icon-download" plain size="small" type="primary">涓嬭浇瀵煎叆妯℃澘</el-button> + <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="uploadRole">瀵煎叆浜哄憳</el-button> + <el-button icon="el-icon-download" plain size="small" type="primary" @click="downloadHandler">涓嬭浇瀵煎叆妯℃澘</el-button> </template> </avue-crud> + <!-- 鍒嗛厤瑙掕壊绌挎妗� --> <transfer ref="transfer" :left-role-data="leftRoleData" :right-role-data="rightRoleData" :transferTitle="transferTitle" title="鍒嗛厤瑙掕壊" @@ -58,7 +81,7 @@ :visible.sync="pwdVisible" append-to-body="true" class="avue-dialog" - style="margin-top: -20vh !important;" + style="margin-top: -15vh !important;" title="璁剧疆瀵嗙爜绛栫暐" width="30%" > @@ -73,6 +96,33 @@ <div slot="footer" class="dialog-footer"> <el-button size="small" @click="pwdVisible = false">鍙� 娑�</el-button> <el-button size="small" type="primary" @click="savePwdHandler">纭� 瀹�</el-button> + </div> + </el-dialog> + + <!-- 瀵煎叆浜哄憳 --> + <upload-file ref="upload" :fileType="upFileType" :fileUrl="fileUrl" title="瀵煎叆浜哄憳"></upload-file> + + <!-- 鍒嗛厤閮ㄩ棬瀵硅瘽妗� --> + <el-dialog + v-dialogDrag + v-loading="departLoading" + :destroy-on-close="true" + :visible.sync="departVisible" + append-to-body="true" + class="avue-dialog" + title="鍒嗛厤閮ㄩ棬" + width="50%" + > + <avue-crud + ref="departCrud" + :data="departData" + :option="departOption" + @current-row-change="handleCurrentRowChange" + > + </avue-crud> + <div slot="footer" class="dialog-footer"> + <el-button size="small" @click="departVisible = false">鍙� 娑�</el-button> + <el-button size="small" type="primary" @click="saveDepartHandler">纭� 瀹�</el-button> </div> </el-dialog> </basic-container> @@ -90,15 +140,55 @@ updateUser, deleteUser, selectPwdStrategyMap, - saveUserPasswordStrateg + saveUserPasswordStrateg, + download, + departmentQueryController, + saveUsersDepts } from '@/api/system/user/api' import {column} from "./option" import func from '@/util/func' export default { name: "userManage", - data() { + data: function () { return { + departSearchObj:{}, + departSearchValue:'', + loadKey: 0, + departStatus: '', // 鍖哄垎涓嶅悓鏂瑰紡鎵撳紑閮ㄩ棬瀵硅瘽妗� + departValue: '', // 閮ㄩ棬瀵硅瘽妗嗕笅鎷夋缁戝畾鍊� + departObj: {}, // 閮ㄩ棬瀵硅瘽妗嗕笅鎷夋閫夐」缁戝畾鍊� + departCurrenRow: {}, + departOption: { + ...basicOption, + rowKey: 'oid', + rowParentKey: 'parentId', + selection: false, + highlightCurrentRow: true, + stripe: false, + menu: false, + refreshBtn: false, + gridBtn: false, + column: [ + { + label: '鍚嶇О', + prop: 'name', + }, + { + label: '缂栧彿', + prop: 'id', + }, + { + label: '鎻忚堪', + prop: 'description', + }, + ] + }, + departData: [], + departLoading: false, + departVisible: false, + upFileType: ['xls', 'xlsx'], + fileUrl: 'api/userQueryController/importUser', pwdVisible: false, pwdLoading: false, pwdValue: '', @@ -107,6 +197,8 @@ tableData: [], option: { ...basicOption, + editBtn: false, + delBtn: false, dialogWidth: '50%', calcHeight: -60, column: column @@ -127,6 +219,14 @@ created() { }, methods: { + // 鏂板鎴栦慨鏀瑰璇濇鎵撳紑鍓� + beforeOpen(done, type) { + if(type == 'add'){ + this.departObj = {}; + this.departValue = ""; + } + done(); + }, // 琛ㄦ牸璇锋眰 getTableList() { this.tableLoading = true; @@ -147,6 +247,11 @@ // 鎼滅储鏌ヨ handleSearch(params, done) { + this.searchParams = {}; + if(this.departSearchObj && this.departSearchValue){ + this.searchParams['conditionMap["pkDepartment"]'] = this.departSearchValue; + } + if (!func.isEmptyObject(params)) { for (let key in params) { if (params.hasOwnProperty(key)) { @@ -155,15 +260,20 @@ this.searchParams[`conditionMap["${newKey}"]`] = params[key]; } } - } else { + } + + if (func.isEmptyObject(params) && !this.departSearchValue) { this.searchParams = {}; } + this.getTableList(); done(); }, // 閲嶇疆鎼滅储鏉′欢 handleReset() { + this.departSearchObj = {}; + this.departSearchValue = ""; this.searchParams = {}; this.getTableList(); }, @@ -282,6 +392,7 @@ this.$message.error('璇锋鏌ヤ袱娆″瘑鐮佹槸鍚﹁緭鍏ヤ竴鑷达紒') return this.$refs.userCrud.$refs.dialogForm.$refs.tableForm.allDisabled = false; } + row.pkDepartment = this.departValue; // 灏嗗綋鍓嶈鐨勯儴闂ㄥ弬鏁皃kDepartment 璧嬪�间负涓嬫媺妗嗙粦瀹氱殑鍊� addUser(row).then(res => { if (res.data.code === 200) { this.$message.success(res.data.obj); @@ -293,12 +404,25 @@ done() }, + // 鎿嶄綔鏍忕紪杈� + rowEditHandler(row, index) { + let obj = { name: row.pkDepartmentName, oid: row.pkDepartment, rowOid: row.oid }; + this.departValue = row.pkDepartment; + this.departObj = obj; + + if (this.departObj.rowOid) { + this.$refs.userCrud.rowEdit(row, index); + } + + }, + // 缂栬緫 rowUpdateHandler(row, index, done) { if (row.password != row.confirmPassword) { this.$message.error('璇锋鏌ヤ袱娆″瘑鐮佹槸鍚﹁緭鍏ヤ竴鑷达紒') return this.$refs.userCrud.$refs.dialogForm.$refs.tableForm.allDisabled = false; } + row.pkDepartment = this.departValue; // 灏嗗綋鍓嶈鐨勯儴闂ㄥ弬鏁皃kDepartment 璧嬪�间负涓嬫媺妗嗙粦瀹氱殑鍊� updateUser(row).then(res => { if (res.data.code === 200) { this.$message.success(res.data.obj); @@ -311,7 +435,7 @@ }, // 鍒犻櫎 - rowDelHandler(row) { + rowDeleteHandler(row) { let params = { ids: row.oid } @@ -351,7 +475,119 @@ message: '宸插彇娑堝垹闄�' }); }); - } + }, + + // 涓嬭浇瀵煎叆妯℃澘 + downloadHandler() { + download().then(res => { + console.log(res); + func.downloadFileByBlobHandler(res); + this.$message.success('涓嬭浇鎴愬姛') + }).catch(err => { + this.$message.error(err); + }) + }, + + // 瀵煎叆浜哄憳 + uploadRole() { + this.$refs.upload.visible = true; + }, + + // 鍒嗛厤閮ㄩ棬 + departmentHandler() { + if (this.selectList.length <= 0) { + this.$message.warning('娓呭厛閫夋嫨浜哄憳鍐嶈繘琛屾搷浣滐紒') + return; + } + this.departStatus = 'default'; // 鍖哄垎涓嶅悓鏂瑰紡鎵撳紑閮ㄩ棬瀵硅瘽妗� + this.departmentQueryOnLoad(); + }, + + // 鍒嗛厤閮ㄩ棬琛ㄦ牸鍒濆鍖栬姹� + departmentQueryOnLoad() { + departmentQueryController({queryAllLevel: true}).then(res => { + const data = res.data.treeData; + this.departData = this.departDtaFormAtter(data); + this.departVisible = true; + }).catch(err => { + this.$message.error(err); + }) + }, + + // 鍒嗛厤閮ㄩ棬鏁版嵁杞崲 + departDtaFormAtter(items) { + return items.map(item => { + // 杞崲褰撳墠鑺傜偣鐨勫睘鎬� + const formList = { + oid: item.oid, + id: item.attributes.id, + name: item.attributes.name, + description: item.attributes.description, + parentId: item.parentId, + parentName: item.parentName, + parentBtmName: item.parentBtmName, + // 濡傛灉children瀛樺湪涓斾笉涓虹┖锛屽垯閫掑綊杞崲children + children: item.children && item.children.length > 0 ? this.departDtaFormAtter(item.children) : undefined + }; + return formList; + }); + }, + + // 鍒嗛厤閮ㄩ棬 琛屽崟閫� + handleCurrentRowChange(row) { + this.departCurrenRow = row; + }, + + // 鍒嗛厤閮ㄩ棬 淇濆瓨 + saveDepartHandler() { + if (func.isEmptyObject(this.departCurrenRow)) { + this.$message.warning('璇烽�夋嫨閮ㄩ棬鑺傜偣锛�') + return; + } + + if (this.departStatus == 'default') { + let params = { + userOIds: this.selectList.map(item => item.oid).join(','), + deptId: this.departCurrenRow.oid, + }; + saveUsersDepts(params).then(res => { + if (res.data.code === 200) { + this.departVisible = false; + this.getTableList(); + this.$message.success('鍒嗛厤鎴愬姛锛�') + } + }).catch(err => { + console.log(err); + }) + return; + } + + if (this.departStatus == 'handle') { + this.departObj = this.departCurrenRow; + this.departValue = this.departCurrenRow.oid; + this.departVisible = false; + return;; + } + + if(this.departStatus == 'search'){ + this.departSearchObj = this.departCurrenRow; + this.departSearchValue = this.departCurrenRow.oid; + this.departVisible = false; + return; + } + }, + + // 瀵硅瘽妗嗗垎閰嶉儴闂ㄦ寜閽� + dialogDepartHandler() { + this.departmentQueryOnLoad(); + this.departStatus = 'handle'; // 鍖哄垎涓嶅悓鏂瑰紡鎵撳紑閮ㄩ棬瀵硅瘽妗� + }, + + // 鎼滅储瀵硅瘽妗嗗垎閰嶉儴闂ㄦ寜閽� + dialogDepartSearchHandler(){ + this.departmentQueryOnLoad(); + this.departStatus = 'search'; // 鍖哄垎涓嶅悓鏂瑰紡鎵撳紑閮ㄩ棬瀵硅瘽妗� + }, } } -- Gitblit v1.9.3