修改交互逻辑.
This commit is contained in:
@@ -111,6 +111,7 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import formRules from '../types/form.rules';
|
||||
import { sortStep } from '../types/const';
|
||||
import { MenuTypeEnum, MenuVisibleEnum, MenuCacheEnum } from '../types/enum.types';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
import IconPicker from '@sanqi377/arco-vue-icon-picker';
|
||||
@@ -131,7 +132,7 @@
|
||||
name: undefined,
|
||||
type: MenuTypeEnum.PARENT_MENU.value,
|
||||
permission: undefined,
|
||||
sort: 10,
|
||||
sort: undefined,
|
||||
visible: MenuVisibleEnum.SHOW.value,
|
||||
cache: MenuCacheEnum.SHOW.value,
|
||||
icon: undefined,
|
||||
@@ -156,7 +157,7 @@
|
||||
const openAdd = (record: any) => {
|
||||
title.value = '添加菜单';
|
||||
isAddHandle.value = true;
|
||||
renderForm({ ...defaultForm(), parentId: record.parentId });
|
||||
renderForm({ ...defaultForm(), parentId: record.parentId, sort: (record.sort || 0) + sortStep });
|
||||
// 如果是父菜单默认选中子菜单 如果是子菜单默认选中功能
|
||||
if (record.type === 1 || record.type === 2) {
|
||||
formModel.type = record.type + 1;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<a-space>
|
||||
<!-- 新增 -->
|
||||
<a-button type="primary"
|
||||
@click="emits('openAdd',{ parentId: 0 })"
|
||||
@click="emits('openAdd',{ parentId: 0, sort: getMaxSort(tableRenderData) })"
|
||||
v-permission="['infra:system-menu:create']">
|
||||
新增
|
||||
<template #icon>
|
||||
@@ -136,7 +136,7 @@
|
||||
size="mini"
|
||||
v-if="record.type !== MenuTypeEnum.FUNCTION.value"
|
||||
v-permission="['infra:system-menu:create']"
|
||||
@click="emits('openAdd', { parentId: record.id, type: record.type })">
|
||||
@click="emits('openAdd', { parentId: record.id, type: record.type, sort: getMaxSort(record.children) })">
|
||||
新增
|
||||
</a-button>
|
||||
<!-- 修改 -->
|
||||
@@ -301,6 +301,15 @@
|
||||
await loadMenuData();
|
||||
};
|
||||
|
||||
// 获取最大排序
|
||||
const getMaxSort = (array: MenuQueryResponse[]) => {
|
||||
if (array?.length) {
|
||||
return array[array.length - 1].sort;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
1
orion-ops-ui/src/views/system/menu/types/const.ts
Normal file
1
orion-ops-ui/src/views/system/menu/types/const.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const sortStep = 10;
|
||||
Reference in New Issue
Block a user