20260730231110
This commit is contained in:
1 parent
4929b78434
commit
318fa0d9e1
23 files changed
+4026
-506
No files matched your search
@@ -1,9 +1,11 @@
|
||||
<script setup>
|
||||
import { computed, ref, useAttrs, watch } from "vue";
|
||||
import { useAppStore } from "@/stores/app";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
const attrs = useAttrs();
|
||||
const appStore = useAppStore();
|
||||
const handledEventAttrs = new Set([
|
||||
"onDrop",
|
||||
"onDragStart",
|
||||
@@ -36,7 +38,6 @@ const props = defineProps({
|
||||
draggable: { type: [Boolean, Function, Object], default: false },
|
||||
allowDrop: { type: Function, default: null },
|
||||
rootKey: { type: [String, Number], default: "__fms_tree_root__" },
|
||||
rootTitle: { type: String, default: "全部分类" },
|
||||
// 右键菜单生成函数:(node) => { items: [...] }
|
||||
contextMenu: { type: Function, default: null },
|
||||
contextMenuDisabled: { type: Boolean, default: false },
|
||||
@@ -48,13 +49,30 @@ const effectiveVirtual = computed(() => {
|
||||
return props.virtual;
|
||||
});
|
||||
|
||||
function getNodeTitle(node) {
|
||||
const fallback = node?.title || node?.b_name || node?.b_code || "";
|
||||
return appStore.t(node?.b_i18n, fallback);
|
||||
}
|
||||
|
||||
function localizeNodes(nodes) {
|
||||
const result = [];
|
||||
for (const node of nodes || []) {
|
||||
result.push({
|
||||
...node,
|
||||
title: getNodeTitle(node),
|
||||
children: localizeNodes(node.children),
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const effectiveTreeData = computed(() => {
|
||||
return [
|
||||
{
|
||||
key: props.rootKey,
|
||||
title: props.rootTitle,
|
||||
title: appStore.t("common.allCategories", "全部分类"),
|
||||
isFmsRoot: true,
|
||||
children: props.treeData,
|
||||
children: localizeNodes(props.treeData),
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user