From 977e332a5338942df338728dbfb77a359e35bd0b Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期五, 09 五月 2025 12:25:21 +0800 Subject: [PATCH] 添加动态溯源相关逻辑(待完成) --- src/model/FactorDatas.js | 78 ++++++++++++++++++++++++++++++++++----- 1 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/model/FactorDatas.js b/src/model/FactorDatas.js index 58bc5a8..f285080 100644 --- a/src/model/FactorDatas.js +++ b/src/model/FactorDatas.js @@ -1,5 +1,7 @@ import { Factor } from './Factor'; import calculate from '@/utils/map/calculate'; +import { Legend } from './Legend'; +import moment from 'moment'; /** * @@ -16,12 +18,24 @@ // 鐩戞祴鍥犲瓙鏁版嵁锛孧ap<String, Factor> this.factor = new Map(); - if (options != undefined) { - this.times = options.times; - this.lnglats_GPS = options.lnglats_GPS; - this.lnglats_GD = options.lnglats_GD; - this.coors_GD = options.coors_GD; - this.factor = options.factor; + this.legendType = Legend.S_TYPE; //鍥句緥妯″紡 + + // if (options != undefined) { + // this.times = options.times; + // this.lnglats_GPS = options.lnglats_GPS; + // this.lnglats_GD = options.lnglats_GD; + // this.coors_GD = options.coors_GD; + // this.factor = options.factor; + // this.legendType = options.legendType; + // } + + if (typeof options === 'object') { + for (const key in options) { + if (Object.prototype.hasOwnProperty.call(options, key)) { + const value = options[key]; + this[key] = value; + } + } } } @@ -47,6 +61,9 @@ }] */ setData: function (dataList, drawMode, callback) { + if (dataList.length == 0) { + return; + } this.clearData(); dataList.forEach((d) => { @@ -55,7 +72,9 @@ d.values.forEach((v) => { var f = this.factor[v.factorId]; if (f == undefined) { - f = new Factor(); + f = new Factor({ + legendType: this.legendType + }); this.factor[v.factorId] = f; } f.pushData(v, drawMode == undefined ? 0 : drawMode); @@ -67,6 +86,10 @@ // 鏂板涓�涓柊鏁版嵁 addData: function (dataList, drawMode, callback) { + if (dataList.length == 0) { + return; + } + var newGps = []; dataList.forEach((data) => { this.times.push(data.time); @@ -111,17 +134,38 @@ // 璁剧疆缁樺浘鑼冨洿 setRange: function (key, range) { - this.factor[key].setRange(range); + this.legendType = Legend.C_TYPE; + if (key != undefined) { + this.factor[key].setRange(range); + } else { + for (const k in this.factor) { + this.factor[k].setRange(range); + } + } }, // 閲嶇疆缁樺浘鑼冨洿 resetRange: function (key) { - this.factor[key].clearRange(); + this.legendType = Legend.D_TYPE; + if (key != undefined) { + this.factor[key].clearRange(); + } else { + for (const k in this.factor) { + this.factor[k].clearRange(); + } + } }, // 璁剧疆涓烘爣鍑嗙粯鍥捐寖鍥� standardRange: function (key) { - this.factor[key].standardRange(); + this.legendType = Legend.S_TYPE; + if (key != undefined) { + this.factor[key].standardRange(); + } else { + for (const k in this.factor) { + this.factor[k].standardRange(); + } + } }, // 鏍规嵁褰撳墠缁樺浘鑼冨洿閲嶆柊璁$畻缁樺浘楂樺害 @@ -157,6 +201,20 @@ }); }, + getByDate(s, e) { + const sTime = moment(s).format('YYYY-MM-DD HH:mm:ss'); + const eTime = moment(e).format('YYYY-MM-DD HH:mm:ss'); + const sIndex = this.times.findIndex((v) => { + return v == sTime; + }); + const eIndex = this.times.findIndex((v) => { + return v == eTime; + }); + if (sIndex != -1 && eIndex != -1) { + return this.getByIndex(sIndex, eIndex); + } + }, + // 鑾峰彇鏁版嵁闀垮害 length: function () { return this.lnglats_GD.length; -- Gitblit v1.9.3