|
@@ -365,26 +365,164 @@ export function calcEndMinAndMaxValue(standalone) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 函数:通过数组描述执行表达式,得到变量对应的颜色
|
|
|
+ * 对每个字段设置颜色值
|
|
|
*/
|
|
|
-function getArgsColor(argsList, runMode, val) {
|
|
|
- let evalString = "";
|
|
|
+function setPropColorVal(data, argsList) {
|
|
|
+ const hpArgsList = argsList.filter((a) => a.En.indexOf("host_") == 0);
|
|
|
+ const dhArgsList = argsList.filter((a) => a.En.indexOf("nt_") == 0);
|
|
|
+ const hexArgsList = argsList.filter((a) => a.En.indexOf("hex_") == 0);
|
|
|
+ const cbArgsList = argsList.filter((a) => a.En.indexOf("end_") == 0);
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ const box = data[i];
|
|
|
+
|
|
|
+ // 主机
|
|
|
+ const hostCtrl = box.hostCtrl || [];
|
|
|
+ for (let j = 0; j < hostCtrl.length; j++) {
|
|
|
+ const hp = hostCtrl[j];
|
|
|
+ // 供水温度
|
|
|
+ hp["colorval_host_su_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ hp,
|
|
|
+ "host_su_temp",
|
|
|
+ hpArgsList
|
|
|
+ );
|
|
|
+ // 回水温度
|
|
|
+ hp["colorval_host_re_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ hp,
|
|
|
+ "host_re_temp",
|
|
|
+ hpArgsList
|
|
|
+ );
|
|
|
+ // 温差
|
|
|
+ hp["colorval_host_temp_diff"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ hp,
|
|
|
+ "host_temp_diff",
|
|
|
+ hpArgsList
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新风机
|
|
|
+ const newTrendCtrl = box.newTrendCtrl || [];
|
|
|
+ for (let j = 0; j < newTrendCtrl.length; j++) {
|
|
|
+ const dh = newTrendCtrl[j];
|
|
|
+ // 送风温度
|
|
|
+ dh["colorval_nt_in_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ dh,
|
|
|
+ "nt_in_temp",
|
|
|
+ dhArgsList
|
|
|
+ );
|
|
|
+ // 送风湿度
|
|
|
+ dh["colorval_nt_in_humidity"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ dh,
|
|
|
+ "nt_in_humidity",
|
|
|
+ dhArgsList
|
|
|
+ );
|
|
|
+ // 送风露点
|
|
|
+ dh["colorval_nt_dew_point"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ dh,
|
|
|
+ "nt_dew_point",
|
|
|
+ dhArgsList
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 换热站
|
|
|
+ const heatExchangeCtrl = box.hex || [];
|
|
|
+ for (let j = 0; j < heatExchangeCtrl.length; j++) {
|
|
|
+ const hex = heatExchangeCtrl[j];
|
|
|
+ // 供水温度
|
|
|
+ hex["colorval_hex_su_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ hex,
|
|
|
+ "hex_su_temp",
|
|
|
+ hexArgsList
|
|
|
+ );
|
|
|
+ // 供水温度
|
|
|
+ hex["colorval_hex_re_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ hex,
|
|
|
+ "hex_re_temp",
|
|
|
+ hexArgsList
|
|
|
+ );
|
|
|
+ // 温差
|
|
|
+ hex["colorval_hex_temp_diff"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ hex,
|
|
|
+ "hex_temp_diff",
|
|
|
+ hexArgsList
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 末端
|
|
|
+ const endCtrl = box.end || [];
|
|
|
+ for (let j = 0; j < endCtrl.length; j++) {
|
|
|
+ const end = endCtrl[j];
|
|
|
+ // 最低室内温度
|
|
|
+ end["colorval_end_min_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ end,
|
|
|
+ "end_min_temp",
|
|
|
+ cbArgsList
|
|
|
+ );
|
|
|
+ // 最低室内湿度
|
|
|
+ end["colorval_end_min_humidity"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ end,
|
|
|
+ "end_min_humidity",
|
|
|
+ cbArgsList
|
|
|
+ );
|
|
|
+ // 最低室内露点
|
|
|
+ end["colorval_end_min_dew_point"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ end,
|
|
|
+ "end_min_dew_point",
|
|
|
+ cbArgsList
|
|
|
+ );
|
|
|
+ // 最高室内温度
|
|
|
+ end["colorval_end_max_temp"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ end,
|
|
|
+ "end_max_temp",
|
|
|
+ cbArgsList
|
|
|
+ );
|
|
|
+ // 最高室内湿度
|
|
|
+ end["colorval_end_max_humidity"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ end,
|
|
|
+ "end_max_humidity",
|
|
|
+ cbArgsList
|
|
|
+ );
|
|
|
+ // 最高室内露点
|
|
|
+ end["colorval_end_max_dew_point"] = runCodeInArgsList(
|
|
|
+ box.runMode,
|
|
|
+ end,
|
|
|
+ "end_max_dew_point",
|
|
|
+ cbArgsList
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 使用eval()方法执行判断
|
|
|
+ */
|
|
|
+function runCodeInArgsList(runMode, row, prop, argsList) {
|
|
|
+ argsList = argsList.filter((a) => a.En === prop);
|
|
|
+
|
|
|
+ var colorVal = 0;
|
|
|
+ var evalString = "";
|
|
|
if (argsList.length <= 0) {
|
|
|
return evalString;
|
|
|
}
|
|
|
|
|
|
- var color = "";
|
|
|
// 先找出条件中有模式的数组跟无模式的数组
|
|
|
// 先拼接带有模式的数组, 再组合一下无模式的数组
|
|
|
- let runModeArgs = argsList.filter((args) => args.RunMode > 0);
|
|
|
- let noneRunModeArgs = argsList.filter((args) => args.RunMode <= 0);
|
|
|
- runModeArgs.forEach((args) => {
|
|
|
- evalString += `if (runMode==${args.RunMode}) {color=val${args.Action}${args.Threshold}`;
|
|
|
- if (args.Action2.length && args.Threshold2 > 0) {
|
|
|
- evalString += `||val${args.Action2}${args.Threshold2}`;
|
|
|
- }
|
|
|
- evalString += `?'yellow':''} else `;
|
|
|
- });
|
|
|
+ const val = row[prop];
|
|
|
+ const runModeArgs = argsList.filter((args) => args.RunMode > 0);
|
|
|
+ const noneRunModeArgs = argsList.filter((args) => args.RunMode <= 0);
|
|
|
if (noneRunModeArgs.length > 0) {
|
|
|
let tmp = "if (";
|
|
|
noneRunModeArgs.forEach((args) => {
|
|
@@ -392,19 +530,22 @@ function getArgsColor(argsList, runMode, val) {
|
|
|
tmp += "||";
|
|
|
});
|
|
|
tmp = tmp.substring(0, tmp.length - 2);
|
|
|
- tmp += `) {color='yellow'} else {color=''}`;
|
|
|
+ tmp += `) {colorVal=1} else {colorVal=0}`;
|
|
|
evalString += tmp;
|
|
|
} else {
|
|
|
+ runModeArgs.forEach((args) => {
|
|
|
+ evalString += `if (runMode==${args.RunMode}) {colorVal=(val${args.Action}${args.Threshold}`;
|
|
|
+ if (args.Action2.length) {
|
|
|
+ evalString += `||val${args.Action2}${args.Threshold2})`;
|
|
|
+ } else {
|
|
|
+ evalString += ')';
|
|
|
+ }
|
|
|
+ evalString += `?1:0} else `;
|
|
|
+ });
|
|
|
evalString = evalString.substring(0, evalString.length - 5);
|
|
|
}
|
|
|
-
|
|
|
- // if (argsList[0].En === "host_temp_diff") {
|
|
|
- // console.log(">>> evalString: ", evalString);
|
|
|
- // }
|
|
|
-
|
|
|
- // 执行命令
|
|
|
eval(evalString);
|
|
|
- return color;
|
|
|
+ return colorVal;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -487,7 +628,8 @@ export default {
|
|
|
filterHostCtrl,
|
|
|
calcMaxStandaloneCnt,
|
|
|
calcEndMinAndMaxValue,
|
|
|
- getArgsColor,
|
|
|
+ setPropColorVal,
|
|
|
+ runCodeInArgsList,
|
|
|
formatData,
|
|
|
getCbOrder,
|
|
|
};
|