From 8a857fe1b0b69dafbdaa15b45edab03a2c3bcdb2 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期二, 09 七月 2024 09:52:47 +0800 Subject: [PATCH] 成员管理表格查询 增删改 分配成员 统计 下载导入模板 --- Source/plt-web/plt-web-ui/src/views/system/department/index.vue | 338 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 338 insertions(+), 0 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/views/system/department/index.vue b/Source/plt-web/plt-web-ui/src/views/system/department/index.vue index fe8983e..d56868a 100644 --- a/Source/plt-web/plt-web-ui/src/views/system/department/index.vue +++ b/Source/plt-web/plt-web-ui/src/views/system/department/index.vue @@ -1,15 +1,353 @@ <template> <basic-container> + <avue-crud + ref="departCrud" + :data="tableData" + :option="option" + :page.sync="page" + :table-loading="tableLoading" + @on-load="getTableList" + @refresh-change="handleRefresh" + @selection-change="selectChange" + @row-save="rowSaveHandler" + @row-update="rowUpdateHandler" + @row-del="rowDeleteHandler" + @current-row-change="handleCurrentRowChange" + > + <template slot="menu" slot-scope="{row,size,type}"> + <el-button icon="el-icon-circle-plus-outline" size="small" type="text" @click="handleAdd()">鏂板瀛愮骇</el-button> + <el-button v-if="row.ALLDept !== 'ALLDept'" icon="el-icon-edit" size="small" type="text" + @click="editBtnClick(row)">缂栬緫 + </el-button> + <el-button v-if="row.ALLDept !== 'ALLDept'" icon="el-icon-delete" size="small" type="text" + @click="rowDeleteHandler(row)">鍒犻櫎 + </el-button> + </template> + + <template slot="menuLeft" slot-scope="scope"> + <el-button icon="el-icon-school" plain size="small" type="primary" @click="assignMembersHandler">鍒嗛厤鎴愬憳</el-button> + <el-button icon="el-icon-user" plain size="small" type="primary" @click="statisticsHandler">缁熻</el-button> + <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="statisticsHandler">瀵煎叆閮ㄩ棬</el-button> + <el-button icon="el-icon-download" plain size="small" type="primary" @click="downLoadHandler">涓嬭浇瀵煎叆妯℃澘</el-button> + </template> + </avue-crud> + + <!-- 缁熻瀵硅瘽妗� --> + <el-dialog + v-dialogDrag + v-loading="statisticsLoading" + :destroy-on-close="true" + :visible.sync="statisticsVisible" + append-to-body="true" + class="avue-dialog" + title="浜哄憳淇℃伅" + width="50%" + > + <avue-crud + :data="countData" + :option="countOption" + > + </avue-crud> + <div slot="footer" class="dialog-footer" style="display: flex;gap: 20px;justify-content: center"> + <div> + <el-tag>褰撳墠瑙掕壊鎬讳汉鏁�: {{ this.countData.length }}</el-tag> + </div> + <el-button icon="el-icon-close" size="small" type="danger" @click="statisticsVisible = false">鍏� 闂�</el-button> + </div> + </el-dialog> + + + <!-- 鍒嗛厤鎴愬憳绌挎妗� --> + <transfer ref="transfer" :left-role-data="leftTransferData" :right-role-data="rightTransferData" + :transferTitle="transferTitle" title="閮ㄩ棬娣诲姞鎴愬憳" + @transferSend="departTransferSend"> + </transfer> + </basic-container> </template> <script> +import { + refTree, + addDept, + updateDept, + deleteDept, + countSmUserByDeptOid, + listUserUnInDeptOid, + listUserByDeptOid, + saveUsersDepts, + download +} from "@/api/system/departMent/api"; +import basicOption from '@/util/basic-option'; +import {column} from './option' +import func from "@/util/func"; + export default { name: "departmentManage", data() { return { + tableData: [], + option: { + ...basicOption, + rowKey: 'oid', + rowParentKey: 'parentId', + selection: false, + addBtn: false, + editBtn: false, + delBtn: false, + gridBtn: false, + highlightCurrentRow: true, + column: column + }, + tableLoading: false, + departCurrenRow: {}, + parentId: '', + statisticsLoading: false, + statisticsVisible: false, + countData: [], + countOption: { + ...basicOption, + selection: false, + refreshBtn: false, + addBtn: false, + menu: false, + column: [ + { + label: '閮ㄩ棬', + prop: 'pkDepartmentName', + sortable: true, + }, + { + label: '鐢ㄦ埛鍚�', + prop: 'id', + sortable: true, + }, + { + label: '鐪熷疄濮撳悕', + prop: 'name', + sortable: true, + }, + { + label: '瑙掕壊', + prop: 'pkPersonName', + sortable: true, + }, + ] + }, + leftTransferData: [], + rightTransferData: [], + transferTitle: ['寰呴�変汉鍛�', '宸查�変汉鍛�'], } }, + methods: { + // 琛ㄦ牸鍒濆鍖栬姹� + getTableList() { + refTree({queryAllLevel: true, 'extandParamsMap[showAllDepartmentNode]': true}).then(res => { + this.tableData = this.departDtaFormAtter(res.data.treeData); + }) + }, + + // 鍒嗛厤閮ㄩ棬鏁版嵁杞崲 + departDtaFormAtter(items) { + return items.map(item => { + // 杞崲褰撳墠鑺傜偣鐨勫睘鎬� + const formList = { + oid: item.oid, + id: item.attributes.id, + name: item.attributes.name, + description: item.attributes.description, + code: item.attributes.code, + specialties: item.attributes.specialties, + uniqueId: item.attributes.uniqueId, + ALLDept: item.attributes.ALLDept ? item.attributes.ALLDept : "", + 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; + }); + }, + + // 鍒楀ご鍒锋柊 + handleRefresh() { + this.getTableList(); + }, + + // 涓嬫媺 + selectChange() { + + }, + + // 琛ㄦ牸琛屾柊澧炲瓙绾� + handleAdd() { + this.$refs.departCrud.rowAdd(); + }, + + // 娣诲姞 + rowSaveHandler(row, done, loading) { + row = {...row, ...{pkFatherDepartment: this.parentId}}; + addDept(row).then(res => { + if (res.data.code === 200) { + this.$message.success(res.data.obj); + this.getTableList(); + done(); + } + }).catch(err => { + console.log(err); + loading(); + }) + + }, + + // 缂栬緫鎸夐挳鐐瑰嚮浜嬩欢 + editBtnClick(row) { + this.$refs.departCrud.rowEdit(row); + }, + + // 缂栬緫 + rowUpdateHandler(row, index, done, loading) { + let params = { + name: row.name, + id: row.id, + code: row.code, + specialties: row.specialties, + description: row.description, + oid: row.oid + } + updateDept(params).then(res => { + if (res.data.code === 200) { + this.$message.success(res.data.obj); + this.getTableList(); + done(); + } + }).catch(err => { + console.log(err); + loading(); + }) + }, + + // 鍒犻櫎 + rowDeleteHandler(row) { + let params = { + ids: row.oid + } + + this.$confirm('鎮ㄧ‘瀹氳鍒犻櫎褰撳墠閮ㄩ棬鍚楋紵', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + deleteDept(params).then(res => { + if (res.data.code === 200) { + this.$message.success(res.data.obj); + this.getTableList(); + } + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '宸插彇娑堝垹闄�' + }); + }); + }, + + // 琛ㄦ牸琛� 琛屽崟閫� + handleCurrentRowChange(row) { + // 鍗曠嫭娣诲姞 ALLDept 灞炴�у垽鏂槸鍚︽槸椤跺眰鑺傜偣鎵�鏈夐儴闂� + if (row.ALLDept === "ALLDept") { + this.parentId = ""; + } else { + this.parentId = row.oid; + } + + this.departCurrenRow = row; + }, + // 缁熻 + statisticsHandler() { + console.log(this.departCurrenRow); + if (func.isEmptyObject(this.departCurrenRow)) { + this.$message.warning('璇烽�夋嫨閮ㄩ棬锛�'); + return + } + + countSmUserByDeptOid({pkDepartment: this.departCurrenRow.ALLDept === 'ALLDept' ? null : this.departCurrenRow.oid}).then(res => { + console.log(res); + if (res.data.code === 200) { + const data = res.data.data; + this.countData = data.map(item => { + return { + pkDepartmentName: item.pkDepartmentName, + name: item.name, + id: item.id, + pkPersonName: item.pkPersonName + } + }); + this.statisticsVisible = true; + } + }).catch(err => { + console.log(err) + }) + }, + + // 鍒嗛厤鎴愬憳 + assignMembersHandler() { + if (func.isEmptyObject(this.departCurrenRow)) { + this.$message.error('璇烽�夋嫨閮ㄩ棬鑺傜偣'); + return + } + if (this.departCurrenRow.ALLDept === "ALLDept") { + this.$message.error('姝よ妭鐐逛负閮ㄩ棬鏍囪瘑锛屼笉鑳芥墽琛屽垎閰嶆垚鍛樻搷浣滐紝璇烽�夋嫨鍏朵粬鑺傜偣锛�') + return + } + + Promise.all([ + listUserUnInDeptOid({pkDepartment: this.departCurrenRow.oid}), + listUserByDeptOid({pkDepartment: this.departCurrenRow.oid}) + ]).then(([unInRoleRes, byRoleRes]) => { + if (unInRoleRes.data.code === 200 && byRoleRes.data.code === 200) { + const leftData = [...unInRoleRes.data.data, ...byRoleRes.data.data]; + // 缁勮濂界┛姊鍙敤鏁版嵁 + this.leftTransferData = leftData.map(item => { + return { + name: item.name + `(${item.id})`, + oid: item.oid + } + }) + this.rightTransferData = byRoleRes.data.data.map(item => item.oid); + this.$refs.transfer.visible = true; + } + }).catch(err => { + console.error(err); + }); + }, + + // 鍒嗛厤鎴愬憳绌挎妗嗗洖濉� + departTransferSend(row) { + let params = { + userOids: row.join(','), + deptId: this.departCurrenRow.oid + } + saveUsersDepts(params).then(res => { + console.log(res); + this.$message.success(res.data.obj); + this.getTableList(); + }).catch(err => { + console.log(err); + }) + }, + + // 涓嬭浇瀵煎叆妯℃澘 + downLoadHandler(){ + download().then(res => { + func.downloadFileByBlobHandler(res); + this.$message.success('涓嬭浇鎴愬姛') + }).catch(err => { + this.$message.error(err); + }) + } + } } </script> -- Gitblit v1.9.3