|
|
@ -7,7 +7,7 @@ |
|
|
|
@register="registerModal" |
|
|
|
@register="registerModal" |
|
|
|
@visible-change="handleVisibleChange" |
|
|
|
@visible-change="handleVisibleChange" |
|
|
|
> |
|
|
|
> |
|
|
|
<div id="formDesign"/> |
|
|
|
<div id="workflowDesign"/> |
|
|
|
</BasicModal> |
|
|
|
</BasicModal> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
@ -15,102 +15,65 @@ |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import { loadMicroApp, MicroApp } from 'qiankun'; |
|
|
|
import { loadMicroApp, MicroApp } from 'qiankun'; |
|
|
|
import { getSubDefineProps } from '/@/qiankun/state'; |
|
|
|
import { getSubDefineProps } from '/@/qiankun/state'; |
|
|
|
import { GlStateEnum } from '/@/enums/microAppEnum'; |
|
|
|
import { GlStateEnum, WORKFLOW_DESIGN_APP_COMPONENTS } from '/@/enums/microAppEnum'; |
|
|
|
import { useMicroAppStore } from '/@/store/modules/microApp'; |
|
|
|
import { useMicroAppStore } from '/@/store/modules/microApp'; |
|
|
|
import { apps } from '/@/qiankun/apps'; |
|
|
|
import { apps } from '/@/qiankun/apps'; |
|
|
|
import { addFormDefinitionJson, editFormDefinitionJson, getFormDefinitionJson } from '/@/api/platform/workflow/extension/controller/formDefinitionJson'; |
|
|
|
import { getModel } from '/@/api/platform/workflow/controller/modelResource'; |
|
|
|
import { FormDefinitionJson } from '/@/api/platform/workflow/extension/entity/formDefinitionJson'; |
|
|
|
import { getModelXml } from '/@/api/platform/workflow/controller/model'; |
|
|
|
import { FORM_DESIGN_APP_COMPONENTS } from '/@/enums/microAppEnum'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface TableState { |
|
|
|
interface TableState { |
|
|
|
tag: string; |
|
|
|
tag: string; |
|
|
|
formDesignApp: MicroApp; |
|
|
|
workflowDesignApp: MicroApp; |
|
|
|
form: Partial<FormDefinitionJson>; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const state = reactive<TableState>({ |
|
|
|
const state = reactive<TableState>({ |
|
|
|
tag: '', |
|
|
|
tag: '', |
|
|
|
formDesignApp: undefined!, |
|
|
|
workflowDesignApp: undefined!, |
|
|
|
form: { |
|
|
|
|
|
|
|
id: undefined!, |
|
|
|
|
|
|
|
formDefinitionId: undefined!, |
|
|
|
|
|
|
|
json: undefined!, |
|
|
|
|
|
|
|
version: undefined!, |
|
|
|
|
|
|
|
status: undefined!, |
|
|
|
|
|
|
|
isPrimary: undefined! |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const formDesignProps = { |
|
|
|
const workflowDesignProps = { |
|
|
|
undoRedo: false, |
|
|
|
|
|
|
|
style: { height: 'calc(100vh - 160px)' }, |
|
|
|
style: { height: 'calc(100vh - 160px)' }, |
|
|
|
toolbar: ['clear', 'preview'], |
|
|
|
workflowSubmitSuccess: () => emit('success') |
|
|
|
options: {} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const microAppStore = useMicroAppStore(); |
|
|
|
const microAppStore = useMicroAppStore(); |
|
|
|
const [registerModal, { setModalProps, closeModal, changeLoading }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
|
|
|
const [registerModal, { setModalProps, closeModal, changeLoading }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
|
|
|
changeLoading(); |
|
|
|
changeLoading(); |
|
|
|
state.formDesignApp = loadMicroApp(Object.assign({} , apps.find(item => item.name == 'form-design'), { |
|
|
|
state.workflowDesignApp = loadMicroApp(Object.assign({} , apps.find(item => item.name == 'workflow-design'), { |
|
|
|
container: '#formDesign', |
|
|
|
container: '#workflowDesign', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
...getSubDefineProps(), |
|
|
|
...getSubDefineProps(), |
|
|
|
// 表单设计器props |
|
|
|
[GlStateEnum.WORKFLOW_DESIGN_APP_PROPS_KEY]: workflowDesignProps |
|
|
|
[GlStateEnum.FORM_DESIGN_APP_PROPS_KEY]: formDesignProps |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}), { sandbox: { experimentalStyleIsolation: true }}); |
|
|
|
}), { sandbox: { experimentalStyleIsolation: true }}); |
|
|
|
state.formDesignApp.mountPromise.then(() => { |
|
|
|
state.workflowDesignApp.mountPromise.then(() => { |
|
|
|
changeLoading(false); |
|
|
|
changeLoading(false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 处理清除脏数据 |
|
|
|
// 处理清除脏数据 |
|
|
|
state.form = {}; |
|
|
|
|
|
|
|
formDesignProps.options = {}; |
|
|
|
|
|
|
|
state.tag = data._tag; |
|
|
|
state.tag = data._tag; |
|
|
|
const id = data.record?.id; |
|
|
|
const id = data.record?.id; |
|
|
|
state.form.formDefinitionId = data.record?.formDefinitionId; |
|
|
|
const workflowDesignApp: Recordable = microAppStore.getWorkflowDesignApp(WORKFLOW_DESIGN_APP_COMPONENTS.DESIGN), |
|
|
|
|
|
|
|
workflowRef: Recordable = workflowDesignApp.getRef().$refs['workflow-design']; |
|
|
|
|
|
|
|
workflowRef.setBpmnXml(''); |
|
|
|
|
|
|
|
workflowRef.reset(); |
|
|
|
// 处理设置数据 |
|
|
|
// 处理设置数据 |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
switch (state.tag) { |
|
|
|
switch (state.tag) { |
|
|
|
case 'add': |
|
|
|
case 'add': |
|
|
|
props.title = '新增流程表单'; |
|
|
|
props.title = '新增流程模型'; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'edit': |
|
|
|
case 'edit': |
|
|
|
props.title = '编辑流程表单'; |
|
|
|
props.title = '编辑流程模型'; |
|
|
|
state.form = await getFormDefinitionJson(id); |
|
|
|
const modelRepresentation = await getModel(id); |
|
|
|
state.form?.json && (formDesignProps.options = state.form.json); |
|
|
|
workflowRef.setModelData(modelRepresentation); |
|
|
|
|
|
|
|
const bpmnXml = await getModelXml(id); |
|
|
|
|
|
|
|
workflowRef.setBpmnXml(bpmnXml); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
setModalProps(props); |
|
|
|
setModalProps(props); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function handleVisibleChange(visible: boolean) { |
|
|
|
function handleVisibleChange(visible: boolean) { |
|
|
|
!visible && state.formDesignApp.unmount(); |
|
|
|
!visible && state.workflowDesignApp.unmount(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 处理弹出框提交 */ |
|
|
|
|
|
|
|
async function handleSubmitForm(status: string) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const formDesignApp: Recordable = microAppStore.getFormDesignApp(FORM_DESIGN_APP_COMPONENTS.DESIGN), |
|
|
|
|
|
|
|
formRef: Recordable = formDesignApp.getRef().$refs['form-design']; |
|
|
|
|
|
|
|
state.form.json = formRef.getWidgetFormJson(); |
|
|
|
|
|
|
|
state.form.status = status; |
|
|
|
|
|
|
|
state.form.isPrimary = '1'; |
|
|
|
|
|
|
|
// 处理提交之前逻辑 |
|
|
|
|
|
|
|
setModalProps({ confirmLoading: true }); |
|
|
|
|
|
|
|
// 采用tag标签区分操作 |
|
|
|
|
|
|
|
switch (state.tag) { |
|
|
|
|
|
|
|
case 'add': |
|
|
|
|
|
|
|
await addFormDefinitionJson(state.form); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'edit': |
|
|
|
|
|
|
|
await editFormDefinitionJson(state.form); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 处理提交完成之后逻辑 |
|
|
|
|
|
|
|
closeModal(); |
|
|
|
|
|
|
|
emit('success'); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
setModalProps({ confirmLoading: false }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|