基本完成 index.vue.vm 模板

This commit is contained in:
YunaiV
2021-02-12 11:53:32 +08:00
parent 0b25eb1c2a
commit b8351f50f2
3 changed files with 97 additions and 88 deletions

View File

@ -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

View File

@ -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;