|
@@ -1,90 +1,102 @@
|
|
|
+import define from "./common.js";
|
|
|
+
|
|
|
/** 根据主机属性进行排序(比较最大值) */
|
|
|
export function sortBoxListByHost(data, sort) {
|
|
|
// 先计算最大值
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
- const box = data[i]
|
|
|
- const hostCtrl = box.hostCtrl || []
|
|
|
- let maxVal = 0
|
|
|
+ const box = data[i];
|
|
|
+ const hostCtrl = box.hostCtrl || [];
|
|
|
+ let maxVal = 0;
|
|
|
for (let j = 0; j < hostCtrl.length; j++) {
|
|
|
- const hp = hostCtrl[j]
|
|
|
- if (hp[sort.prop] > maxVal) {
|
|
|
- maxVal = hp[sort.prop]
|
|
|
+ const hp = hostCtrl[j];
|
|
|
+ if (_isFloat(sort.prop)) {
|
|
|
+ if (hp[sort.prop] > maxVal && box.runStatus == 1) {
|
|
|
+ maxVal = hp[sort.prop];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // TODO:
|
|
|
}
|
|
|
}
|
|
|
- box["max_" + sort.prop] = maxVal
|
|
|
+ box["max_" + sort.prop] = maxVal;
|
|
|
console.log(
|
|
|
`盒子[${box.boxName}]的${"max_" + sort.prop}值为: ${
|
|
|
box["max_" + sort.prop]
|
|
|
}`
|
|
|
);
|
|
|
}
|
|
|
- return _sortData(data, sort)
|
|
|
+ return _sortData(data, sort);
|
|
|
}
|
|
|
|
|
|
/** 根据新风机属性进行排序(比较最大值) */
|
|
|
export function sortBoxListByNewTrend(data, sort) {
|
|
|
// 先计算最大值
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
- const box = data[i]
|
|
|
+ const box = data[i];
|
|
|
const newTrendCtrl = box.newTrendCtrl || [];
|
|
|
- let maxVal = 0
|
|
|
+ let maxVal = 0;
|
|
|
for (let j = 0; j < newTrendCtrl.length; j++) {
|
|
|
- const dh = newTrendCtrl[j]
|
|
|
+ const dh = newTrendCtrl[j];
|
|
|
if (dh[sort.prop] > maxVal) {
|
|
|
- maxVal = dh[sort.prop]
|
|
|
+ maxVal = dh[sort.prop];
|
|
|
}
|
|
|
}
|
|
|
- box["max_" + sort.prop] = maxVal
|
|
|
+ box["max_" + sort.prop] = maxVal;
|
|
|
}
|
|
|
- return _sortData(data, sort)
|
|
|
+ return _sortData(data, sort);
|
|
|
}
|
|
|
|
|
|
/** 根据换热站属性进行排序(比较最大值) */
|
|
|
export function sortBoxListByHeatExchange(data, sort) {
|
|
|
// 先计算最大值
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
- const box = data[i]
|
|
|
+ const box = data[i];
|
|
|
const heatExchangeCtrl = box.hex || [];
|
|
|
- let maxVal = 0
|
|
|
+ let maxVal = 0;
|
|
|
for (let j = 0; j < heatExchangeCtrl.length; j++) {
|
|
|
- const hex = heatExchangeCtrl[j]
|
|
|
+ const hex = heatExchangeCtrl[j];
|
|
|
if (hex[sort.prop] > maxVal) {
|
|
|
maxVal = hex[sort.prop];
|
|
|
}
|
|
|
}
|
|
|
- box["max_" + sort.prop] = maxVal
|
|
|
+ box["max_" + sort.prop] = maxVal;
|
|
|
}
|
|
|
- return _sortData(data, sort)
|
|
|
+ return _sortData(data, sort);
|
|
|
}
|
|
|
|
|
|
/** 根据面板属性进行排序(比较最大值) */
|
|
|
export function sortBoxListByEnd(data, sort) {
|
|
|
// 先计算最大值
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
- const box = data[i]
|
|
|
+ const box = data[i];
|
|
|
const endCtrl = box.end || [];
|
|
|
- let maxVal = 0
|
|
|
+ let maxVal = 0;
|
|
|
for (let j = 0; j < endCtrl.length; j++) {
|
|
|
- const end = endCtrl[j]
|
|
|
+ const end = endCtrl[j];
|
|
|
if (end[sort.prop] > maxVal) {
|
|
|
maxVal = end[sort.prop];
|
|
|
}
|
|
|
}
|
|
|
- box["max_" + sort.prop] = maxVal
|
|
|
+ box["max_" + sort.prop] = maxVal;
|
|
|
}
|
|
|
- return _sortData(data, sort)
|
|
|
+ return _sortData(data, sort);
|
|
|
}
|
|
|
|
|
|
+// 数据排序
|
|
|
function _sortData(data, sort) {
|
|
|
return data.sort(function(obj1, obj2) {
|
|
|
- let val1 = obj1["max_" + sort.prop]
|
|
|
- let val2 = obj2["max_" + sort.prop]
|
|
|
+ let val1 = obj1["max_" + sort.prop];
|
|
|
+ let val2 = obj2["max_" + sort.prop];
|
|
|
if (val1 < val2) {
|
|
|
- return sort.order === "descending" ? 1 : -1
|
|
|
+ return sort.order === "descending" ? 1 : -1;
|
|
|
} else if (val1 > val2) {
|
|
|
- return sort.order === "descending" ? -1 : 1
|
|
|
+ return sort.order === "descending" ? -1 : 1;
|
|
|
} else {
|
|
|
- return 0
|
|
|
+ return 0;
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 是否为float类型
|
|
|
+function _isFloat(prop) {
|
|
|
+ return define.calcFloatProps.includes(prop);
|
|
|
}
|