锘縱ar zhexiantu1; var zhexiantu2; var zhexiantu3; var zhexiantu4; var swiper; var clock; var dateNow; var urls = { LuWen: "/Home/GetSetDataListLuWen", Monitor: "/Home/GetSetDataListMonitor", RemoteData: "/Home/GetRemoteData", GetLive: "/Home/GetLive", GetSetDataListGkInfo: "/Home/GetSetDataListGkInfo", averger: "/Home/GetAverger", }; function getDate(strDate) { var date = eval( "new Date(" + strDate .replace(/\d+(?=-[^-]+$)/, function (a) { return parseInt(a, 10) - 1; }) .match(/\d+/g) + ")" ); return date; } var vm = new Vue({ el: "#app", data: { isSynchronization: false, isShow: true, date: "", now1Date: "", dateTime: "", loading: true, nowDate: "", Monitor1: [], LuWen1: [], standardValue1: [], Monitor2: [], LuWen2: [], standardValue2: [], Monitor3: [], LuWen3: [], standardValue3: [], Monitor4: [], LuWen4: [], standardValue4: [], xzhou: [], isAutoplay: true, liveList: [], isHasData: true, isShiShi: false, isFirst: true, standardList: [0, 0, 0, 0, 0], luwen: 0, gk1: "姝e父", gk2: "姝e父", gk3: "姝e父", gk4: "姝e父", timerEnsvc: {}, num: 0, //isShowDataLive1: true, //isShowDataLive2: true, //isShowDataLive3: true, //isShowDataLive4: true, lu1: { keliwu: "", danyang: "", eryang: "", yanghuaqing: "", yiyanghuatan: "", lutangwendu: "", lukuangwendu: "", lukuangqiyangliang: "", }, lu2: { keliwu: "", danyang: "", eryang: "", yanghuaqing: "", yiyanghuatan: "", lutangwendu: "", lukuangwendu: "", lukuangqiyangliang: "", }, lu3: { keliwu: "", danyang: "", eryang: "", yanghuaqing: "", yiyanghuatan: "", lutangwendu: "", lukuangwendu: "", lukuangqiyangliang: "", }, lu4: { keliwu: "", danyang: "", eryang: "", yanghuaqing: "", yiyanghuatan: "", lutangwendu: "", lukuangwendu: "", lukuangqiyangliang: "", }, isError: false, // 閫氳鏁呴殰, liAverage: {}, isLoadGkInfo: false, averger: [ { name: "棰楃矑鐗?, stander: "10", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "mg/m鲁", }, { name: "浜屾哀鍖栫~", stander: "80", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "mg/m鲁", }, { name: "姘寲姘?, stander: "30", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "mg/m鲁", }, { name: "姘哀鍖栫墿", stander: "200", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "mg/m鲁", }, { name: "涓€姘у寲纰?, stander: "100", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "mg/m鲁", }, { name: "鐐夎啗娓╁害
瀹炴椂", stander: "鈮?50", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "鈩?, }, { name: "鐐夎啗娓╁害", stander: "鈮?50", lu1: "-", lu2: "-", lu3: "-", lu4: "-", unit: "鈩?, }, { name: "宸ュ喌", stander: "--", lu1: "姝e父", lu2: "姝e父", lu3: "姝e父", lu4: "姝e父", unit: "--", }, ], averageTime: "", }, computed: { avgLuwen1: function () { let sum = 0; let avg = 0; if (this.LuWen1.length > 0) { this.LuWen1.forEach((i) => { if (i[0]) { sum += i[0]; } }); avg = Math.round(sum / this.LuWen1.length); } if (avg < 100) { return "--"; } return avg; }, avgLuwen2: function () { let sum = 0; let avg = 0; if (this.LuWen2.length > 0) { this.LuWen2.forEach((i) => { if (i[0]) { sum += i[0]; } }); avg = Math.round(sum / this.LuWen2.length); } if (avg < 100) { return "--"; } return avg; }, avgLuwen3: function () { let sum = 0; let avg = 0; if (this.LuWen3.length > 0) { this.LuWen3.forEach((i) => { if (i[0]) { sum += i[0]; } }); avg = Math.round(sum / this.LuWen3.length); } if (avg < 100) { return "--"; } return avg; }, avgLuwen4: function () { let sum = 0; let avg = 0; if (this.LuWen4.length > 0) { this.LuWen4.forEach((i) => { if (i[0]) { sum += i[0]; } }); avg = Math.round(sum / this.LuWen4.length); } if (avg < 100) { return "--"; } return avg; }, dateFormated: function () { let myDate = new Date(this.date); let year = myDate.getFullYear(); var month = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; var day = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate(); var dateStr = year + "骞? + month + "鏈? + day + "鏃?; return dateStr; }, }, methods: { ultZeroize(v) { return v < 10 ? "0" + v : v; }, initAverageModel: function (arr, lu) { // console.log(arr); for (const item of arr) { if (item.name.indexOf("棰楃矑鐗?) > -1) { this.averger[0][lu] = item.value; } else if (item.name.indexOf("浜屾哀鍖栫~") > -1) { this.averger[1][lu] = item.value; } else if (item.name.indexOf("姘寲姘?) > -1) { this.averger[2][lu] = item.value; } else if (item.name.indexOf("姘哀鍖栫墿") > -1) { this.averger[3][lu] = item.value; } else if (item.name.indexOf("涓€姘у寲纰?) > -1) { this.averger[4][lu] = item.value; } else if (item.name.indexOf("鐐夎啗娓╁害瀹炴椂") > -1) { this.averger[5][lu] = item.value; } else if (item.name.indexOf("鐐夎啗娓╁害DCS") > -1) { this.averger[6][lu] = item.value; } else if (item.name.indexOf("宸ュ喌") > -1) { this.averger[7][lu] = this.getGKValue(item.value); } } // console.log("averger", this.averger); }, getGKValue: function (param) { let value = ""; if (param == "011BLR01GZBJ") { value = "鏁呴殰"; } else if (param == "011BLR01HLBJ") { value = "鐑樼倝"; } else if (param == "011BLR01QLBJ") { value = "鍚倝"; } else if (param == "011BLR01SGBJ") { value = "浜嬫晠"; } else if (param == "011BLR01TLBJ") { value = "鍋滅倝"; } else if (param == "011BLR01TLJWBJ") { value = "鍋滅倝闄嶆俯"; } else if (param == "011BLR01TYBJ") { value = "鍋滆繍"; } else if (param == "012BLR01GZBJ") { value = "鏁呴殰"; } else if (param == "012BLR01HLBJ") { value = "鐑樼倝"; } else if (param == "012BLR01QLBJ") { value = "鍚倝"; } else if (param == "012BLR01SGBJ") { value = "浜嬫晠"; } else if (param == "012BLR01TLBJ") { value = "鍋滅倝"; } else if (param == "012BLR01TLJWBJ") { value = "鍋滅倝闄嶆俯"; } else if (param == "012BLR01TYBJ") { value = "鍋滆繍"; } else if (param == "013BLR01GZBJ") { value = "鏁呴殰"; } else if (param == "013BLR01HLBJ") { value = "鐑樼倝"; } else if (param == "013BLR01QLBJ") { value = "鍚倝"; } else if (param == "013BLR01SGBJ") { value = "浜嬫晠"; } else if (param == "013BLR01TLBJ") { value = "鍋滅倝"; } else if (param == "013BLR01TLJWBJ") { value = "鍋滅倝闄嶆俯"; } else if (param == "013BLR01TYBJ") { value = "鍋滆繍"; } else if (param == "014BLR01GZBJ") { value = "鏁呴殰"; } else if (param == "014BLR01HLBJ") { value = "鐑樼倝"; } else if (param == "014BLR01QLBJ") { value = "鍚倝"; } else if (param == "014BLR01SGBJ") { value = "浜嬫晠"; } else if (param == "014BLR01TLBJ") { value = "鍋滅倝"; } else if (param == "014BLR01TLJWBJ") { value = "鍋滅倝闄嶆俯"; } else if (param == "014BLR01TYBJ") { value = "鍋滆繍"; } else if (param == '0') { value = "姝e父"; } return value; }, loadAverage: function () { console.log("loadAverage"); // console.log("gk1", gk1) var that = this; var averageNow = new Date(); this.averageTime = averageNow.getFullYear() + "骞? + (averageNow.getMonth() + 1) + "鏈? + averageNow.getDate() + "鏃? + that.ultZeroize(averageNow.getHours()) + ":" + that.ultZeroize(averageNow.getMinutes()) + ":" + that.ultZeroize(averageNow.getSeconds()); axios.get(urls.averger).then(function (result) { let res = result.data.model; let liLu1 = res[0].list; for (const item of liLu1) { if (item.name.indexOf("宸ュ喌") > -1) { } else if (item.value) { item.value = parseFloat(item.value).toFixed(2); } else { item.value = "-"; } } let liLu2 = res[1].list; for (const item of liLu2) { if (item.name.indexOf("宸ュ喌") > -1) { } else if (item.value) { item.value = parseFloat(item.value).toFixed(2); } else { item.value = "-"; } } let liLu3 = res[2].list; for (const item of liLu3) { if (item.name.indexOf("宸ュ喌") > -1) { } else if (item.value) { item.value = parseFloat(item.value).toFixed(2); } else { item.value = "-"; } } let liLu4 = res[3].list; for (const item of liLu4) { if (item.name.indexOf("宸ュ喌") > -1) { } else if (item.value) { item.value = parseFloat(item.value).toFixed(2); } else { item.value = "-"; } } that.initAverageModel(liLu1, "lu1"); that.initAverageModel(liLu2, "lu2"); that.initAverageModel(liLu3, "lu3"); that.initAverageModel(liLu4, "lu4"); setTimeout(() => { that.loadAverage(); }, refreshAvergerTime * 1000); }); }, pageLoaded: function () { var that = this; document.getElementById("loadingMask").style.display = "none"; }, getTimeSpan: function (str) { var cuo = new Date(str).getTime(); }, changeDate: function () { var that = this; var cuo = getDate(that.date).getTime(); var mytime24 = new Array(); var i = 0; var ttt = cuo; for (; i <= 24; i++) { mytime24.push([ttt, ""]); ttt = ttt + 3600000; } that.xzhou = mytime24; }, change: function () { console.log("change"); var that = this; var arr = []; arr = this.date.split("-"); that.now1Date = arr[1] + "鏈? + arr[2]; that.loadDataSet1(); that.loadDataSet2(); that.loadDataSet3(); that.loadDataSet4(); this.loadAverage(); }, // detailDate: function (date) { // console.log("detailDate"); // var that = this; // //鑾峰彇鏃ユ湡骞朵笖杞崲鏃堕棿鎴 // var longtime = new Date(date).getTime(); // //鑾峰彇鍓嶄竴澶╃殑鏃堕棿 // var ago = parseInt(longtime) - 24 * 60 * 60 * 1000; // //杞崲鏃堕棿鎴筹紝鑾峰彇鍓嶄竴澶╃殑鏃堕棿 // var agoDate = new Date(ago); // var year = agoDate.getFullYear(); // var month = agoDate.getMonth() + 1; // var strDate = agoDate.getDate(); // if (month >= 1 && month <= 9) { // month = "0" + month; // } // if (strDate >= 0 && strDate <= 9) { // strDate = "0" + strDate; // } // that.isFirst = false; // that.date = year + "-" + month + "-" + strDate; // that.now1Date = +month + "鏈? + strDate; // that.change(); // }, detailDate: function (date) { let returnDate = ""; var that = this; //鑾峰彇鏃ユ湡骞朵笖杞崲鏃堕棿鎴 var longtime = new Date(date).getTime(); //鑾峰彇鍓嶄竴澶╃殑鏃堕棿 var ago = parseInt(longtime) - 24 * 60 * 60 * 1000; //杞崲鏃堕棿鎴筹紝鑾峰彇鍓嶄竴澶╃殑鏃堕棿 var agoDate = new Date(ago); var year = agoDate.getFullYear(); var month = agoDate.getMonth() + 1; var strDate = agoDate.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } that.isFirst = false; returnDate = year + "-" + month + "-" + strDate; that.now1Date = +month + "鏈? + strDate; return returnDate }, getHasDataDate: function (freshDate) { var that = this; axios .get(urls.Monitor, { params: { mpCode: 44900001182785, dateTime: freshDate }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list = model.list; if (list.length == 0) { that.getHasDataDate(that.detailDate(freshDate)) } else { that.date = freshDate; // that.change(); that.loadDataSet1(); that.loadDataSet2(); that.loadDataSet3(); that.loadDataSet4(); that.loadAverage(); } } }); }, loadDataSet1: function () { var that = this; that.gk1 = "姝e父"; that.LuWen1 = []; that.Monitor1 = []; that.standardValue1 = []; that.changeDate(); axios .get(urls.Monitor, { params: { mpCode: 44900001182785, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list = model.list; if (list.length == 0) { // if (that.isFirst) { // that.detailDate(that.date); // } // else { list.push( { pollutantName: "棰楃矑鐗?, strength: " ", standardValue: " ", }, { pollutantName: "姘哀鍖栫墿", strength: " ", standardValue: " ", }, { pollutantName: "浜屾哀鍖栫~", strength: " ", standardValue: " ", }, { pollutantName: "姘寲姘?, strength: " ", standardValue: " ", }, { pollutantName: "涓€姘у寲纰?, strength: " ", standardValue: " ", } ); that.Monitor1 = list; that.isHasData = false; // } } else { that.Monitor1 = []; that.Monitor1.push(list[0], list[2], list[1], list[4], list[3]); // that.standardList = []; // for (var n = 0; n < list.length; n++) { // that.standardList.push(list[n].standardValue); // } that.isHasData = true; // that.isFirst = false; } } }); if (zhexiantu1) { zhexiantu1.showLoading(); } axios .get(urls.LuWen, { params: { mpCode: 44900001182785, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list1 = model.list; var setNull = 0; for (var i = 0; i < list1.length; i++) { var it = list1[i].monitorTime; it = it.replace(/T/g, " "); it = it.substring(0, 19); it = it.replace(/-/g, "/"); var timestamp = new Date(it).getTime(); list1[i].monitorTime = timestamp; that.standardValue1.push([ parseFloat(list1[i].standardValue), list1[i].monitorTime, ]); if (list1[i].strength != null) { setNull = list1[i].strength; that.LuWen1.push([list1[i].strength, list1[i].monitorTime]); } else { that.LuWen1.push([setNull, list1[i].monitorTime]); } if (i == list1.length - 1) { that.luwen = list1[i].standardValue; } } var option = { tooltip: { trigger: "axis", }, title: [ { left: "center", text: "鐐夎啗娓╁害鏇茬嚎", textStyle: { color: "#27c1e3", fontWeight: "normal", fontSize: 16, }, }, ], legend: { data: [ { name: "鏍囧噯鍊?, textStyle: { color: "#fd083d", }, }, { name: "娓╁害", textStyle: { color: "#000", }, }, ], top: "15%", right: "5%", }, xAxis: { type: "time", name: "鏃堕棿", data: [], }, yAxis: { type: "value", name: "鍗曚綅锛氣剝", splitNumber: 5, scale: true, }, visualMap: { show: false, pieces: [ { gt: 0, lte: 400, color: "#096", }, { gt: 400, lte: 10000, color: "#cc0033", }, ], }, series: [ { name: "娓╁害", type: "line", lineStyle: { color: "#000", }, itemStyle: { normal: { color: "#000", }, }, connectNulls: true, showSymbol: false, data: that.LuWen1.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏍囧噯鍊?, type: "line", lineStyle: { color: "#fd083d", }, itemStyle: { normal: { color: "#fd083d", }, }, connectNulls: true, showSymbol: false, data: that.standardValue1.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏃堕棿", type: "line", data: that.xzhou, }, ], }; zhexiantu1.setOption(option, true); zhexiantu1.hideLoading(); } }); axios .get(urls.GetSetDataListGkInfo, { params: { mpCode: 44900001182785, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var list = res.data.model.list; if (list.length != 0) { var arr2 = []; arr2 = list[0].gkName.split(";"); for (var a = 0; a < arr2.length; a++) { if (arr2[a] == "") { arr2.splice(a, 1); } } that.gk1 = arr2.join(",") + "(" + list[0].remark + ")" || "姝e父"; } } }); }, loadDataSet2: function () { var that = this; that.gk2 = "姝e父"; that.LuWen2 = []; that.Monitor2 = []; that.standardValue2 = []; that.changeDate(); axios .get(urls.Monitor, { params: { mpCode: 44900001182775, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list = model.list; if (list.length == 0) { list.push( { pollutantName: "棰楃矑鐗?, strength: " ", standardValue: " ", }, { pollutantName: "姘哀鍖栫墿", strength: " ", standardValue: " ", }, { pollutantName: "浜屾哀鍖栫~", strength: " ", standardValue: " ", }, { pollutantName: "姘寲姘?, strength: " ", standardValue: " ", }, { pollutantName: "涓€姘у寲纰?, strength: " ", standardValue: " ", } ); that.Monitor2 = list; that.isHasData = false; } else { that.Monitor2 = []; that.Monitor2.push(list[0], list[2], list[1], list[4], list[3]); that.isHasData = true; } } }); if (zhexiantu2) { zhexiantu2.showLoading(); } axios .get(urls.LuWen, { params: { mpCode: 44900001182775, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list1 = model.list; var setNull = 0; for (var i = 0; i < list1.length; i++) { var it = list1[i].monitorTime; it = it.replace(/T/g, " "); it = it.substring(0, 19); it = it.replace(/-/g, "/"); var timestamp = new Date(it).getTime(); list1[i].monitorTime = timestamp; that.standardValue2.push([ parseFloat(list1[i].standardValue), list1[i].monitorTime, ]); if (list1[i].strength != null) { setNull = list1[i].strength; that.LuWen2.push([list1[i].strength, list1[i].monitorTime]); } else { that.LuWen2.push([setNull, list1[i].monitorTime]); } } var option = { tooltip: { trigger: "axis", }, title: [ { left: "center", text: "鐐夎啗娓╁害鏇茬嚎", textStyle: { color: "#27c1e3", fontWeight: "normal", fontSize: 16, }, }, ], legend: { data: [ { name: "鏍囧噯鍊?, textStyle: { color: "#fd083d", }, }, { name: "娓╁害", textStyle: { color: "#000", }, }, ], top: "15%", right: "5%", }, xAxis: { type: "time", name: "鏃堕棿", data: [], }, yAxis: { type: "value", name: "鍗曚綅锛氣剝", splitNumber: 5, scale: true, //min: 840, //minInterval: 60, //interval: 60, }, visualMap: { show: false, pieces: [ { gt: 0, lte: 400, color: "#096", }, { gt: 400, lte: 10000, color: "#cc0033", }, ], }, series: [ { name: "娓╁害", type: "line", lineStyle: { color: "#000", }, itemStyle: { normal: { color: "#000", }, }, connectNulls: true, showSymbol: false, data: that.LuWen2.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏍囧噯鍊?, type: "line", connectNulls: true, showSymbol: false, lineStyle: { color: "#fd083d", }, itemStyle: { normal: { color: "#fd083d", }, }, data: that.standardValue2.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏃堕棿", type: "line", data: that.xzhou, }, ], }; zhexiantu2.setOption(option, true); zhexiantu2.hideLoading(); } }); axios .get(urls.GetSetDataListGkInfo, { params: { mpCode: 44900001182775, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var list = res.data.model.list; if (list.length != 0) { var arr2 = []; arr2 = list[0].gkName.split(";"); for (var a = 0; a < arr2.length; a++) { if (arr2[a] == "") { arr2.splice(a, 1); } } that.gk2 = arr2.join(",") + "(" + list[0].remark + ")" || "姝e父"; } } }); }, loadDataSet3: function () { var that = this; that.gk3 = "姝e父"; that.LuWen3 = []; that.Monitor3 = []; that.standardValue3 = []; that.changeDate(); axios .get(urls.Monitor, { params: { mpCode: 44900001182765, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list = model.list; if (list.length == 0) { list.push( { pollutantName: "棰楃矑鐗?, strength: " ", standardValue: " ", }, { pollutantName: "姘哀鍖栫墿", strength: " ", standardValue: " ", }, { pollutantName: "浜屾哀鍖栫~", strength: " ", standardValue: " ", }, { pollutantName: "姘寲姘?, strength: " ", standardValue: " ", }, { pollutantName: "涓€姘у寲纰?, strength: " ", standardValue: " ", } ); that.Monitor3 = list; that.isHasData = false; } else { that.Monitor3 = []; that.Monitor3.push(list[0], list[2], list[1], list[4], list[3]); that.isHasData = true; } } }); if (zhexiantu3) { zhexiantu3.showLoading(); } axios .get(urls.LuWen, { params: { mpCode: 44900001182765, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list1 = model.list; var setNull = 0; for (var i = 0; i < list1.length; i++) { var it = list1[i].monitorTime; it = it.replace(/T/g, " "); it = it.substring(0, 19); it = it.replace(/-/g, "/"); var timestamp = new Date(it).getTime(); list1[i].monitorTime = timestamp; that.standardValue3.push([ parseFloat(list1[i].standardValue), list1[i].monitorTime, ]); if (list1[i].strength != null) { setNull = list1[i].strength; that.LuWen3.push([list1[i].strength, list1[i].monitorTime]); } else { that.LuWen3.push([setNull, list1[i].monitorTime]); } } var option = { tooltip: { trigger: "axis", }, title: [ { left: "center", text: "鐐夎啗娓╁害鏇茬嚎", textStyle: { color: "#27c1e3", fontWeight: "normal", fontSize: 16, }, }, ], legend: { data: [ { name: "鏍囧噯鍊?, textStyle: { color: "#fd083d", }, }, { name: "娓╁害", textStyle: { color: "#000", }, }, ], top: "15%", right: "5%", }, xAxis: { type: "time", name: "鏃堕棿", data: [], }, yAxis: { type: "value", name: "鍗曚綅锛氣剝", //min: 840, //minInterval: 60, //interval: 60, splitNumber: 5, scale: true, }, visualMap: { show: false, pieces: [ { gt: 0, lte: 400, color: "#096", }, { gt: 400, lte: 10000, color: "#cc0033", }, ], }, series: [ { name: "娓╁害", type: "line", lineStyle: { color: "#000", }, itemStyle: { normal: { color: "#000", }, }, connectNulls: true, showSymbol: false, data: that.LuWen3.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏍囧噯鍊?, type: "line", connectNulls: true, showSymbol: false, lineStyle: { color: "#fd083d", }, itemStyle: { normal: { color: "#fd083d", }, }, data: that.standardValue3.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏃堕棿", type: "line", data: that.xzhou, }, ], }; zhexiantu3.setOption(option, true); zhexiantu3.hideLoading(); } }); axios .get(urls.GetSetDataListGkInfo, { params: { mpCode: 44900001182765, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var list = res.data.model.list; if (list.length != 0) { var arr2 = []; arr2 = list[0].gkName.split(";"); for (var a = 0; a < arr2.length; a++) { if (arr2[a] == "") { arr2.splice(a, 1); } } that.gk3 = arr2.join(",") + "(" + list[0].remark + ")" || "姝e父"; } } }); }, loadDataSet4: function () { var that = this; that.gk4 = "姝e父"; that.LuWen4 = []; that.Monitor4 = []; that.standardValue4 = []; that.changeDate(); axios .get(urls.Monitor, { params: { mpCode: 44900001182755, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list = model.list; if (list.length == 0) { list.push( { pollutantName: "棰楃矑鐗?, strength: " ", standardValue: " ", }, { pollutantName: "姘哀鍖栫墿", strength: " ", standardValue: " ", }, { pollutantName: "浜屾哀鍖栫~", strength: " ", standardValue: " ", }, { pollutantName: "姘寲姘?, strength: " ", standardValue: " ", }, { pollutantName: "涓€姘у寲纰?, strength: " ", standardValue: " ", } ); that.Monitor4 = list; that.isHasData = false; } else { that.Monitor4 = []; that.Monitor4.push(list[0], list[2], list[1], list[4], list[3]); that.isHasData = true; } } }); if (zhexiantu4) { zhexiantu4.showLoading(); } axios .get(urls.LuWen, { params: { mpCode: 44900001182755, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var model = res.data.model; var list1 = model.list; var setNull = 0; for (var i = 0; i < list1.length; i++) { var it = list1[i].monitorTime; it = it.replace(/T/g, " "); it = it.substring(0, 19); it = it.replace(/-/g, "/"); var timestamp = new Date(it).getTime(); list1[i].monitorTime = timestamp; that.standardValue4.push([ parseFloat(list1[i].standardValue), list1[i].monitorTime, ]); if (list1[i].strength != null) { setNull = list1[i].strength; that.LuWen4.push([list1[i].strength, list1[i].monitorTime]); } else { that.LuWen4.push([setNull, list1[i].monitorTime]); } } var option = { tooltip: { trigger: "axis", }, title: [ { left: "center", text: "鐐夎啗娓╁害鏇茬嚎", textStyle: { color: "#27c1e3", fontWeight: "normal", fontSize: 16, }, }, ], legend: { data: [ { name: "鏍囧噯鍊?, textStyle: { color: "#fd083d", }, }, { name: "娓╁害", textStyle: { color: "#000", }, }, ], top: "15%", right: "5%", }, xAxis: { type: "time", name: "鏃堕棿", data: [], }, yAxis: { type: "value", name: "鍗曚綅锛氣剝", splitNumber: 5, scale: true, }, visualMap: { show: false, pieces: [ { gt: 0, lte: 400, color: "#096", }, { gt: 400, lte: 10000, color: "#cc0033", }, ], }, series: [ { name: "娓╁害", type: "line", lineStyle: { color: "#000", }, itemStyle: { normal: { color: "#000", }, }, connectNulls: true, showSymbol: false, data: that.LuWen4.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏍囧噯鍊?, type: "line", connectNulls: true, showSymbol: false, lineStyle: { color: "#fd083d", }, itemStyle: { normal: { color: "#fd083d", }, }, data: that.standardValue4.map(function (item) { return [item[1], item[0]]; }), }, { name: "鏃堕棿", type: "line", data: that.xzhou, }, ], }; zhexiantu4.setOption(option, true); zhexiantu4.hideLoading(); } }); axios .get(urls.GetSetDataListGkInfo, { params: { mpCode: 44900001182755, dateTime: that.date }, }) .then(function (res) { if (res.data.state == 0) { var list = res.data.model.list; if (list.length != 0) { var arr2 = []; arr2 = list[0].gkName.split(";"); for (var a = 0; a < arr2.length; a++) { if (arr2[a] == "") { arr2.splice(a, 1); } } that.gk4 = arr2.join(",") + "(" + list[0].remark + ")" || "姝e父"; } } }); }, getLive: function () { var that = this; that.liveList = []; var timestamp = new Date().getTime(); axios.get(urls.GetLive + "?d=" + timestamp).then(function (res) { if (res.data.state == 0) { var model = res.data.model; var now = Date.now(); //var lastTime = (new Date(model.lastTime)).getTime() //if (now > (lastTime + 15 * 60 * 1000)) { // that.isError = true; //} else { // that.isError = false; //} var list = model.list; var num; for (var i = 0; i < list.length; i++) { if (list[i].setName == "1#鐐? && list[i].setPointName == "棰楃矑鐗?) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu1.keliwu = num; } else if ( list[i].setName == "1#鐐? && list[i].setPointName == "浜屾哀鍖栫~" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu1.eryang = num; } else if ( list[i].setName == "1#鐐? && list[i].setPointName == "姘у寲姘? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu1.yanghuaqing = num; } else if ( list[i].setName == "1#鐐? && list[i].setPointName == "姘哀鍖栫墿" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu1.danyang = num; } else if ( list[i].setName == "1#鐐? && list[i].setPointName == "涓€姘у寲纰? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu1.yiyanghuatan = num; } else if ( list[i].setName == "1#鐐? && list[i].setPointName == "鐐夎啗娓╁害" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu1.lutangwendu = num; } else if ( list[i].setName == "1#鐐? && list[i].setPointName == "鐐夊喌骞冲潎鍊? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } var lastTime = new Date(list[i].setPointValueTime).getTime(); if (now > lastTime + 4 * 60 * 60 * 1000) { that.lu1.isStop = true; } else { that.lu1.isStop = false; } if (list[i].setPointValue == 0) { that.lu1.isError = true; } else { that.lu1.isError = false; } that.lu1.lukuangwendu = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "棰楃矑鐗? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu2.keliwu = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "浜屾哀鍖栫~" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu2.eryang = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "姘у寲姘? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu2.yanghuaqing = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "姘哀鍖栫墿" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu2.danyang = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "涓€姘у寲纰? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu2.yiyanghuatan = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "鐐夎啗娓╁害" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu2.lutangwendu = num; } else if ( list[i].setName == "2#鐐? && list[i].setPointName == "鐐夊喌骞冲潎鍊? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } var lastTime = new Date(list[i].setPointValueTime).getTime(); if (now > lastTime + 4 * 60 * 60 * 1000) { that.lu2.isStop = true; } else { that.lu2.isStop = false; } if (list[i].setPointValue == 0) { that.lu2.isError = true; } else { that.lu2.isError = false; } that.lu2.lukuangwendu = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "棰楃矑鐗? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu3.keliwu = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "浜屾哀鍖栫~" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu3.eryang = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "姘у寲姘? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu3.yanghuaqing = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "姘哀鍖栫墿" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu3.danyang = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "涓€姘у寲纰? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu3.yiyanghuatan = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "鐐夎啗娓╁害" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu3.lutangwendu = num; } else if ( list[i].setName == "3#鐐? && list[i].setPointName == "鐐夊喌骞冲潎鍊? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } var lastTime = new Date(list[i].setPointValueTime).getTime(); if (now > lastTime + 4 * 60 * 60 * 1000) { that.lu3.isStop = true; } else { that.lu3.isStop = false; } if (list[i].setPointValue == 0) { that.lu3.isError = true; } else { that.lu3.isError = false; } that.lu3.lukuangwendu = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "棰楃矑鐗? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu4.keliwu = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "浜屾哀鍖栫~" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu4.eryang = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "姘у寲姘? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu4.yanghuaqing = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "姘哀鍖栫墿" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu4.danyang = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "涓€姘у寲纰? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu4.yiyanghuatan = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "鐐夎啗娓╁害" ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } that.lu4.lutangwendu = num; } else if ( list[i].setName == "4#鐐? && list[i].setPointName == "鐐夊喌骞冲潎鍊? ) { if (list[i].setPointValue.toString().indexOf("+") != -1) { var newNum = new Number(list[i].setPointValue); num = parseFloat(newNum).toFixed(2); } else { num = parseFloat(list[i].setPointValue).toFixed(2); } var lastTime = new Date(list[i].setPointValueTime).getTime(); if (now > lastTime + 4 * 60 * 60 * 1000) { that.lu4.isStop = true; } else { that.lu4.isStop = false; } if (list[i].setPointValue == 0) { that.lu4.isError = true; } else { that.lu4.isError = false; } that.lu4.lukuangwendu = num; } } var arr = []; arr = model.lastTime.split("T"); that.dateTime = arr[0] + " " + arr[1]; var dateNow = new Date(); console.log(that.lu1, that.lu2, that.lu3, that.lu4); } }); clock = setTimeout(function () { that.getLive(); }, 5000); }, refresh: function () { console.log("refresh") var that = this; that.changeDate(); //淇濆瓨褰撳墠鍒锋柊鏃堕棿 var dateNow1 = new Date(); var date = new Date(dateNow1.getTime()); var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var now = year + "-" + month + "-" + strDate; sessionStorage.setItem("refreshTime", now); //鍒锋柊鏁版嵁 that.loadDataSet1(); that.loadDataSet2(); that.loadDataSet3(); that.loadDataSet4(); that.loadAverage(); }, getStander: function (name) { if (name == "棰楃矑鐗?) { return "10"; } else if (name == "浜屾哀鍖栫~") { return "80"; } else if (name == "姘哀鍖栫墿") { return "150"; } else if (name == "姘寲姘?) { return "10"; } else if (name == "涓€姘у寲纰?) { return "80"; } else if (name == "鐐夎啗娓╁害") { return "850"; } }, getEurStander: function (name) { if (name == "棰楃矑鐗?) { return "10"; } else if (name == "浜屾哀鍖栫~") { return "50"; } else if (name == "姘哀鍖栫墿") { return "200"; } else if (name == "姘寲姘?) { return "10"; } else if (name == "涓€姘у寲纰?) { return "--"; } else if (name == "鐐夎啗娓╁害") { return "850"; } }, getUnit: function (name) { if (name == "棰楃矑鐗?) { return "mg/m鲁"; } else if (name == "浜屾哀鍖栫~") { return "mg/m鲁"; } else if (name == "姘哀鍖栫墿") { return "mg/m鲁"; } else if (name == "姘寲姘?) { return "mg/m鲁"; } else if (name == "涓€姘у寲纰?) { return "mg/m鲁"; } else if (name == "鐐夎啗娓╁害") { return "鈩?; } }, }, mounted: function () { //鍒濆鍖栭粯璁ゆ棩鏈熶负鏄ㄥぉ var that = this; // dateNow = new Date(); var freshDate = new Date(startTime); var date = new Date(freshDate.getTime() - 24 * 60 * 60 * 1000); var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var now = year + "-" + month + "-" + strDate; // this.date = now; this.now1Date = +month + "鏈? + strDate; ////this.pageLoaded(); this.changeDate(); //鑾峰彇璁惧鏁版嵁 // this.loadDataSet1(); // this.loadDataSet2(); // this.loadDataSet3(); // this.loadDataSet4(); // if (!that.isLoadGkInfo) { // that.getListGkInfo(); // } // this.loadAverage(); this.getHasDataDate(freshDate); // 璁剧疆鍒ゆ柇鍒锋柊缂撳瓨 let refreshTimeYYYYMMDD = startTime.substring(0, 10); let actualTimeYYYYMMDD = new Date().getFullYear() + "/" + (new Date().getMonth() + 1) + "/" + new Date().getDate(); let actualTime = new Date().getTime(); let refreshTime = new Date(startTime).getTime(); if (!localStorage.getItem("isNeedFreshData")) { localStorage.setItem("isNeedFreshData", false); } if (!localStorage.getItem("lastOpenTime")) { localStorage.setItem("lastOpenTime", actualTime); } else { // 鑾峰彇缂撳瓨鏈€鍚庝竴娆¤褰曠殑鏃堕棿 let storageTime = localStorage.getItem("lastOpenTime"); if ( storageTime > refreshTime && refreshTimeYYYYMMDD != actualTimeYYYYMMDD ) { localStorage.setItem("isNeedFreshData", true); } } //this.getDateTime(); //鑾峰彇瀹炴椂鏁版嵁 2021-09-15鍋滅敤 // this.getLive(); ////閰嶇疆echarts zhexiantu1 = echarts.init(document.getElementById("zhexiantu1")); zhexiantu2 = echarts.init(document.getElementById("zhexiantu2")); zhexiantu3 = echarts.init(document.getElementById("zhexiantu3")); zhexiantu4 = echarts.init(document.getElementById("zhexiantu4")); swiper = new Swiper(".swiper-container", { autoplay: { delay: 5000, disableOnInteraction: false, stopOnLastSlide: false, }, // autoplay: false, pagination: { el: ".my_pagination", clickable: true, renderBullet: function (index, className) { var text; switch (index) { case 0: text = "#1寰€澶嶅紡鏈烘鐐夋帓鐐?; break; case 1: text = "#2寰€澶嶅紡鏈烘鐐夋帓鐐?; break; case 2: text = "#3寰€澶嶅紡鏈烘鐐夋帓鐐?; break; case 3: text = "#4寰€澶嶅紡鏈烘鐐夋帓鐐?; break; case 4: text = "鎵胯涔?; break; case 5: text = "灏忔椂鍧囧€?; break; } return '' + text + ""; }, }, on: { slideChange: function () { if (this.activeIndex == 5) { //瀹氭椂鍒锋柊 var everydayRefreshTime = new Date(startTime).getTime(); var dateTimeNow = new Date().getTime(); if (dateTimeNow > everydayRefreshTime) { window.location.href = "/?d=" + new Date().getTime(); } //鍦ㄥ疄鏃剁湅鏉块偅閲屽埛鏂板巻鍙茬湅鏉挎暟鎹 // that.refresh(); } }, slideChangeTransitionStart: function () { if (this.activeIndex == 5) { that.isShow = false; that.isShiShi = true; } else { that.isShow = true; that.isShiShi = false; } }, //slideChangeTransitionEnd: function () { // if (this.activeIndex == 4) { // that.getLive(); // } //}, }, }); document.onkeydown = function (event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if (e && e.keyCode == 32) { // 鎸 Esc if (that.isAutoplay) { that.isAutoplay = false; console.log("鍋滄"); swiper.autoplay.stop(); } else if (!that.isAutoplay) { that.isAutoplay = true; console.log("鎾斁"); swiper.autoplay.start(); } } }; }, });