Header.vue
4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<template>
<div>
<el-button-group>
<el-tooltip class="item" effect="dark" content="保存并发布" placement="bottom">
<el-button type="primary" size="small" @click="deploy"><i class="fa fa-save"> 保存并发布</i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="保存草稿" placement="bottom">
<el-button type="primary" size="small" @click="save"><i class="fa fa-save"> 保存草稿</i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="打开流程文件" placement="bottom">
<el-button type="primary" size="small" @click="importXml"><i class="fa fa-folder-open"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="创建新流程图" placement="bottom">
<el-button type="primary" size="small" @click="reset"><i class="fa fa-plus-circle"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="下载流程图" placement="bottom">
<el-button type="primary" size="small" @click="downloadSvg"><i class="fa fa-picture-o"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="下载流程文件" placement="bottom">
<el-button type="primary" size="small" @click="downloadBpmn"><i class="fa fa-download"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="撤销" placement="bottom">
<el-button size="small"><i class="fa fa-rotate-left" @click="undo"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="恢复" placement="bottom">
<el-button size="small"><i class="fa fa-rotate-right" :class="!canRedo?'default-undo':''"
@click="redo"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="放大" placement="bottom">
<el-button size="small" @click="zoom(0.05)"><i class="fa fa-search-plus"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="缩小" placement="bottom">
<el-button size="small" @click="zoom(-0.05)"><i class="fa fa-search-minus"></i></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="重置" placement="bottom">
<el-button size="small" @click="zoom(0)"><i class="fa fa-arrows"></i></el-button>
</el-tooltip>
</el-button-group>
</div>
</template>
<script>
export default {
name: "ViewerHeader",
data() {
return {
scale: 1.0,
canRedo: false
}
},
props: {
processData: {
type: Object
},
modeler: {
type: Object
}
},
components: {},
methods: {
deploy() {
let that = this;
let _xml;
let _svg;
this.modeler.saveXML((err, xml) => {
if (err) {
console.error(err)
}
_xml = xml;
})
this.modeler.saveSVG((err, svg) => {
if (err) {
console.error(err)
}
_svg = svg;
})
that.post(this.Apis.deployProcess, {
processKey: "s1111",
processName: "阿达达",
resourceName: "test01",
xml: _xml,
svg: _svg
}, function (data) {
console.log(data)
});
},
save(){
let that = this;
let _xml;
let _svg;
this.modeler.saveXML((err, xml) => {
if (err) {
console.error(err)
}
_xml = xml;
})
this.modeler.saveSVG((err, svg) => {
if (err) {
console.error(err)
}
_svg = svg;
})
that.$emit("processSave",{"xmlStr":_xml,"svgStr":_svg});
},
reset() {
this.$emit('restart')
},
importXml() {
this.$emit('importXml')
},
downloadSvg() {
this.$emit("handleExportSvg")
},
downloadBpmn() {
this.$emit("handleExportBpmn");
},
undo() {
this.modeler.get('commandStack').undo();
this.canRedo = this.modeler.get('commandStack').canRedo();
},
redo() {
if (!this.canRedo) {
return;
}
this.modeler.get('commandStack').redo()
this.canRedo = this.modeler.get('commandStack').canRedo();
},
zoom(val) {
let newScale = !val ? 1.0 : ((this.scale + val) <= 0.2) ? 0.2 : (this.scale + val);
this.modeler.get('canvas').zoom(newScale);
this.scale = newScale;
}
}
}
</script>
<style scoped>
</style>