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,
|
parseTime,
|
||||||
resetForm,
|
resetForm,
|
||||||
addDateRange,
|
addDateRange,
|
||||||
|
addBeginAndEndTime,
|
||||||
selectDictLabel,
|
selectDictLabel,
|
||||||
selectDictLabels,
|
|
||||||
download,
|
download,
|
||||||
handleTree,
|
handleTree,
|
||||||
downloadExcel,
|
downloadExcel,
|
||||||
@ -41,8 +41,8 @@ Vue.prototype.getConfigKey = getConfigKey
|
|||||||
Vue.prototype.parseTime = parseTime
|
Vue.prototype.parseTime = parseTime
|
||||||
Vue.prototype.resetForm = resetForm
|
Vue.prototype.resetForm = resetForm
|
||||||
Vue.prototype.addDateRange = addDateRange
|
Vue.prototype.addDateRange = addDateRange
|
||||||
|
Vue.prototype.addBeginAndEndTime = addBeginAndEndTime
|
||||||
Vue.prototype.selectDictLabel = selectDictLabel
|
Vue.prototype.selectDictLabel = selectDictLabel
|
||||||
Vue.prototype.selectDictLabels = selectDictLabels
|
|
||||||
Vue.prototype.getDictDatas = getDictDatas
|
Vue.prototype.getDictDatas = getDictDatas
|
||||||
Vue.prototype.getDictDataLabel = getDictDataLabel
|
Vue.prototype.getDictDataLabel = getDictDataLabel
|
||||||
Vue.prototype.DICT_TYPE = DICT_TYPE
|
Vue.prototype.DICT_TYPE = DICT_TYPE
|
||||||
|
@ -69,6 +69,35 @@ export function addDateRange(params, dateRange, propName) {
|
|||||||
return search;
|
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) {
|
export function selectDictLabel(datas, value) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
@ -81,21 +110,6 @@ export function selectDictLabel(datas, value) {
|
|||||||
return actions.join('');
|
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) {
|
export function download(fileName) {
|
||||||
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<el-table v-loading="loading" :data="${businessName}List">
|
<el-table v-loading="loading" :data="list">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if ($column.listOperationResult)
|
#if ($column.listOperationResult)
|
||||||
#set ($dictType=$column.dictType)
|
#set ($dictType=$column.dictType)
|
||||||
@ -211,7 +211,7 @@ export default {
|
|||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// ${functionName}表格数据
|
// ${table.tableComment}表格数据
|
||||||
list: [],
|
list: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
@ -250,27 +250,20 @@ export default {
|
|||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询${functionName}列表 */
|
/** 查询列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
#foreach ($column in $columns)
|
let params = {...this.queryParams};
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#foreach ($column in $columns)
|
||||||
this.queryParams.params = {};
|
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||||
#break
|
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#end
|
this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField});
|
||||||
#end
|
#end
|
||||||
#foreach ($column in $columns)
|
#end
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
// 执行查询
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
get${simpleClassName}Page(params).then(response => {
|
||||||
if (null != this.dateRange${AttrName} && '' != this.dateRange${AttrName}) {
|
this.list = response.data.list;
|
||||||
this.queryParams.params["begin${AttrName}"] = this.dateRange${AttrName}[0];
|
this.total = response.data.total;
|
||||||
this.queryParams.params["end${AttrName}"] = this.dateRange${AttrName}[1];
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
|
||||||
this.list = response.rows;
|
|
||||||
this.total = response.total;
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -282,18 +275,13 @@ export default {
|
|||||||
// 表单重置
|
// 表单重置
|
||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "radio")
|
#if($column.htmlType == "checkbox")
|
||||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
$column.javaField: [],
|
||||||
|
#else
|
||||||
#elseif($column.htmlType == "checkbox")
|
$column.javaField: null,
|
||||||
$column.javaField: []#if($velocityCount != $columns.size()),#end
|
#end
|
||||||
|
#end
|
||||||
#else
|
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
@ -304,12 +292,12 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
#foreach ($column in $columns)
|
#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)})
|
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
this.dateRange${AttrName} = [];
|
this.dateRange${AttrName} = [];
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
@ -317,21 +305,21 @@ export default {
|
|||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加${functionName}";
|
this.title = "添加${table.tableComment}";
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
|
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||||
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
get${simpleClassName}(${primaryColumn.javaField}).then(response => {
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "checkbox")## checkbox 特殊处理
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "修改${functionName}";
|
this.title = "修改${table.tableComment}";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
@ -340,36 +328,37 @@ export default {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "checkbox")
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||||
#end
|
#end
|
||||||
#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.msgSuccess("修改成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
});
|
});
|
||||||
} else {
|
return;
|
||||||
add${BusinessName}(this.form).then(response => {
|
}
|
||||||
|
// 添加的提交
|
||||||
|
create${simpleClassName}(this.form).then(response => {
|
||||||
this.msgSuccess("新增成功");
|
this.msgSuccess("新增成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const ${pkColumn.javaField}s = row.${pkColumn.javaField};
|
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||||
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
|
this.$confirm('是否确认删除${table.tableComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return del${BusinessName}(${pkColumn.javaField}s);
|
return delete${simpleClassName}(${primaryColumn.javaField});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
@ -377,15 +366,21 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.queryParams;
|
this.$confirm('是否确认导出所有${table.tableComment}数据项?', "警告", {
|
||||||
this.$confirm('是否确认导出所有${functionName}数据项?', "警告", {
|
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).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 => {
|
}).then(response => {
|
||||||
this.download(response.msg);
|
this.downloadExcel(response, '${table.classComment}.xls');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user