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 1 <template>
2 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 12 #foreach($column in $columns)
6 13 #if ($column.listOperation)
7 14 #set ($dictType = $column.dictType)
8 15 #set ($javaField = $column.javaField)
  16 + #set ($javaType = $column.javaType)
9 17 #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
10 18 #set ($comment = $column.columnComment)
11 19 #if ($column.htmlType == "input")
... ... @@ -15,15 +23,31 @@
15 23 placeholder="请输入${comment}"
16 24 clearable
17 25 @keyup.enter="handleQuery"
  26 + class="!w-240px"
18 27 />
19 28 </el-form-item>
20 29 #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
21 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 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 49 <el-option
26   - v-for="dict in getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
  50 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
27 51 :key="dict.value"
28 52 :label="dict.label"
29 53 :value="dict.value"
... ... @@ -42,6 +66,7 @@
42 66 type="date"
43 67 placeholder="选择${comment}"
44 68 clearable
  69 + class="!w-240px"
45 70 />
46 71 </el-form-item>
47 72 #else## 范围
... ... @@ -53,6 +78,7 @@
53 78 start-placeholder="开始日期"
54 79 end-placeholder="结束日期"
55 80 :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  81 + class="!w-240px"
56 82 />
57 83 </el-form-item>
58 84 #end
... ... @@ -137,7 +163,9 @@
137 163 </template>
138 164  
139 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 169 import { dateFormatter } from '@/utils/formatTime'
142 170 import download from '@/utils/download'
143 171 import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'
... ... @@ -151,13 +179,19 @@ const list = ref([]) // 列表的数据
151 179 const queryParams = reactive({
152 180 pageNo: 1,
153 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 188 #foreach ($column in $columns)
155 189 #if ($column.listOperation)
156 190 #if ($column.listOperationCondition != 'BETWEEN')
157   - $column.javaField: null,
  191 + $column.javaField: null#if($foreach.index < $listOperationLastIndex),#end
158 192 #end
159 193 #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
160   - $column.javaField: [],
  194 + $column.javaField: []#if($foreach.index < $listOperationLastIndex),#end
161 195 #end
162 196 #end
163 197 #end
... ...