feat: device of menu

This commit is contained in:
louis 2024-04-10 17:38:56 +08:00
parent c0df1d704a
commit 015a8140bb
6 changed files with 62 additions and 6 deletions

View File

@ -448,6 +448,8 @@ declare namespace API {
orderNo: number; orderNo: number;
/** 前端路由地址 */ /** 前端路由地址 */
path: string; path: string;
/** 应用客户端 */
device: number;
/** 是否外链 */ /** 是否外链 */
isExt: boolean; isExt: boolean;
/** 外链打开方式 */ /** 外链打开方式 */
@ -472,7 +474,8 @@ declare namespace API {
parentId: number; parentId: number;
name: string; name: string;
path: string; path: string;
permission: string; permission: string /** 应用客户端 */;
device: number;
type: number; type: number;
icon: string; icon: string;
orderNo: number; orderNo: number;
@ -498,8 +501,11 @@ declare namespace API {
parentId: number; parentId: number;
name: string; name: string;
path: string; path: string;
/** 应用客户端 */
device: number;
permission: string; permission: string;
type: number; type: number;
device: number;
icon: string; icon: string;
orderNo: number; orderNo: number;
component: string; component: string;
@ -572,6 +578,8 @@ declare namespace API {
orderNo?: number; orderNo?: number;
/** 前端路由地址 */ /** 前端路由地址 */
path?: string; path?: string;
/** 应用客户端 */
device: number;
/** 是否外链 */ /** 是否外链 */
isExt?: boolean; isExt?: boolean;
/** 外链打开方式 */ /** 外链打开方式 */
@ -808,6 +816,7 @@ declare namespace API {
page?: number; page?: number;
pageSize?: number; pageSize?: number;
field?: string; field?: string;
useForSelect?: number; // 1: 用于下拉选择
order?: 'ASC' | 'DESC'; order?: 'ASC' | 'DESC';
_t?: number; _t?: number;
}; };

4
src/enums/index.ts Normal file
View File

@ -0,0 +1,4 @@
export enum ResourceDeviceEnum{
APP = 0,
PC = 1
}

View File

@ -22,6 +22,20 @@ const getMenuType = (type) => {
} }
}; };
/**
*
*/
const getDeviceType = (type) => {
switch (type) {
case 0:
return <Tag color="warning">APP端</Tag>;
case 1:
return <Tag color="success">PC端</Tag>;
default:
return '';
}
};
export const baseColumns: TableColumnItem[] = [ export const baseColumns: TableColumnItem[] = [
{ {
title: '名称', title: '名称',
@ -44,6 +58,13 @@ export const baseColumns: TableColumnItem[] = [
hideInSearch: true, hideInSearch: true,
customRender: ({ record }) => getMenuType(record.type), customRender: ({ record }) => getMenuType(record.type),
}, },
{
title: '客户端',
width: 80,
dataIndex: 'device',
hideInSearch: true,
customRender: ({ record }) => getDeviceType(record.device),
},
{ {
title: '节点路由', title: '节点路由',
dataIndex: 'path', dataIndex: 'path',

View File

@ -4,8 +4,10 @@ import { IconPicker, Icon } from '@/components/basic/icon';
import { asyncRoutes } from '@/router/asyncModules'; import { asyncRoutes } from '@/router/asyncModules';
import Api from '@/api/'; import Api from '@/api/';
import { findPath, str2tree } from '@/utils/common'; import { findPath, str2tree } from '@/utils/common';
import { ResourceDeviceEnum } from '@/enums';
/** 菜单类型 0: 目录 | 1: 菜单 | 2: 按钮 */ /** 菜单类型 0: 目录 | 1: 菜单 | 2: 按钮 */
const isPC = (type: API.MenuDto['device']) => type === ResourceDeviceEnum.PC;
const isDir = (type: API.MenuDto['type']) => type === 0; const isDir = (type: API.MenuDto['type']) => type === 0;
const isMenu = (type: API.MenuDto['type']) => type === 1; const isMenu = (type: API.MenuDto['type']) => type === 1;
const isButton = (type: API.MenuDto['type']) => type === 2; const isButton = (type: API.MenuDto['type']) => type === 2;
@ -34,6 +36,25 @@ export const useMenuSchemas = (): FormSchema<API.MenuDto>[] => [
], ],
}, },
}, },
{
field: 'device',
component: 'RadioGroup',
label: '客户端类型',
defaultValue: 1,
rules: [{ required: true, type: 'number' }],
componentProps: {
options: [
{
label: 'PC端',
value: 1,
},
{
label: 'APP端',
value: 0,
},
],
},
},
{ {
field: 'name', field: 'name',
component: 'Input', component: 'Input',
@ -55,7 +76,7 @@ export const useMenuSchemas = (): FormSchema<API.MenuDto>[] => [
findPath(menuTree, formModel['parentId']) || [], findPath(menuTree, formModel['parentId']) || [],
); );
schema.componentProps.treeDefaultExpandedKeys = treeDefaultExpandedKeys; schema.componentProps.treeDefaultExpandedKeys = treeDefaultExpandedKeys;
return [{ id: -1, name: '一级菜单', children: menuTree }]; return [{ id: -1, name: '根目录', children: menuTree }];
}, },
getPopupContainer: () => document.body, getPopupContainer: () => document.body,
}, },
@ -119,7 +140,8 @@ export const useMenuSchemas = (): FormSchema<API.MenuDto>[] => [
field: 'component', field: 'component',
component: 'Cascader', component: 'Cascader',
label: '文件路径', label: '文件路径',
vIf: ({ formModel }) => isMenu(formModel['type']) && !formModel['isExt'], vIf: ({ formModel }) =>
isMenu(formModel['type']) && !formModel['isExt'] && isPC(formModel['device']),
componentProps: { componentProps: {
options: Object.keys(asyncRoutes).reduce( options: Object.keys(asyncRoutes).reduce(
(prev, curr) => (str2tree(curr, prev, '/'), prev), (prev, curr) => (str2tree(curr, prev, '/'), prev),

View File

@ -53,7 +53,7 @@
const uploadAvatar = async (file: FileType) => { const uploadAvatar = async (file: FileType) => {
const { filename } = await Api.toolsUpload.uploadUpload({ file }); const { filename } = await Api.toolsUpload.uploadUpload({ file });
modelValue.value = filename; modelValue.value = filename?.path;
}; };
const customRequest: UploadProps['customRequest'] = async (options) => { const customRequest: UploadProps['customRequest'] = async (options) => {

View File

@ -29,7 +29,7 @@ export const userSchemas: FormSchema<API.UserDto>[] = [
componentProps: { componentProps: {
mode: 'multiple', mode: 'multiple',
request: async () => { request: async () => {
const { items = [] } = await Api.systemRole.roleList({}); const { items = [] } = await Api.systemRole.roleList({ useForSelect: 1 });
return items.map((n) => ({ label: n.name, value: n.id })); return items.map((n) => ({ label: n.name, value: n.id }));
}, },
}, },