|
|
@ -10,6 +10,7 @@ import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router' |
|
|
|
import type { App, Plugin } from 'vue'; |
|
|
|
import type { App, Plugin } from 'vue'; |
|
|
|
import { unref } from 'vue'; |
|
|
|
import { unref } from 'vue'; |
|
|
|
import { isObject } from '/@/utils/is'; |
|
|
|
import { isObject } from '/@/utils/is'; |
|
|
|
|
|
|
|
import { isEmpty } from 'lodash-es'; |
|
|
|
|
|
|
|
|
|
|
|
export const noop = () => {}; |
|
|
|
export const noop = () => {}; |
|
|
|
|
|
|
|
|
|
|
@ -102,11 +103,12 @@ export const withInstall = <T>(component: T, alias?: string) => { |
|
|
|
export const findListNameById = (id: string, list: any[], options: Partial<{ idField: string, nameField: string, childrenField: string }> = {}) => { |
|
|
|
export const findListNameById = (id: string, list: any[], options: Partial<{ idField: string, nameField: string, childrenField: string }> = {}) => { |
|
|
|
// 设置默认配置
|
|
|
|
// 设置默认配置
|
|
|
|
options = Object.assign({ idField: 'id', nameField: 'name', childrenField: 'children' }, options); |
|
|
|
options = Object.assign({ idField: 'id', nameField: 'name', childrenField: 'children' }, options); |
|
|
|
|
|
|
|
console.log(id, list, options); |
|
|
|
for (let i = 0; i < list.length; i++) { |
|
|
|
for (let i = 0; i < list.length; i++) { |
|
|
|
if (list[i][options.idField!] === id) { |
|
|
|
if (list[i][options.idField!] === id) { |
|
|
|
return list[i][options.nameField!]; |
|
|
|
return list[i][options.nameField!]; |
|
|
|
} |
|
|
|
} |
|
|
|
if (list[i][options.childrenField!]) { |
|
|
|
if (!isEmpty(list[i][options.childrenField!])) { |
|
|
|
return findListNameById(id, list[i][options.childrenField!],options); |
|
|
|
return findListNameById(id, list[i][options.childrenField!],options); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|