Forráskód Böngészése

代码生成器模板调整

bing 1 éve
szülő
commit
549f395efe

+ 23 - 19
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/DetailForm.vue.vm

@@ -1,7 +1,7 @@
 <template>
   <div class="p-2">
     <el-dialog v-model="dialog.visible" :title="dialog.title" width="600px" :draggable="draggable">
-      <el-form ref="formRef" v-loading="formLoading" :model="formData" :rules="formRules"  label-width="80px">
+      <el-form ref="formRef" v-loading="formLoading" :model="formData" :rules="formRules" label-width="80px">
 #foreach($column in $columns)
 #set($field=$column.javaField)
 #if(($column.insert || $column.edit) && !$column.pk)
@@ -88,11 +88,7 @@
         </el-form-item>
 #elseif($column.htmlType == "datetime")
         <el-form-item label="${comment}" prop="${field}">
-          <el-date-picker clearable
-            v-model="form.${field}"
-            type="datetime"
-            value-format="YYYY-MM-DD HH:mm:ss"
-            placeholder="请选择${comment}">
+          <el-date-picker v-model="formData.${field}" clearable type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择${comment}">
           </el-date-picker>
         </el-form-item>
 #elseif($column.htmlType == "textarea")
@@ -118,14 +114,14 @@ import * as ${BusinessName}Api from '@/api/${moduleName}/${businessName}';
 import { ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
 import { useI18n } from 'vue-i18n';
 
-defineOptions({ name: '${BusinessName}Form' })
+defineOptions({ name: '${BusinessName}Form' });
 
 // 接收父组件传入属性
 // const props = defineProps({})
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 // 国际化
-const { t } = useI18n()
+const { t } = useI18n();
 
 #if(${dicts} != '')
 #set($dictsNoSymbol=$dicts.replace("'", ""))
@@ -172,7 +168,7 @@ const formRules = reactive({
 #else
     #set($comment=$column.columnComment)
 #end
-  $column.javaField: [{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }]#if($foreach.count != $columns.size()),#end
+  $column.javaField: [{ required: true, message: '$comment不能为空', trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")'change'#else'blur'#end }]#if($foreach.count != $columns.size()),#end
 #end
 #end
 #end
@@ -181,17 +177,17 @@ const formRules = reactive({
 /** 窗体打开事件 */
 const open = async (type: string, id?: number) => {
   dialog.visible = true;
-  dialog.title = t('action.' + type)
-  formType.value = type
-  resetForm()
+  dialog.title = t('action.' + type);
+  formType.value = type;
+  resetForm();
   // 修改时,设置数据
   if (id) {
-    formLoading.value = true
+    formLoading.value = true;
     try {
       const res = await ${BusinessName}Api.get${BusinessName}(id);
       Object.assign(formData.value, res.data);
     } finally {
-      formLoading.value = false
+      formLoading.value = false;
     }
   }
 };
@@ -201,11 +197,19 @@ const resetForm = () => {
   #foreach ($column in $columns)
   #if($column.insert || $column.edit)
   #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN")
-    $column.javaField: '',
+  #if($column.htmlType == "checkbox")
+    $column.javaField: []#if($foreach.count != $columns.size()),#end
+  #elseif($column.javaType == "String")
+    $column.javaField: ''#if($foreach.count != $columns.size()),#end
+  #elseif($column.javaType == "Integer" || $column.javaType == "Long")
+    $column.javaField: 0#if($foreach.count != $columns.size()),#end
+  #else
+    $column.javaField: undefined#if($foreach.count != $columns.size()),#end
   #end
   #end
   #end
-  }
+  #end
+  };
   formRef.value?.resetFields();
 };
 // 传回给父组件的属性与方法
@@ -226,16 +230,16 @@ const submitForm = async () => {
     const data = formData.value as unknown as ${BusinessName}Form;
     if (formType.value === 'create') {
       await ${BusinessName}Api.add${BusinessName}(data);
-      proxy?.$modal.msgSuccess("新增成功");
+      proxy?.$modal.msgSuccess('新增成功');
     } else {
       await ${BusinessName}Api.update${BusinessName}(data);
-      proxy?.$modal.msgSuccess("修改成功");
+      proxy?.$modal.msgSuccess('修改成功');
     }
     dialog.visible = false;
     // 发送操作成功的事件
     emit('success');
   } finally {
-      formLoading.value = false;
+    formLoading.value = false;
   }
 };
 

+ 9 - 8
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm

@@ -31,8 +31,9 @@
           </el-form-item>
 #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
           <el-form-item label="${comment}" prop="${column.javaField}">
-            <el-date-picker clearable
+            <el-date-picker
               v-model="queryParams.${column.javaField}"
+              clearable
               type="date"
               value-format="YYYY-MM-DD"
               placeholder="请选择${comment}"
@@ -76,7 +77,7 @@
           <el-col :span="1.5">
             <el-button v-hasPermi="['${moduleName}:${businessName}:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
           </el-col>
-          <right-toolbar v-model:showSearch="showSearch" :columns="columns"  @queryTable="getList"></right-toolbar>
+          <right-toolbar v-model:showSearch="showSearch" :columns="columns"  @query-table="getList"></right-toolbar>
         </el-row>
       </template>
 
@@ -135,7 +136,7 @@
         </el-table-column>
       </el-table>
       <!-- 翻页组件 -->
-        <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
+      <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
     </el-card>
     <!-- 添加或修改${functionName}对话框 -->
     <detail-form ref="detailFormRef" apped-to-body @success="getList" />
@@ -148,7 +149,7 @@ import { list${BusinessName}, del${BusinessName} } from '@/api/${moduleName}/${b
 import { ${BusinessName}VO } from '@/api/${moduleName}/${businessName}/types';
 import DetailForm from './DetailForm.vue';
 
-defineOptions({ name: '${BusinessName}' })
+defineOptions({ name: '${BusinessName}' });
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 #if(${dicts} != '')
@@ -267,7 +268,7 @@ const handleSelectionChange = (selection: ${BusinessName}VO[]) => {
 /** 删除按钮操作 */
 const handleDelete = async (row?: ${BusinessName}VO) => {
   const _${pkColumn.javaField}s = row?.${pkColumn.javaField} || ids.value;
-  await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').finally(() => loading.value = false);
+  await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').finally(() => (loading.value = false));
   await del${BusinessName}(_${pkColumn.javaField}s);
   await getList();
   proxy?.#[[$modal]]#.msgSuccess('删除成功');
@@ -278,15 +279,15 @@ const handleExport = () => {
   proxy?.download(
     '${moduleName}/${businessName}/export',
     {
-       ...queryParams
+      ...queryParams
     },
-    `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
+    `${businessName}_#[[${new Date().getTime()}]]#.xlsx`);
 };
 /** 弹出框(增加、修改) */
 const detailFormRef = ref();
 const openForm = (type: string, row?: ${BusinessName}VO) => {
   const id = row?.${pkColumn.javaField} || ids.value[0];
-  detailFormRef?.value.open(type, id)
+  detailFormRef?.value.open(type, id);
 };
 onMounted(() => {
   getList();