|
@@ -713,8 +713,8 @@ export default {
|
|
|
if (val == null || val == undefined || val <= 0) return;
|
|
|
if (this.$route.query.type == "document") {
|
|
|
this.loadArticle(val);
|
|
|
- }else{
|
|
|
- this.onTemplateInfo(val)
|
|
|
+ } else {
|
|
|
+ this.onTemplateInfo(val);
|
|
|
}
|
|
|
//
|
|
|
},
|
|
@@ -1215,13 +1215,20 @@ export default {
|
|
|
const {
|
|
|
data: { dataList },
|
|
|
} = await searchFormula({ page: 1, pageSize: 999 });
|
|
|
- /* console.log(data); */
|
|
|
+ console.log(data);
|
|
|
data.attrs = data.attrs.map((item) => {
|
|
|
const formula = dataList.find((el) => el.id === item.id);
|
|
|
return formula
|
|
|
? { ...item, formula: formula.formula, data: formula }
|
|
|
: item;
|
|
|
});
|
|
|
+ // 从 content 中提取 {{}} 包裹的 ID
|
|
|
+ const contentIds = (data.content.match(/{{([^}]+)}}/g) || []).map(
|
|
|
+ (match) => match.slice(2, -2).trim()
|
|
|
+ );
|
|
|
+
|
|
|
+ // 过滤 attrs,只保留在 content 中出现的 ID
|
|
|
+ data.attrs = data.attrs.filter((item) => contentIds.includes(item.id));
|
|
|
|
|
|
this.coms = [data];
|
|
|
} catch (error) {
|
|
@@ -1362,7 +1369,6 @@ export default {
|
|
|
},
|
|
|
/* 加载模版信息 */
|
|
|
async onTemplateInfo(id) {
|
|
|
-
|
|
|
try {
|
|
|
this.loading = true;
|
|
|
const res = await getDocumentInfo({ id });
|
|
@@ -1434,7 +1440,7 @@ export default {
|
|
|
// 过滤掉 null 值
|
|
|
this.coms = updatedComs.filter(Boolean);
|
|
|
console.log("coms", this.coms);
|
|
|
- console.log("模版",this.docAttr);
|
|
|
+ console.log("模版", this.docAttr);
|
|
|
if (this.articleId !== undefined) {
|
|
|
document.title = `${this.docAttr.title}-轻良实业`;
|
|
|
}
|
|
@@ -1559,6 +1565,7 @@ export default {
|
|
|
createDocument(_this.docAttr).then((res) => {
|
|
|
if (res.status != 200) return; //保存文档
|
|
|
_this.docAttr.id = res.data;
|
|
|
+ _this.articleId=res.data
|
|
|
_this.$alert("文档保存成功");
|
|
|
_this.docVisible = false;
|
|
|
_this.docForm = {
|
|
@@ -1630,7 +1637,7 @@ export default {
|
|
|
createDocument(_this.docAttr).then((res) => {
|
|
|
if (res.status != 200) return; //保存文档
|
|
|
_this.docAttr.id = res.data;
|
|
|
- _this.articleId=res.data
|
|
|
+ _this.articleId = res.data;
|
|
|
_this.$alert("模版保存成功");
|
|
|
_this.searchArticle();
|
|
|
});
|