refactor: 优化 antd 模板代码生成示例提到的一些问题

This commit is contained in:
puhui999
2025-04-27 18:16:38 +08:00
parent 5c4b95b01e
commit 994b444319
4 changed files with 49 additions and 39 deletions

View File

@@ -26,11 +26,9 @@ import { ImageUpload } from '#/components/upload';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
const emit = defineEmits(['success']); // TODO @puhui999emit 和下面空一行?
const emit = defineEmits(['success']);
const formRef = ref();
// TODO @puhui999labelCol、wrapperCol 直接写?不用单独定义变量,
const labelCol = { span: 5 };
const wrapperCol = { span: 13 };
const formData = ref<Partial<Demo01ContactApi.Demo01Contact>>({
id: undefined,
name: undefined,
@@ -90,8 +88,7 @@ const [Modal, modalApi] = useVbenModal({
resetForm();
return;
}
// 加载数据 TODO @puhui999这里不用空行
// 加载数据
let data = modalApi.getData<Demo01ContactApi.Demo01Contact>();
if (!data) {
return;
@@ -115,8 +112,8 @@ const [Modal, modalApi] = useVbenModal({
ref="formRef"
:model="formData"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 18 }"
>
<Form.Item label="名字" name="name">
<Input v-model:value="formData.name" placeholder="请输入名字" />