mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 系统权限和菜单
This commit is contained in:
+2
-2
@@ -21,9 +21,9 @@ public class MenuPO {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
* 父菜单ID(可清空为顶级;ALWAYS 保证 null 写入库)
|
||||
*/
|
||||
@TableField("parent_id")
|
||||
@TableField(value = "parent_id", updateStrategy = FieldStrategy.ALWAYS)
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
export namespace MenuDTO {
|
||||
/** 创建菜单参数 */
|
||||
export interface CreateMenuDTO {
|
||||
/** 父级菜单ID */
|
||||
parentId?: number;
|
||||
/** 父级菜单ID(null 表示顶级) */
|
||||
parentId?: number | null;
|
||||
/** 超级菜单标识 */
|
||||
superMenu?: number;
|
||||
/** 菜单名称 */
|
||||
@@ -35,8 +35,8 @@ export namespace MenuDTO {
|
||||
|
||||
/** 更新菜单参数 */
|
||||
export interface UpdateMenuDTO {
|
||||
/** 父级菜单ID */
|
||||
parentId?: number;
|
||||
/** 父级菜单ID(null 表示清除父级、置为顶级) */
|
||||
parentId?: number | null;
|
||||
/** 超级菜单标识 */
|
||||
superMenu?: number;
|
||||
/** 菜单名称 */
|
||||
|
||||
@@ -63,7 +63,7 @@ const formRef = ref();
|
||||
|
||||
// 内部表单数据类型
|
||||
interface FormData {
|
||||
parentId?: number;
|
||||
parentId: number | null;
|
||||
superMenu: boolean;
|
||||
name: string;
|
||||
title: string;
|
||||
@@ -80,7 +80,7 @@ interface FormData {
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<FormData>({
|
||||
parentId: undefined,
|
||||
parentId: null,
|
||||
superMenu: false,
|
||||
name: '',
|
||||
title: '',
|
||||
@@ -228,7 +228,7 @@ function onParentMenuCascaderChange(value: unknown) {
|
||||
.filter((n) => Number.isFinite(n) && n > 0)
|
||||
: [];
|
||||
parentMenuPath.value = arr;
|
||||
formData.value.parentId = arr.length ? arr[arr.length - 1] : undefined;
|
||||
formData.value.parentId = arr.length ? arr[arr.length - 1]! : null;
|
||||
}
|
||||
|
||||
// 获取父菜单选项(扁平列表建树,供级联)
|
||||
@@ -341,7 +341,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
if (edit && record) {
|
||||
// 编辑模式,填充表单数据
|
||||
formData.value = {
|
||||
parentId: record.parentId || undefined,
|
||||
parentId: record.parentId || null,
|
||||
superMenu: record.superMenu === 1, // 转换为boolean
|
||||
name: record.name,
|
||||
title: record.title || '',
|
||||
@@ -386,7 +386,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
} else {
|
||||
// 新增根菜单模式,重置表单
|
||||
formData.value = {
|
||||
parentId: undefined,
|
||||
parentId: null,
|
||||
superMenu: false,
|
||||
name: '',
|
||||
title: '',
|
||||
@@ -475,9 +475,10 @@ async function handleSubmit() {
|
||||
// 设置模态框为loading状态
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
|
||||
// 转换boolean值为number值
|
||||
// 转换boolean值为number值;parentId 显式传 null,避免 undefined 被 JSON 省略
|
||||
const submitData = {
|
||||
...formData.value,
|
||||
parentId: formData.value.parentId ?? null,
|
||||
superMenu: formData.value.superMenu ? 1 : 0,
|
||||
visible: formData.value.visible ? 1 : 0,
|
||||
status: formData.value.status ? 1 : 0,
|
||||
|
||||
+3
-4
@@ -266,11 +266,10 @@ defineExpose({
|
||||
:tree-data="parentPermissionOptions"
|
||||
:dropdown-match-select-width="false"
|
||||
allow-clear
|
||||
tree-checkable
|
||||
:tree-default-expand-all="false"
|
||||
:max-tag-count="2"
|
||||
class="w-full"
|
||||
show-search
|
||||
tree-node-filter-prop="title"
|
||||
:tree-default-expand-all="false"
|
||||
class="w-full"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user