1 changed files with 43 additions and 46 deletions
@ -1,64 +1,61 @@ |
|||||||
<template> |
<template> |
||||||
<BasicModal |
<BasicModal |
||||||
v-bind="$attrs" |
v-bind="$attrs" |
||||||
width="720px" |
defaultFullscreen |
||||||
minHeight="100px" |
cancelText="关闭" |
||||||
|
:showOkBtn="false" |
||||||
@register="registerModal" |
@register="registerModal" |
||||||
@ok="handleSubmit" |
@visible-change="handleVisibleChange" |
||||||
> |
> |
||||||
todo |
<div id="formPreview"/> |
||||||
</BasicModal> |
</BasicModal> |
||||||
</template> |
</template> |
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import { ref, unref } from 'vue'; |
import { reactive } from 'vue'; |
||||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
import { loadMicroApp, MicroApp } from 'qiankun'; |
||||||
|
import { getSubDefineProps } from '/@/qiankun/state'; |
||||||
|
import { GlStateEnum } from '/@/enums/microAppEnum'; |
||||||
|
import { useMicroAppStore } from '/@/store/modules/microApp'; |
||||||
|
import { apps } from '/@/qiankun/apps'; |
||||||
|
import { FORM_DESIGN_APP_COMPONENTS } from '/@/enums/microAppEnum'; |
||||||
|
|
||||||
/** 通用变量统一声明区域 */ |
interface TableState { |
||||||
const tag = ref<Nullable<string>>(''); |
formDesignApp: MicroApp; |
||||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
} |
||||||
|
|
||||||
|
const state = reactive<TableState>({ |
||||||
|
formDesignApp: undefined!, |
||||||
|
}); |
||||||
|
const formPreviewProps = { |
||||||
|
style: { height: 'calc(100vh - 160px)' }, |
||||||
|
options: {}, |
||||||
|
disabled: false, |
||||||
|
readonly: false, |
||||||
|
formSubmitSuccess: () => {}, |
||||||
|
formSubmitError: () => {}, |
||||||
|
formResetChange: () => {} |
||||||
|
}; |
||||||
const emit = defineEmits(['success', 'register']); |
const emit = defineEmits(['success', 'register']); |
||||||
|
const microAppStore = useMicroAppStore(); |
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
||||||
// 处理清除脏数据 |
state.formDesignApp = loadMicroApp(Object.assign({} , apps.find(item => item.name == 'form-design'), { |
||||||
|
container: '#formPreview', |
||||||
// 处理设置数据 |
props: { |
||||||
tag.value = data._tag; |
...getSubDefineProps(), |
||||||
const id = data.record?.id; |
// 表单设计器props |
||||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
[GlStateEnum.FORM_DESIGN_APP_PROPS_KEY]: formPreviewProps, |
||||||
// 采用tag标签区分操作 |
mountApp: FORM_DESIGN_APP_COMPONENTS.PREVIEW |
||||||
switch (unref(tag)) { |
|
||||||
case 'add': |
|
||||||
props.title = '新增流程表单'; |
|
||||||
break; |
|
||||||
case 'edit': |
|
||||||
props.title = '编辑流程表单'; |
|
||||||
// await setFieldsValue(await getFormDefinition(id)); |
|
||||||
break; |
|
||||||
} |
} |
||||||
// 尾部:设置处理后的最终配置数据 |
}), { sandbox: { experimentalStyleIsolation: true }}); |
||||||
|
data?.json && (formPreviewProps.options = data?.json); |
||||||
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
|
props.title = '预览流程表单'; |
||||||
setModalProps(props); |
setModalProps(props); |
||||||
}); |
}); |
||||||
|
|
||||||
/** 处理弹出框提交 */ |
function handleVisibleChange(visible: boolean) { |
||||||
async function handleSubmit() { |
!visible && state.formDesignApp.unmount(); |
||||||
try { |
|
||||||
// 提取验证数据 |
|
||||||
|
|
||||||
// 处理提交之前逻辑 |
|
||||||
setModalProps({ confirmLoading: true }); |
|
||||||
// 采用tag标签区分操作 |
|
||||||
switch (unref(tag)) { |
|
||||||
case 'add': |
|
||||||
|
|
||||||
break; |
|
||||||
case 'edit': |
|
||||||
|
|
||||||
break; |
|
||||||
} |
|
||||||
// 处理提交完成之后逻辑 |
|
||||||
closeModal(); |
|
||||||
emit('success'); |
|
||||||
} finally { |
|
||||||
setModalProps({ confirmLoading: false }); |
|
||||||
} |
|
||||||
} |
} |
||||||
|
|
||||||
</script> |
</script> |
||||||
|
Loading…
Reference in new issue