添加导出json

This commit is contained in:
caixiaofeng 2024-01-24 15:58:32 +08:00
parent 98e6855935
commit a6e3c981c1
2 changed files with 29 additions and 4 deletions

View File

@ -20,7 +20,7 @@ const $props = defineProps<FlowDesignProps>()
const $emits = defineEmits(['update:process', 'update:fields']) const $emits = defineEmits(['update:process', 'update:fields'])
const {fields} = useVModels($props, $emits) const {fields} = useVModels($props, $emits)
const process = ref<FlowNode>($props.process) const process = ref<FlowNode>($props.process)
const { undo, redo, canUndo, canRedo} = useRefHistory(process, {deep: true, clone: cloneDeep }) const {undo, redo, canUndo, canRedo} = useRefHistory(process, {deep: true, clone: cloneDeep})
const nodePenalRef = ref<InstanceType<typeof NodePenal>>() const nodePenalRef = ref<InstanceType<typeof NodePenal>>()
const zoom = ref(100) const zoom = ref(100)
const getScale = computed(() => zoom.value / 100) const getScale = computed(() => zoom.value / 100)
@ -79,6 +79,30 @@ const converterBpmn = () => {
} }
downloadXml(processModel) downloadXml(processModel)
} }
const downloadJson = () => {
const processModel = {
code: 'test',
name: '测试',
icon: {
name: 'el:HomeFilled',
color: '#409EFF',
},
process: process.value,
form: {
fields: fields.value
},
version: 1,
sort: 0,
groupId: '',
remark: '',
}
const blob = new Blob([JSON.stringify(processModel, null, 2)], {type: 'application/json'})
const a = document.createElement('a')
a.download = 'process.json'
a.href = URL.createObjectURL(blob)
a.click()
URL.revokeObjectURL(a.href)
}
// shift/ // shift/
window.addEventListener('wheel', handleZoom) window.addEventListener('wheel', handleZoom)
// //
@ -89,7 +113,7 @@ onUnmounted(() => {
<template> <template>
<div class="designer-container"> <div class="designer-container">
<div class="dark"> <div class="tool">
<el-switch <el-switch
inline-prompt inline-prompt
:active-icon="Sunny" :active-icon="Sunny"
@ -105,6 +129,7 @@ onUnmounted(() => {
<el-button @click="undo()" :disabled="!canUndo" :icon="TopLeft">撤销</el-button> <el-button @click="undo()" :disabled="!canUndo" :icon="TopLeft">撤销</el-button>
<el-button @click="redo()" :disabled="!canRedo" :icon="TopRight">重做</el-button> <el-button @click="redo()" :disabled="!canRedo" :icon="TopRight">重做</el-button>
<el-button @click="validate">校验</el-button> <el-button @click="validate">校验</el-button>
<el-button @click="downloadJson" type="primary" :icon="Download">导出json</el-button>
<el-button @click="converterBpmn" type="primary" :icon="Download">转bpmn</el-button> <el-button @click="converterBpmn" type="primary" :icon="Download">转bpmn</el-button>
</div> </div>
<!--流程树--> <!--流程树-->
@ -138,7 +163,7 @@ onUnmounted(() => {
} }
} }
.dark { .tool {
position: fixed; position: fixed;
z-index: 999; z-index: 999;
top: 10px; top: 10px;

View File

@ -38,7 +38,7 @@ defineExpose({
</script> </script>
<template> <template>
<el-drawer v-model="visible" size="35%"> <el-drawer v-model="visible" destroy-on-close size="35%">
<template #header="{ titleId, titleClass }"> <template #header="{ titleId, titleClass }">
<span :id="titleId" :class="titleClass"> <span :id="titleId" :class="titleClass">
<el-input v-click-outside="onClickOutside" @blur="onClickOutside" maxlength="30" v-model="flowNode!.name" <el-input v-click-outside="onClickOutside" @blur="onClickOutside" maxlength="30" v-model="flowNode!.name"