mirror of
https://github.com/bufanyun/hotgo.git
synced 2026-04-25 04:24:31 +08:00
发布v2.11.5版本,更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
</n-form-item>
|
||||
<n-form-item label="上级目录" path="pid">
|
||||
<n-tree-select
|
||||
filterable
|
||||
:options="optionTreeData"
|
||||
:default-value="formParams.pid"
|
||||
@update:value="handleUpdateValue"
|
||||
|
||||
@@ -124,7 +124,8 @@
|
||||
<n-gi>
|
||||
<n-form-item label="上级目录" path="pid">
|
||||
<n-tree-select
|
||||
:options="optionTreeData"
|
||||
filterable
|
||||
:options="optionTreeDataEdit"
|
||||
:value="formParams.pid"
|
||||
@update:value="handleUpdateValue"
|
||||
/>
|
||||
@@ -374,7 +375,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, reactive, ref, unref } from 'vue';
|
||||
import { onMounted, reactive, ref, unref, computed } from 'vue';
|
||||
import { FormItemRule, useDialog, useMessage } from 'naive-ui';
|
||||
import {
|
||||
AlignLeftOutlined,
|
||||
@@ -388,6 +389,7 @@
|
||||
import CreateDrawer from './CreateDrawer.vue';
|
||||
import IconSelector from '@/components/IconSelector/index.vue';
|
||||
import { newState, State } from '@/views/permission/menu/model';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
const menuTypes = [
|
||||
{
|
||||
@@ -466,11 +468,52 @@
|
||||
const treeItemTitle = ref('');
|
||||
const pattern = ref('');
|
||||
const drawerTitle = ref('');
|
||||
const treeItemKey = ref([]);
|
||||
const expandedKeys = ref([]);
|
||||
const optionTreeData = ref<any>([]);
|
||||
const formParams = reactive<State>(newState(null));
|
||||
const optionTreeDataEdit = computed(() => {
|
||||
let list = cloneDeep(optionTreeData.value);
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
if (item.id === formParams.id) {
|
||||
item.disabled = true;
|
||||
setChildrenDisabled(item.children);
|
||||
} else {
|
||||
const foundChild = findItemById(item.children, formParams.id);
|
||||
if (foundChild) {
|
||||
foundChild.disabled = true;
|
||||
setChildrenDisabled(foundChild.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
});
|
||||
|
||||
function setChildrenDisabled(children) {
|
||||
if (!children) return;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.disabled = true;
|
||||
setChildrenDisabled(child.children);
|
||||
}
|
||||
}
|
||||
|
||||
function findItemById(children, id) {
|
||||
if (!children) return null;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const item = children[i];
|
||||
if (item.id === id) {
|
||||
return item;
|
||||
}
|
||||
const foundChild = findItemById(item.children, id);
|
||||
if (foundChild) {
|
||||
return foundChild;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
let treeItemKey = ref([]);
|
||||
let expandedKeys = ref([]);
|
||||
|
||||
function openCreateDrawer() {
|
||||
drawerTitle.value = '添加菜单';
|
||||
|
||||
Reference in New Issue
Block a user