Files
system-jibei/pqs9000/src/main/webapp/jspJS/utils/plateUtils.js

246 lines
4.9 KiB
JavaScript
Raw Normal View History

2024-04-01 09:20:31 +08:00
/*********************
* add by denghhuajun
*主要对历史数据公共类抽取
* ********************/
// 右边统计类型tree节点增加数据(星型)
var reportNode = [{
id: 1,
pId: 0,
name: "电度基本电能量",
open: true,
checked: true,
},
// {
// id: 11,
// pId: 1,
// name: "有功电能",
// checked: true
// },
{
id: 111,
pId: 1,
name: "三相总有功电能",
checked: true
},
// {
// id: 12,
// pId: 1,
// name: "无功电能"
// },
{
id: 121,
pId: 1,
name: "三相总无功电能"
},
// {
// id: 13,
// pId: 1,
// name: "视在电能"
// },
{
id: 131,
pId: 1,
name: "三相总视在电能"
},
// {
// id: 14,
// pId: 1,
// name: "基波有功电能"
// },
{
id: 141,
pId: 1,
name: "三相总基波有功电能"
},
// {
// id: 15,
// pId: 1,
// name: "基波无功电能"
// },
{
id: 151,
pId: 1,
name: "三相总基波无功电能"
},
// {
// id: 16,
// pId: 1,
// name: "总谐波有功电能"
// },
{
id: 161,
pId: 1,
name: "三相总谐波有功电能"
},
// {
// id: 17,
// pId: 1,
// name: "总谐波无功电能"
// },
{
id: 171,
pId: 1,
name: "三相总谐波无功电能"
}];
var zNodes = [{
id: 1,
pId: 0,
name: "电度基本电能量",
open: true,
checked: true,
}, {
id: 11,
pId: 1,
name: "有功电能",
checked: true
}, {
id: 111,
pId: 1,
name: "三相总有功电能",
checked: true
}, {
id: 12,
pId: 1,
name: "无功电能"
}, {
id: 121,
pId: 1,
name: "三相总无功电能"
}, {
id: 13,
pId: 1,
name: "视在电能"
}, {
id: 131,
pId: 1,
name: "三相总视在电能"
}, {
id: 14,
pId: 1,
name: "基波有功电能"
}, {
id: 141,
pId: 1,
name: "三相总基波有功电能"
}, {
id: 15,
pId: 1,
name: "基波无功电能"
}, {
id: 151,
pId: 1,
name: "三相总基波无功电能"
}, {
id: 16,
pId: 1,
name: "总谐波有功电能"
}, {
id: 161,
pId: 1,
name: "三相总谐波有功电能"
}, {
id: 17,
pId: 1,
name: "总谐波无功电能"
}, {
id: 171,
pId: 1,
name: "三相总谐波无功电能"
}, {
id: 2,
pId: 0,
name: "电度谐波电能量",
}, {
id: 21,
pId: 2,
name: "谐波有功电能",
}, {
id: 22,
pId: 2,
name: "谐波无功电能"
}, {
id: 3,
pId: 0,
name: "电度需量",
}, {
id: 31,
pId: 3,
name: "有功需量"
}, {
id: 32,
pId: 3,
name: "无功需量"
}];
/*********************
* 开始时间与结束时间比较
* 开始时间大于结束时间返回false
* 开始时间小于结束时间返回true
* @param startTime
* @param endTime
* @returns
********************/
function compareTime(startTime, endTime) {
if (startTime > endTime) {
return false;
}
return true;
}
/**
* 根据两个日期判断相差天数
* @param sDate1 开始日期 2016-11-01
* @param sDate2 结束日期 2016-11-02
* @returns {number} 返回相差天数
*/
function daysBetween(sDate1, sDate2) {
//Date.parse() 解析一个日期时间字符串并返回1970/1/1 午夜距离该日期时间的毫秒数
var time1 = Date.parse(new Date(sDate1.replace(/-/g, "/")));
var time2 = Date.parse(new Date(sDate2.replace(/-/g, "/")));
var nDays = Math.abs(Math.ceil(parseFloat(time2 - time1).toFixed(2) / (1000 * 3600 * 24)));
return nDays;
};
function dataAddOneDay(dataEnd) {
var strdate = dataEnd; //日期字符串
var isdate = new Date(strdate.replace(/-/g, "/")); //把日期字符串转换成日期格式
isdate = new Date((isdate / 1000 + 86400) * 1000); //日期加1天
// 把日期格式转换成字符串
var year = isdate.getFullYear();
var month = (isdate.getMonth() + 1).toString();
var day = (isdate.getDate()).toString();
if (month.length == 1) {
month = "0" + month;
}
if (day.length == 1) {
day = "0" + day;
}
var pdate = year + "-" + month + "-" + day;
return pdate;
}
//日期加天数的方法
//dataStr日期字符串
//dayCount 要增加的天数
//return 增加n天后的日期字符串
function dateAddDays(dataStr, dayCount) {
var strdate = dataStr; //日期字符串
var isdate = new Date(strdate.replace(/-/g, "/")); //把日期字符串转换成日期格式
isdate = new Date((isdate / 1000 + (86400 * (dayCount - 1))) * 1000); //日期加1天
// 把日期格式转换成字符串
var year = isdate.getFullYear();
var month = (isdate.getMonth() + 1).toString();
var day = (isdate.getDate()).toString();
if (month.length == 1) {
month = "0" + month;
}
if (day.length == 1) {
day = "0" + day;
}
var pdate = year + "-" + month + "-" + day;
return pdate;
}