Commit a9c6ba12e6f96fe316927324f2a038b61bc3a2bc
1 parent
ba068eae
代码生成日期控件区分范围
Showing
3 changed files
with
85 additions
and
9 deletions
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
| ... | ... | @@ -38,15 +38,28 @@ |
| 38 | 38 | <el-option label="请选择字典生成" value="" /> |
| 39 | 39 | </el-select> |
| 40 | 40 | </el-form-item> |
| 41 | -#elseif($column.htmlType == "datetime") | |
| 41 | +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") | |
| 42 | 42 | <el-form-item label="${comment}" prop="${column.javaField}"> |
| 43 | - <el-date-picker clearable size="small" style="width: 200px" | |
| 43 | + <el-date-picker clearable size="small" | |
| 44 | 44 | v-model="queryParams.${column.javaField}" |
| 45 | 45 | type="date" |
| 46 | 46 | value-format="yyyy-MM-dd" |
| 47 | 47 | placeholder="选择${comment}"> |
| 48 | 48 | </el-date-picker> |
| 49 | 49 | </el-form-item> |
| 50 | +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 51 | + <el-form-item label="${comment}"> | |
| 52 | + <el-date-picker | |
| 53 | + v-model="daterange${AttrName}" | |
| 54 | + size="small" | |
| 55 | + style="width: 240px" | |
| 56 | + value-format="yyyy-MM-dd" | |
| 57 | + type="daterange" | |
| 58 | + range-separator="-" | |
| 59 | + start-placeholder="开始日期" | |
| 60 | + end-placeholder="结束日期" | |
| 61 | + ></el-date-picker> | |
| 62 | + </el-form-item> | |
| 50 | 63 | #end |
| 51 | 64 | #end |
| 52 | 65 | #end |
| ... | ... | @@ -201,7 +214,7 @@ |
| 201 | 214 | </el-form-item> |
| 202 | 215 | #elseif($column.htmlType == "datetime") |
| 203 | 216 | <el-form-item label="${comment}" prop="${field}"> |
| 204 | - <el-date-picker clearable size="small" style="width: 200px" | |
| 217 | + <el-date-picker clearable size="small" | |
| 205 | 218 | v-model="form.${field}" |
| 206 | 219 | type="date" |
| 207 | 220 | value-format="yyyy-MM-dd" |
| ... | ... | @@ -283,6 +296,10 @@ export default { |
| 283 | 296 | #if(${column.dictType} != '') |
| 284 | 297 | // $comment字典 |
| 285 | 298 | ${column.javaField}Options: [], |
| 299 | +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 300 | +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 301 | + // $comment时间范围 | |
| 302 | + daterange${AttrName}: [], | |
| 286 | 303 | #end |
| 287 | 304 | #end |
| 288 | 305 | // 查询参数 |
| ... | ... | @@ -329,6 +346,21 @@ export default { |
| 329 | 346 | /** 查询${functionName}列表 */ |
| 330 | 347 | getList() { |
| 331 | 348 | this.loading = true; |
| 349 | +#foreach ($column in $columns) | |
| 350 | +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 351 | + this.queryParams.params = {}; | |
| 352 | +#break | |
| 353 | +#end | |
| 354 | +#end | |
| 355 | +#foreach ($column in $columns) | |
| 356 | +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 357 | +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 358 | + if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) { | |
| 359 | + this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0]; | |
| 360 | + this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1]; | |
| 361 | + } | |
| 362 | +#end | |
| 363 | +#end | |
| 332 | 364 | list${BusinessName}(this.queryParams).then(response => { |
| 333 | 365 | this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}"); |
| 334 | 366 | this.loading = false; |
| ... | ... | @@ -397,6 +429,12 @@ export default { |
| 397 | 429 | }, |
| 398 | 430 | /** 重置按钮操作 */ |
| 399 | 431 | resetQuery() { |
| 432 | +#foreach ($column in $columns) | |
| 433 | +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 434 | +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 435 | + this.daterange${AttrName} = []; | |
| 436 | +#end | |
| 437 | +#end | |
| 400 | 438 | this.resetForm("queryForm"); |
| 401 | 439 | this.handleQuery(); |
| 402 | 440 | }, | ... | ... |
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
| ... | ... | @@ -38,15 +38,28 @@ |
| 38 | 38 | <el-option label="请选择字典生成" value="" /> |
| 39 | 39 | </el-select> |
| 40 | 40 | </el-form-item> |
| 41 | -#elseif($column.htmlType == "datetime") | |
| 41 | +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") | |
| 42 | 42 | <el-form-item label="${comment}" prop="${column.javaField}"> |
| 43 | - <el-date-picker clearable size="small" style="width: 200px" | |
| 43 | + <el-date-picker clearable size="small" | |
| 44 | 44 | v-model="queryParams.${column.javaField}" |
| 45 | 45 | type="date" |
| 46 | 46 | value-format="yyyy-MM-dd" |
| 47 | 47 | placeholder="选择${comment}"> |
| 48 | 48 | </el-date-picker> |
| 49 | 49 | </el-form-item> |
| 50 | +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 51 | + <el-form-item label="${comment}"> | |
| 52 | + <el-date-picker | |
| 53 | + v-model="daterange${AttrName}" | |
| 54 | + size="small" | |
| 55 | + style="width: 240px" | |
| 56 | + value-format="yyyy-MM-dd" | |
| 57 | + type="daterange" | |
| 58 | + range-separator="-" | |
| 59 | + start-placeholder="开始日期" | |
| 60 | + end-placeholder="结束日期" | |
| 61 | + ></el-date-picker> | |
| 62 | + </el-form-item> | |
| 50 | 63 | #end |
| 51 | 64 | #end |
| 52 | 65 | #end |
| ... | ... | @@ -95,7 +108,7 @@ |
| 95 | 108 | v-hasPermi="['${moduleName}:${businessName}:export']" |
| 96 | 109 | >导出</el-button> |
| 97 | 110 | </el-col> |
| 98 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | |
| 111 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | |
| 99 | 112 | </el-row> |
| 100 | 113 | |
| 101 | 114 | <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> |
| ... | ... | @@ -230,7 +243,7 @@ |
| 230 | 243 | </el-form-item> |
| 231 | 244 | #elseif($column.htmlType == "datetime") |
| 232 | 245 | <el-form-item label="${comment}" prop="${field}"> |
| 233 | - <el-date-picker clearable size="small" style="width: 200px" | |
| 246 | + <el-date-picker clearable size="small" | |
| 234 | 247 | v-model="form.${field}" |
| 235 | 248 | type="date" |
| 236 | 249 | value-format="yyyy-MM-dd" |
| ... | ... | @@ -315,6 +328,10 @@ export default { |
| 315 | 328 | #if(${column.dictType} != '') |
| 316 | 329 | // $comment字典 |
| 317 | 330 | ${column.javaField}Options: [], |
| 331 | +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 332 | +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 333 | + // $comment时间范围 | |
| 334 | + daterange${AttrName}: [], | |
| 318 | 335 | #end |
| 319 | 336 | #end |
| 320 | 337 | // 查询参数 |
| ... | ... | @@ -363,6 +380,21 @@ export default { |
| 363 | 380 | /** 查询${functionName}列表 */ |
| 364 | 381 | getList() { |
| 365 | 382 | this.loading = true; |
| 383 | +#foreach ($column in $columns) | |
| 384 | +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 385 | + this.queryParams.params = {}; | |
| 386 | +#break | |
| 387 | +#end | |
| 388 | +#end | |
| 389 | +#foreach ($column in $columns) | |
| 390 | +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 391 | +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 392 | + if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) { | |
| 393 | + this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0]; | |
| 394 | + this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1]; | |
| 395 | + } | |
| 396 | +#end | |
| 397 | +#end | |
| 366 | 398 | list${BusinessName}(this.queryParams).then(response => { |
| 367 | 399 | this.${businessName}List = response.rows; |
| 368 | 400 | this.total = response.total; |
| ... | ... | @@ -413,6 +445,12 @@ export default { |
| 413 | 445 | }, |
| 414 | 446 | /** 重置按钮操作 */ |
| 415 | 447 | resetQuery() { |
| 448 | +#foreach ($column in $columns) | |
| 449 | +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | |
| 450 | +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | |
| 451 | + this.daterange${AttrName} = []; | |
| 452 | +#end | |
| 453 | +#end | |
| 416 | 454 | this.resetForm("queryForm"); |
| 417 | 455 | this.handleQuery(); |
| 418 | 456 | }, | ... | ... |
ruoyi-ui/src/utils/ruoyi.js
| ... | ... | @@ -62,8 +62,8 @@ export function addDateRange(params, dateRange, propName) { |
| 62 | 62 | search.params["beginTime"] = dateRange[0]; |
| 63 | 63 | search.params["endTime"] = dateRange[1]; |
| 64 | 64 | } else { |
| 65 | - search.params[propName + "BeginTime"] = dateRange[0]; | |
| 66 | - search.params[propName + "EndTime"] = dateRange[1]; | |
| 65 | + search.params["begin" + propName] = dateRange[0]; | |
| 66 | + search.params["end" + propName] = dateRange[1]; | |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | return search; | ... | ... |