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='启用'))
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()
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",
diff --git a/www/src/views/system/menus/MenuDialog.vue b/www/src/views/system/menus/MenuDialog.vue
deleted file mode 100644
index 9cfffd7..0000000
--- a/www/src/views/system/menus/MenuDialog.vue
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
-
- 一级菜单
- 子菜单
- 按钮
-
-
-
-
- 取消
-
- 更新
- 添加
-
-
-
-
-
-
-
-
-
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 = () => {
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 @@
-
+
@@ -9,7 +9,7 @@
-
+
- {{data.name}}
+ {{ data.name }}
- 取消
- 更新
- 添加
+ 取消
+ 确定
@@ -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})