vue-vben-admin/src/components/ProcessDesigner/index.vue

144 lines
4.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="process-design" :style="'display: flex; height:' + data.height">
<bpmn-process-designer v-model="data.xmlString" v-bind="data.controlForm" keyboard ref="processDesigner" :events="[
'element.click',
'connection.added',
'connection.removed',
'connection.changed'
]" @connection-added="connectionAdded" @connection-removed="connectionRemoved"
@connection-changed="connectionChanged" @element-click="elementClick" @init-finished="initModeler"
@event="handlerEvent" @save="onSaveProcess" :schemeCode="props.schemeCode" :pageFlow="props.pageFlow" :pageType="props.pageType"/>
<!-- 属性面板 -->
<bmpn-process-penal :element="data.element" :bpmn-modeler="data.modeler" :prefix="data.controlForm.prefix"
class="process-panel" ref=processPanel :schemeCode="props.schemeCode" :pageView="props.pageView" :pageType="props.pageType"/>
</div>
</template>
<script lang="ts" setup>
import { h, reactive, onMounted, defineProps, computed, defineEmits, inject,ref } from 'vue';
import './package/theme/index.scss';
// 流程面板和属性面板
import { BpmnProcessDesigner, BmpnProcessPenal } from './package/index';
import 'highlight.js/styles/atom-one-dark-reasonable.css';
const emit = defineEmits(['save']);
// Vue.use(vuePlugin);
const props = defineProps({
// 编辑模板code供详情接口使用
schemeCode:{
type:String,
},
// 预览历史版本wfData
pageView:String,
// 分辨是不是预览历史版本detial
pageType:String,
// 流程图
pageFlow:String,
})
const data = reactive({
height: document.documentElement.clientHeight - 144.5 + "px;",
xmlString: props.bpmnXml,
modeler: null,
controlForm: {
prefix: 'flowable',
},
element: null,
})
if(props.pageType == 'detail'){
data.height = document.documentElement.clientHeight - 294.5 + "px;"
}
const processPanel = ref < any > ()
const processDesigner = ref <any> ()
async function getFlow() {
let panel = await processPanel.value.getPanel()
let flow = await processDesigner.value.getFlow()
panel.scheme.flowContent = flow
return panel
}
async function validateFlow(){
let res = await processPanel.value.validatePanel()
return res
}
defineExpose({
getFlow,
validateFlow
})
function connectionAdded(node) {
console.log(node)
console.log('connectionAdded')
}
function connectionRemoved(node) {
console.log(node)
console.log('connectionRemoved')
}
function connectionChanged(node) {
console.log(node)
console.log('connectionChanged')
}
function elementClick(element) {
console.log(element)
data.element = element;
}
function initModeler(modeler) {
setTimeout(() => {
data.modeler = modeler;
}, 10);
}
function handlerEvent(eventName, element) {
}
function onSaveProcess(saveData) {
emit('save', saveData);
}
</script>
<style lang="scss" scoped>
body {
overflow: auto !important;
margin: 0;
box-sizing: border-box;
}
body,
body * {
/* 滚动条 */
&::-webkit-scrollbar-track-piece {
background-color: #fff;
/*滚动条的背景颜色*/
-webkit-border-radius: 0;
/*滚动条的圆角宽度*/
}
&::-webkit-scrollbar {
width: 10px;
/*滚动条的宽度*/
height: 8px;
/*滚动条的高度*/
}
&::-webkit-scrollbar-thumb:vertical {
/*垂直滚动条的样式*/
height: 50px;
background-color: rgba(153, 153, 153, 0.5);
-webkit-border-radius: 4px;
outline: 2px solid #fff;
outline-offset: -2px;
border: 2px solid #fff;
}
&::-webkit-scrollbar-thumb {
/*滚动条的hover样式*/
background-color: rgba(159, 159, 159, 0.3);
-webkit-border-radius: 4px;
}
&::-webkit-scrollbar-thumb:hover {
/*滚动条的hover样式*/
background-color: rgba(159, 159, 159, 0.5);
-webkit-border-radius: 4px;
}
}
.process-panel {
height: 100%;
}
</style>