diff --git a/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/AddModal.ftl b/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/AddModal.ftl index e42ee3ce..aa452a91 100644 --- a/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/AddModal.ftl +++ b/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/AddModal.ftl @@ -4,8 +4,7 @@ :title="title" :mask-closable="false" :esc-to-close="false" - :modal-style="{ maxWidth: '520px' }" - width="90%" + :width="width >= 600 ? 600 : '100%'" @before-ok="save" @close="reset" > @@ -25,6 +24,7 @@ const emit = defineEmits<{ }>() const dataId = ref('') +const visible = ref(false) const isUpdate = computed(() => !!dataId.value) const title = computed(() => (isUpdate.value ? '修改${businessName}' : '新增${businessName}')) const formRef = ref>() @@ -34,15 +34,11 @@ const { <#list dictCodes as dictCode>${dictCode}<#if dictCode_has_next>, const options: Options = { - form: {}, - btns: { hide: true } + form: { size: 'large' }, + btns: { hide: true }, } -const { form, resetForm } = useForm({ - // todo 待补充 -}) - -const columns = computed>(() => [ +const columns: Columns = reactive([ <#list fieldConfigs as fieldConfig> <#if fieldConfig.showInForm> { @@ -69,7 +65,7 @@ const columns = computed>(() => [ <#elseif fieldConfig.formType = 'SELECT'> type: 'select', <#elseif fieldConfig.formType = 'RADIO'> - type: 'radio-group' + type: 'radio-group', <#if fieldConfig.dictCode?? && fieldConfig.dictCode != ''> options: ${fieldConfig.dictCode}, @@ -82,29 +78,16 @@ const columns = computed>(() => [ ]) +const { form, resetForm } = useForm({ + // todo 待补充 +}) + // 重置 const reset = () => { formRef.value?.formRef?.resetFields() resetForm() } -const visible = ref(false) -// 新增 -const onAdd = () => { - reset() - dataId.value = '' - visible.value = true -} - -// 修改 -const onUpdate = async (id: string) => { - reset() - dataId.value = id - const res = await get${classNamePrefix}(id) - Object.assign(form, res.data) - visible.value = true -} - // 保存 const save = async () => { try { @@ -124,5 +107,21 @@ const save = async () => { } } +// 新增 +const onAdd = async () => { + reset() + dataId.value = '' + visible.value = true +} + +// 修改 +const onUpdate = async (id: string) => { + reset() + dataId.value = id + const { data } = await get${classNamePrefix}(id) + Object.assign(form, data) + visible.value = true +} + defineExpose({ onAdd, onUpdate }) diff --git a/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/DetailDrawer.ftl b/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/DetailDrawer.ftl index e568350f..7a39bc2f 100644 --- a/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/DetailDrawer.ftl +++ b/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/DetailDrawer.ftl @@ -1,5 +1,5 @@ - diff --git a/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/index.ftl b/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/index.ftl index b2fa0249..0c39fd8c 100644 --- a/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/index.ftl +++ b/continew-plugin/continew-plugin-generator/src/main/resources/templates/frontend/index.ftl @@ -83,13 +83,13 @@