chore: 优化代码生成模板

This commit is contained in:
xlsea 2024-09-09 11:10:39 +08:00
parent 1bb3e53656
commit 74529144aa
2 changed files with 12 additions and 10 deletions

View File

@ -92,14 +92,14 @@ async function handleSubmit() {
// request
if (props.operateType === 'add') {
const { #foreach($column in $columns)#if($column.insert)$column.javaType#if($foreach.hasNext), #end#end#end } = model;
const { error } = await fetchCreate${BusinessName}({ #foreach($column in $columns)#if($column.insert)$column.javaType#if($foreach.hasNext), #end#end#end });
const { #foreach($column in $columns)#if($column.insert)$column.javaField#if($foreach.hasNext), #end#end#end } = model;
const { error } = await fetchCreate${BusinessName}({ #foreach($column in $columns)#if($column.insert)$column.javaField#if($foreach.hasNext), #end#end#end });
if (error) return;
}
if (props.operateType === 'edit') {
const { #foreach($column in $columns)#if($column.edit)$column.javaType#if($foreach.hasNext), #end#end#end } = model;
const { error } = await fetchUpdate${BusinessName}({ #foreach($column in $columns)#if($column.edit)$column.javaType#if($foreach.hasNext), #end#end#end });
const { #foreach($column in $columns)#if($column.edit)$column.javaField#if($foreach.hasNext), #end#end#end } = model;
const { error } = await fetchUpdate${BusinessName}({ #foreach($column in $columns)#if($column.edit)$column.javaField#if($foreach.hasNext), #end#end#end });
if (error) return;
}
@ -136,7 +136,7 @@ watch(visible, () => {
v-model:value="model.$column.javaField"
:rows="3"
type="textarea"
:placeholder="请输入$column.columnComment"
placeholder="请输入$column.columnComment"
/>
#elseif($column.htmlType == "select" && "" != $dictType)
<NSelect

View File

@ -21,8 +21,7 @@ const { formRef, validate, restoreValidation } = useNaiveForm();
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
const dateRange${AttrName} = ref<[string, string]>();
#end
#end
#end#end
const model = defineModel<Api.$ModuleName.${BusinessName}SearchParams>('model', { required: true });
@ -30,6 +29,7 @@ const model = defineModel<Api.$ModuleName.${BusinessName}SearchParams>('model',
#foreach($dict in $dictList)
const { options: ${dict.name}Options } = useDict(${dict.type}#if($dict.immediate), false#end);
#end#end
async function reset() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
@ -60,7 +60,7 @@ async function search() {
<NCard :bordered="false" size="small" class="card-wrapper">
<NCollapse>
<NCollapseItem :title="$t('common.search')" name="user-search">
<NForm ref="formRef" :model="model" :rules="rules" label-placement="left" :label-width="80">
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
<NGrid responsive="screen" item-responsive>
#foreach($column in $columns)
#if($column.query)
@ -129,8 +129,10 @@ async function search() {
</NButton>
</NSpace>
</NFormItemGi>
</NGrid>
</NForm>
</NGrid>
</NForm>
</NCollapseItem>
</NCollapse>
</NCard>
</template>