657 lines
13 KiB
JavaScript
657 lines
13 KiB
JavaScript
|
|
/** 项目配置 **/
|
||
|
|
//配置中英文
|
||
|
|
function i18n(lng) {
|
||
|
|
var name = "language";
|
||
|
|
if (lng === undefined) {
|
||
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||
|
|
var _r = window.location.search;
|
||
|
|
var r = _r.substr(1).match(reg);
|
||
|
|
if (r != null) {
|
||
|
|
lng = unescape(r[2]);
|
||
|
|
} else {
|
||
|
|
lng = "cn";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
var language = {
|
||
|
|
cn: "cn", //中文
|
||
|
|
en: "en" //英文
|
||
|
|
};
|
||
|
|
return language[lng];
|
||
|
|
}
|
||
|
|
function getTheme() {
|
||
|
|
var obj = {
|
||
|
|
"$base-bgc": "#096ae4",
|
||
|
|
"$panel-bgc": "#fff",
|
||
|
|
"$font-color": "#333",
|
||
|
|
"$border-color": "#cccfd9",
|
||
|
|
"$bg-color": "#E7ECF2",
|
||
|
|
"$search-color": "#0caa4d",
|
||
|
|
"$refrash-color": "#ffbb28"
|
||
|
|
};
|
||
|
|
var urlParam = decodeURIComponent(location.search);
|
||
|
|
if (urlParam.indexOf("theme") !== -1) {
|
||
|
|
var arr = urlParam.substr(urlParam.indexOf("theme")).split(/[\=\&]/g);
|
||
|
|
}
|
||
|
|
getThemeJson({
|
||
|
|
async: false,
|
||
|
|
success: function(data) {
|
||
|
|
var d = JSON.parse(data);
|
||
|
|
obj = d[(arr&&arr[1])||d.theme].color;
|
||
|
|
},
|
||
|
|
error: function() {
|
||
|
|
console.error("获取主题失败");
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return obj;
|
||
|
|
}
|
||
|
|
//浏览预览时报表默认居中显示
|
||
|
|
function viewCenter() {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
//默认倍率
|
||
|
|
function defaulte() {
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
//配置连接符
|
||
|
|
function connector() {
|
||
|
|
return ".";
|
||
|
|
}
|
||
|
|
//配置设备查询方法
|
||
|
|
function configDevSearch() {
|
||
|
|
var fn = [
|
||
|
|
{
|
||
|
|
fnName: "getZY",
|
||
|
|
labelName: i18n() == "cn" ? "专业" : "Profession",
|
||
|
|
type: "list"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
fnName: "getST",
|
||
|
|
labelName: i18n() == "cn" ? "位置" : "Location",
|
||
|
|
type: "list"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
return fn;
|
||
|
|
}
|
||
|
|
//配置页面上某些按钮或多选框显示和隐藏
|
||
|
|
function htmlConfig() {
|
||
|
|
return {
|
||
|
|
upload: false, //导入导出
|
||
|
|
excel: false, //导入excel报表
|
||
|
|
hiddenDev: true //隐藏设备行
|
||
|
|
};
|
||
|
|
}
|
||
|
|
//配置是否需要进行权限管理
|
||
|
|
function powerDialog() {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
//是否向所有的请求发送token和用户信息等
|
||
|
|
function getToken() {
|
||
|
|
var obj = {
|
||
|
|
token: "",
|
||
|
|
data: {
|
||
|
|
userInfo: ""
|
||
|
|
},
|
||
|
|
path: ""
|
||
|
|
};
|
||
|
|
var fn = window.originParent.getData;
|
||
|
|
if (typeof fn == "function") {
|
||
|
|
var o = fn();
|
||
|
|
obj.token = o.token;
|
||
|
|
obj.data.userInfo = JSON.parse(o.userInfo);
|
||
|
|
obj.path = o.path;
|
||
|
|
}
|
||
|
|
return obj;
|
||
|
|
}
|
||
|
|
|
||
|
|
//配置尖峰平谷的显示顺序
|
||
|
|
function tiemInterval() {
|
||
|
|
switch (i18n()) {
|
||
|
|
case "en":
|
||
|
|
return ["Sharp", "Peak", "Flat", "Valley"];
|
||
|
|
|
||
|
|
default:
|
||
|
|
return ["尖", "峰", "平", "谷"];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// /*统计*/
|
||
|
|
function getALLTotals() {
|
||
|
|
switch (i18n()) {
|
||
|
|
case "en":
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
label: "Max",
|
||
|
|
value: "max"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Min",
|
||
|
|
value: "min"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Maximum generation time",
|
||
|
|
value: "maxTime"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Time of minimum generation",
|
||
|
|
value: "minTime"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Average",
|
||
|
|
value: "avg"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Total",
|
||
|
|
value: "sum"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
|
||
|
|
default:
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
label: "最大值",
|
||
|
|
value: "max"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "最小值",
|
||
|
|
value: "min"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "最大值时间",
|
||
|
|
value: "maxTime"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "最小值时间",
|
||
|
|
value: "minTime"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "平均值",
|
||
|
|
value: "avg"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "求和",
|
||
|
|
value: "sum"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// /*对比*/
|
||
|
|
function getAllContrasts() {
|
||
|
|
switch (i18n()) {
|
||
|
|
case "en":
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
label: "Selected date",
|
||
|
|
disabled: true,
|
||
|
|
checked: true,
|
||
|
|
value: "-1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Compared with the same(Same period last year)",
|
||
|
|
disabled: false,
|
||
|
|
checked: true,
|
||
|
|
value: "0"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Link relative ratio(Same period last month)",
|
||
|
|
disabled: false,
|
||
|
|
checked: true,
|
||
|
|
value: "1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "Compare the date",
|
||
|
|
disabled: false,
|
||
|
|
checked: true,
|
||
|
|
value: "2"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
|
||
|
|
default:
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
label: "选择的日期",
|
||
|
|
disabled: true,
|
||
|
|
checked: true,
|
||
|
|
value: "-1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "同比(去年同期比较)",
|
||
|
|
disabled: false,
|
||
|
|
checked: true,
|
||
|
|
value: "0"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "环比(上月同期比较)",
|
||
|
|
disabled: false,
|
||
|
|
checked: true,
|
||
|
|
value: "1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "对比日期(自选比较日期)",
|
||
|
|
disabled: false,
|
||
|
|
checked: true,
|
||
|
|
value: "2"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @desc 所有报表类型
|
||
|
|
*/
|
||
|
|
function getReportType() {
|
||
|
|
var o = {
|
||
|
|
cn: [
|
||
|
|
{
|
||
|
|
name: "日报表",
|
||
|
|
value: "day",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "日运行",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "日电度",
|
||
|
|
value: "dd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "日报表",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "dd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "日统计",
|
||
|
|
value: "tj"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "日对比",
|
||
|
|
value: "db"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "班报表",
|
||
|
|
value: "cr",
|
||
|
|
cdtype: "dd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "月报表",
|
||
|
|
value: "month",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "月运行",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "月电度",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "月报表",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "月统计",
|
||
|
|
value: "tj"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "月对比",
|
||
|
|
value: "db"
|
||
|
|
},
|
||
|
|
// {
|
||
|
|
// name: "月收益",
|
||
|
|
// value: "sy"
|
||
|
|
// }
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "年报表",
|
||
|
|
value: "year",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "年运行",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "年电度",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "年报表",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "年统计",
|
||
|
|
value: "tj"
|
||
|
|
},
|
||
|
|
// {
|
||
|
|
// name: "年收益",
|
||
|
|
// value: "sy"
|
||
|
|
// }
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "周报表",
|
||
|
|
value: "td",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "周运行",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "周电度",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "周报表",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "季报表",
|
||
|
|
value: "tm",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "季运行",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "季电度",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "季报表",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "自定义跨度",
|
||
|
|
value: "udf",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "自定义跨度报表",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
en: [
|
||
|
|
{
|
||
|
|
name: "Daily report",
|
||
|
|
value: "day",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "Daily running report",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Daily electricity report",
|
||
|
|
value: "dd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Daily report",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "dd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Daily statistics report",
|
||
|
|
value: "tj"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Daily comparison report",
|
||
|
|
value: "db"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Team report",
|
||
|
|
value: "cr",
|
||
|
|
cdtype: "dd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Monthly report",
|
||
|
|
value: "month",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "Monthly running report",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Monthly electricity report",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Monthly report",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Monthly statistics report",
|
||
|
|
value: "tj"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Monthly comparison report",
|
||
|
|
value: "db"
|
||
|
|
},
|
||
|
|
// {
|
||
|
|
// name: "Monthly income statement",
|
||
|
|
// value: "sy"
|
||
|
|
// }
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Annual report",
|
||
|
|
value: "year",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "Annual running report",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Annual electricity report",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Annual report",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Annual statistics report",
|
||
|
|
value: "tj"
|
||
|
|
},
|
||
|
|
// {
|
||
|
|
// name: "Annual income statement",
|
||
|
|
// value: "sy"
|
||
|
|
// }
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Weekly report",
|
||
|
|
value: "td",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "Weekly running report",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Weekly electricity report",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Weekly report",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Quarterly report",
|
||
|
|
value: "tm",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "Quarterly running report",
|
||
|
|
value: "yx"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Quarterly electricity report",
|
||
|
|
value: "dd",
|
||
|
|
cdtype: "nydd"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Quarterly report",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Custom report",
|
||
|
|
value: "udf",
|
||
|
|
type: [
|
||
|
|
{
|
||
|
|
name: "Custom report",
|
||
|
|
value: "bb",
|
||
|
|
cdtype: "nydd"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
};
|
||
|
|
return o[i18n()];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @desc 间隔时间
|
||
|
|
*/
|
||
|
|
function getReportIntreval() {
|
||
|
|
switch (i18n()) {
|
||
|
|
case "en":
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
label: "10 minute",
|
||
|
|
value: "0.168"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "15 minute",
|
||
|
|
value: "0.25"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "30 minute",
|
||
|
|
value: "0.5"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "1 hour",
|
||
|
|
value: "1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "1 day",
|
||
|
|
value: "24"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "1 week",
|
||
|
|
value: "168"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
|
||
|
|
default:
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
label: "10分钟",
|
||
|
|
value: "0.168"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "15分钟",
|
||
|
|
value: "0.25"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "30分钟",
|
||
|
|
value: "0.5"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "1小时",
|
||
|
|
value: "1"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "1天",
|
||
|
|
value: "24"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "1周",
|
||
|
|
value: "168"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @desc 返回表格样式
|
||
|
|
*/
|
||
|
|
function getReportStyle() {
|
||
|
|
switch (i18n()) {
|
||
|
|
case "en":
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
name: "Horizontal",
|
||
|
|
value: "0",
|
||
|
|
img: "../img/ty1.png"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Vertical",
|
||
|
|
value: "1",
|
||
|
|
img: "../img/ty2.png"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
|
||
|
|
default:
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
name: "横向报表",
|
||
|
|
value: "0",
|
||
|
|
img: "../img/ty1.png"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "纵向报表",
|
||
|
|
value: "1",
|
||
|
|
img: "../img/ty2.png"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
window.originiframe = function(s) {
|
||
|
|
s = s === undefined ? self : s;
|
||
|
|
try {
|
||
|
|
s.parent.name;
|
||
|
|
} catch (err) {
|
||
|
|
return s;
|
||
|
|
}
|
||
|
|
return s.parent;
|
||
|
|
};
|
||
|
|
//子iframe查找非跨域的父级层iframe,用于在跨域环境中代替parent
|
||
|
|
window.originParent = window.originiframe(self);
|
||
|
|
//子iframe查找非跨域的最上级层iframe,用于在跨域环境中代替top
|
||
|
|
window.originTop = (function() {
|
||
|
|
var p,
|
||
|
|
s = self;
|
||
|
|
while (p !== s) {
|
||
|
|
s = p;
|
||
|
|
p = window.originiframe(p);
|
||
|
|
}
|
||
|
|
return p;
|
||
|
|
})();
|