Commit b8351f50f23ecd43d1a7612c649b57ba7311a485
1 parent
0b25eb1c
基本完成 index.vue.vm 模板
Showing
3 changed files
with
97 additions
and
88 deletions
ruoyi-ui/src/main.js
| @@ -20,8 +20,8 @@ import { | @@ -20,8 +20,8 @@ import { | ||
| 20 | parseTime, | 20 | parseTime, |
| 21 | resetForm, | 21 | resetForm, |
| 22 | addDateRange, | 22 | addDateRange, |
| 23 | + addBeginAndEndTime, | ||
| 23 | selectDictLabel, | 24 | selectDictLabel, |
| 24 | - selectDictLabels, | ||
| 25 | download, | 25 | download, |
| 26 | handleTree, | 26 | handleTree, |
| 27 | downloadExcel, | 27 | downloadExcel, |
| @@ -41,8 +41,8 @@ Vue.prototype.getConfigKey = getConfigKey | @@ -41,8 +41,8 @@ Vue.prototype.getConfigKey = getConfigKey | ||
| 41 | Vue.prototype.parseTime = parseTime | 41 | Vue.prototype.parseTime = parseTime |
| 42 | Vue.prototype.resetForm = resetForm | 42 | Vue.prototype.resetForm = resetForm |
| 43 | Vue.prototype.addDateRange = addDateRange | 43 | Vue.prototype.addDateRange = addDateRange |
| 44 | +Vue.prototype.addBeginAndEndTime = addBeginAndEndTime | ||
| 44 | Vue.prototype.selectDictLabel = selectDictLabel | 45 | Vue.prototype.selectDictLabel = selectDictLabel |
| 45 | -Vue.prototype.selectDictLabels = selectDictLabels | ||
| 46 | Vue.prototype.getDictDatas = getDictDatas | 46 | Vue.prototype.getDictDatas = getDictDatas |
| 47 | Vue.prototype.getDictDataLabel = getDictDataLabel | 47 | Vue.prototype.getDictDataLabel = getDictDataLabel |
| 48 | Vue.prototype.DICT_TYPE = DICT_TYPE | 48 | Vue.prototype.DICT_TYPE = DICT_TYPE |
ruoyi-ui/src/utils/ruoyi.js
| @@ -69,6 +69,35 @@ export function addDateRange(params, dateRange, propName) { | @@ -69,6 +69,35 @@ export function addDateRange(params, dateRange, propName) { | ||
| 69 | return search; | 69 | return search; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | +/** | ||
| 73 | + * 添加开始和结束时间到 params 参数中 | ||
| 74 | + * | ||
| 75 | + * @param params 参数 | ||
| 76 | + * @param dateRange 时间范围。 | ||
| 77 | + * 大小为 2 的数组,每个时间为 yyyy-MM-dd 格式 | ||
| 78 | + * @param propName 加入的参数名,可以为空 | ||
| 79 | + */ | ||
| 80 | +export function addBeginAndEndTime(params, dateRange, propName) { | ||
| 81 | + // 必须传入参数 | ||
| 82 | + if (!dateRange) { | ||
| 83 | + return params; | ||
| 84 | + } | ||
| 85 | + // 如果未传递 propName 属性,默认为 time | ||
| 86 | + if (!propName) { | ||
| 87 | + propName = 'Time'; | ||
| 88 | + } else { | ||
| 89 | + propName = propName.charAt(0).toUpperCase() + propName.slice(1); | ||
| 90 | + } | ||
| 91 | + // 设置参数 | ||
| 92 | + if (dateRange[0]) { | ||
| 93 | + params['begin' + propName] = dateRange[0] + ' 00:00:00'; | ||
| 94 | + } | ||
| 95 | + if (dateRange[1]) { | ||
| 96 | + params['end' + propName] = dateRange[0] + ' 23:59:59'; | ||
| 97 | + } | ||
| 98 | + return params; | ||
| 99 | +} | ||
| 100 | + | ||
| 72 | // 回显数据字典 | 101 | // 回显数据字典 |
| 73 | export function selectDictLabel(datas, value) { | 102 | export function selectDictLabel(datas, value) { |
| 74 | var actions = []; | 103 | var actions = []; |
| @@ -81,21 +110,6 @@ export function selectDictLabel(datas, value) { | @@ -81,21 +110,6 @@ export function selectDictLabel(datas, value) { | ||
| 81 | return actions.join(''); | 110 | return actions.join(''); |
| 82 | } | 111 | } |
| 83 | 112 | ||
| 84 | -// 回显数据字典(字符串数组) | ||
| 85 | -export function selectDictLabels(datas, value, separator) { | ||
| 86 | - var actions = []; | ||
| 87 | - var currentSeparator = undefined === separator ? "," : separator; | ||
| 88 | - var temp = value.split(currentSeparator); | ||
| 89 | - Object.keys(value.split(currentSeparator)).some((val) => { | ||
| 90 | - Object.keys(datas).some((key) => { | ||
| 91 | - if (datas[key].dictValue == ('' + temp[val])) { | ||
| 92 | - actions.push(datas[key].dictLabel + currentSeparator); | ||
| 93 | - } | ||
| 94 | - }) | ||
| 95 | - }) | ||
| 96 | - return actions.join('').substring(0, actions.join('').length - 1); | ||
| 97 | -} | ||
| 98 | - | ||
| 99 | // 通用下载方法 | 113 | // 通用下载方法 |
| 100 | export function download(fileName) { | 114 | export function download(fileName) { |
| 101 | window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; | 115 | window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; |
src/main/resources/codegen/vue/views/index.vue.vm
| @@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
| 58 | </el-row> | 58 | </el-row> |
| 59 | 59 | ||
| 60 | <!-- 列表 --> | 60 | <!-- 列表 --> |
| 61 | - <el-table v-loading="loading" :data="${businessName}List"> | 61 | + <el-table v-loading="loading" :data="list"> |
| 62 | #foreach($column in $columns) | 62 | #foreach($column in $columns) |
| 63 | #if ($column.listOperationResult) | 63 | #if ($column.listOperationResult) |
| 64 | #set ($dictType=$column.dictType) | 64 | #set ($dictType=$column.dictType) |
| @@ -211,7 +211,7 @@ export default { | @@ -211,7 +211,7 @@ export default { | ||
| 211 | showSearch: true, | 211 | showSearch: true, |
| 212 | // 总条数 | 212 | // 总条数 |
| 213 | total: 0, | 213 | total: 0, |
| 214 | - // ${functionName}表格数据 | 214 | + // ${table.tableComment}表格数据 |
| 215 | list: [], | 215 | list: [], |
| 216 | // 弹出层标题 | 216 | // 弹出层标题 |
| 217 | title: "", | 217 | title: "", |
| @@ -250,27 +250,20 @@ export default { | @@ -250,27 +250,20 @@ export default { | ||
| 250 | this.getList(); | 250 | this.getList(); |
| 251 | }, | 251 | }, |
| 252 | methods: { | 252 | methods: { |
| 253 | - /** 查询${functionName}列表 */ | 253 | + /** 查询列表 */ |
| 254 | getList() { | 254 | getList() { |
| 255 | this.loading = true; | 255 | this.loading = true; |
| 256 | -#foreach ($column in $columns) | ||
| 257 | -#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | ||
| 258 | - this.queryParams.params = {}; | ||
| 259 | -#break | ||
| 260 | -#end | ||
| 261 | -#end | ||
| 262 | -#foreach ($column in $columns) | ||
| 263 | -#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | ||
| 264 | -#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||
| 265 | - if (null != this.dateRange${AttrName} && '' != this.dateRange${AttrName}) { | ||
| 266 | - this.queryParams.params["begin${AttrName}"] = this.dateRange${AttrName}[0]; | ||
| 267 | - this.queryParams.params["end${AttrName}"] = this.dateRange${AttrName}[1]; | ||
| 268 | - } | ||
| 269 | -#end | ||
| 270 | -#end | ||
| 271 | - list${BusinessName}(this.queryParams).then(response => { | ||
| 272 | - this.list = response.rows; | ||
| 273 | - this.total = response.total; | 256 | + let params = {...this.queryParams}; |
| 257 | + #foreach ($column in $columns) | ||
| 258 | + #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | ||
| 259 | + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||
| 260 | + this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField}); | ||
| 261 | + #end | ||
| 262 | + #end | ||
| 263 | + // 执行查询 | ||
| 264 | + get${simpleClassName}Page(params).then(response => { | ||
| 265 | + this.list = response.data.list; | ||
| 266 | + this.total = response.data.total; | ||
| 274 | this.loading = false; | 267 | this.loading = false; |
| 275 | }); | 268 | }); |
| 276 | }, | 269 | }, |
| @@ -282,18 +275,13 @@ export default { | @@ -282,18 +275,13 @@ export default { | ||
| 282 | // 表单重置 | 275 | // 表单重置 |
| 283 | reset() { | 276 | reset() { |
| 284 | this.form = { | 277 | this.form = { |
| 285 | -#foreach ($column in $columns) | ||
| 286 | -#if($column.htmlType == "radio") | ||
| 287 | - $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end | ||
| 288 | - | ||
| 289 | -#elseif($column.htmlType == "checkbox") | ||
| 290 | - $column.javaField: []#if($velocityCount != $columns.size()),#end | ||
| 291 | - | ||
| 292 | -#else | ||
| 293 | - $column.javaField: null#if($velocityCount != $columns.size()),#end | ||
| 294 | - | ||
| 295 | -#end | ||
| 296 | -#end | 278 | + #foreach ($column in $columns) |
| 279 | + #if($column.htmlType == "checkbox") | ||
| 280 | + $column.javaField: [], | ||
| 281 | + #else | ||
| 282 | + $column.javaField: null, | ||
| 283 | + #end | ||
| 284 | + #end | ||
| 297 | }; | 285 | }; |
| 298 | this.resetForm("form"); | 286 | this.resetForm("form"); |
| 299 | }, | 287 | }, |
| @@ -304,12 +292,12 @@ export default { | @@ -304,12 +292,12 @@ export default { | ||
| 304 | }, | 292 | }, |
| 305 | /** 重置按钮操作 */ | 293 | /** 重置按钮操作 */ |
| 306 | resetQuery() { | 294 | resetQuery() { |
| 307 | -#foreach ($column in $columns) | ||
| 308 | -#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") | ||
| 309 | -#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | 295 | + #foreach ($column in $columns) |
| 296 | + #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | ||
| 297 | + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||
| 310 | this.dateRange${AttrName} = []; | 298 | this.dateRange${AttrName} = []; |
| 311 | -#end | ||
| 312 | -#end | 299 | + #end |
| 300 | + #end | ||
| 313 | this.resetForm("queryForm"); | 301 | this.resetForm("queryForm"); |
| 314 | this.handleQuery(); | 302 | this.handleQuery(); |
| 315 | }, | 303 | }, |
| @@ -317,21 +305,21 @@ export default { | @@ -317,21 +305,21 @@ export default { | ||
| 317 | handleAdd() { | 305 | handleAdd() { |
| 318 | this.reset(); | 306 | this.reset(); |
| 319 | this.open = true; | 307 | this.open = true; |
| 320 | - this.title = "添加${functionName}"; | 308 | + this.title = "添加${table.tableComment}"; |
| 321 | }, | 309 | }, |
| 322 | /** 修改按钮操作 */ | 310 | /** 修改按钮操作 */ |
| 323 | handleUpdate(row) { | 311 | handleUpdate(row) { |
| 324 | this.reset(); | 312 | this.reset(); |
| 325 | - const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids | ||
| 326 | - get${BusinessName}(${pkColumn.javaField}).then(response => { | 313 | + const ${primaryColumn.javaField} = row.${primaryColumn.javaField}; |
| 314 | + get${simpleClassName}(${primaryColumn.javaField}).then(response => { | ||
| 327 | this.form = response.data; | 315 | this.form = response.data; |
| 328 | -#foreach ($column in $columns) | ||
| 329 | -#if($column.htmlType == "checkbox") | 316 | + #foreach ($column in $columns) |
| 317 | + #if($column.htmlType == "checkbox")## checkbox 特殊处理 | ||
| 330 | this.form.$column.javaField = this.form.${column.javaField}.split(","); | 318 | this.form.$column.javaField = this.form.${column.javaField}.split(","); |
| 331 | -#end | ||
| 332 | -#end | 319 | + #end |
| 320 | + #end | ||
| 333 | this.open = true; | 321 | this.open = true; |
| 334 | - this.title = "修改${functionName}"; | 322 | + this.title = "修改${table.tableComment}"; |
| 335 | }); | 323 | }); |
| 336 | }, | 324 | }, |
| 337 | /** 提交按钮 */ | 325 | /** 提交按钮 */ |
| @@ -340,36 +328,37 @@ export default { | @@ -340,36 +328,37 @@ export default { | ||
| 340 | if (valid) { | 328 | if (valid) { |
| 341 | return; | 329 | return; |
| 342 | } | 330 | } |
| 343 | -#foreach ($column in $columns) | ||
| 344 | -#if($column.htmlType == "checkbox") | ||
| 345 | - this.form.$column.javaField = this.form.${column.javaField}.join(","); | ||
| 346 | -#end | ||
| 347 | -#end | ||
| 348 | - if (this.form.${pkColumn.javaField} != null) { | ||
| 349 | - update${BusinessName}(this.form).then(response => { | ||
| 350 | - this.msgSuccess("修改成功"); | ||
| 351 | - this.open = false; | ||
| 352 | - this.getList(); | ||
| 353 | - }); | ||
| 354 | - } else { | ||
| 355 | - add${BusinessName}(this.form).then(response => { | ||
| 356 | - this.msgSuccess("新增成功"); | ||
| 357 | - this.open = false; | ||
| 358 | - this.getList(); | ||
| 359 | - }); | ||
| 360 | - } | 331 | + #foreach ($column in $columns) |
| 332 | + #if($column.htmlType == "checkbox") | ||
| 333 | + this.form.$column.javaField = this.form.${column.javaField}.join(","); | ||
| 334 | + #end | ||
| 335 | + #end | ||
| 336 | + // 修改的提交 | ||
| 337 | + if (this.form.${primaryColumn.javaField} != null) { | ||
| 338 | + update${simpleClassName}(this.form).then(response => { | ||
| 339 | + this.msgSuccess("修改成功"); | ||
| 340 | + this.open = false; | ||
| 341 | + this.getList(); | ||
| 342 | + }); | ||
| 343 | + return; | ||
| 361 | } | 344 | } |
| 345 | + // 添加的提交 | ||
| 346 | + create${simpleClassName}(this.form).then(response => { | ||
| 347 | + this.msgSuccess("新增成功"); | ||
| 348 | + this.open = false; | ||
| 349 | + this.getList(); | ||
| 350 | + }); | ||
| 362 | }); | 351 | }); |
| 363 | }, | 352 | }, |
| 364 | /** 删除按钮操作 */ | 353 | /** 删除按钮操作 */ |
| 365 | handleDelete(row) { | 354 | handleDelete(row) { |
| 366 | - const ${pkColumn.javaField}s = row.${pkColumn.javaField}; | ||
| 367 | - this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", { | 355 | + const ${primaryColumn.javaField} = row.${primaryColumn.javaField}; |
| 356 | + this.$confirm('是否确认删除${table.tableComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", { | ||
| 368 | confirmButtonText: "确定", | 357 | confirmButtonText: "确定", |
| 369 | cancelButtonText: "取消", | 358 | cancelButtonText: "取消", |
| 370 | type: "warning" | 359 | type: "warning" |
| 371 | }).then(function() { | 360 | }).then(function() { |
| 372 | - return del${BusinessName}(${pkColumn.javaField}s); | 361 | + return delete${simpleClassName}(${primaryColumn.javaField}); |
| 373 | }).then(() => { | 362 | }).then(() => { |
| 374 | this.getList(); | 363 | this.getList(); |
| 375 | this.msgSuccess("删除成功"); | 364 | this.msgSuccess("删除成功"); |
| @@ -377,15 +366,21 @@ export default { | @@ -377,15 +366,21 @@ export default { | ||
| 377 | }, | 366 | }, |
| 378 | /** 导出按钮操作 */ | 367 | /** 导出按钮操作 */ |
| 379 | handleExport() { | 368 | handleExport() { |
| 380 | - const queryParams = this.queryParams; | ||
| 381 | - this.$confirm('是否确认导出所有${functionName}数据项?', "警告", { | 369 | + this.$confirm('是否确认导出所有${table.tableComment}数据项?', "警告", { |
| 382 | confirmButtonText: "确定", | 370 | confirmButtonText: "确定", |
| 383 | cancelButtonText: "取消", | 371 | cancelButtonText: "取消", |
| 384 | type: "warning" | 372 | type: "warning" |
| 385 | }).then(function() { | 373 | }).then(function() { |
| 386 | - return export${BusinessName}(queryParams); | 374 | + let params = {...this.queryParams}; |
| 375 | + #foreach ($column in $columns) | ||
| 376 | + #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | ||
| 377 | + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||
| 378 | + this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField}); | ||
| 379 | + #end | ||
| 380 | + #end | ||
| 381 | + return export${simpleClassName}(params); | ||
| 387 | }).then(response => { | 382 | }).then(response => { |
| 388 | - this.download(response.msg); | 383 | + this.downloadExcel(response, '${table.classComment}.xls'); |
| 389 | }) | 384 | }) |
| 390 | } | 385 | } |
| 391 | } | 386 | } |