Parcourir la source

reactor:权限选择调整;

zhangchong il y a 1 an
Parent
commit
8ddea33448

+ 2 - 3
src/views/auxiliary/advice/index.vue

@@ -20,10 +20,10 @@
     </el-card>
 		<el-card shadow="never">
 			<div class="mb20">
-				<el-button type="primary" @click="onAdviceAdd" v-waves v-auth="'auxiliary:advice:add'">
+				<el-button type="primary" @click="onAdviceAdd">
 					<SvgIcon name="ele-Plus" class="mr5" />新增
 				</el-button>
-        <el-button type="primary" @click="onAdviceDelete" v-waves v-auth="'auxiliary:advice:delete'" :disabled="!multipleSelection.length">
+        <el-button type="primary" @click="onAdviceDelete" :disabled="!multipleSelection.length">
           <SvgIcon name="ele-Delete" class="mr5" />删除
         </el-button>
 			</div>
@@ -47,7 +47,6 @@
 				<el-table-column label="操作" width="120" fixed="right" align="center">
 					<template #default="{ row }">
 						<el-button link type="primary" @click="updateAdvice(row)" v-auth="'auxiliary:advice:edit'" title="修改参数"> 修改 </el-button>
-						<!--              <el-button link type="danger" @click="parameterDelete(row)" v-auth="'system:timeLimit:detail'" title="删除参数"> 删除 </el-button>-->
 					</template>
 				</el-table-column>
 				<template #empty>

+ 18 - 21
src/views/auxiliary/area/index.vue

@@ -52,14 +52,14 @@
 	</div>
 </template>
 <script lang="ts" setup name="auxiliaryArea">
-import {defineAsyncComponent, h, onMounted, reactive, ref, watch} from 'vue';
-import type {FormInstance} from 'element-plus';
-import {ElButton, ElMessage, ElMessageBox} from 'element-plus';
-import {formatDate} from '/@/utils/formatTime';
-import {auth} from '/@/utils/authFunction';
-import {throttle} from '/@/utils/tools';
+import { defineAsyncComponent, h, onMounted, reactive, ref, watch } from 'vue';
+import type { FormInstance } from 'element-plus';
+import { ElButton, ElMessage, ElMessageBox } from 'element-plus';
+import { formatDate } from '/@/utils/formatTime';
+import { auth } from '/@/utils/authFunction';
+import { throttle } from '/@/utils/tools';
 import other from '/@/utils/other';
-import {treeArea, treeAreaDelete} from '/@/api/auxiliary/area';
+import { treeArea, treeAreaDelete } from '/@/api/auxiliary/area';
 // 引入组件
 const AreaAdd = defineAsyncComponent(() => import('/@/views/auxiliary/area/component/Area-add.vue')); // 新增区域
 const AreaEdit = defineAsyncComponent(() => import('/@/views/auxiliary/area/component/Area-edit.vue')); // 编辑区域
@@ -170,7 +170,7 @@ const handleQuery = throttle(() => {
 		emptyArr = [];
 		state.orgTableData = formatTable(other.deepClone(state.staticArr), state.queryParams.keyword);
 		state.expandedRowKeys = getExpand(state.orgTableData);
-    state.isExpand = true;
+		state.isExpand = true;
 		state.loading = false;
 	} else {
 		queryList();
@@ -183,7 +183,7 @@ const resetQuery = throttle((formEl: FormInstance | undefined) => {
 	queryList();
 	state.expandedRowKeys = [];
 	emptyArr = [];
-  state.isExpand = false;
+	state.isExpand = false;
 }, 300);
 // 打开新增弹窗
 const areaAddRef = ref<RefType>(); // 新增组织机构ref
@@ -231,18 +231,15 @@ const onDelArea = (row: any) => {
 };
 // 获取所有部门结构
 const queryList = async () => {
-	if (!auth('auxiliary:area:query')) ElMessage.error('抱歉,您没有权限获区域列表!');
-	else {
-		state.loading = true;
-		try {
-			const res: any = await Promise.all([treeArea()]);
-			state.orgTableData = res[0].result ?? [];
-			state.staticArr = res[0].result ?? [];
-			state.loading = false;
-		} catch (error) {
-			console.log(error);
-			state.loading = false;
-		}
+	state.loading = true;
+	try {
+		const res: any = await Promise.all([treeArea()]);
+		state.orgTableData = res[0].result ?? [];
+		state.staticArr = res[0].result ?? [];
+		state.loading = false;
+	} catch (error) {
+		console.log(error);
+		state.loading = false;
 	}
 };
 // 页面加载时

+ 45 - 43
src/views/system/roles/component/Role-permission.vue

@@ -21,35 +21,37 @@
 					></el-switch>
 				</el-col>
 			</el-row>
-<!--      权限码重复的有: <span v-for="item in duplicates" :key="item.permissionCode" class="mr5 mb5">{{item.pageName}} {{item.permissionCode}}</span>-->
-			<el-tree
-				class="tree-border mt20"
-				:data="state.menuTableData"
-				show-checkbox
-				ref="menuRef"
-				node-key="permissionCode"
-				check-on-click-node
-				:expand-on-click-node="false"
-        check-strictly
-				:props="{ label: 'pageName', children: 'children', class: customNodeClass }"
-			>
-				<template #default="{ data }">
-<!--            {{ data.permissionCode }}-->
-					<span>{{ data.pageName }} </span>
-				</template>
-			</el-tree>
+      <div class="border-box">
+        <el-input v-model="filterText" placeholder="权限名称" clearable />
+        <el-tree
+            class="tree-border mt20"
+            :data="state.menuTableData"
+            show-checkbox
+            ref="menuRef"
+            node-key="permissionCode"
+            check-on-click-node
+            :expand-on-click-node="false"
+            :props="{ label: 'pageName', children: 'children', class: customNodeClass }"
+            :filter-node-method="filterNode"
+        >
+          <template #default="{ data }">
+
+            <span>{{ data.pageName }}-{{ data.permissionCode }}</span>
+          </template>
+        </el-tree>
+      </div>
 		</div>
 		<template #footer>
 			<span class="dialog-footer">
 				<el-button @click="closeDialog" class="default-button">取 消</el-button>
-				<el-button type="primary" @click="onSubmit">确 定</el-button>
+				<el-button type="primary" @click="onSubmit" :loading="state.loading">确 定</el-button>
 			</span>
 		</template>
 	</el-dialog>
 </template>
 
 <script setup lang="ts" name="rolePermission">
-import {onMounted, reactive, ref} from 'vue';
+import {onMounted, reactive, ref, watch} from 'vue';
 import {ElMessage} from 'element-plus';
 import {auth} from '/@/utils/authFunction';
 import {getMenuList} from '/@/api/system/menu';
@@ -63,6 +65,7 @@ interface Tree {
 	isPenultimate?: boolean;
 	expanded: boolean;
 	menuType?: number;
+  pageName: string;
 	children?: Tree[];
 }
 
@@ -122,6 +125,15 @@ const opened = () => {
 			});
 	}
 };
