配置聚合路由的地址时,报系统已存在该值的错误
parent
4a78bef74b
commit
602aac5bf0
|
@ -61,6 +61,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi
|
|||
meta: node.meta,
|
||||
name: title,
|
||||
hideMenu,
|
||||
alwaysShow:node.alwaysShow||false,
|
||||
path: node.path,
|
||||
...(node.redirect ? { redirect: node.redirect } : {}),
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@ export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
|
|||
children?: AppRouteRecordRaw[];
|
||||
props?: Recordable;
|
||||
fullPath?: string;
|
||||
alwaysShow?: boolean;
|
||||
}
|
||||
|
||||
export interface MenuTag {
|
||||
|
@ -44,6 +45,9 @@ export interface Menu {
|
|||
tag?: MenuTag;
|
||||
|
||||
hideMenu?: boolean;
|
||||
|
||||
alwaysShow?: boolean;
|
||||
|
||||
}
|
||||
|
||||
export interface MenuModule {
|
||||
|
|
|
@ -11,6 +11,7 @@ enum Api {
|
|||
ruleSave = '/sys/permission/addPermissionRule',
|
||||
ruleEdit = '/sys/permission/editPermissionRule',
|
||||
ruleDelete = '/sys/permission/deletePermissionRule',
|
||||
checkPermDuplication = '/sys/permission/checkPermDuplication',
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,3 +82,38 @@ export const deleteRule = (params, handleSuccess) => {
|
|||
* @param params
|
||||
*/
|
||||
export const ajaxGetDictItems = (params) => defHttp.get({ url: `/sys/dict/getDictItems/${params.code}` });
|
||||
|
||||
/**
|
||||
* 唯一校验
|
||||
* @param params
|
||||
*/
|
||||
export const getCheckPermDuplication = (params) => defHttp.get({ url: Api.checkPermDuplication, params }, { isTransformResponse: false });
|
||||
|
||||
/**
|
||||
* 校验菜单是否存在
|
||||
* @param model
|
||||
* @param schema
|
||||
* @param required
|
||||
*/
|
||||
export const checkPermDuplication=(model, schema, required?)=>{
|
||||
return [
|
||||
{
|
||||
validator: (_, value) => {
|
||||
if (!value && required) {
|
||||
return Promise.reject(`请输入${schema.label}`);
|
||||
}
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
getCheckPermDuplication({
|
||||
id: model.id,
|
||||
url:model.url,
|
||||
alwaysShow:model.alwaysShow
|
||||
}).then((res) => {
|
||||
res.success ? resolve() : reject(res.message || '校验失败');
|
||||
}).catch((err) => {
|
||||
reject(err.message || '验证失败');
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ import { FormSchema } from '/@/components/Table';
|
|||
import { h } from 'vue';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { duplicateCheck } from '../user/user.api';
|
||||
import { ajaxGetDictItems } from './menu.api';
|
||||
import { ajaxGetDictItems ,checkPermDuplication } from './menu.api';
|
||||
import { render } from '/@/utils/common/renderUtils';
|
||||
import { Select } from 'ant-design-vue';
|
||||
import { rules } from '/@/utils/helper/validator';
|
||||
|
||||
const isDir = (type) => type === 0;
|
||||
const isMenu = (type) => type === 1;
|
||||
|
@ -142,9 +140,11 @@ export const formSchema: FormSchema[] = [
|
|||
component: 'Input',
|
||||
required: true,
|
||||
ifShow: ({ values }) => !(values.component === ComponentTypes.IFrame && values.internalOrExternal) && values.menuType !== 2,
|
||||
dynamicRules: ({ model, schema }) => {
|
||||
return rules.duplicateCheckRule('sys_permission', 'url', model, schema, true);
|
||||
//update-begin-author:zyf date:2022-11-02 for: 聚合路由允许路径重复
|
||||
dynamicRules: ({ model, schema }) => {
|
||||
return checkPermDuplication(model, schema, true);
|
||||
},
|
||||
//update-end-author:zyf date:2022-11-02 for: 聚合路由允许路径重复
|
||||
},
|
||||
{
|
||||
field: 'component',
|
||||
|
|
Loading…
Reference in New Issue