From 6c0a4220fc2532c06fb0be0dafc664484cfd1bd7 Mon Sep 17 00:00:00 2001
From: lzhe <181968431@qq.com>
Date: 星期二, 16 四月 2024 23:30:32 +0800
Subject: [PATCH] 1

---
 src/views/console/authority/addDatascope.vue |  174 ++++++++++++++++++++++++
 src/views/console/authority/datascope.vue    |  219 +++++++++++++++++++++++++++---
 2 files changed, 368 insertions(+), 25 deletions(-)

diff --git a/src/views/console/authority/addDatascope.vue b/src/views/console/authority/addDatascope.vue
new file mode 100644
index 0000000..51b0ce8
--- /dev/null
+++ b/src/views/console/authority/addDatascope.vue
@@ -0,0 +1,174 @@
+<template>
+	<el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
+		<el-form :model="addDictForm" :rules="addDictRules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center">
+			<el-row>
+				<el-col :span="12">
+					<el-form-item label="鏉冮檺鍚嶇О" prop="scopeName">
+						<el-input v-model="addDictForm.scopeName" placeholder="鏉冮檺鍚嶇О" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="12">
+					<el-form-item label="鏉冮檺缂栧彿" prop="resourceCode">
+						<el-input v-model="addDictForm.resourceCode" placeholder="鏉冮檺缂栧彿" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="12">
+					<el-form-item label="鏉冮檺瀛楁" prop="scopeColumn">
+						<el-input v-model="addDictForm.scopeColumn" placeholder="鏉冮檺瀛楁" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="12">
+					<el-form-item label="瑙勫垯鍒嗙被" prop="scopeType">
+						<el-select v-model="addDictForm.scopeType" style="width: 100%" @change="scopeTypeNameChange" placeholder="瑙勫垯鍒嗙被">
+							<el-option v-for="item in scopeTypeNameList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey"/>
+						</el-select>
+					</el-form-item>
+				</el-col>
+				<el-col :span="24">
+					<el-form-item label="鍙瀛楁" prop="scopeField">
+						<el-input v-model="addDictForm.scopeField" placeholder="鍙瀛楁" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="24">
+					<el-form-item label="鏉冮檺绫诲悕" prop="scopeClass">
+						<el-input v-model="addDictForm.scopeClass" placeholder="鏉冮檺绫诲悕" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="24">
+					<el-form-item label="瑙勫垯鍊�" v-if="addDictForm.scopeType == '5'">
+						<el-input type="textarea" v-model="addDictForm.scopeValue" placeholder="瑙勫垯鍊�" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="24">
+					<el-form-item label="澶囨敞">
+						<el-input v-model="addDictForm.remark" placeholder="澶囨敞" clearable></el-input>
+					</el-form-item>
+				</el-col>
+			</el-row>
+		</el-form>
+		<template #footer>
+			<el-button @click="visible=false" >鍙� 娑�</el-button>
+			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="dictSubmit()">淇� 瀛�</el-button>
+		</template>
+	</el-dialog>
+</template>
+
+<script>
+	export default {
+		emits: ['success', 'closed'],
+		data() {
+			return {
+				value1: true,
+				mode: "add",
+				titleMap: {
+					add: '鏂板',
+					edit: '淇敼',
+					show: '鏌ョ湅'
+				},
+				visible: false,
+				isSaveing: false,
+				//琛ㄥ崟鏁版嵁
+				addDictForm: {
+					$scopeType: "",
+					scopeName: "宸ヤ綔鍙癧鏆傛棤]",
+					resourceCode: "",
+					scopeColumn: "",
+					scopeType: "",
+					scopeField: "",
+					scopeClass: "",
+					remark: "",
+					scopeValue: ""
+				},
+				//楠岃瘉瑙勫垯
+				addDictRules: {
+					scopeName:[{required: true, message: '璇疯緭鍏ユ潈闄愬悕绉�'}],
+					resourceCode:[{required: true, message: '璇疯緭鍏ユ潈闄愮紪鍙�'}],
+					scopeColumn:[{required: true, message: '璇疯緭鍏ユ潈闄愬瓧娈�'}],
+					scopeType:[{required: true, message: '璇疯緭鍏ヨ鍒欏垎绫�',trigger: 'change'}],
+					scopeField:[{required: true, message: '璇疯緭鍏ュ彲瑙佸瓧娈�'}],
+					scopeClass:[{required: true, message: '璇疯緭鍏ユ潈闄愮被鍚�'}],
+				},
+				//鎵�闇�鏁版嵁閫夐」
+				groups: [],
+				groupsProps: {
+					value: "id",
+					multiple: true,
+					checkStrictly: true
+				},
+				depts: [],
+				deptsProps: {
+					value: "id",
+					checkStrictly: true
+				}
+			}
+		},
+		mounted() {
+			// this.getDept()
+		},
+		props: ['scopeTypeNameList','tableRow'],
+		methods: {
+			scopeTypeNameChange(value) {
+				this.scopeTypeNameList.forEach(item=> {
+					if(item.dictKey == value) {
+						this.addDictForm.scopeName = `宸ヤ綔鍙癧${item.dictValue}]`;
+						this.addDictForm.$scopeType = item.dictValue;
+					}
+				})
+				if(value == "2") {
+					this.addDictForm.scopeColumn = 'create_user';
+				}else if(value == "3" || value == "4") {
+					this.addDictForm.scopeColumn = 'create_dept';
+				}else {
+					this.addDictForm.scopeColumn = "";
+				}
+			},
+			//鏄剧ず
+			open(mode='add'){
+				this.mode = mode;
+				this.visible = true;
+				this.addDictForm.resourceCode = this.tableRow.alias;
+				return this
+			},
+			//鍔犺浇鏍戞暟鎹�
+			async getGroup(){
+				var res = await this.$API.system.role.list.get();
+				this.groups = res.data.rows;
+			},
+			async getDept(){
+				var res = await this.$API.system.dept.list.get();
+				this.depts = res.data;
+			},
+			//琛ㄥ崟鎻愪氦鏂规硶
+			dictSubmit(){
+				this.addDictForm.menuId = this.tableRow.id;
+				var obj = Object.assign({},this.addDictForm);
+				this.$refs.dialogForm.validate(async (valid) => {
+					if (valid) {
+						this.isSaveing = true;
+						this.$HTTP.post("/api/blade-system/data-scope/submit",obj).then(res=> {
+							this.isSaveing = false;
+							if(res.code == 200) {
+								this.$emit('success', this.addDictForm, this.mode);
+								this.visible = false;
+								this.$message.success("鎿嶄綔鎴愬姛");
+							}else {
+								this.$alert(res.message, "鎻愮ず", {type: 'error'});
+							}
+						})
+					}else{
+						return false;
+					}
+				})
+			},
+			//琛ㄥ崟娉ㄥ叆鏁版嵁
+			setData(data){
+				data.scopeType = String(data.scopeType);
+				//鍙互鍜屼笂闈竴鏍峰崟涓敞鍏ワ紝涔熷彲浠ュ儚涓嬮潰涓�鏍风洿鎺ュ悎骞惰繘鍘�
+				Object.assign(this.addDictForm, data);
+			}
+		}
+	}
+</script>
+
+<style>
+</style>
diff --git a/src/views/console/authority/datascope.vue b/src/views/console/authority/datascope.vue
index 1f5b2ae..d217583 100644
--- a/src/views/console/authority/datascope.vue
+++ b/src/views/console/authority/datascope.vue
@@ -47,37 +47,95 @@
 						</template>
 					</el-table-column>
 					<el-table-column prop="belongApplication" label="鎵�灞炲簲鐢�"></el-table-column>
