-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
452 additions
and
646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
continew-admin-generator/src/main/resources/templates/api.ftl
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
103 changes: 103 additions & 0 deletions
103
continew-admin-generator/src/main/resources/templates/frontend/AddModal.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<template> | ||
<a-modal | ||
v-model:visible="visible" | ||
:title="title" | ||
:mask-closable="false" | ||
:esc-to-close="false" | ||
:modal-style="{ maxWidth: '520px' }" | ||
width="90%" | ||
@before-ok="save" | ||
@close="reset" | ||
> | ||
<GiForm ref="formRef" v-model="form" :options="options" :columns="columns" /> | ||
</a-modal> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { get${classNamePrefix}, add${classNamePrefix}, update${classNamePrefix} } from '@/apis' | ||
import { Message } from '@arco-design/web-vue' | ||
import { GiForm, type Columns } from '@/components/GiForm' | ||
import { useForm } from '@/hooks' | ||
const dataId = ref('') | ||
const isUpdate = computed(() => !!dataId.value) | ||
const title = computed(() => (isUpdate.value ? '修改${businessName}' : '新增${businessName}')) | ||
const formRef = ref<InstanceType<typeof GiForm>>() | ||
const options: Options = { | ||
form: {}, | ||
col: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 }, | ||
btns: { hide: true } | ||
} | ||
const columns: Columns = [ | ||
<#list fieldConfigs as fieldConfig> | ||
<#if fieldConfig.showInForm> | ||
{ | ||
label: '${fieldConfig.comment}', | ||
field: '${fieldConfig.fieldName}', | ||
<#if fieldConfig.formType = 'TEXT'> | ||
type: 'input', | ||
<#elseif fieldConfig.formType = 'TEXT_AREA'> | ||
type: 'textarea', | ||
</#if> | ||
<#if fieldConfig.isRequired> | ||
rules: [{ required: true, message: '请输入${fieldConfig.comment}' }] | ||
</#if> | ||
}, | ||
</#if> | ||
</#list> | ||
] | ||
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 { | ||
const isInvalid = await formRef.value?.formRef?.validate() | ||
if (isInvalid) return false | ||
if (isUpdate.value) { | ||
await update${classNamePrefix}(form, dataId.value) | ||
Message.success('修改成功') | ||
} else { | ||
await add${classNamePrefix}(form) | ||
Message.success('新增成功') | ||
} | ||
emit('save-success') | ||
return true | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
const emit = defineEmits<{ | ||
(e: 'save-success'): void | ||
}>() | ||
defineExpose({ onAdd, onUpdate }) | ||
</script> |
Oops, something went wrong.