|
@@ -1285,9 +1285,11 @@ export default {
|
|
this.operation = "drag";
|
|
this.operation = "drag";
|
|
},
|
|
},
|
|
|
|
|
|
- onRebuild(e) {
|
|
|
|
- let _this = this;
|
|
|
|
- _this.coms = [...e];
|
|
|
|
|
|
+ onRebuild(updatedComList) {
|
|
|
|
+ this.coms = [...updatedComList];
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.$forceUpdate();
|
|
|
|
+ });
|
|
},
|
|
},
|
|
//初始化当前用户信息
|
|
//初始化当前用户信息
|
|
async initCurrentUser() {
|
|
async initCurrentUser() {
|
|
@@ -1565,7 +1567,7 @@ export default {
|
|
createDocument(_this.docAttr).then((res) => {
|
|
createDocument(_this.docAttr).then((res) => {
|
|
if (res.status != 200) return; //保存文档
|
|
if (res.status != 200) return; //保存文档
|
|
_this.docAttr.id = res.data;
|
|
_this.docAttr.id = res.data;
|
|
- _this.articleId=res.data
|
|
|
|
|
|
+ _this.articleId = res.data;
|
|
_this.$alert("文档保存成功");
|
|
_this.$alert("文档保存成功");
|
|
_this.docVisible = false;
|
|
_this.docVisible = false;
|
|
_this.docForm = {
|
|
_this.docForm = {
|
|
@@ -1595,6 +1597,7 @@ export default {
|
|
_this.docAttr.projects = JSON.stringify(_this.docAttr.linkProject);
|
|
_this.docAttr.projects = JSON.stringify(_this.docAttr.linkProject);
|
|
_this.docAttr.data = JSON.stringify(_this.coms);
|
|
_this.docAttr.data = JSON.stringify(_this.coms);
|
|
_this.docAttr.is_template = 1;
|
|
_this.docAttr.is_template = 1;
|
|
|
|
+ _this.docAttr.id = this.$route.query.articleId;
|
|
_this.docAttr.user_name = _this.$store.state.user.name;
|
|
_this.docAttr.user_name = _this.$store.state.user.name;
|
|
_this.docAttr.user_id = _this.$store.state.user.id;
|
|
_this.docAttr.user_id = _this.$store.state.user.id;
|
|
updateDocument(_this.docAttr).then((res) => {
|
|
updateDocument(_this.docAttr).then((res) => {
|
|
@@ -1775,11 +1778,15 @@ export default {
|
|
}
|
|
}
|
|
|
|
|
|
let com = _this.coms[_this.comIndex];
|
|
let com = _this.coms[_this.comIndex];
|
|
- let uniqueId = "Directory" + (com.attrs.length + 1);
|
|
|
|
|
|
+ let uniqueId = `Directory_${_this.comIndex}_${com.attrs.length + 1}`;
|
|
|
|
|
|
- // 查找现有的目录内容
|
|
|
|
- let existingDirectory = com.attrs.find(
|
|
|
|
- (attr) => attr.type === "Directory"
|
|
|
|
|
|
+ // 获取当前层级
|
|
|
|
+ let currentLevel = e.content.level || 1;
|
|
|
|
+
|
|
|
|
+ // 生成带有模块索引和层级的内容
|
|
|
|
+ let numberedContent = this.generateNumberedContent(
|
|
|
|
+ _this.comIndex,
|
|
|
|
+ currentLevel
|
|
);
|
|
);
|
|
|
|
|
|
let data = {
|
|
let data = {
|
|
@@ -1787,21 +1794,79 @@ export default {
|
|
id: uniqueId,
|
|
id: uniqueId,
|
|
name: "目录信息",
|
|
name: "目录信息",
|
|
intro: "目录信息",
|
|
intro: "目录信息",
|
|
- content: existingDirectory ? existingDirectory.content : "目录信息",
|
|
|
|
- level: e.content.level,
|
|
|
|
|
|
+ content: numberedContent,
|
|
|
|
+ level: currentLevel,
|
|
|
|
+ moduleIndex: _this.comIndex,
|
|
};
|
|
};
|
|
|
|
|
|
- // 始终添加新的目录项
|
|
|
|
- com.attrs.push(data);
|
|
|
|
|
|
+ // 使用 $set 来确保响应式更新
|
|
|
|
+ this.$set(com.attrs, com.attrs.length, data);
|
|
|
|
|
|
- console.log(_this.coms);
|
|
|
|
|
|
+ // 强制更新视图
|
|
|
|
+ this.$forceUpdate();
|
|
|
|
+
|
|
|
|
+ // 使用 nextTick 确保 DOM 更新后再检查
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ if (!com.attrs[com.attrs.length - 1].content) {
|
|
|
|
+ this.$set(
|
|
|
|
+ com.attrs[com.attrs.length - 1],
|
|
|
|
+ "content",
|
|
|
|
+ numberedContent
|
|
|
|
+ );
|
|
|
|
+ this.$forceUpdate();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
- // 在插入命令中使用新的唯一ID
|
|
|
|
|
|
+ // 使用新的唯一 ID 在插入命令中
|
|
_this.insertCmd = {
|
|
_this.insertCmd = {
|
|
- content: `<div class="directory-level-${e.content.level}">{{${uniqueId}}}</div>`,
|
|
|
|
|
|
+ content: `{{${uniqueId}}}`,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ generateNumberedContent(moduleIndex, level) {
|
|
|
|
+ let numberedContent = "";
|
|
|
|
+ let prefix = this.generateLevelPrefix(moduleIndex, level);
|
|
|
|
+
|
|
|
|
+ if (this.coms[moduleIndex].type === "TextArea") {
|
|
|
|
+ numberedContent = `${prefix}\n`;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return numberedContent.trim();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ generateLevelPrefix(moduleIndex, level) {
|
|
|
|
+ let prefix = [];
|
|
|
|
+ let currentModule = this.coms[moduleIndex];
|
|
|
|
+
|
|
|
|
+ // 获取当前模块中已存在的目录项
|
|
|
|
+ let existingDirectories = currentModule.attrs.filter(
|
|
|
|
+ (attr) => attr.type === "Directory"
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 计算当前层级的序号
|
|
|
|
+ let currentLevelCount =
|
|
|
|
+ existingDirectories.filter((dir) => dir.level === level).length + 1;
|
|
|
|
+
|
|
|
|
+ // 构建多级序号
|
|
|
|
+ for (let i = 1; i <= level; i++) {
|
|
|
|
+ if (i === 1) {
|
|
|
|
+ prefix.push(moduleIndex + 1);
|
|
|
|
+ } else if (i === level) {
|
|
|
|
+ prefix.push(currentLevelCount);
|
|
|
|
+ } else {
|
|
|
|
+ // 对于中间层级,找到最近的上级目录项
|
|
|
|
+ let parentLevel = existingDirectories
|
|
|
|
+ .filter((dir) => dir.level === i - 1)
|
|
|
|
+ .pop();
|
|
|
|
+ prefix.push(
|
|
|
|
+ parentLevel ? parentLevel.content.split(" ")[0].split(".").pop() : 1
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return prefix.join(".");
|
|
|
|
+ },
|
|
|
|
+
|
|
onInsertProductAttr(e) {
|
|
onInsertProductAttr(e) {
|
|
let _this = this;
|
|
let _this = this;
|
|
this.showProductAttr = false;
|
|
this.showProductAttr = false;
|