-					<!-- <el-table-column prop="attachSize" label="闄勪欢澶у皬">
-						<template #default="scope">
-							<span class="attachSize">{{scope.row.attachSize}} B</span>
-						</template>
-					</el-table-column> -->
 					<el-table-column fixed="right" label="鎿嶄綔">
 						<template #default="scope">
-							<el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)">鏉冮檺閰嶇疆</el-button>
+							<el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">鏉冮檺閰嶇疆</el-button>
 						</template>
 					</el-table-column>
 				</el-table>
 			</div>
 		</div>
+		<el-drawer title="[鎺у埗涓績]鏁版嵁鏉冮檺閰嶇疆" v-model="drawer" :direction="direction" :before-close="handleClose" size="920" class="drawerStyle">
+			<el-form :inline="true" :model="drawerSearchData" abel-width="120px">
+				<el-form-item label="鑿滃崟鍚嶇О">
+					<el-input v-model="drawerSearchData.scopeName" placeholder="鑿滃崟鍚嶇О" clearable />
+				</el-form-item>
+				<el-form-item label="鑿滃崟缂栧彿">
+					<el-input v-model="drawerSearchData.resourceCode" placeholder="鑿滃崟缂栧彿" clearable></el-input>
+				</el-form-item>
+				<el-form-item>
+					<el-button type="primary" @click="drawerSearchclick">鎼滅储</el-button>
+					<el-button @click="drawerSearchClearBtn">娓呯┖</el-button>
+				</el-form-item>
+			</el-form>
+			<div>
+				<div class="datascope-drawer-btn">
+					<el-button type="primary" @click="addData">+ 鏂板</el-button>
+					<el-button type="danger" plain @click="delData">鍒犻櫎</el-button>
+				</div>
+				<div class="dict-table">
+					<el-table ref="multipleTableRef" :data="drawerTableData" border style="width: 100%" class="multipleTableRef" @selection-change="drawerHandleSelectionChange">
+						<el-table-column type="selection" width="55" />
+						<el-table-column prop="scopeName" label="鏉冮檺鍚嶇О"></el-table-column>
+						<el-table-column prop="resourceCode" label="鏉冮檺缂栧彿"></el-table-column>
+						<el-table-column prop="scopeColumn" label="鏉冮檺瀛楁"></el-table-column>
+						<el-table-column prop="scopeTypeName" label="瑙勫垯鍒嗙被"></el-table-column>
+						<el-table-column fixed="right" label="鎿嶄綔">
+							<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="table_edit(scope.row, scope.$index)">缂栬緫</el-button>
+								<el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)">鍒犻櫎</el-button>
+							</template>
+						</el-table-column>
+					</el-table>
+					<el-pagination
+						style="margin-top: 12px;"
+						@size-change="handleSizeChange"
+						@current-change="handleCurrentChange"
+						:current-page="currentPage4"
+						:page-sizes="[15, 50, 100]"
+						:page-size="15"
+						layout="total, sizes, prev, pager, next, jumper"
+						:total="drawerTotal">
+					</el-pagination>
+				</div>
+			</div>
+		</el-drawer>
+		<save-dialog v-if="dialog.save" ref="saveDialog" :scopeTypeNameList="scopeTypeNameList" :tableRow="tableRow" @success="addDatascopeSuccess" @closed="dialog.save=false"></save-dialog>
 	</div>
 </template>
 <script>
