Commit 975b978e37f26ef030c34bc44a9244071eac6e06

Authored by YunaiV
Committed by &wxr
1 parent 4f00d923

代码生成:完善 Vue3 标准模版的列表

yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
1 <template> 1 <template>
2 <content-wrap> 2 <content-wrap>
3 <!-- 搜索工作栏 --> 3 <!-- 搜索工作栏 -->
4 - <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"> 4 + <el-form
  5 + class="-mb-15px"
  6 + :model="queryParams"
  7 + ref="queryFormRef"
  8 + :inline="true"
  9 + label-width="68px"
  10 + >
  11 + #set ($dictMethods = []) ## 使用到的 dict 字典方法
5 #foreach($column in $columns) 12 #foreach($column in $columns)
6 #if ($column.listOperation) 13 #if ($column.listOperation)
7 #set ($dictType = $column.dictType) 14 #set ($dictType = $column.dictType)
8 #set ($javaField = $column.javaField) 15 #set ($javaField = $column.javaField)
  16 + #set ($javaType = $column.javaType)
9 #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) 17 #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
10 #set ($comment = $column.columnComment) 18 #set ($comment = $column.columnComment)
11 #if ($column.htmlType == "input") 19 #if ($column.htmlType == "input")
@@ -15,15 +23,31 @@ @@ -15,15 +23,31 @@
15 placeholder="请输入${comment}" 23 placeholder="请输入${comment}"
16 clearable 24 clearable
17 @keyup.enter="handleQuery" 25 @keyup.enter="handleQuery"
  26 + class="!w-240px"
18 /> 27 />
19 </el-form-item> 28 </el-form-item>
20 #elseif ($column.htmlType == "select" || $column.htmlType == "radio") 29 #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
21 <el-form-item label="${comment}" prop="${javaField}"> 30 <el-form-item label="${comment}" prop="${javaField}">
22 - <el-select v-model="queryParams.${javaField}" placeholder="请选择${comment}" clearable> 31 + <el-select
  32 + v-model="queryParams.${javaField}"
  33 + placeholder="请选择${comment}"
  34 + clearable
  35 + class="!w-240px"
  36 + >
23 #if ("" != $dictType)## 设置了 dictType 数据字典的情况 37 #if ("" != $dictType)## 设置了 dictType 数据字典的情况
24 - <!-- TODO 芋艿:需要考虑不同类型的处理 --> 38 + #set ($dictMethod = "getDictOptions") ## 计算使用哪个 dict 字典方法
  39 + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  40 + #set ($dictMethod = "getIntDictOptions")
  41 + #elseif ($javaType == "String")
  42 + #set ($dictMethod = "getStrDictOptions")
  43 + #elseif ($javaType == "Boolean")
  44 + #set ($dictMethod = "getBoolDictOptions")
  45 + #end
  46 + #if (!$dictMethods.contains($dictMethod)) ## 如果不存在,则添加到 dictMethods 数组中,后续好 import
  47 + #( $dictMethods.add($dictMethod) )
  48 + #end
25 <el-option 49 <el-option
26 - v-for="dict in getDictDatas(DICT_TYPE.$dictType.toUpperCase())" 50 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
27 :key="dict.value" 51 :key="dict.value"
28 :label="dict.label" 52 :label="dict.label"
29 :value="dict.value" 53 :value="dict.value"
@@ -42,6 +66,7 @@ @@ -42,6 +66,7 @@
42 type="date" 66 type="date"
43 placeholder="选择${comment}" 67 placeholder="选择${comment}"
44 clearable 68 clearable
  69 + class="!w-240px"
45 /> 70 />
46 </el-form-item> 71 </el-form-item>
47 #else## 范围 72 #else## 范围
@@ -53,6 +78,7 @@ @@ -53,6 +78,7 @@
53 start-placeholder="开始日期" 78 start-placeholder="开始日期"
54 end-placeholder="结束日期" 79 end-placeholder="结束日期"
55 :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" 80 :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  81 + class="!w-240px"
56 /> 82 />
57 </el-form-item> 83 </el-form-item>
58 #end 84 #end
@@ -137,7 +163,9 @@ @@ -137,7 +163,9 @@
137 </template> 163 </template>
138 164
139 <script setup lang="ts" name="${simpleClassName}"> 165 <script setup lang="ts" name="${simpleClassName}">
140 -import { DICT_TYPE, getDictOptions } from '@/utils/dict' 166 +#if ($dictMethods.size() > 0)
  167 +import { DICT_TYPE#foreach ($dictMethod in $dictMethods), ${dictMethod}#end } from '@/utils/dict'
  168 +#end
141 import { dateFormatter } from '@/utils/formatTime' 169 import { dateFormatter } from '@/utils/formatTime'
142 import download from '@/utils/download' 170 import download from '@/utils/download'
143 import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' 171 import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'
@@ -151,13 +179,19 @@ const list = ref([]) // 列表的数据 @@ -151,13 +179,19 @@ const list = ref([]) // 列表的数据
151 const queryParams = reactive({ 179 const queryParams = reactive({
152 pageNo: 1, 180 pageNo: 1,
153 pageSize: 10, 181 pageSize: 10,
  182 + #set ($listOperationLastIndex = -1) ## 求最后一个需要 , 的地方
  183 + #foreach ($column in $columns)
  184 + #if ($column.listOperation)
  185 + #set ($listOperationLastIndex = $foreach.index)
  186 + #end
  187 + #end
154 #foreach ($column in $columns) 188 #foreach ($column in $columns)
155 #if ($column.listOperation) 189 #if ($column.listOperation)
156 #if ($column.listOperationCondition != 'BETWEEN') 190 #if ($column.listOperationCondition != 'BETWEEN')
157 - $column.javaField: null, 191 + $column.javaField: null#if($foreach.index < $listOperationLastIndex),#end
158 #end 192 #end
159 #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") 193 #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
160 - $column.javaField: [], 194 + $column.javaField: []#if($foreach.index < $listOperationLastIndex),#end
161 #end 195 #end
162 #end 196 #end
163 #end 197 #end