|
@@ -2390,7 +2390,7 @@ export default {
|
|
|
try {
|
|
|
// 生成目录编号和内容
|
|
|
const { number, content } = this.generateDirectoryItem(this.comIndex, currentLevel);
|
|
|
-
|
|
|
+ console.log(number);
|
|
|
const directoryItem = {
|
|
|
type: "Directory",
|
|
|
id: `Directory_${this.comIndex}_${currentLevel}_${Date.now()}`,
|
|
@@ -3423,8 +3423,8 @@ export default {
|
|
|
await this.onRebuild(this.coms);
|
|
|
|
|
|
} catch (error) {
|
|
|
- console.error("切换模式失败:", error);
|
|
|
- this.$message.error("切换模式失败:" + error.message);
|
|
|
+ /* console.error("切换模式失败:", error);
|
|
|
+ this.$message.error("切换模式失败:" + error.message); */
|
|
|
} finally {
|
|
|
this.isSaving = false;
|
|
|
}
|
|
@@ -3769,12 +3769,45 @@ export default {
|
|
|
|
|
|
// 生成目录编号
|
|
|
generateDirectoryNumber(moduleIndex, level) {
|
|
|
- const moduleNumber = moduleIndex + 1;
|
|
|
+ let number = '';
|
|
|
+
|
|
|
if (level === 1) {
|
|
|
- return moduleNumber.toString();
|
|
|
+ // 一级标题使用模块序号
|
|
|
+ number = (moduleIndex + 1).toString();
|
|
|
+ } else {
|
|
|
+ // 查找父级目录编号
|
|
|
+ const parentNumber = this.findParentNumber(moduleIndex, level);
|
|
|
+
|
|
|
+ // 获取当前级别的计数
|
|
|
+ const siblings = this.getSiblingDirectories(moduleIndex, level, parentNumber);
|
|
|
+ const currentCount = siblings.length + 1;
|
|
|
+
|
|
|
+ // 组合编号
|
|
|
+ number = `${parentNumber}.${currentCount}`;
|
|
|
}
|
|
|
- // 为多级目录生成编号
|
|
|
- return `${moduleNumber}.${level}`;
|
|
|
+
|
|
|
+ return number;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取同级目录项
|
|
|
+ getSiblingDirectories(moduleIndex, level, parentNumber) {
|
|
|
+ const siblings = [];
|
|
|
+
|
|
|
+ // 遍历所有模块查找同级目录
|
|
|
+ for (let i = 0; i < moduleIndex; i++) {
|
|
|
+ const module = this.coms[i];
|
|
|
+ if (module.attrs) {
|
|
|
+ module.attrs.forEach(attr => {
|
|
|
+ if (attr.type === 'Directory' &&
|
|
|
+ attr.level === level &&
|
|
|
+ attr.number.startsWith(parentNumber)) {
|
|
|
+ siblings.push(attr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return siblings;
|
|
|
},
|
|
|
|
|
|
// 更新组件中的目录信息
|
|
@@ -4486,7 +4519,7 @@ export default {
|
|
|
/* 调整节点内容的位置,为线条留出空间 */
|
|
|
.el-tree-node__content {
|
|
|
position: relative;
|
|
|
- padding-left: 28px !important; /* 调整缩进 */
|
|
|
+ /* 调整缩进 */
|
|
|
}
|
|
|
|
|
|
/* 确保展开箭头在正确位置 */
|