UNPKG

@javaguns/flow-ui

Version:

``` <template> <a-spin :spinning="loading"> <FlowDesigner ref="flowDesigner" top="50px"> </FlowDesigner> </a-spin> </template> <script lang="ts" setup> import { ref, provide, onMounted } from 'vue'; import { FlowDesigner, LoadingKey } from '@j

61 lines (60 loc) 1.87 kB
import { ref as o } from "vue"; import { saveDesign as w, updateDesignUpgrade as g, getDesign as K } from "../../utils/api.mjs"; import { useNode as j } from "../../hooks/useNode.mjs"; import N from "../../hooks/useData.mjs"; function J(e, i, t, d) { const { initNode: c } = N(), { validate: n } = j(), l = o(null), s = o(null), I = o(!1), v = () => { i("close"); }, m = () => { i("preview", { modelId: l.value, definitionId: s.value }); }, y = async () => { if (!n(e.value)) return e.value; if (t.value = !0, e.value && l.value) { const a = { modelId: l.value, definitionId: s.value, node: e.value }; I.value ? t.value = !1 : (await w(a), t.value = !1, v()); } else t.value = !1; return e.value; }, p = async () => { if (!n(e.value)) return e.value; if (t.value = !0, console.log("getValue", JSON.stringify(e)), e.value && l.value) { const a = { modelId: l.value, definitionId: s.value, node: e.value }; await g(a), t.value = !1, v(); } else t.value = !1; }, D = async () => { const a = { modelId: l.value, definitionId: s.value }; f(a); }, f = async (a) => { const r = a.json; if (r) Object.assign(e.value, r); else { t.value = !0, d(a.modelId, a.definitionId); const u = await K({ modelId: a.modelId, formKey: a.formKey, modelKey: a.modelKey, edit: !0 }); u && u.data && u.data.data ? e.value = u.data.data : e.value = c(), l.value = a.modelId, s.value = a.definitionId, t.value = !1, i("load", { node: e.value }); } }; return { loading: t, publish: y, upgrade: p, refresh: D, preview: m, close: v, setData: f, getData: () => e.value, modelId: l, definitionId: s }; } export { J as useInteraction };