houzhongjian
2024-07-11 759b1c71011abd6b58c37d2566f3f3c208c2f1b2
提交 | 用户 | 时间
759b1c 1 <template>
H 2   <div class="app-container">
3
4     <!-- 流程设计器,负责绘制流程等 -->
5     <my-process-designer v-if="xmlString !== undefined" :key="`designer-${reloadIndex}`" v-model="xmlString" v-bind="controlForm"
6       keyboard ref="processDesigner" @init-finished="initModeler"
7       @save="save"/>
8
9     <!-- 流程属性器,负责编辑每个流程节点的属性 -->
10     <my-properties-panel :key="`penal-${reloadIndex}`" :bpmn-modeler="modeler" :prefix="controlForm.prefix" class="process-panel"
11       :model="model" />
12
13   </div>
14 </template>
15
16 <script>
17 import translations from "@/components/bpmnProcessDesigner/src/translations";
18 // 自定义元素选中时的弹出菜单(修改 默认任务 为 用户任务)
19 import CustomContentPadProvider from "@/components/bpmnProcessDesigner/package/designer/plugins/content-pad";
20 // 自定义左侧菜单(修改 默认任务 为 用户任务)
21 import CustomPaletteProvider from "@/components/bpmnProcessDesigner/package/designer/plugins/palette";
22 // import xmlObj2json from "./utils/xml2json";
23 import MyProcessPalette from "@/components/bpmnProcessDesigner/package/palette/ProcessPalette";
24 import {createModel, getModel, updateModel} from "@/api/bpm/model";
25 // 自定义侧边栏
26 // import MyProcessPanel from "../package/process-panel/ProcessPanel";
27
28 export default {
29   name: "BpmModelEditor",
30   components: { MyProcessPalette },
31   data() {
32     return {
33       xmlString: undefined, // BPMN XML
34       modeler: null,
35       reloadIndex: 0,
36       controlDrawerVisible: false,
37       translationsSelf: translations,
38       controlForm: {
39         simulation: true,
40         labelEditing: false,
41         labelVisible: false,
42         prefix: "flowable",
43         headerButtonSize: "mini",
44         additionalModel: [CustomContentPadProvider, CustomPaletteProvider]
45       },
46       addis: {
47         CustomContentPadProvider,
48         CustomPaletteProvider
49       },
50       // 流程模型的信息
51       model: {},
52     };
53   },
54   created() {
55     // 如果 modelId 非空,说明是修改流程模型
56     const modelId = this.$route.query && this.$route.query.modelId
57     if (modelId) {
58       getModel(modelId).then(response => {
59         this.xmlString = response.data.bpmnXml
60         this.model = {
61           ...response.data,
62           bpmnXml: undefined, // 清空 bpmnXml 属性
63         }
64         // this.controlForm.processId = response.data.key
65       })
66     }
67   },
68   methods: {
69     initModeler(modeler) {
70       setTimeout(() => {
71         this.modeler = modeler;
72         console.log(modeler);
73       }, 10);
74     },
75     save(bpmnXml) {
76       const data = {
77         ...this.model,
78         bpmnXml: bpmnXml, // this.bpmnXml 只是初始化流程图,后续修改无法通过它获得
79       }
80
81       // 修改的提交
82       if (data.id) {
83         updateModel(data).then(response => {
84           this.$modal.msgSuccess("修改成功")
85           // 跳转回去
86           this.close()
87         })
88         return
89       }
90       // 添加的提交
91       createModel(data).then(response => {
92         this.$modal.msgSuccess("保存成功")
93         // 跳转回去
94         this.close()
95       })
96     },
97     /** 关闭按钮 */
98     close() {
99       this.$tab.closeOpenPage({ path: "/bpm/manager/model" });
100     },
101   }
102 };
103 </script>
104
105 <style lang="scss">
106 //body {
107 //  overflow: hidden;
108 //  margin: 0;
109 //  box-sizing: border-box;
110 //}
111 //.app {
112 //  width: 100%;
113 //  height: 100%;
114 //  box-sizing: border-box;
115 //  display: inline-grid;
116 //  grid-template-columns: 100px auto max-content;
117 //}
118 .demo-control-bar {
119   position: fixed;
120   right: 8px;
121   bottom: 8px;
122   z-index: 1;
123   .open-control-dialog {
124     width: 48px;
125     height: 48px;
126     display: flex;
127     align-items: center;
128     justify-content: center;
129     border-radius: 4px;
130     font-size: 32px;
131     background: rgba(64, 158, 255, 1);
132     color: #ffffff;
133     cursor: pointer;
134   }
135 }
136
137 // TODO iailab:去掉多余的 faq
138 //.info-tip {
139 //  position: fixed;
140 //  top: 40px;
141 //  right: 500px;
142 //  z-index: 10;
143 //  color: #999999;
144 //}
145
146 .control-form {
147   .el-radio {
148     width: 100%;
149     line-height: 32px;
150   }
151 }
152 .element-overlays {
153   box-sizing: border-box;
154   padding: 8px;
155   background: rgba(0, 0, 0, 0.6);
156   border-radius: 4px;
157   color: #fafafa;
158 }
159
160 .my-process-designer {
161   height: calc(100vh - 84px);
162 }
163 .process-panel__container {
164   position: absolute;
165   right: 0;
166   top: 55px;
167   height: calc(100vh - 84px);
168 }
169
170 </style>