|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<el-button @click="saveHandler" type="primary" size="small"
|
|
|
- >保存
|
|
|
+ >保存
|
|
|
<!-- <div class="button-list_column">
|
|
|
<el-button type="primary" size="small" @click="getProcessAsBpmn"
|
|
|
>导出为 Bpmn</el-button
|
|
@@ -16,9 +16,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { downloadFile, setEncoded } from "@utils/files";
|
|
|
-import { mapGetters } from "vuex";
|
|
|
-import { addProcess, updateProcess } from "@/api/bpmprocess/process";
|
|
|
+import {downloadFile, setEncoded} from "@utils/files";
|
|
|
+import {mapGetters} from "vuex";
|
|
|
+import {addProcess, updateProcess} from "@/api/bpmprocess/process";
|
|
|
import xml from "highlight.js/lib/languages/xml";
|
|
|
|
|
|
export default {
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
const modeler = this.getModeler;
|
|
|
// 按需要类型创建文件并下载
|
|
|
if (type === "xml" || type === "bpmn") {
|
|
|
- const { err, xml } = await modeler.saveXML();
|
|
|
+ const {err, xml} = await modeler.saveXML();
|
|
|
// 读取异常时抛出异常
|
|
|
if (err) {
|
|
|
console.error(`[Process Designer Warn ]: ${err.message || err}`);
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
// downloadFile(href, filename);
|
|
|
return xml;
|
|
|
} else {
|
|
|
- const { err, svg } = await modeler.saveSVG();
|
|
|
+ const {err, svg} = await modeler.saveSVG();
|
|
|
// 读取异常时抛出异常
|
|
|
if (err) {
|
|
|
console.error(err);
|
|
@@ -73,7 +73,7 @@ export default {
|
|
|
try {
|
|
|
if (!this.getModeler)
|
|
|
return this.$message.error("流程图引擎初始化失败");
|
|
|
- const { xml } = await this.getModeler.saveXML({
|
|
|
+ const {xml} = await this.getModeler.saveXML({
|
|
|
format: true,
|
|
|
preamble: true,
|
|
|
});
|
|
@@ -94,11 +94,12 @@ export default {
|
|
|
// }
|
|
|
// return xmlObj;
|
|
|
// },
|
|
|
- getFileBinaryHandler() {},
|
|
|
+ getFileBinaryHandler() {
|
|
|
+ },
|
|
|
async saveHandler() {
|
|
|
let _this = this;
|
|
|
let processJsonObj = await this.getProcessJson();
|
|
|
- let { rootElements } = processJsonObj.rootElement;
|
|
|
+ let {rootElements} = processJsonObj.rootElement;
|
|
|
let processKey = rootElements[0].id;
|
|
|
let processName = rootElements[0].name;
|
|
|
let processType = ""; //流程类型
|
|
@@ -107,7 +108,7 @@ export default {
|
|
|
let processXmlContent = xmlPro; //xml标签内容
|
|
|
// const buffer = Buffer.from(xmlPro, "utf-8");
|
|
|
// 将 Buffer 对象转换为二进制流
|
|
|
- const blob = new Blob([xmlPro], { type: "text/plain;charset=utf-8" });
|
|
|
+ const blob = new Blob([xmlPro]);
|
|
|
blob.filename = processName + ".xml";
|
|
|
|
|
|
let reader = new FileReader();
|
|
@@ -126,8 +127,9 @@ export default {
|
|
|
processName,
|
|
|
processType,
|
|
|
processJson: JSON.stringify(processJsonObj),
|
|
|
+ // fileXML: undefined,
|
|
|
},
|
|
|
- fileXML: [...processXml],
|
|
|
+
|
|
|
// processXmlContent,
|
|
|
};
|
|
|
if (_this.$route.query?.id) {
|
|
@@ -140,7 +142,17 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- addProcess(data).then((res) => {
|
|
|
+ // 后台回传文件
|
|
|
+ var file = new File([processXmlContent], "hello.txt", {
|
|
|
+ type: "text/plain",
|
|
|
+ });
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('fileXML', file);
|
|
|
+ formData.append('processKey', processKey);
|
|
|
+ formData.append('processName', processName);
|
|
|
+ formData.append('processType', processType);
|
|
|
+ formData.append('processJson', JSON.stringify(processJsonObj));
|
|
|
+ addProcess(formData).then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
_this.$message.success("保存成功");
|
|
|
} else {
|