|
@@ -6,7 +6,7 @@
|
|
|
:ID="ID"
|
|
|
:data="state.workflowData"
|
|
|
ref="ref_workflow"
|
|
|
- @save="getJsonData"
|
|
|
+ @save="onSave"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="operations">
|
|
@@ -18,7 +18,7 @@
|
|
|
<SvgIcon name="env" />
|
|
|
</div>
|
|
|
</div>
|
|
|
- <a-button type="primary" @click="getJsonData">保存配置</a-button>
|
|
|
+ <a-button type="primary" @click="onSave">保存配置</a-button>
|
|
|
</div>
|
|
|
<div class="panel">
|
|
|
<workflowPanel />
|
|
@@ -46,11 +46,13 @@ import {
|
|
|
workflowDraftDetail,
|
|
|
workflowDraftSave,
|
|
|
} from '@/api/modules/workflow/chart'
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
+import { ElLoading, ElMessage } from 'element-plus'
|
|
|
+import { debounce } from 'lodash'
|
|
|
+import { YMDHms } from '@/utils/czr-util'
|
|
|
|
|
|
const TeleportContainer = getTeleport()
|
|
|
const WorkflowStore = useWorkflowStore()
|
|
|
-const emit = defineEmits([])
|
|
|
+const emit = defineEmits(['autoSave'])
|
|
|
const props = defineProps({
|
|
|
ID: {},
|
|
|
})
|
|
@@ -61,13 +63,16 @@ const state: any = reactive({
|
|
|
})
|
|
|
const ref_workflow = ref()
|
|
|
|
|
|
+const autoSave = debounce(() => {
|
|
|
+ onSave()
|
|
|
+}, 5000)
|
|
|
watch(
|
|
|
() => WorkflowStore.autoSaveFlag,
|
|
|
() => {
|
|
|
- console.log('自动保存')
|
|
|
+ autoSave()
|
|
|
},
|
|
|
)
|
|
|
-const getJsonData = () => {
|
|
|
+const onSave = () => {
|
|
|
const data = ref_workflow.value.toJSON()
|
|
|
const offset = WorkflowStore.graph.translate()
|
|
|
const res: any = {
|
|
@@ -86,7 +91,6 @@ const getJsonData = () => {
|
|
|
}
|
|
|
JSON.parse(JSON.stringify(data.cells)).forEach((cell: any) => {
|
|
|
if (cell.shape === 'workflow-node') {
|
|
|
- console.log(cell)
|
|
|
const node: any = {
|
|
|
id: cell.id,
|
|
|
type: cell.data.workflowData.type,
|
|
@@ -107,10 +111,17 @@ const getJsonData = () => {
|
|
|
res.graph.edges.push(edge)
|
|
|
}
|
|
|
})
|
|
|
- console.log(res)
|
|
|
+ {{#175317120168.text#}}
|
|
|
+ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
|
|
|
+ const loading = ElLoading.service({
|
|
|
+ text: '自动保存中……',
|
|
|
+ background: 'rgba(0, 0,0, 0.3)',
|
|
|
+ })
|
|
|
workflowDraftSave(props.ID, res)
|
|
|
.then(({ data }: any) => {
|
|
|
+ loading.close()
|
|
|
state.uniqueHash = data.uniqueHash
|
|
|
+ emit('autoSave', data.updateTime)
|
|
|
})
|
|
|
.catch(() => {})
|
|
|
.finally(() => {})
|
|
@@ -118,6 +129,7 @@ const getJsonData = () => {
|
|
|
const initData = () => {
|
|
|
workflowDraftDetail(props.ID)
|
|
|
.then(({ data }: any) => {
|
|
|
+ emit('autoSave', data.updateTime)
|
|
|
state.uniqueHash = data.uniqueHash
|
|
|
WorkflowStore.$patch(
|
|
|
(s: any) => (s.envVars.vars = data.environmentVariables || []),
|