From 986aa62ed00bee39363bab41b4eeb8259d446efd Mon Sep 17 00:00:00 2001 From: ludc <ludc@vci-tech.com> Date: 星期四, 16 一月 2025 18:20:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-ui/src/views/system/department/index.vue | 391 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 391 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..e665d5b 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,406 @@ <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 v-if="permissionList.departmentAddChildrenBtn" size="small" + type="text" @click="handleAdd()"> + <icon-show :name="permissionList.departmentAddChildrenBtn.source"></icon-show> + 鏂板瀛愮骇 + </el-button> + <el-button v-if="row.ALLDept !== 'ALLDept' && permissionList.editBtn" size="small" + type="text" + @click="editBtnClick(row)"> + <icon-show :name="permissionList.editBtn.source"></icon-show> + 缂栬緫 + </el-button> + <el-button v-if="row.ALLDept !== 'ALLDept' && permissionList.delBtn" size="small" + type="text" + @click="rowDeleteHandler(row)"> + <icon-show :name="permissionList.delBtn.source"></icon-show> + 鍒犻櫎 + </el-button> + </template> + + <template slot="menuLeft" slot-scope="scope"> + <el-button v-if="permissionList.assignMembersBtn" class="button-custom-icon" plain size="small" type="primary" + @click="assignMembersHandler"> + <icon-show :name="permissionList.assignMembersBtn.source"></icon-show> + 鍒嗛厤鎴愬憳 + </el-button> + <el-button v-if="permissionList.statisticsBtn" class="button-custom-icon" plain size="small" type="primary" + @click="statisticsHandler"> + <icon-show :name="permissionList.statisticsBtn.source"></icon-show> + 缁熻 + </el-button> + <el-button v-if="permissionList.importDepartmentBtn" class="button-custom-icon" plain size="small" type="primary" + @click="upLoadHandler"> + <icon-show :name="permissionList.importDepartmentBtn.source"></icon-show> + 瀵煎叆閮ㄩ棬 + </el-button> + <el-button v-if="permissionList.downloadImportTemplateBtn" class="button-custom-icon" plain size="small" + type="primary" @click="downLoadHandler"> + <icon-show :name="permissionList.downloadImportTemplateBtn.source"></icon-show> + 涓嬭浇瀵煎叆妯℃澘 + </el-button> + </template> + </avue-crud> + + <!-- 缁熻瀵硅瘽妗� --> + <el-dialog + v-dialogDrag + v-loading="statisticsLoading" + :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> + + <!-- 瀵煎叆閮ㄩ棬 --> + <upload-file ref="upload" :fileType="upFileType" :fileUrl="fileUrl" :tipList="tipList" title="瀵煎叆閮ㄩ棬" + @updata="getTableList"></upload-file> + </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"; +import {mapGetters} from "vuex"; + export default { name: "departmentManage", data() { return { + tableData: [], + option: { + ...basicOption, + rowKey: 'oid', + rowParentKey: 'parentId', + expandRowKeys: [], + selection: false, + addBtn: false, + editBtn: false, + delBtn: false, + gridBtn: false, + menuWidth: 280, + highlightCurrentRow: true, + calcHeight: -50, + column: column + }, + tableLoading: false, + departCurrenRow: {}, + parentId: '', + statisticsLoading: false, + statisticsVisible: false, + countData: [], + countOption: { + ...basicOption, + selection: false, + refreshBtn: false, + addBtn: false, + header: false, + menu: false, + calcHeight: 80, + column: [ + { + label: '閮ㄩ棬', + prop: 'pkDepartmentName', + sortable: true, + }, + { + label: '鐢ㄦ埛鍚�', + prop: 'id', + sortable: true, + }, + { + label: '鐪熷疄濮撳悕', + prop: 'name', + sortable: true, + }, + { + label: '瑙掕壊', + prop: 'pkPersonName', + sortable: true, + overHidden: true, + }, + ] + }, + leftTransferData: [], + rightTransferData: [], + transferTitle: ['寰呴�変汉鍛�', '宸查�変汉鍛�'], + tipList: ['瀵煎叆妯℃澘涓爣鏄庣孩鑹插瓧浣撶殑涓哄繀杈撻」', '瀵煎叆缁撴瀯涓烘爲缁撴瀯鏃惰淇濊瘉ID鍒椾笉鑳介噸澶�', '鐖禝D璇蜂娇鐢ㄧ晫闈笂閮ㄩ棬鐨勫敮涓�鏍囪瘑ID鎴栬�匛xcel涓墜鍔ㄨ緭鍏ョ殑ID', '鐖禝D鍒椾负绌烘椂锛屽鍏ョ殑閮ㄩ棬鍗充负椤跺眰閮ㄩ棬'], + upFileType: ['xls', 'xlsx'], + fileUrl: 'api/departmentQueryController/importDept', } }, + computed: { + ...mapGetters(["permission"]), + permissionList() { + return { + delBtn: this.vaildData(this.permission[this.$route.query.id].DELETE, false), + editBtn: this.vaildData(this.permission[this.$route.query.id].EDIT, false), + assignMembersBtn: this.vaildData(this.permission[this.$route.query.id].ASSIGN, false), + departmentAddChildrenBtn: this.vaildData(this.permission[this.$route.query.id].ADD, false), + downloadImportTemplateBtn: this.vaildData(this.permission[this.$route.query.id].DOWNLOAD, false), + importDepartmentBtn: this.vaildData(this.permission[this.$route.query.id].IMPORT, false), + statisticsBtn: this.vaildData(this.permission[this.$route.query.id].STATISTICS, false), + }; + }, + }, + methods: { + // 琛ㄦ牸鍒濆鍖栬姹� + getTableList() { + refTree({queryAllLevel: true, 'extandParamsMap[showAllDepartmentNode]': true}).then(res => { + this.tableData = this.departDtaFormAtter(res.data.treeData); + this.option.expandRowKeys = [res.data.treeData[0].oid]; + }) + }, + + // 鍒嗛厤閮ㄩ棬鏁版嵁杞崲 + departDtaFormAtter(items) { + return items.map(item => { + // 杞崲褰撳墠鑺傜偣鐨勫睘鎬� + const formList = { + expanded: item.expanded, + 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 => { + 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 => { + 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 => { + 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; + } + }); + }, + + // 鍒嗛厤鎴愬憳绌挎妗嗗洖濉� + 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('涓嬭浇鎴愬姛') + }); + }, + + // 瀵煎叆閮ㄩ棬 + upLoadHandler() { + this.$refs.upload.visible = true; + } + } } </script> -- Gitblit v1.9.3