20260727173703
This commit is contained in:
1 parent
a8478d60ed
commit
9dbaef7787
114 files changed
+959
-2588
No files matched your search
@@ -17,9 +17,10 @@ const props = defineProps({
|
||||
visible: { type: Boolean, default: false },
|
||||
moduleId: { type: String, required: true },
|
||||
groups: { type: Array, default: () => [] },
|
||||
referencedGroupIds: { type: Array, default: () => [] },
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:visible", "update"]);
|
||||
const emit = defineEmits(["update:visible", "saved"]);
|
||||
|
||||
const localGroups = ref([]);
|
||||
const selectedGroupId = ref(null);
|
||||
@@ -81,7 +82,7 @@ function addGroup(parentId) {
|
||||
b_parent_id: parentId || null,
|
||||
b_title: "",
|
||||
b_i18n: null,
|
||||
b_xh: localGroups.value.length * 10,
|
||||
b_xh: (localGroups.value.length + 1) * 10,
|
||||
b_canuse: 1,
|
||||
};
|
||||
localGroups.value.push(newGroup);
|
||||
@@ -90,6 +91,17 @@ function addGroup(parentId) {
|
||||
|
||||
function deleteGroup() {
|
||||
if (!selectedGroupId.value) return;
|
||||
const hasChildren = localGroups.value.some(
|
||||
(group) => String(group.b_parent_id) === selectedGroupId.value,
|
||||
);
|
||||
if (hasChildren) {
|
||||
message.warning("该分组下还有子分组,请先删除子分组");
|
||||
return;
|
||||
}
|
||||
if (props.referencedGroupIds.map(String).includes(selectedGroupId.value)) {
|
||||
message.warning("该分组仍被列表或编辑配置引用,请先清空引用");
|
||||
return;
|
||||
}
|
||||
localGroups.value = localGroups.value.filter((g) => String(g.b_id) !== selectedGroupId.value);
|
||||
selectedGroupId.value = null;
|
||||
}
|
||||
@@ -114,7 +126,7 @@ async function saveAllGroups() {
|
||||
]);
|
||||
remapForeignKeys(localGroups.value, ["b_parent_id"], idMapping);
|
||||
await saveObjectApi([req]);
|
||||
emit("update", cloneData(localGroups.value));
|
||||
emit("saved", cloneData(localGroups.value), idMapping);
|
||||
message.success("分组已保存");
|
||||
emit("update:visible", false);
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user