From e0d9085c62f7d59838f8b242e5e51d33d85beda7 Mon Sep 17 00:00:00 2001 From: 4linuxfun Date: Wed, 24 Jan 2024 15:52:22 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=AE=A1=E7=90=86-=E8=A7=92=E8=89=B2=E7=AE=A1?= =?UTF-8?q?=E7=90=86=EF=BC=9A=E9=87=8D=E6=9E=84=E8=A7=92=E8=89=B2=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/src/views/system/roles/RoleDialog.vue | 67 ++++++++++++++--------- www/src/views/system/roles/index.vue | 19 ++----- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/www/src/views/system/roles/RoleDialog.vue b/www/src/views/system/roles/RoleDialog.vue index a24e857..5862ec6 100644 --- a/www/src/views/system/roles/RoleDialog.vue +++ b/www/src/views/system/roles/RoleDialog.vue @@ -1,6 +1,6 @@ - 取消 - 更新 - 添加 + 取消 + 确定 @@ -40,11 +39,10 @@ } from '@/api/roles' import {ElNotification} from 'element-plus' import AutoDict from '@/components/AutoDict' - import {GetUserExist} from '@/api/users' - const props = defineProps(['role', 'visible']) - const emit = defineEmits(['update:visible']) - const selectData = reactive(props.role) + const emit = defineEmits(['success']) + const visible = ref(false) + const selectData = reactive({}) const menus = ref([]) const defaultProps = reactive({ children: 'children', @@ -81,60 +79,77 @@ }) } - function handleUpdate() { + async function handleUpdate() { let checkedKeys = menuTree.value.getCheckedKeys().concat(menuTree.value.getHalfCheckedKeys()) console.log(checkedKeys) selectData.menus = checkedKeys console.log(selectData) if (selectData.id === null) { - PostNewRoles(selectData).then(() => { + try { + await PostNewRoles(selectData) ElNotification({ title: 'success', message: '角色新建成功', type: 'success' }) - }).catch((error) => { + } catch (error) { ElNotification({ title: 'error', message: '角色新建失败:' + error, type: 'error' }) - }) + } } else { - PutRoles(selectData).then(() => { - console.log('notification') + try { + await PutRoles(selectData) ElNotification({ title: 'success', message: '角色更新成功', type: 'success' }) - }).catch((error) => { + } catch (error) { ElNotification({ title: 'error', message: '失败:' + error, type: 'error' }) - }) + } } - - emit('update:visible', false) + visible.value = false + emit('success') } - function customNodeClass(data,node){ - if (data.type === "subPage"){ + function customNodeClass(data, node) { + if (data.type === 'subPage') { return 'is-btn' } return null } - onMounted(()=>{ + function add() { + Object.assign(selectData, { + id: null, + name: '', + description: '', + enable: true + }) GetInfo() - }) + visible.value = true + } + + function edit(role) { + Object.assign(selectData, role) + GetInfo() + visible.value = true + } + + + defineExpose({add, edit}) diff --git a/www/src/views/system/menus/MenuDrawer.vue b/www/src/views/system/menus/MenuDrawer.vue new file mode 100644 index 0000000..a89f062 --- /dev/null +++ b/www/src/views/system/menus/MenuDrawer.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/www/src/views/system/menus/index.vue b/www/src/views/system/menus/index.vue index 71583a6..cbc0f05 100644 --- a/www/src/views/system/menus/index.vue +++ b/www/src/views/system/menus/index.vue @@ -50,7 +50,8 @@ 编辑 - 添加子菜单 + 添加子菜单 删除 @@ -63,9 +64,8 @@ - - - + + @@ -81,8 +81,8 @@ DeleteMenu, GetAllMenus } from '@/api/menus' - import MenuDialog from './MenuDialog' import {provide, reactive, ref, shallowRef, watch} from 'vue' + import MenuDrawer from '@/views/system/menus/MenuDrawer.vue' const dialogVisible = ref(false) const menuInfo = reactive({ @@ -91,6 +91,7 @@ }) const menuData = shallowRef([]) const selectData = reactive({}) + const menuDrawerRef = ref(null) provide('menuData', menuData) @@ -110,8 +111,7 @@ let row = command.row switch (command.command) { case 'detail': - dialogVisible.value = true - Object.assign(selectData, row) + menuDrawerRef.value.edit(row) break case 'addSubPage': handleAdd(row.id, 'subPage') @@ -128,17 +128,7 @@ } const handleAdd = (parentId = null, menuType = 'page') => { - Object.assign(selectData, { - id: null, - parent_id: parentId, - name: '', - path: '', - component: null, - auth: '', - enable: 0, - type: menuType - }) - dialogVisible.value = true + menuDrawerRef.value.add(parentId, menuType) } const getMenuInfo = () => { From 1138ddf4bc62ba834f30e4fc7a5e0bd8e4140af5 Mon Sep 17 00:00:00 2001 From: 4linuxfun Date: Thu, 25 Jan 2024 09:49:02 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=90=8E=E7=AB=AF=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=96=B0=E5=A2=9E=E8=8F=9C=E5=8D=95icon=E3=80=81sort?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/models/internal/menu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/models/internal/menu.py b/server/models/internal/menu.py index b1e2245..5c7f123 100644 --- a/server/models/internal/menu.py +++ b/server/models/internal/menu.py @@ -6,13 +6,13 @@ class MenuBase(SQLModel): id: Optional[int] = Field(sa_column=Column('id', Integer, primary_key=True, autoincrement=True)) name: str = Field(max_length=20, sa_column_kwargs={'comment': '菜单名'}) - icon: Optional[str] = Field(max_length=50, sa_column_kwargs={'comment': 'Icon图标'}) + icon: Optional[str] = Field(default=None, max_length=50, sa_column_kwargs={'comment': 'Icon图标'}) path: Optional[str] = Field(max_length=100, sa_column_kwargs={'comment': '路径'}) component: Optional[str] = Field(max_length=50, sa_column_kwargs={'comment': '组件'}) auth: Optional[str] = Field(max_length=50, sa_column_kwargs={'comment': '授权标识'}) type: str = Field(max_length=10, sa_column_kwargs={'comment': '类型'}) parent_id: Optional[int] = Field(default=None, sa_column_kwargs={'comment': '父级ID'}) - sort: Optional[float] = Field(sa_column_kwargs={'comment': '菜单排序'}) + sort: Optional[float] = Field(default=None, sa_column_kwargs={'comment': '菜单排序'}) enable: bool = Field(default=True, sa_column=Column(Boolean, comment='启用')) From 2fbe50a366c1dfb9a60e3c2d554152ce90098035 Mon Sep 17 00:00:00 2001 From: 4linuxfun Date: Thu, 25 Jan 2024 09:49:22 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=90=8E=E7=AB=AF=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=88=A0=E9=99=A4=E8=8F=9C=E5=8D=95=E6=97=A0=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/routers/internal/menu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/routers/internal/menu.py b/server/routers/internal/menu.py index 268bdca..d4aa1bb 100644 --- a/server/routers/internal/menu.py +++ b/server/routers/internal/menu.py @@ -59,7 +59,7 @@ async def update_menu(menu: MenuBase, session: Session = Depends(get_session)): ) -@router.delete('/menus/{id}', summary='删除菜单', status_code=status.HTTP_204_NO_CONTENT, +@router.delete('/menus/{id}', summary='删除菜单', dependencies=[Depends(Authority("menu:del"))]) async def del_menu(id: int, session: Session = Depends(get_session)): db_obj = crud.menu.get(session, id) @@ -67,3 +67,4 @@ async def del_menu(id: int, session: Session = Depends(get_session)): roles = [role.name for role in db_obj.roles] raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=f"{roles} 角色关联菜单,请先取消关联") crud.menu.delete(session, id) + return ApiResponse() From 1c238597ae90017dbaf9b8ee2baa0b160bdd4d28 Mon Sep 17 00:00:00 2001 From: 4linuxfun Date: Thu, 25 Jan 2024 09:49:56 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8DUserDialog=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/src/views/system/user/UserDialog.vue | 99 ------------------------ 1 file changed, 99 deletions(-) delete mode 100644 www/src/views/system/user/UserDialog.vue diff --git a/www/src/views/system/user/UserDialog.vue b/www/src/views/system/user/UserDialog.vue deleted file mode 100644 index 2b47079..0000000 --- a/www/src/views/system/user/UserDialog.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - From 7ed72f114bb647c6abeedf6be43223068bad3d81 Mon Sep 17 00:00:00 2001 From: 4linuxfun Date: Thu, 25 Jan 2024 09:50:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E5=8D=87?= =?UTF-8?q?=E7=BA=A7element=20plus=EF=BC=8C=E5=A2=9E=E5=8A=A0vue-draggable?= =?UTF-8?q?-plus=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/package.json b/www/package.json index 4ff9e84..dae2e59 100644 --- a/www/package.json +++ b/www/package.json @@ -14,18 +14,18 @@ "axios": "^1.6.2", "core-js": "^3.34.0", "echarts": "^5.4.2", - "element-plus": "^2.4.4", + "element-plus": "^2.5.3", "js-base64": "^3.7.5", "js-cookie": "^3.0.5", "jsonref": "^8.0.8", "pinia": "2.1.7", "vue": "^3.4.3", + "vue-draggable-plus": "^0.3.5", "vue-echarts": "^6.6.5", "vue-router": "^4.2.5", "xterm": "^5.3.0", "xterm-addon-attach": "^0.9.0", "xterm-addon-fit": "^0.8.0" - }, "devDependencies": { "@rollup/plugin-dynamic-import-vars": "^2.1.2",