+	import saveDialog from './addDatascope'
 	import * as ElementPlusIconsVue from '@element-plus/icons-vue'
 	let icons = []
 	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
 	    icons.push(key)
 	}
 	export default {
-		name: "attach",
+		name: "datascope",
 		data(){
 			return {
+				scopeTypeNameList: [],
+				dialog: {
+					save: false
+				},
+				drawerTotal: 0,
+				direction: "rtl",
+				drawer: false,
 				icons,
 				belongApplicationList: [],
 				fileDialogVisible: false,
 				getModalData: [],
 				selection: [],
+				drawerSelection: [],
 				total: 0,
+				drawerSearchData: {
+					scopeName: "",
+					resourceCode: "",
+					menuId: "",
+					current: 1,
+					size: 10
+				},
 				searchData: {
 					name: "",
 					code: "",
@@ -88,19 +146,99 @@
 					save: false,
 					allocation: false
 				},
-				tableData: []
+				tableData: [],
+				drawerTableData: [],
+				rowId: "",
+				tableRow: {}
 			}
 		},
 		created(){
 			
 		},
 		mounted(){
+			this.getscopeTypeNameList();//瑙勫垯鍒嗙被鏋氫妇
 			this.searchBtn();
 		},
 		components: {
-	    	...ElementPlusIconsVue
+	    	...ElementPlusIconsVue,saveDialog
 	    },
 		methods: {
+			getscopeTypeNameList() {  //瑙勫垯鍒嗙被鏋氫妇
+				this.$HTTP.get("/api/blade-system/dict/dictionary?code=data_scope_type").then(res=> {
+					if(res.code == 200) {
+						this.scopeTypeNameList = res.data;
+					}
+				})
+			},
+			addDatascopeSuccess() {
+				this.drawerSearchclick();
+			},
+			//娣诲姞鏉冮檺
+			addData(){
+				this.dialog.save = true
+				this.$nextTick(() => {
+					this.$refs.saveDialog.open()
+				})
+			},
+			// 鍒犻櫎
+			delData() {
+				if(this.drawerSelection.length == 0) {
+					this.$message({
+			          message: '璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�',
+			          type: 'warning'
+			        });
+			        return;
+				}
+				var selStr = "";
+				this.drawerSelection.map(item=> {
+					selStr += item.id + ","
+				})
+				selStr = selStr.replace(/,$/, '');
+				var that = this;
+				this.$HTTP.post("/api/blade-system/data-scope/remove?ids="+selStr).then(res=> {
+					if(res.code == 200) {
+						that.$message.success("鎿嶄綔鎴愬姛");
+						that.drawerSearchclick();
+					}
+				})
+			},
+			table_edit(row){  //缂栬緫
+				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);
+						})
+					}
+				})
+			},
+			//鏌ョ湅
+			table_show(row){  //鏌ョ湅
+				this.dialog.save = true
+				this.$nextTick(() => {
+					this.$refs.saveDialog.open('show').setData(row)
+				})
+			},
+			table_del(row) {
+				var that = this;
+				this.$confirm(`纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?`, '', {
+					type: 'warning'
+				}).then(() => {
+					this.$HTTP.post("/api/blade-system/data-scope/remove?ids="+row.id).then(res=> {
+						if(res.code == 200) {
+							that.$message.success("鎿嶄綔鎴愬姛");
+							that.drawerSearchclick();
+						}
+					})
+				}).catch(() => {
+
+				})
+			},
+			handleClose(done) {
+				this.drawerTableData = [];
+		        done();
+		    },
 			exportFile(row,index){
 				window.open(row.link);
 			},
