3 changed files with 121 additions and 8 deletions
@ -0,0 +1,101 @@ |
|||||||
|
<template> |
||||||
|
<BasicModal v-bind="$attrs" |
||||||
|
width="720px" |
||||||
|
@register="registerModal" |
||||||
|
@ok="handleSubmit" |
||||||
|
> |
||||||
|
<loquat-form-design ref="loquat-form-design" |
||||||
|
style="height:calc(100vh - 133px)" |
||||||
|
:toolbar="['clear', 'preview']" |
||||||
|
:options="state.options" |
||||||
|
:custom-fields="state.customFields" |
||||||
|
/> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup> |
||||||
|
import { reactive } from 'vue'; |
||||||
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
|
||||||
|
interface TableState { |
||||||
|
tag: string; |
||||||
|
options: Recordable; |
||||||
|
customFields: Recordable[]; |
||||||
|
} |
||||||
|
|
||||||
|
const state = reactive<TableState>({ |
||||||
|
tag: '', |
||||||
|
options: {}, |
||||||
|
customFields: [{ |
||||||
|
title: '自定义字段', |
||||||
|
list: [ |
||||||
|
{ |
||||||
|
title: '分割线', |
||||||
|
type: 'custom', |
||||||
|
component: 'el-divider', |
||||||
|
icon: 'iconfont icon-divider', |
||||||
|
label: '', |
||||||
|
propExclude: true, |
||||||
|
labelWidth: 0, |
||||||
|
params: { |
||||||
|
html: '<h3 style="color:red">分割线标题</h3>', |
||||||
|
contentPosition: 'left' |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '警告', |
||||||
|
type: 'custom', |
||||||
|
component: 'el-alert', |
||||||
|
icon: 'el-icon-warning', |
||||||
|
label: '', |
||||||
|
propExclude: true, |
||||||
|
labelWidth: 0, |
||||||
|
params: { |
||||||
|
title: '警告警告警告警告', |
||||||
|
type: 'success' |
||||||
|
}, |
||||||
|
events: { |
||||||
|
close () { |
||||||
|
console.log('alert关闭事件'); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
}], |
||||||
|
}); |
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
||||||
|
state.tag = data._tag; |
||||||
|
const id = data.record?.id; |
||||||
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
|
switch (state.tag) { |
||||||
|
case 'add': |
||||||
|
props.title = '新增流程表单'; |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
props.title = '编辑流程表单'; |
||||||
|
break; |
||||||
|
} |
||||||
|
setModalProps(props); |
||||||
|
}); |
||||||
|
|
||||||
|
/** 处理弹出框提交 */ |
||||||
|
async function handleSubmit() { |
||||||
|
try { |
||||||
|
// 处理提交之前逻辑 |
||||||
|
setModalProps({ confirmLoading: true }); |
||||||
|
// 采用tag标签区分操作 |
||||||
|
switch (state.tag) { |
||||||
|
case 'add': |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
break; |
||||||
|
} |
||||||
|
// 处理提交完成之后逻辑 |
||||||
|
closeModal(); |
||||||
|
emit('success'); |
||||||
|
} finally { |
||||||
|
setModalProps({ confirmLoading: false }); |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
Loading…
Reference in new issue