This commit is contained in:
孟帅
2024-07-21 22:21:02 +08:00
parent 7d8330f72f
commit a37d088360
440 changed files with 6303 additions and 3339 deletions

View File

@@ -17,7 +17,7 @@
:on-update:value="handleUpdateType"
>
<n-radio-button
v-for="menuType in options.sys_menu_types"
v-for="menuType in dict.getOptionUnRef('sys_menu_types')"
:key="menuType.value"
:value="menuType.value"
:label="menuType.label"
@@ -91,7 +91,7 @@
<n-form-item label="目录组件" path="component">
<n-select
v-if="formParams.type === 1"
:options="options.sys_menu_component"
:options="dict.getOptionUnRef('sys_menu_component')"
v-model:value="formParams.component"
placeholder="请选择目录组件"
clearable
@@ -159,7 +159,7 @@
<n-input-group>
<n-select
:style="{ width: '33%', minWidth: '80px' }"
:options="options.sys_switch"
:options="dict.getOptionUnRef('sys_switch')"
v-model:value="formParams.isFrame"
/>
<n-input
@@ -173,7 +173,7 @@
<n-form-item label="菜单状态" path="status">
<n-radio-group v-model:value="formParams.status" name="status">
<n-radio-button
v-for="status in options.sys_normal_disable"
v-for="status in dict.getOptionUnRef('sys_normal_disable')"
:key="status.value"
:value="status.value"
:label="status.label"
@@ -210,13 +210,15 @@
import { QuestionCircleOutlined } from '@vicons/antd';
import IconSelector from '@/components/IconSelector/index.vue';
import { computed, ref } from 'vue';
import { newState, State, options } from '@/views/permission/menu/model';
import { newState, State } from '@/views/permission/menu/model';
import { FormItemRule, useDialog, useMessage } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { DeleteMenu, EditMenu } from '@/api/system/menu';
import { findTreeNode } from '@/utils';
import { useDictStore } from '@/store/modules/dict';
import type { FormRules } from 'naive-ui/es/form/src/interface';
const rules = {
const rules: FormRules = {
title: {
required: true,
message: '请输入名称',
@@ -231,15 +233,17 @@
required: false,
message: '请输入路由地址',
trigger: 'blur',
validator: function (_rule: FormItemRule, value: any, callback: Function) {
validator: function (_rule: FormItemRule, value: any, callback: Function): boolean | Error {
if (formParams.value.type != 3 && !value) {
callback(new Error('请输入路由地址'));
}
return true;
},
},
};
const emit = defineEmits(['reloadTable', 'closeForm']);
const dict = useDictStore();
const message = useMessage();
const dialog = useDialog();
const loading = ref(false);

View File

@@ -21,14 +21,14 @@
import { computed, ref } from 'vue';
import Menu from './menu.vue';
import { adaModalWidth } from '@/utils/hotgo';
const emit = defineEmits(['reloadTable']);
const showModal = ref(false);
const isModal = ref(true);
const dialogWidth = computed(() => {
return adaModalWidth(1280);
});
const emit = defineEmits(['reloadTable']);
function openModal() {
showModal.value = true;
}

View File

@@ -1,11 +1,11 @@
import { ref } from 'vue';
import { cloneDeep } from 'lodash-es';
import { Option } from '@/utils/hotgo';
import { Dicts } from '@/api/dict/dict';
import { useDictStore } from '@/store/modules/dict';
const dict = useDictStore();
export interface State {
id: number;
pid?: number;
pid?: number | null;
title: string;
name: string;
path: string;
@@ -15,7 +15,7 @@ export interface State {
redirect: string;
permissions: string;
permissionName: string;
component?: string;
component?: string | null;
alwaysShow: number;
activeMenu: string;
isRoot: number;
@@ -27,7 +27,7 @@ export interface State {
status: number;
sort: number;
disabled: boolean;
children?: State[];
children?: State[] | null;
}
export const defaultState: State = {
@@ -66,7 +66,10 @@ export function newState(state: State | null): State {
// 默认值校正,主要为了解决历史数据格式不规范问题
export function defaultValueCheck(state: State): State {
if (state.pid < 1) {
if (!state) {
state = newState(null);
}
if (!state.pid || state.pid < 1) {
state.pid = null;
}
if (state.alwaysShow != 1) {
@@ -93,19 +96,7 @@ export function defaultValueCheck(state: State): State {
return state;
}
// 字典数据选项
export const options = ref({
sys_menu_types: [] as Option[],
sys_menu_component: [] as Option[],
sys_normal_disable: [] as Option[],
sys_switch: [] as Option[],
});
// 加载字典数据选项
export function loadOptions() {
Dicts({
types: ['sys_menu_types', 'sys_menu_component', 'sys_normal_disable', 'sys_switch'],
}).then((res) => {
options.value = res;
});
dict.loadOptions(['sys_menu_types', 'sys_menu_component', 'sys_normal_disable', 'sys_switch']);
}