|
@@ -11,15 +11,23 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="right">
|
|
|
+ <el-button type="primary" size="mini" @click="onSaveAs"
|
|
|
+ >保存文档</el-button
|
|
|
+ ><!-- v-if="docAttr.id > 0" -->
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
size="mini"
|
|
|
- @click="onSaveAs"
|
|
|
- v-if="docAttr.id > 0"
|
|
|
- >另存为</el-button
|
|
|
+ @click="onSave"
|
|
|
+ v-if="docAttr.is_template == 0 && docAttr.id > 0"
|
|
|
+ >更新文档</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ v-if="$store.state.user.name == 'admin'"
|
|
|
+ @click="onSaveUpload"
|
|
|
+ >保存并更新模版</el-button
|
|
|
>
|
|
|
- <el-button type="primary" size="mini" @click="onSave">保存文档</el-button>
|
|
|
- <el-button type="primary" size="mini" v-if="$store.state.user.name=='admin'">保存并更新模版</el-button>
|
|
|
<el-button type="primary" size="mini" @click="onOpenView"
|
|
|
>预览导出
|
|
|
</el-button>
|
|
@@ -54,14 +62,14 @@
|
|
|
</el-collapse-item>
|
|
|
<el-collapse-item title="模版列表" name="-2" v-if="showView == 0">
|
|
|
<div
|
|
|
- v-for="(it, index) in articleList"
|
|
|
+ v-for="(it, index) in templateList"
|
|
|
draggable
|
|
|
:key="it.id"
|
|
|
:data-index="index"
|
|
|
data-type="article"
|
|
|
class="sub-menus"
|
|
|
>
|
|
|
- <div @click="onLoadArticle(it)">{{ it.title }}</div>
|
|
|
+ <div @click="onTemplateInfo(it)">{{ it.title }}</div>
|
|
|
</div>
|
|
|
</el-collapse-item>
|
|
|
|
|
@@ -97,9 +105,13 @@
|
|
|
:title="item.name"
|
|
|
:name="item.id"
|
|
|
>
|
|
|
- <el-collapse v-model="nestedActiveNames">
|
|
|
+ <el-collapse
|
|
|
+ v-model="item.activeChildren"
|
|
|
+ @change="handleItemVal"
|
|
|
+ v-show="item.children"
|
|
|
+ >
|
|
|
<el-collapse-item
|
|
|
- v-for="(child, childIndex) in childrenList"
|
|
|
+ v-for="(child, childIndex) in item.children"
|
|
|
:key="childIndex"
|
|
|
:title="child.name"
|
|
|
:name="child.id"
|
|
@@ -110,7 +122,6 @@
|
|
|
group: { name: 'itxst', pull: 'clone' },
|
|
|
sort: true,
|
|
|
}"
|
|
|
- animation="300"
|
|
|
>
|
|
|
<transition-group>
|
|
|
<div
|
|
@@ -130,7 +141,6 @@
|
|
|
group: { name: 'itxst', pull: 'clone' },
|
|
|
sort: true,
|
|
|
}"
|
|
|
- animation="300"
|
|
|
>
|
|
|
<transition-group>
|
|
|
<div
|
|
@@ -167,7 +177,11 @@
|
|
|
|
|
|
<div class="editor-main">
|
|
|
<div class="menus-box">
|
|
|
- <menus @onEvents="onInsert" @onVariable="uptadeVariable"></menus>
|
|
|
+ <menus
|
|
|
+ @onEvents="onInsert"
|
|
|
+ @onVariable="uptadeVariable"
|
|
|
+ :comArr="coms"
|
|
|
+ ></menus>
|
|
|
</div>
|
|
|
<div class="editor-box" ref="tabHtml" v-loading="loading">
|
|
|
<editor
|
|
@@ -234,16 +248,23 @@
|
|
|
</template>
|
|
|
<!-- comIndex != 9999 && comIndex != 9998 && comIndex != 9997 AttributeIndex==1-->
|
|
|
<template
|
|
|
- v-if="comIndex != 9999 && comIndex != 9998 && catalogIndex != 9997 &&AttributeIndex != 1"
|
|
|
+ v-if="
|
|
|
+ comIndex != 9999 &&
|
|
|
+ comIndex != 9998 &&
|
|
|
+ catalogIndex != 9997 &&
|
|
|
+ AttributeIndex != 1
|
|
|
+ "
|
|
|
>
|
|
|
<Attribute
|
|
|
:com="coms[comIndex]"
|
|
|
@onRefresh="initCategoryList"
|
|
|
></Attribute>
|
|
|
</template>
|
|
|
- <template v-if="AttributeIndex == 1">
|
|
|
- <attributeVar :com="coms[comIndex]"
|
|
|
- @onRefresh="initCategoryList"></attributeVar>
|
|
|
+ <template v-if="AttributeIndex == 1">
|
|
|
+ <attributeVar
|
|
|
+ :com="coms[comIndex]"
|
|
|
+ @onRefresh="initCategoryList"
|
|
|
+ ></attributeVar>
|
|
|
</template>
|
|
|
<!-- <Directory :coms="coms" /> -->
|
|
|
</div>
|
|
@@ -251,6 +272,7 @@
|
|
|
|
|
|
<el-dialog
|
|
|
:visible.sync="showViewForm"
|
|
|
+ :close-on-click-modal="false"
|
|
|
append-to-body
|
|
|
v-el-drag-dialog
|
|
|
width="850px"
|
|
@@ -264,6 +286,7 @@
|
|
|
:visible.sync="showProductAttr"
|
|
|
append-to-body
|
|
|
v-el-drag-dialog
|
|
|
+ :close-on-click-modal="false"
|
|
|
width="850px"
|
|
|
custom-class="prod-verify"
|
|
|
title="插入产品属性"
|
|
@@ -282,7 +305,7 @@ import { searchDocument } from "@/api/document";
|
|
|
import menus from "./com/menus";
|
|
|
import editor from "./com/editor";
|
|
|
import Attribute from "./com/components/Attribute";
|
|
|
-import attributeVar from './com/components/Attribute/attributeVar/index.vue'
|
|
|
+import attributeVar from "./com/components/Attribute/attributeVar/index.vue";
|
|
|
import ProductAttr from "./com/components/ProductAttr";
|
|
|
import {
|
|
|
searchTemplateCategory,
|
|
@@ -318,7 +341,7 @@ export default {
|
|
|
ProductAttr,
|
|
|
Directory,
|
|
|
draggable,
|
|
|
- attributeVar
|
|
|
+ attributeVar,
|
|
|
},
|
|
|
directives: {
|
|
|
elDragDialog,
|
|
@@ -328,6 +351,7 @@ export default {
|
|
|
activeNames: "-1",
|
|
|
nestedActiveNames: [],
|
|
|
articleList: [],
|
|
|
+ templateList: [],
|
|
|
categoryList: [],
|
|
|
//组件相关
|
|
|
coms: [],
|
|
@@ -358,10 +382,10 @@ export default {
|
|
|
articleId: 0,
|
|
|
loading: false, // 增加 loading 状态
|
|
|
showView: 0, //查看 文档/模块
|
|
|
- childrenList: [],
|
|
|
+ childrenList: "",
|
|
|
value: [],
|
|
|
AttributeIndex: 0,
|
|
|
- catalogIndex:0,//目录信息
|
|
|
+ catalogIndex: 0, //目录信息
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -397,18 +421,30 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ handleItemVal(value) {
|
|
|
+ this.$forceUpdate();
|
|
|
+ },
|
|
|
async handleItemClick(item) {
|
|
|
- if (item == "-1") return;
|
|
|
- await searchTemplateCategory({ parent_id: item }).then((res) => {
|
|
|
- if (res.status != 200 && res.data.length == 0) return;
|
|
|
- this.childrenList = res.data;
|
|
|
- for (var i = 0; i < this.childrenList.length; i++) {
|
|
|
- this.childrenList[i].dataList = this.getTemplateList(
|
|
|
- this.childrenList[i].id
|
|
|
- );
|
|
|
+ const category = this.categoryList.find((cat) => cat.id === item);
|
|
|
+ if (!category) return;
|
|
|
+
|
|
|
+ if (!category.children) {
|
|
|
+ try {
|
|
|
+ const res = await searchTemplateCategory({ parent_id: item });
|
|
|
+ if (res.status != 200 || res.data.length == 0) return;
|
|
|
+ category.children = res.data;
|
|
|
+ for (let i = 0; i < category.children.length; i++) {
|
|
|
+ category.children[i].dataList = await this.getTemplateList(
|
|
|
+ category.children[i].id
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("Error fetching template categories:", error);
|
|
|
}
|
|
|
- });
|
|
|
- // Add your custom logic here
|
|
|
+ }
|
|
|
+
|
|
|
+ // 触发视图更新
|
|
|
+ this.$set(category, "activeChildren", category.activeChildren || []);
|
|
|
},
|
|
|
/* 切换标签 */
|
|
|
viewDocument() {
|
|
@@ -418,12 +454,12 @@ export default {
|
|
|
this.showView = 1;
|
|
|
},
|
|
|
/* 更新变量 */
|
|
|
- uptadeVariable(value){
|
|
|
+ uptadeVariable(value) {
|
|
|
for (const item of this.coms) {
|
|
|
for (const el of item.attrs) {
|
|
|
if (el.type === "variable") {
|
|
|
- if(el.data.id==value.id){
|
|
|
- el.content=value.value
|
|
|
+ if (el.data.id == value.id) {
|
|
|
+ el.content = value.value;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -434,7 +470,7 @@ export default {
|
|
|
for (const item of this.coms) {
|
|
|
for (const el of item.attrs) {
|
|
|
if (el.type === "ai") {
|
|
|
- // await this.retrieval(el);
|
|
|
+ // await this.retrieval(el);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -562,6 +598,27 @@ export default {
|
|
|
title: e.title,
|
|
|
content: "",
|
|
|
status: e.status,
|
|
|
+ is_template: e.is_template,
|
|
|
+ linkProduct: e.linkProduct,
|
|
|
+ links: e.links,
|
|
|
+ linkProject: e.linkProject,
|
|
|
+ projects: e.projects,
|
|
|
+ };
|
|
|
+
|
|
|
+ _this.coms = JSON.parse(e.data);
|
|
|
+ console.log(_this.coms);
|
|
|
+ this.uptadeSearch();
|
|
|
+ },
|
|
|
+ /* 加载模版信息 */
|
|
|
+ onTemplateInfo(e) {
|
|
|
+ let _this = this;
|
|
|
+ _this.docAttr = {
|
|
|
+ id: e.id,
|
|
|
+ category_id: e.category_id * 1,
|
|
|
+ title: e.title,
|
|
|
+ content: "",
|
|
|
+ status: e.status,
|
|
|
+ is_template: e.is_template,
|
|
|
linkProduct: e.linkProduct,
|
|
|
links: e.links,
|
|
|
linkProject: e.linkProject,
|
|
@@ -574,8 +631,8 @@ export default {
|
|
|
this.coms.splice(index, 1);
|
|
|
},
|
|
|
/* 目录信息 */
|
|
|
- onCatalogIndex(e){
|
|
|
- this.catalogIndex=e
|
|
|
+ onCatalogIndex(e) {
|
|
|
+ this.catalogIndex = e;
|
|
|
if (
|
|
|
this.comIndex == 9999 ||
|
|
|
this.comIndex == 9998 ||
|
|
@@ -584,7 +641,6 @@ export default {
|
|
|
this.comIndex = 0;
|
|
|
this.AttributeIndex = 0;
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
//设置当前索引
|
|
|
onSetActiveIndex(e) {
|
|
@@ -634,7 +690,9 @@ export default {
|
|
|
_this.docAttr.links = JSON.stringify(_this.docAttr.linkProduct);
|
|
|
_this.docAttr.projects = JSON.stringify(_this.docAttr.linkProject);
|
|
|
_this.docAttr.data = JSON.stringify(_this.coms);
|
|
|
-
|
|
|
+ _this.docAttr.is_template = 0;
|
|
|
+ _this.docAttr.user_name = _this.$store.state.user.name;
|
|
|
+ _this.docAttr.user_id = _this.$store.state.user.id;
|
|
|
if (_this.docAttr.id > 0) {
|
|
|
updateDocument(_this.docAttr).then((res) => {
|
|
|
if (res.status != 200) return; //更新文档
|
|
@@ -651,6 +709,44 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ /* 保存并更新模版 */
|
|
|
+ onSaveUpload(e) {
|
|
|
+ let _this = this;
|
|
|
+ if (_this.coms.length <= 0) {
|
|
|
+ _this.$alert("增加组件");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_this.docAttr.category_id == "" || _this.docAttr.category_id <= 0) {
|
|
|
+ _this.$alert("请选择分类");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_this.docAttr.title == "") {
|
|
|
+ _this.$alert("请填写模版标题");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ _this.docAttr.links = JSON.stringify(_this.docAttr.linkProduct);
|
|
|
+ _this.docAttr.projects = JSON.stringify(_this.docAttr.linkProject);
|
|
|
+ _this.docAttr.data = JSON.stringify(_this.coms);
|
|
|
+ _this.docAttr.is_template = 1;
|
|
|
+ _this.docAttr.user_name = _this.$store.state.user.name;
|
|
|
+ _this.docAttr.user_id = _this.$store.state.user.id;
|
|
|
+ if (_this.docAttr.id > 0) {
|
|
|
+ updateDocument(_this.docAttr).then((res) => {
|
|
|
+ if (res.status != 200) return; //更新文档
|
|
|
+ _this.docAttr.id = res.data;
|
|
|
+ _this.$alert("模版更新成功");
|
|
|
+ _this.searchArticle();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ createDocument(_this.docAttr).then((res) => {
|
|
|
+ if (res.status != 200) return; //保存文档
|
|
|
+ _this.docAttr.id = res.data;
|
|
|
+ _this.$alert("模版保存成功");
|
|
|
+ _this.searchArticle();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
//设置组件值
|
|
|
onSetComs(e) {
|
|
@@ -750,7 +846,7 @@ export default {
|
|
|
}
|
|
|
console.log(e);
|
|
|
let com = _this.coms[_this.comIndex];
|
|
|
- console.log("com:",com);
|
|
|
+ console.log("com:", com);
|
|
|
let data = {
|
|
|
type: "Directory",
|
|
|
id: "Directory" + (com.attrs.length + 1),
|
|
@@ -1050,10 +1146,15 @@ export default {
|
|
|
let _this = this;
|
|
|
searchDocument({
|
|
|
page: 1,
|
|
|
- pageSize: 10,
|
|
|
+ pageSize: 99,
|
|
|
}).then((res) => {
|
|
|
if (res.status != 200) return;
|
|
|
- _this.articleList = res.data.dataList;
|
|
|
+ _this.articleList = res.data.dataList.filter(
|
|
|
+ (el) => el.is_template == 0
|
|
|
+ );
|
|
|
+ _this.templateList = res.data.dataList.filter(
|
|
|
+ (el) => el.is_template == 1
|
|
|
+ );
|
|
|
});
|
|
|
},
|
|
|
},
|