|
@@ -1098,7 +1098,7 @@ export default {
|
|
|
});
|
|
|
this.initTemplateSelection();
|
|
|
this.expandedKeys = []; // 初始化展开节点数组
|
|
|
- this.initCatalog(); // 初始化目录
|
|
|
+ //this.initCatalog(); // 初始化目录
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
@@ -3909,7 +3909,63 @@ export default {
|
|
|
|
|
|
// 对顶层目录进行排序
|
|
|
return sortItems(catalogData);
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加允许拖拽和放置的方法
|
|
|
+ allowDrag(node) {
|
|
|
+ // 允许所有节点拖拽
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
+ allowDrop(draggingNode, dropNode, type) {
|
|
|
+ // 不允许跨级拖拽,只允许同级拖拽
|
|
|
+ return draggingNode.data.level === dropNode.data.level;
|
|
|
+ },
|
|
|
+
|
|
|
+ handleDragEnd(draggingNode, dropNode, dropType, ev) {
|
|
|
+ if (!dropNode) return;
|
|
|
+
|
|
|
+ // 获取拖拽节点和目标节点的模块索引
|
|
|
+ const dragModuleIndex = draggingNode.data.moduleIndex;
|
|
|
+ const dropModuleIndex = dropNode.data.moduleIndex;
|
|
|
+
|
|
|
+ // 如果是同一级目录的拖拽
|
|
|
+ if (draggingNode.data.level === dropNode.data.level) {
|
|
|
+ // 更新模块顺序
|
|
|
+ const dragModule = this.coms[dragModuleIndex];
|
|
|
+ this.coms.splice(dragModuleIndex, 1);
|
|
|
+
|
|
|
+ // 根据放置类型确定插入位置
|
|
|
+ const targetIndex = dropType === 'before' ?
|
|
|
+ dropModuleIndex :
|
|
|
+ dropModuleIndex + 1;
|
|
|
+
|
|
|
+ this.coms.splice(targetIndex, 0, dragModule);
|
|
|
+
|
|
|
+ // 重新生成目录编号
|
|
|
+ this.updateDirectoryNumbers();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 更新目录编号的方法
|
|
|
+ updateDirectoryNumbers() {
|
|
|
+ this.coms.forEach((module, moduleIndex) => {
|
|
|
+ const directories = module.attrs.filter(attr => attr.type === 'Directory');
|
|
|
+ directories.forEach(dir => {
|
|
|
+ const { level } = dir;
|
|
|
+ const { number, content } = this.generateNumberedContent(moduleIndex, level);
|
|
|
+ dir.number = number;
|
|
|
+ // 只更新编号部分,保留原有内容
|
|
|
+ dir.content = dir.content.replace(/^[\d.]+/, number);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 强制更新视图
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.updateCatalog(this.coms);
|
|
|
+ this.$forceUpdate();
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|