From 1d8ffe35090c3e541dc2e0d9a26a4ef1c853d3b1 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 27 九月 2024 18:10:20 +0800
Subject: [PATCH] UI授权
---
Source/plt-web/plt-web-ui/src/views/system/department/index.vue | 352 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 352 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..e71ddd1 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,367 @@
<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="upLoadHandler">瀵煎叆閮ㄩ棬</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"
+ :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";
+
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,
+ calcHeight: -60,
+ column: column
+ },
+ tableLoading: false,
+ departCurrenRow: {},
+ parentId: '',
+ statisticsLoading: false,
+ statisticsVisible: false,
+ countData: [],
+ countOption: {
+ ...basicOption,
+ selection: false,
+ refreshBtn: false,
+ addBtn: 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',
}
},
+ 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 => {
+ 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);
+ })
+ },
+
+ // 瀵煎叆閮ㄩ棬
+ upLoadHandler() {
+ this.$refs.upload.visible = true;
+ }
+ }
}
</script>
--
Gitblit v1.9.3