Files
FiDA_Front/src/components/Canvas/FlowCanvas/index.vue
X1627315083@163.com 1333a885d1 fix
2026-03-13 15:06:33 +08:00

55 lines
1.2 KiB
Vue

<template>
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
<flow-canvas :config="config" @exportFlow="exportFlow" />
</fullscreen-dialog>
</template>
<script setup lang="ts">
import FullscreenDialog from '../components/fullscreen-dialog.vue'
import flowCanvas from './flow-canvas.vue'
import { ref } from 'vue'
import { getSketchFlowCanvas, putSketchFlowCanvas } from '@/api/flow-canvas'
const dialogVisible = ref(false)
const config = ref({}) as any
const open = async (options) => {
let json = []
await new Promise((resolve) => {
getSketchFlowCanvas({ id: options.imgId }).then((res:any) => {
if (res) {
json = JSON.parse(res)
}
resolve(true)
}).catch(() => {
resolve(true)
})
})
config.value = options || {}
config.value.json = json
dialogVisible.value = true
}
const exportFlow = async (str) => {
if(!config.value.imgId)return
await new Promise((resolve) => {
putSketchFlowCanvas({
id: config.value.imgId,
canvasData: str }).then(() => {
resolve(true)
}).catch(() => {
resolve(true)
})
})
}
const close = () => {
dialogVisible.value = false
}
defineExpose({
open,
close,
exportFlow
})
</script>
<style lang="less" scoped>
</style>