|
@@ -1290,6 +1290,31 @@ module.exports = {
|
|
|
return result;
|
|
|
},
|
|
|
|
|
|
+ filterLastestData2(data, keyFields, timesField = 'times', orderField = 'order') {
|
|
|
+ const dataIndex = {};
|
|
|
+ for (const d of data) {
|
|
|
+ let key = 'd';
|
|
|
+ for (const kf of keyFields) {
|
|
|
+ key = key + '.' + (d[kf] || '');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!dataIndex[key]) dataIndex[key] = { index: 0, source: [] };
|
|
|
+ const di = dataIndex[key];
|
|
|
+ const curIndex = d[timesField] * timesLen + d[orderField];
|
|
|
+ if (curIndex === di.index) {
|
|
|
+ di.source.push(d);
|
|
|
+ } else if (curIndex > di.index) {
|
|
|
+ di.index = curIndex;
|
|
|
+ di.source = [d];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const result = [];
|
|
|
+ for (const prop in dataIndex) {
|
|
|
+ result.push(...dataIndex[prop].source);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+
|
|
|
calcExpr(expr) {
|
|
|
const validExpr = expr.replace('=', '').replace('%', '/100');
|
|
|
return math.eval(validExpr);
|