fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
|
<fullscreen-dialog v-model="dialogVisible" @close="onClose" hide-destroy>
|
||||||
<div class="canvas-box">
|
<div class="canvas-box">
|
||||||
<depth-canvas :config="config" @workbench="onWorkbench" @close="onClose" />
|
<depth-canvas :config="config" @workbench="onWorkbench" @close="onClose" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -146,7 +146,7 @@
|
|||||||
const { layout } = useLayout()
|
const { layout } = useLayout()
|
||||||
const index = ref(0)
|
const index = ref(0)
|
||||||
async function layoutGraph(direction) {
|
async function layoutGraph(direction) {
|
||||||
if (props.config.json > 0) return
|
if (props.config.json.length > 0) return
|
||||||
if (index.value > 0) return
|
if (index.value > 0) return
|
||||||
index.value++
|
index.value++
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -187,10 +187,14 @@
|
|||||||
stateManager.sendToBack(id)
|
stateManager.sendToBack(id)
|
||||||
}
|
}
|
||||||
// 导出流程
|
// 导出流程
|
||||||
|
const getFlowJson = () => {
|
||||||
|
if(!stateManager.isSave.value)return ''
|
||||||
|
return JSON.stringify(stateManager.nodes.value)
|
||||||
|
}
|
||||||
const exportFlow = () => {
|
const exportFlow = () => {
|
||||||
// flowManager.exportFlow()
|
// flowManager.exportFlow()
|
||||||
|
const str = getFlowJson()
|
||||||
const str = JSON.stringify(stateManager.nodes.value)
|
stateManager.isSave.value = false
|
||||||
emit('exportFlow', str)
|
emit('exportFlow', str)
|
||||||
// localStorage.setItem('flow_json', str)
|
// localStorage.setItem('flow_json', str)
|
||||||
}
|
}
|
||||||
@@ -259,6 +263,9 @@
|
|||||||
nodeManager.dispose()
|
nodeManager.dispose()
|
||||||
toolManager.dispose()
|
toolManager.dispose()
|
||||||
})
|
})
|
||||||
|
defineExpose({
|
||||||
|
getFlowJson
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@import '@vue-flow/core/dist/style.css';
|
@import '@vue-flow/core/dist/style.css';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
|
<fullscreen-dialog v-model="dialogVisible" @close="close" hide-destroy>
|
||||||
<flow-canvas :config="config" @exportFlow="exportFlow" />
|
<flow-canvas ref="flowCanvasRef" :config="config" @exportFlow="exportFlow" />
|
||||||
</fullscreen-dialog>
|
</fullscreen-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const config = ref({}) as any
|
const config = ref({}) as any
|
||||||
|
const flowCanvasRef = ref<any>()
|
||||||
const open = async (options) => {
|
const open = async (options) => {
|
||||||
let json = []
|
let json = []
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
const exportFlow = async (str) => {
|
const exportFlow = async (str) => {
|
||||||
if(!config.value.imgId)return
|
if(!config.value.imgId || !str)return
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
putSketchFlowCanvas({
|
putSketchFlowCanvas({
|
||||||
id: config.value.imgId,
|
id: config.value.imgId,
|
||||||
@@ -41,7 +42,9 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const close = () => {
|
const close = async () => {
|
||||||
|
const str = flowCanvasRef.value?.getFlowJson()
|
||||||
|
await exportFlow(str)
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ export class StateManager {
|
|||||||
nodeManager: any
|
nodeManager: any
|
||||||
toolManager: any
|
toolManager: any
|
||||||
generateManager: any
|
generateManager: any
|
||||||
|
|
||||||
|
// 是否有数据没保存
|
||||||
|
isSave: any
|
||||||
// 设置管理器
|
// 设置管理器
|
||||||
setManager(options) {
|
setManager(options) {
|
||||||
options.eventManager && (this.eventManager = options.eventManager)
|
options.eventManager && (this.eventManager = options.eventManager)
|
||||||
@@ -54,6 +57,7 @@ export class StateManager {
|
|||||||
this.mxHistory = ref(50)
|
this.mxHistory = ref(50)
|
||||||
this.historyList = ref([])
|
this.historyList = ref([])
|
||||||
this.historyIndex = ref(0)
|
this.historyIndex = ref(0)
|
||||||
|
this.isSave = ref(false)
|
||||||
|
|
||||||
this.activeNodeID = ref("")
|
this.activeNodeID = ref("")
|
||||||
this.nodes = ref<NodesItem[]>([]);
|
this.nodes = ref<NodesItem[]>([]);
|
||||||
@@ -172,6 +176,8 @@ export class StateManager {
|
|||||||
const size = this.historyList.value.length - this.mxHistory.value
|
const size = this.historyList.value.length - this.mxHistory.value
|
||||||
if (size > 0) this.historyList.value.splice(0, size)
|
if (size > 0) this.historyList.value.splice(0, size)
|
||||||
this.historyIndex.value = this.historyList.value.length - 1
|
this.historyIndex.value = this.historyList.value.length - 1
|
||||||
|
|
||||||
|
this.isSave.value = true
|
||||||
}
|
}
|
||||||
/** 撤回状态 */
|
/** 撤回状态 */
|
||||||
undoState() {
|
undoState() {
|
||||||
@@ -205,6 +211,7 @@ export class StateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
this.isSave.value = false
|
||||||
this.historyList.value = []
|
this.historyList.value = []
|
||||||
this.historyIndex.value = 0
|
this.historyIndex.value = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
transitionTime: { default: 300, type: Number },
|
transitionTime: { default: 300, type: Number },
|
||||||
hideDestroy: { default: false, type: Boolean }
|
hideDestroy: { default: false, type: Boolean }
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['update:modelValue', 'closed'])
|
const emit = defineEmits(['close', 'closed'])
|
||||||
const show = ref(props.modelValue)
|
const show = ref(props.modelValue)
|
||||||
const show_ = ref(props.modelValue)
|
const show_ = ref(props.modelValue)
|
||||||
const timeout = ref(null)
|
const timeout = ref(null)
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const close = () => {
|
const close = () => {
|
||||||
emit('update:modelValue', false)
|
emit('close', false)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user