mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
基本完成 index.vue.vm 模板
This commit is contained in:
parent
0b25eb1c2a
commit
b8351f50f2
@ -20,8 +20,8 @@ import {
|
||||
parseTime,
|
||||
resetForm,
|
||||
addDateRange,
|
||||
addBeginAndEndTime,
|
||||
selectDictLabel,
|
||||
selectDictLabels,
|
||||
download,
|
||||
handleTree,
|
||||
downloadExcel,
|
||||
@ -41,8 +41,8 @@ Vue.prototype.getConfigKey = getConfigKey
|
||||
Vue.prototype.parseTime = parseTime
|
||||
Vue.prototype.resetForm = resetForm
|
||||
Vue.prototype.addDateRange = addDateRange
|
||||
Vue.prototype.addBeginAndEndTime = addBeginAndEndTime
|
||||
Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.getDictDatas = getDictDatas
|
||||
Vue.prototype.getDictDataLabel = getDictDataLabel
|
||||
Vue.prototype.DICT_TYPE = DICT_TYPE
|
||||
|
@ -69,6 +69,35 @@ export function addDateRange(params, dateRange, propName) {
|
||||
return search;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加开始和结束时间到 params 参数中
|
||||
*
|
||||
* @param params 参数
|
||||
* @param dateRange 时间范围。
|
||||
* 大小为 2 的数组,每个时间为 yyyy-MM-dd 格式
|
||||
* @param propName 加入的参数名,可以为空
|
||||
*/
|
||||
export function addBeginAndEndTime(params, dateRange, propName) {
|
||||
// 必须传入参数
|
||||
if (!dateRange) {
|
||||
return params;
|
||||
}
|
||||
// 如果未传递 propName 属性,默认为 time
|
||||
if (!propName) {
|
||||
propName = 'Time';
|
||||
} else {
|
||||
propName = propName.charAt(0).toUpperCase() + propName.slice(1);
|
||||
}
|
||||
// 设置参数
|
||||
if (dateRange[0]) {
|
||||
params['begin' + propName] = dateRange[0] + ' 00:00:00';
|
||||
}
|
||||
if (dateRange[1]) {
|
||||
params['end' + propName] = dateRange[0] + ' 23:59:59';
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
// 回显数据字典
|
||||
export function selectDictLabel(datas, value) {
|
||||
var actions = [];
|
||||
@ -81,21 +110,6 @@ export function selectDictLabel(datas, value) {
|
||||
return actions.join('');
|
||||
}
|
||||
|
||||
// 回显数据字典(字符串数组)
|
||||
export function selectDictLabels(datas, value, separator) {
|
||||
var actions = [];
|
||||
var currentSeparator = undefined === separator ? "," : separator;
|
||||
var temp = value.split(currentSeparator);
|
||||
Object.keys(value.split(currentSeparator)).some((val) => {
|
||||
Object.keys(datas).some((key) => {
|
||||
if (datas[key].dictValue == ('' + temp[val])) {
|
||||
actions.push(datas[key].dictLabel + currentSeparator);
|
||||
}
|
||||
})
|
||||
})
|
||||
return actions.join('').substring(0, actions.join('').length - 1);
|
||||
}
|
||||
|
||||
// 通用下载方法
|
||||
export function download(fileName) {
|
||||
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
||||
|
@ -58,7 +58,7 @@
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="${businessName}List">
|
||||
<el-table v-loading="loading" :data="list">
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperationResult)
|
||||
#set ($dictType=$column.dictType)
|
||||
@ -211,7 +211,7 @@ export default {
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// ${functionName}表格数据
|
||||
// ${table.tableComment}表格数据
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
@ -250,27 +250,20 @@ export default {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询${functionName}列表 */
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
let params = {...this.queryParams};
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
this.queryParams.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
if (null != this.dateRange${AttrName} && '' != this.dateRange${AttrName}) {
|
||||
this.queryParams.params["begin${AttrName}"] = this.dateRange${AttrName}[0];
|
||||
this.queryParams.params["end${AttrName}"] = this.dateRange${AttrName}[1];
|
||||
}
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField});
|
||||
#end
|
||||
#end
|
||||
list${BusinessName}(this.queryParams).then(response => {
|
||||
this.list = response.rows;
|
||||
this.total = response.total;
|
||||
// 执行查询
|
||||
get${simpleClassName}Page(params).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
@ -283,15 +276,10 @@ export default {
|
||||
reset() {
|
||||
this.form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "radio")
|
||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#elseif($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: [],
|
||||
#else
|
||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||
|
||||
$column.javaField: null,
|
||||
#end
|
||||
#end
|
||||
};
|
||||
@ -305,7 +293,7 @@ export default {
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.dateRange${AttrName} = [];
|
||||
#end
|
||||
@ -317,21 +305,21 @@ export default {
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加${functionName}";
|
||||
this.title = "添加${table.tableComment}";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
|
||||
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
||||
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||
get${simpleClassName}(${primaryColumn.javaField}).then(response => {
|
||||
this.form = response.data;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
#if($column.htmlType == "checkbox")## checkbox 特殊处理
|
||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
this.open = true;
|
||||
this.title = "修改${functionName}";
|
||||
this.title = "修改${table.tableComment}";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
@ -345,31 +333,32 @@ export default {
|
||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
if (this.form.${pkColumn.javaField} != null) {
|
||||
update${BusinessName}(this.form).then(response => {
|
||||
// 修改的提交
|
||||
if (this.form.${primaryColumn.javaField} != null) {
|
||||
update${simpleClassName}(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
add${BusinessName}(this.form).then(response => {
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
create${simpleClassName}(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ${pkColumn.javaField}s = row.${pkColumn.javaField};
|
||||
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
|
||||
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||
this.$confirm('是否确认删除${table.tableComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return del${BusinessName}(${pkColumn.javaField}s);
|
||||
return delete${simpleClassName}(${primaryColumn.javaField});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
@ -377,15 +366,21 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有${functionName}数据项?', "警告", {
|
||||
this.$confirm('是否确认导出所有${table.tableComment}数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return export${BusinessName}(queryParams);
|
||||
let params = {...this.queryParams};
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField});
|
||||
#end
|
||||
#end
|
||||
return export${simpleClassName}(params);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
this.downloadExcel(response, '${table.classComment}.xls');
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user