From 4c810c1feb3f78c458084d73e89adc6c4f2256f1 Mon Sep 17 00:00:00 2001
From: lzhe <lzhe@example.com>
Date: 星期四, 06 六月 2024 18:22:55 +0800
Subject: [PATCH] 1

---
 src/views/console/system/data-scope-manager.vue |  125 +++++++++++++++++++++++++++++------------
 1 files changed, 87 insertions(+), 38 deletions(-)

diff --git a/src/views/console/system/data-scope-manager.vue b/src/views/console/system/data-scope-manager.vue
index 7d49217..1c0d827 100644
--- a/src/views/console/system/data-scope-manager.vue
+++ b/src/views/console/system/data-scope-manager.vue
@@ -8,7 +8,7 @@
 -->
 <template>
 	<div class="dict-main">
-		<el-form :inline="true" :model="searchData" abel-width="120px">
+		<el-form :inline="true" :model="searchData" label-width="80px">
 			<el-form-item label="鏉冮檺鍚嶇О">
 				<el-input v-model="searchData.deptName" placeholder="鏉冮檺鍚嶇О" clearable />
 			</el-form-item>
@@ -27,7 +27,8 @@
 				<el-button type="primary" @click="addAuthority">鏉冮檺璁剧疆</el-button>
 			</div>
 			<div class="dict-table">
-				<el-table ref="multipleTableRef" :data="tableData" border row-key="id" style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange" :tree-props="{ children: 'children', hasChildren: 'has' }">
+				<el-table ref="multipleTableRef" :data="tableData" border row-key="id" style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange" lazy
+      :load="tableLoad" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" default-expand-all>
 					<el-table-column type="selection" width="55" />
 					<el-table-column prop="deptName" label="鏉冮檺鍚嶇О"></el-table-column>
 					<el-table-column prop="fullName" label="鏉冮檺鎻忚堪"></el-table-column>
@@ -36,15 +37,27 @@
 					<el-table-column fixed="right" label="鎿嶄綔" width="280">
 						<template #default="scope">
 							<el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">鏌ョ湅</el-button>
-							<el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">缂栬緫</el-button>
-							<el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">鍒犻櫎</el-button>
-							<el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">鏂板瀛愰」</el-button>
+							<el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">缂栬緫</el-button>
+							<el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)">鍒犻櫎</el-button>
+							<el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index,'fixed')">鏂板瀛愰」</el-button>
 						</template>
 					</el-table-column>
 				</el-table>
 			</div>
 		</div>
 		<save-dialog v-if="dialog.save" ref="saveDialog" :deptCategoryList="deptCategoryList" :parentIdList ="parentIdList" @success="addDatascopeSuccess" @closed="dialog.save=false"></save-dialog>
+
+		<el-dialog title="鏉冮檺閰嶇疆" v-model="authorityVisible" :width="800" destroy-on-close>
+			<el-tabs type="border-card">
+			    <el-tab-pane label="鏁版嵁鏉冮檺">
+			    	<el-tree ref="authorityTree" :data="authorityTreeData" :props="{ label: 'title',children: 'children'}" node-key="id" show-checkbox @check-change="treeHandleCheckChange" :default-checked-keys="treeCheck" />
+			    </el-tab-pane>
+			</el-tabs>
+		<template #footer>
+			<el-button @click="authorityVisible=false" >鍙� 娑�</el-button>
+			<el-button type="primary" :loading="authoritySaveing" @click="authoritySubmit">纭畾</el-button>
+		</template>
+	</el-dialog>
 	</div>
 </template>
 <script>
