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

View File

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