+const filterText = ref('')
+watch(filterText, (val) => {
+  menuRef.value!.filter(val)
+})
+const filterNode = (value: string, data: Tree) => {
+  if (!value) return true
+  return data.pageName.includes(value)
+}
+
 // 关闭弹窗
 const closeDialog = () => {
 	state.dialogVisible = false;
@@ -138,32 +150,12 @@ const getCode = (arr: any) => {
 	});
 	return newArr;
 };
-const duplicates = ref<any>([]);
 // 获取所有菜单
 const getMenuListApi = () => {
 	getMenuList().then((res: any) => {
 		state.menuTableData = res?.result ?? [];
-    duplicates.value = findDuplicateNodes(state.menuTableData, 'permissionCode');
 	});
 };
-//  查找重复的节点
-const  findDuplicateNodes = (tree:any, property:any)=> {
-  const hash:any = {};
-  const duplicates = new Set();
-  tree.forEach((node:any) => {
-    const value = node[property];
-    if (hash[value]) {
-      duplicates.add(node);
-    } else {
-      hash[value] = true;
-    }
-    if (node.children) {
-      const childDuplicates = findDuplicateNodes(node.children, property);
-      childDuplicates.forEach(duplicate => duplicates.add(duplicate));
-    }
-  });
-  return duplicates;
-}
 /** 树权限(展开/折叠)*/
 const handleCheckedTreeExpand = (value: boolean) => {
 	for (let i = 0; i < state.menuTableData.length; i++) {
@@ -187,19 +179,26 @@ const handleCheckedTreeNodeAll = (value: boolean) => {
 };
 // 保存
 const onSubmit = () => {
-	let systemMenuArr: EmptyArrayType;
-	systemMenuArr = menuRef.value.getCheckedNodes();
+  let systemMenuArr = menuRef.value.getCheckedNodes();
+  let halfCheck = menuRef.value.getHalfCheckedNodes();
 	systemMenuArr = systemMenuArr.map((v: any) => {
 		return {
 			code: v.permissionCode,
 			type: v.menuType,
 		};
 	});
+  halfCheck = halfCheck.map((v: any) => {
+    return {
+      code: v.permissionCode,
+      type: v.menuType,
+    };
+  })
 	let req = {
 		roleId: state.currentRow.id,
 		roleCode: state.currentRow.name,
-		systemMenuArr: systemMenuArr,
+		systemMenuArr:[...systemMenuArr,...halfCheck],
 	};
+  state.loading = true;
 	setRolePower(req)
 		.then(() => {
 			ElMessage({
@@ -208,10 +207,12 @@ const onSubmit = () => {
 			});
 			closeDialog();
 			emit('updateList');
+      state.loading = false;
 		})
 		.catch(() => {
 			// 新增失败
 			closeDialog();
+      state.loading = false;
 		});
 };
 onMounted(() => {
@@ -230,10 +231,11 @@ defineExpose({
 	box-sizing: border-box;
 	align-items: center;
 }
-.tree-border {
+.border-box{
 	border: var(--el-border);
 	border-radius: var(--el-border-radius-base);
 	padding: 15px;
+  margin-top: 15px;
 }
 :deep(.el-tree-node.is-expanded.is-penultimate > .el-tree-node__children) {
 	display: flex;