修改交互逻辑.

This commit is contained in:
lijiahang
2023-09-14 17:24:18 +08:00
parent f8b694c16a
commit a210fb93fd
15 changed files with 67 additions and 43 deletions

View File

@@ -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;

View File

@@ -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>

View File

@@ -0,0 +1 @@
export const sortStep = 10;