From d4bf79f802a5d3f605410de933a44a15df6e3fdd Mon Sep 17 00:00:00 2001
From: easy <1358086367@qq.com>
Date: Wed, 1 Feb 2023 18:10:53 +0800
Subject: [PATCH] =?UTF-8?q?update:=20=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/system/menu.ts | 4 +-
src/views/system/Menu/Detail/BasicInfo.vue | 97 ++++++++++++-------
src/views/system/Menu/Detail/ButtonMange.vue | 37 +++++--
src/views/system/Menu/Setting/index.vue | 16 +++
.../Menu/components/ButtonAddDialog.vue | 84 +++++++++++++---
.../system/Menu/components/PermissChoose.vue | 16 +--
src/views/system/Menu/index.vue | 42 ++++----
7 files changed, 215 insertions(+), 81 deletions(-)
create mode 100644 src/views/system/Menu/Setting/index.vue
diff --git a/src/api/system/menu.ts b/src/api/system/menu.ts
index a8e6a60e..9f2c8ebd 100644
--- a/src/api/system/menu.ts
+++ b/src/api/system/menu.ts
@@ -14,4 +14,6 @@ export const getMenuInfo_api = (id:string) => server.get(`/menu/${id}`);
// 编辑菜单信息
export const saveMenuInfo_api = (data: object) => server.patch(`/menu`, data);
// 新增菜单信息
-export const addMenuInfo_api = (data: object) => server.post(`/menu`, data);
\ No newline at end of file
+export const addMenuInfo_api = (data: object) => server.post(`/menu`, data);
+// 删除菜单信息
+export const delMenuInfo_api = (id: string) => server.remove(`/menu/${id}`);
\ No newline at end of file
diff --git a/src/views/system/Menu/Detail/BasicInfo.vue b/src/views/system/Menu/Detail/BasicInfo.vue
index 790d38b7..ea01abbc 100644
--- a/src/views/system/Menu/Detail/BasicInfo.vue
+++ b/src/views/system/Menu/Detail/BasicInfo.vue
@@ -181,11 +181,18 @@
-
+
- 保存
@@ -215,14 +222,17 @@ import {
addMenuInfo_api,
} from '@/api/system/menu';
+// 路由
const route = useRoute();
const router = useRouter();
const routeParams = {
id: route.params.id === ':id' ? undefined : (route.params.id as string),
...route.query,
url: route.query.basePath,
+ parentId: route.query.pid,
};
+// 表单
const basicFormRef = ref();
const permissFormRef = ref();
const form = reactive({
@@ -238,15 +248,18 @@ const form = reactive({
indirectMenus: [],
...routeParams,
} as formType,
-
treeData: [], // 关联菜单
assetsType: [] as assetType[], // 资产类型
+ saveLoading: false,
init: () => {
// 获取菜单详情
routeParams.id &&
- getMenuInfo_api(routeParams.id).then((resp) => {
- form.data = resp.result as formType
+ getMenuInfo_api(routeParams.id).then((resp: any) => {
+ form.data = {
+ ...(resp.result as formType),
+ accessSupport: resp.result.accessSupport.value,
+ };
});
// 获取关联菜单
getMenuTree_api({ paging: false }).then((resp: any) => {
@@ -260,9 +273,52 @@ const form = reactive({
}));
});
},
+ clickSave: () => {
+ if (!basicFormRef || !permissFormRef) return;
+ Promise.all([
+ basicFormRef.value?.validate(),
+ permissFormRef.value?.validate(),
+ ])
+ .then(() => {
+ const api = routeParams.id ? saveMenuInfo_api : addMenuInfo_api;
+ form.saveLoading = true;
+ const accessSupportValue = form.data.accessSupport;
+ const params = {
+ ...form.data,
+ accessSupport: {
+ value: accessSupportValue,
+ label:
+ accessSupportValue === 'unsupported'
+ ? '不支持'
+ : accessSupportValue === 'support'
+ ? '支持'
+ : '间接控制',
+ },
+ };
+ api(params)
+ .then((resp: any) => {
+ if (resp.status === 200) {
+ message.success('操作成功!');
+ // 新增后刷新页面,编辑则不需要
+ if (!routeParams.id) {
+ router.push(
+ `/system/Menu/detail/${resp.result.id}`,
+ );
+ routeParams.id = resp.result.id;
+ form.init();
+ }
+ } else {
+ message.error('操作失败!');
+ }
+ })
+ .finally(() => (form.saveLoading = false));
+ })
+ .catch((err) => {});
+ },
});
form.init();
+// 弹窗
const ChooseIconRef = ref(null);
const dialog = {
openDialog: () => {
@@ -272,36 +328,6 @@ const dialog = {
form.data.icon = typeStr || form.data.icon;
},
};
-const saveLoading = ref(false);
-const clickSave = () => {
- if (!basicFormRef || !permissFormRef) return;
- Promise.all([
- basicFormRef.value?.validate(),
- permissFormRef.value?.validate(),
- ])
- .then(() => {
- const api = routeParams.id ? saveMenuInfo_api : addMenuInfo_api;
- saveLoading.value = true;
- api(form.data)
- .then((resp: any) => {
- if (resp.status === 200) {
- message.success('操作成功!');
- // 新增后刷新页面,编辑则不需要
- if (!routeParams.id) {
- router.push(
- `/system/Menu/detail/${resp.result.id}`,
- );
- routeParams.id = resp.result.id;
- form.init();
- }
- } else {
- message.error('操作失败!');
- }
- })
- .finally(() => (saveLoading.value = false));
- })
- .catch((err) => {});
-};
type formType = {
name: string;
@@ -314,6 +340,7 @@ type formType = {
accessSupport: string;
assetType: string | undefined;
indirectMenus: any[];
+ parentId?: string;
};
type assetType = {
diff --git a/src/views/system/Menu/Detail/ButtonMange.vue b/src/views/system/Menu/Detail/ButtonMange.vue
index 861b510f..cc232ce3 100644
--- a/src/views/system/Menu/Detail/ButtonMange.vue
+++ b/src/views/system/Menu/Detail/ButtonMange.vue
@@ -5,6 +5,7 @@
:columns="table.columns"
model="TABLE"
:dataSource="table.tableData"
+ noPagination
>
dialog.openDialog('查看', slotProps)"
>
-
+
@@ -41,7 +42,7 @@
title="确认删除"
ok-text="确定"
cancel-text="取消"
- :disabled="slotProps.status"
+ @confirm="table.clickDel(slotProps)"
>
删除
@@ -55,7 +56,11 @@
-
+
@@ -63,12 +68,14 @@
+
+
diff --git a/src/views/system/Menu/components/ButtonAddDialog.vue b/src/views/system/Menu/components/ButtonAddDialog.vue
index 78f9d309..0a54e5df 100644
--- a/src/views/system/Menu/components/ButtonAddDialog.vue
+++ b/src/views/system/Menu/components/ButtonAddDialog.vue
@@ -4,8 +4,12 @@
:title="form.mode"
width="660px"
@ok="dialog.handleOk"
+ :maskClosable="false"
+ cancelText="取消"
+ okText="确定"
+ :confirmLoading="dialog.loading"
>
-
+
+
+ :first-width="8"
+ max-height="350px"
+ v-model:value="form.data.permissions"
+ :disabled="form.mode === '查看'"
+ />