@@ -58,6 +71,10 @@
 		name: "datascope",
 		data(){
 			return {
+				treeCheck: [],
+				authorityTreeData: [],
+				authoritySaveing: false,
+				authorityVisible: false,
 				scopeTypeNameList: [],
 				dialog: {
 					save: false
@@ -107,6 +124,33 @@
 	    	...ElementPlusIconsVue,saveDialog
 	    },
 		methods: {
+			treeHandleCheckChange() {
+
+			},
+			authoritySubmit() {
+				var obj = {
+					dataScopeIds: this.$refs.authorityTree.getCheckedKeys(),
+					deptId: this.selectId
+				}
+				this.authoritySaveing = true;
+				this.$HTTP.post("/api/blade-system/data-scope-manager/grant",obj).then(res=> {
+					this.authoritySaveing = false;
+					if(res.code == 200) {
+						this.authorityVisible = false;
+						this.$message.success("鎿嶄綔鎴愬姛");
+						this.searchClearBtn();
+					}else {
+						this.$alert(res.message, "鎻愮ず", {type: 'error'});
+					}
+				})
+			},
+			tableLoad(row,treeNode,resolve) {
+				this.$HTTP.get(`/api/blade-system/data-scope-manager/lazy-list?parentId=${row.id}`).then(res=> {
+					if(res.code == 200) {
+						resolve(res.data);
+					}
+				})
+			},
 			getParentIdList() {
 				this.$HTTP.get("/api/blade-system/data-scope-manager/tree").then(res=> {
 					if(res.code == 200) {
@@ -128,18 +172,37 @@
 			addData(){
 				this.dialog.save = true;
 				this.$nextTick(() => {
-					this.$refs.saveDialog.open();
+					this.$refs.saveDialog.open(this.parentIdList,this.deptCategoryList);
+				})
+			},
+			getTreeSelect(id) {
+				this.$HTTP.get(`/api/blade-system/data-scope-manager/grant-select?deptId=${id}`).then(res=> {
+					if(res.code == 200) {
+						this.treeCheck = res.data;
+					}
 				})
 			},
 			addAuthority() {
-				this.$message({
-					message: '鍙兘閫夋嫨涓�鏉℃暟鎹�',
-					type: 'warning'
-				});
+				if(this.selection.length != 1) {
+					this.$message({
+						message: '鍙兘閫夋嫨涓�鏉℃暟鎹�',
+						type: 'warning'
+					});
+			        return;
+				}
+				this.selectId = this.selection[0].id;
+				this.treeCheck = [];
+				this.$HTTP.get("/api/blade-system/menu/grant-tree").then(res=> {
+					if(res.code == 200) {
+						this.authorityTreeData = res.data.dataScope;
+						this.getTreeSelect(this.selectId);
+						this.authorityVisible = true;
+					}
+				})
 			},
 			// 鍒犻櫎
 			delData() {
-				if(this.drawerSelection.length == 0) {
+				if(this.selection.length == 0) {
 					this.$message({
 			          message: '璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�',
 			          type: 'warning'
@@ -147,33 +210,32 @@
 			        return;
 				}
 				var selStr = "";
-				this.drawerSelection.map(item=> {
+				this.selection.map(item=> {
 					selStr += item.id + ","
 				})
 				selStr = selStr.replace(/,$/, '');
 				var that = this;
-				this.$HTTP.post("/api/blade-system/data-scope/remove?ids="+selStr).then(res=> {
+				this.$HTTP.post("/api/blade-system/data-scope-manager/remove?ids="+selStr).then(res=> {
 					if(res.code == 200) {
 						that.$message.success("鎿嶄綔鎴愬姛");
+						that.searchclick();
 					}
 				})
 			},
-			table_edit(row){  //缂栬緫
+			table_edit(row,index,fixed){  //缂栬緫
 				this.dialog.save = true
-				this.$HTTP.get("/api/blade-system/data-scope/detail?id="+row.id).then(res=> {
-					if(res.code == 200) {
-						this.dialog.save = true;
-						this.$nextTick(() => {
-							this.$refs.saveDialog.open('edit').setData(res.data);
-						})
+				this.$nextTick(() => {
+					if(fixed) {  //鍒ゆ柇鏂板瀛愰」
+						row.fixed = "fixed";
 					}
+					this.$refs.saveDialog.open(this.parentIdList,this.deptCategoryList,'edit').setData(row)
 				})
 			},
 			//鏌ョ湅
 			table_show(row){  //鏌ョ湅
 				this.dialog.save = true
 				this.$nextTick(() => {
-					this.$refs.saveDialog.open('show').setData(row)
+					this.$refs.saveDialog.open(this.parentIdList,this.deptCategoryList,'show').setData(row)
 				})
 			},
 			table_del(row) {
@@ -181,9 +243,10 @@
 				this.$confirm(`纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?`, '', {
 					type: 'warning'
 				}).then(() => {
-					this.$HTTP.post("/api/blade-system/data-scope/remove?ids="+row.id).then(res=> {
+					this.$HTTP.post("/api/blade-system/data-scope-manager/remove?ids="+row.id).then(res=> {
 						if(res.code == 200) {
 							that.$message.success("鎿嶄綔鎴愬姛");
+							that.searchBtn();
 						}
 					})
 				}).catch(() => {
@@ -219,6 +282,7 @@
 						obj[key] = this.searchData[key];
 					}
 				}
+				this.tableData = [];
 				this.$HTTP.get("/api/blade-system/data-scope-manager/lazy-list?" + this.$TOOL.qsStringify(obj)).then(res=> {
 					if(res.code == 200) {
 						this.tableData = res.data;
@@ -227,21 +291,6 @@
 			},
 			handleSelectionChange(selection) {
 				this.selection = selection;
-			},
-			drawerHandleSelectionChange(selection) {
-				this.drawerSelection = selection;
-			},
-			changeDepartment() {
-				this.departmentVisible = true;
-			},
-			handleSizeChange(val) {
-				console.log(`姣忛〉 ${val} 鏉);
-				this.drawerSearchData.current = "1";
-				this.drawerSearchData.size = val;
-			},
-			handleCurrentChange(val) {
-				console.log(`褰撳墠椤�: ${val}`);
-				this.drawerSearchData.current = val;
 			}
 		}
 	}
@@ -276,7 +325,7 @@
 		margin-bottom: 8px;
 	}
 	.attachSize {
-		color:#3b8e8e;
+		color:#409eff;
 		padding: 0 10px;
     	font-size: 12px;
 		background-color: #ebf4f4;

--
Gitblit v1.9.3