You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.3 KiB
82 lines
2.3 KiB
1 year ago
|
// 窗口改变,页面刷新
|
||
|
var addEventResizeFlesh = function(){
|
||
|
window.addEventListener('resize',function(){
|
||
|
window.location.reload()
|
||
|
})
|
||
|
}
|
||
|
|
||
|
// 时间查询(agTable)
|
||
|
var dateFilterParams = {
|
||
|
comparator: (filterLocalDateAtMidnight, cellValue) => {
|
||
|
var dateAsString = cellValue;
|
||
|
if (dateAsString == null) return -1;
|
||
|
var dateParts = dateAsString.split('/');
|
||
|
var cellDate = new Date(
|
||
|
Number(dateParts[2]),
|
||
|
Number(dateParts[1]) - 1,
|
||
|
Number(dateParts[0])
|
||
|
);
|
||
|
if (filterLocalDateAtMidnight.getTime() === cellDate.getTime()) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (cellDate < filterLocalDateAtMidnight) {
|
||
|
return -1;
|
||
|
}
|
||
|
if (cellDate > filterLocalDateAtMidnight) {
|
||
|
return 1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 2022-08-31T09:45:51.9340433 转 2022-08-31 09:45:51
|
||
|
var formatTimeStrToStr = function(timeStr) {
|
||
|
if (!timeStr || !new Date(timeStr)) {
|
||
|
return ''
|
||
|
}
|
||
|
if (timeStr.lastIndexOf('.') == -1) {
|
||
|
return timeStr.replace('T',' ').substring(0,timeStr.length)
|
||
|
}
|
||
|
return timeStr.replace('T',' ').substring(0,timeStr.lastIndexOf('.'))
|
||
|
}
|
||
|
|
||
|
// 转换数字小数点保留+千位符
|
||
|
/**
|
||
|
* @param {*} number 数值
|
||
|
* @param {*} isKilo 是否用千位符,默认否(选填)
|
||
|
* @param {*} fixed 保留小数位数,默认2(选填)
|
||
|
* @returns
|
||
|
*/
|
||
|
var numberFixedFormatter = function(number,isKilo,fixed){
|
||
|
let _fixed = fixed || 2;
|
||
|
let _res = Number(number).toFixed(_fixed)
|
||
|
if(isKilo){
|
||
|
_res = Number(Number(number).toFixed(_fixed)).toLocaleString('en-US');
|
||
|
}
|
||
|
return _res;
|
||
|
}
|
||
|
|
||
|
// 转换数字百分号+小数点保留
|
||
|
/**
|
||
|
* @param {*} number 数值
|
||
|
* @param {*} isPercent 是否需要手动转*100,默认否(选填)
|
||
|
* @param {*} fixed 保留小数位数,默认2(选填)
|
||
|
* @returns
|
||
|
*/
|
||
|
var numberPercentFormatter = function(number,isPercent,fixed){
|
||
|
let _fixed = fixed || 2;
|
||
|
let _res = Number(number).toFixed(_fixed) + ' %'
|
||
|
if(isPercent){
|
||
|
_res = Number(Number(number)*100).toFixed(_fixed) + ' %'
|
||
|
}
|
||
|
return _res;
|
||
|
}
|
||
|
|
||
|
export default {
|
||
|
waitTime:20000,//滚屏列表刷新等待间隔配置项
|
||
|
addEventResizeFlesh:addEventResizeFlesh,
|
||
|
dateFilterParams:dateFilterParams,
|
||
|
numberFixedFormatter,
|
||
|
numberPercentFormatter,
|
||
|
formatTimeStrToStr
|
||
|
}
|