|
@@ -33,9 +33,7 @@
|
|
|
size="mini"
|
|
|
@click="renew"
|
|
|
v-if="
|
|
|
- articleId !== undefined &&
|
|
|
- type !== 'module' &&
|
|
|
- type == 'document'
|
|
|
+ articleId !== undefined && type !== 'module' && type == 'document'
|
|
|
"
|
|
|
>更新文档</el-button
|
|
|
>
|
|
@@ -1213,7 +1211,7 @@ export default {
|
|
|
data: { dataList },
|
|
|
} = await searchFormula({ page: 1, pageSize: 999 });
|
|
|
data.attrs = data.attrs.map((item) => {
|
|
|
- const formula = dataList.find((el) => el.id === item.data.id);
|
|
|
+ const formula = dataList.find((el) => el.id === item.id);
|
|
|
return formula
|
|
|
? { ...item, formula: formula.formula, data: formula }
|
|
|
: item;
|
|
@@ -1312,7 +1310,7 @@ export default {
|
|
|
typeof res.data.data === "string"
|
|
|
? JSON.parse(res.data.data)
|
|
|
: res.data.data;
|
|
|
-
|
|
|
+
|
|
|
const updatedComs = await Promise.all(
|
|
|
templateData.map(async (el) => {
|
|
|
/* let templateInfo = { data: {} };
|
|
@@ -1321,11 +1319,11 @@ export default {
|
|
|
} */
|
|
|
const formulaData = await searchFormula({ page: 1, pageSize: 999 });
|
|
|
|
|
|
- const attrs =el.attrs
|
|
|
- /* typeof templateInfo.data.attrs === "string"
|
|
|
+ const attrs = el.attrs;
|
|
|
+ /* typeof templateInfo.data.attrs === "string"
|
|
|
? JSON.parse(templateInfo.data.attrs)
|
|
|
: templateInfo.data.attrs || []; // Add a fallback empty array */
|
|
|
-
|
|
|
+
|
|
|
attrs.forEach((item) => {
|
|
|
const matchedFormula = formulaData.data.dataList.find(
|
|
|
(ite) => ite.id === item.data.id
|
|
@@ -1336,7 +1334,7 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- return { ...el/* , ...templateInfo.data, attrs */ };
|
|
|
+ return { ...el /* , ...templateInfo.data, attrs */ };
|
|
|
})
|
|
|
);
|
|
|
|
|
@@ -1649,7 +1647,7 @@ export default {
|
|
|
this.insertProductAttr();
|
|
|
break;
|
|
|
case "Directory": //插入主题
|
|
|
- _this.insertDirectory();
|
|
|
+ _this.insertDirectory(e);
|
|
|
break;
|
|
|
case "addNew": //插入新记录
|
|
|
_this.insertNew(e);
|
|
@@ -1736,19 +1734,30 @@ export default {
|
|
|
|
|
|
let com = _this.coms[_this.comIndex];
|
|
|
let uniqueId = "Directory" + (com.attrs.length + 1);
|
|
|
+
|
|
|
+ // 查找现有的目录内容
|
|
|
+ let existingDirectory = com.attrs.find(
|
|
|
+ (attr) => attr.type === "Directory"
|
|
|
+ );
|
|
|
+
|
|
|
let data = {
|
|
|
type: "Directory",
|
|
|
id: uniqueId,
|
|
|
name: "目录信息",
|
|
|
intro: "目录信息",
|
|
|
- content: "目录信息",
|
|
|
+ content: existingDirectory ? existingDirectory.content : "目录信息",
|
|
|
+ level: e.content.level,
|
|
|
};
|
|
|
+
|
|
|
+ // 始终添加新的目录项
|
|
|
com.attrs.push(data);
|
|
|
+
|
|
|
console.log(_this.coms);
|
|
|
+
|
|
|
+ // 在插入命令中使用新的唯一ID
|
|
|
_this.insertCmd = {
|
|
|
- content: "<div>{{" + uniqueId + "}}</div>",
|
|
|
+ content: `<div class="directory-level-${e.content.level}">{{${uniqueId}}}</div>`,
|
|
|
};
|
|
|
- // com.content+='{{'+data.id+'}}';
|
|
|
},
|
|
|
|
|
|
onInsertProductAttr(e) {
|