@@ -115,6 +253,37 @@
 					parentId: ""
 				}
 				this.searchBtn();
+			},
+			showDrawer(row){
+				this.rowId = row.id;
+				this.tableRow = row;  //鍚庨潰缁勪欢浼氱敤鍒�
+				this.drawerSearchclick();
+				this.drawer = true;
+			},
+			drawerSearchclick() {
+				var obj = {};
+				for(var key in this.drawerSearchData) {
+					if(this.drawerSearchData[key]) {
+						obj[key] = this.drawerSearchData[key];
+					}
+				}
+				obj.menuId = this.rowId;
+				this.$HTTP.get("/api/blade-system/data-scope/list?"+this.$TOOL.qsStringify(obj)).then(res=> {
+					if(res.code == 200) {
+						this.drawerTableData = res.data.records;
+						this.drawerTotal = res.data.total;
+					}
+				})
+			},
+			drawerSearchClearBtn() {
+				this.drawerSearchData = {
+					scopeName: "",
+					resourceCode: "",
+					menuId: this.rowId,
+					current: 1,
+					size: 10
+				}
+				this.drawerSearchclick();
 			},
 			searchclick() {
 				this.searchBtn();
@@ -132,33 +301,25 @@
 					}
 				})
 			},
-			//鍒犻櫎
-			table_del(row) {
-				
-			},
-			//鏌ョ湅
-			table_show(row){
-				this.dialog.save = true
-				this.$nextTick(() => {
-					this.$refs.saveDialog.open('show').setData(row)
-				})
-			},
 			handleSelectionChange(selection) {
 				this.selection = selection;
+			},
+			drawerHandleSelectionChange(selection) {
+				this.drawerSelection = selection;
 			},
 			changeDepartment() {
 				this.departmentVisible = true;
 			},
 			handleSizeChange(val) {
 				console.log(`姣忛〉 ${val} 鏉);
-				this.searchData.current = "1";
-				this.searchData.size = val;
-				this.searchBtn();
+				this.drawerSearchData.current = "1";
+				this.drawerSearchData.size = val;
+				this.drawerSearchclick();
 			},
 			handleCurrentChange(val) {
 				console.log(`褰撳墠椤�: ${val}`);
-				this.searchData.current = val;
-				this.searchBtn();
+				this.drawerSearchData.current = val;
+				this.drawerSearchclick();
 			}
 		}
 	}
@@ -199,4 +360,12 @@
 		background-color: #ebf4f4;
 		border: 1px solid #d8e8e8;
 	}
+	/deep/ .drawerStyle {
+		padding: 20px;
+	}
+	.datascope-drawer-btn {
+		margin-bottom: 8px;
+		padding-left: 8px;
+		padding-right: 8px;
+	}
 </style>

--
Gitblit v1.9.3