From 5fb459b9d8cdf659eb53f2e49e4901b0b4249025 Mon Sep 17 00:00:00 2001
From: cwchen <1048842385@qq.com>
Date: Tue, 23 Apr 2024 14:20:47 +0800
Subject: [PATCH] =?UTF-8?q?=E7=9C=81=E4=BE=A7=E5=A4=A7=E5=B1=8F=E8=B7=B3?=
=?UTF-8?q?=E8=BD=AC=E6=96=BD=E5=B7=A5=E5=A4=A7=E5=B1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/web/js/main.js | 479 ++++++++++++++++++++++++-------------------
1 file changed, 267 insertions(+), 212 deletions(-)
diff --git a/pages/web/js/main.js b/pages/web/js/main.js
index 91d54e8..ba0f3d1 100644
--- a/pages/web/js/main.js
+++ b/pages/web/js/main.js
@@ -1,6 +1,3 @@
-const baseUrl = 'http://127.0.0.1:18080/zhgd'
-// const baseUrl = 'http://192.168.0.7:18080/zhgd'
-
var loader = {
get: function (url, data = null, scb) {
let reqData = {
@@ -15,7 +12,7 @@ var loader = {
}
$.ajax({
- url: baseUrl + url,
+ url: commonUrl + url,
type: 'get',
headers: {
"authorization": sessionStorage.getItem("zhgd_token")
@@ -25,12 +22,12 @@ var loader = {
});
}
}
-let gtList=[];
+let gtList = [];
var terrainMap;
let element, layer, table;
// 选中标段工程
let checkBidCode = null;
-layui.use(['form','layer', 'element', 'table'], function () {
+layui.use(['form', 'layer', 'element', 'table'], function () {
element = layui.element;
layer = layui.layer;
table = layui.table;
@@ -84,8 +81,10 @@ layui.use(['form','layer', 'element', 'table'], function () {
form.on('select(bidPro)', function (data) {
let value = data.value;
let valueArr = value.split('@');
- loadBidProTower(valueArr[0],valueArr[1]);
+ loadBidProTower(valueArr[0], valueArr[1]);
});
+ $("#quality-ranking-table").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
+ $("#alarm-reminder-table").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
});
$('#indexIframe').attr('src', './views/main.html');
@@ -117,52 +116,70 @@ const tooltip = {
*/
// 工程统计
function initEngineeringStatistic() {
- const url = '/screen/largeScreen/scIndex/proStatusStatistics'
+ const url = 'screen/largeScreen/scIndex/proStatusStatistics'
loader.get(url, null, function (res) {
- const {djNum, zjNum, allNum, tcNum, tgNum} = res.data
- $('#engineering-statistic-item-1').text(djNum)
- $('#engineering-statistic-item-2').text(zjNum)
- $('#engineering-statistic-item-3').text(allNum)
- $('#engineering-statistic-item-4').text(tcNum)
- $('#engineering-statistic-item-5').text(tgNum)
+ if (res.code === 200) {
+ const { djNum, zjNum, allNum, tcNum, tgNum } = res.data
+ $('#engineering-statistic-item-1').text(djNum)
+ $('#engineering-statistic-item-2').text(zjNum)
+ $('#engineering-statistic-item-3').text(allNum)
+ $('#engineering-statistic-item-4').text(tcNum)
+ $('#engineering-statistic-item-5').text(tgNum)
+ } else if (res.code === 401) {
+ loginout(1);
+ } else {
+ console.error('工程统计:' + res.msg);
+ }
})
}
// 施工质量排名
function initQualityRanking() {
- const url = '/screen/largeScreen/scIndex/constrQuality'
+ const url = 'screen/largeScreen/scIndex/constrQuality'
loader.get(url, null, function (res) {
- res.data.forEach((item, index) => {
- const {bidName, teamName, teamLeader, score} = item
- var newRow = `
- ${index + 1}
- ${bidName}
- ${teamName}
- ${teamLeader}
- ${score}
- `;
- $("#quality-ranking-table").append(newRow);
- })
- if (res.data && res.data.length === 0) {
- $("#quality-ranking-table").append('无数据
');
+ if (res.code === 200) {
+ res.data.forEach((item, index) => {
+ const { bidName, teamName, teamLeader, score } = item
+ var newRow = `
+ ${index + 1}
+ ${bidName}
+ ${teamName}
+ ${teamLeader}
+ ${score}
+ `;
+ $("#quality-ranking-table").append(newRow);
+ })
+ if (res.data && res.data.length === 0) {
+ $("#quality-ranking-table").append('无数据
');
+ }
+ } else if (res.code === 401) {
+ loginout(1);
+ } else {
+ console.error('施工质量排名:' + res.msg);
}
- $("#quality-ranking-table").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
})
}
// 环境分析
function initEnvironmentAnalysis() {
- const url = '/screen/largeScreen/scIndex/environmentDetection'
+ const url = 'screen/largeScreen/scIndex/environmentDetection'
loader.get(url, null, function (res) {
- const data = res.data[0]
- if (!data) { return }
- const {aqiNormalNum, aqiErrorNum, dbNormalNum, dbErrorNum, hcNormalNum, hcErrorNum} = data
- $('#environment-analysis-1').find('div:first').find('p:first span').text(aqiNormalNum)
- $('#environment-analysis-1').find('div:first').find('p:last span').text(aqiErrorNum)
- $('#environment-analysis-2').find('div:first').find('p:first span').text(dbNormalNum)
- $('#environment-analysis-2').find('div:first').find('p:last span').text(dbErrorNum)
- $('#environment-analysis-3').find('div:first').find('p:first span').text(hcNormalNum)
- $('#environment-analysis-3').find('div:first').find('p:last span').text(hcErrorNum)
+ if (res.code === 200) {
+ const data = res.data[0]
+ if (!data) { return }
+ const { aqiNormalNum, aqiErrorNum, dbNormalNum, dbErrorNum, hcNormalNum, hcErrorNum } = data
+ $('#environment-analysis-1').find('div:first').find('p:first span').text(aqiNormalNum)
+ $('#environment-analysis-1').find('div:first').find('p:last span').text(aqiErrorNum)
+ $('#environment-analysis-2').find('div:first').find('p:first span').text(dbNormalNum)
+ $('#environment-analysis-2').find('div:first').find('p:last span').text(dbErrorNum)
+ $('#environment-analysis-3').find('div:first').find('p:first span').text(hcNormalNum)
+ $('#environment-analysis-3').find('div:first').find('p:last span').text(hcErrorNum)
+ } else if (res.code === 401) {
+ loginout(1);
+ } else {
+ console.error('环境分析:' + res.msg);
+ }
+
})
}
@@ -174,21 +191,27 @@ function initDeviceStatus() {
let data2 = []
let data3 = []
- const url = '/screen/largeScreen/scIndex/deviceStatus'
+ const url = 'screen/largeScreen/scIndex/deviceStatus'
loader.get(url, null, function (res) {
- const {allTotalNum, onlineTotalNum, offTotalNum, valueList} = res.data;
- $('#device-status__total').text(allTotalNum)
- $('#device-status__online').text(onlineTotalNum)
- $('#device-status__offline').text(offTotalNum)
- // console.log(valueList)
- valueList.forEach(item => {
- const {proName, totalNum, onlineNum, offLineNum} = item
- xLabel.push(proName)
- data1.push(totalNum)
- data2.push(onlineNum)
- data3.push(offLineNum)
- })
+ if (res.code === 200) {
+ const { allTotalNum, onlineTotalNum, offTotalNum, valueList } = res.data;
+ $('#device-status__total').text(allTotalNum)
+ $('#device-status__online').text(onlineTotalNum)
+ $('#device-status__offline').text(offTotalNum)
+ // console.log(valueList)
+ valueList.forEach(item => {
+ const { proName, totalNum, onlineNum, offLineNum } = item
+ xLabel.push(proName)
+ data1.push(totalNum)
+ data2.push(onlineNum)
+ data3.push(offLineNum)
+ })
+ } else if (res.code === 401) {
+ loginout(1);
+ } else {
+ console.error('设备状态:' + res.msg);
+ }
// console.log(xLabel)
let option = {
tooltip,
@@ -209,14 +232,14 @@ function initDeviceStatus() {
color: "#08A0A3",
},
},
- {
- type: "inside", // 支持内部鼠标滚动平移
- startValue: 0,
- endValue: 4,
- zoomOnMouseWheel: false, // 关闭滚轮缩放
- moveOnMouseWheel: true, // 开启滚轮平移
- moveOnMouseMove: true, // 鼠标移动能触发数据窗口平移
- }],
+ {
+ type: "inside", // 支持内部鼠标滚动平移
+ startValue: 0,
+ endValue: 4,
+ zoomOnMouseWheel: false, // 关闭滚轮缩放
+ moveOnMouseWheel: true, // 开启滚轮平移
+ moveOnMouseMove: true, // 鼠标移动能触发数据窗口平移
+ }],
grid: {
top: '20%',
left: '8%',
@@ -355,19 +378,19 @@ function initDeviceStatus() {
normal: {
//线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: '#1ED6FF30',
- },
- {
- offset: 0.6,
- color: '#1ED6FF20',
- },
- {
- offset: 1,
- color: '#1ED6FF10',
- },
- ],
+ {
+ offset: 0,
+ color: '#1ED6FF30',
+ },
+ {
+ offset: 0.6,
+ color: '#1ED6FF20',
+ },
+ {
+ offset: 1,
+ color: '#1ED6FF10',
+ },
+ ],
false
),
},
@@ -472,13 +495,13 @@ function initMainMap(dataMap = []) {
textStyle: {
color: '#fff'
},
- formatter (res) {
- const dom = ''+ `标段工程名称:${res.data.bidName}` + '
' +
- ''+ `标段编码:${res.data.bidCode}` + '
' +
- ''+ `班组名称:${res.data.teamName}` + '
' +
- ''+ `班组长:${res.data.workManager}` + '
' +
- ''+ `风险等级:${res.data.riskLevel}` + '
' +
- ''+ `工作内容:${res.data.workContent}` + '
'
+ formatter(res) {
+ const dom = '' + `标段工程名称:${res.data.bidName}` + '
' +
+ '' + `标段编码:${res.data.bidCode}` + '
' +
+ '' + `班组名称:${res.data.teamName}` + '
' +
+ '' + `班组长:${res.data.workManager}` + '
' +
+ '' + `风险等级:${res.data.riskLevel}` + '
' +
+ '' + `工作内容:${res.data.workContent}` + '
'
return dom
},
extraCssText: "max-width:300px;height:auto;word-break:break-all;white-space:pre-wrap;",
@@ -597,6 +620,20 @@ function initMainMap(dataMap = []) {
myChart.clear();
myChart.setOption(option, true);
+ myChart.off('dblclick').on("dblclick", function (params) {
+ if(params.componentType === 'series'){
+ const paramsData = {
+ 'bidCode': params.data.bidCode,
+ 'token': token
+ };
+ // 将参数转换为查询字符串
+ const queryString = Object.keys(paramsData)
+ .map(key => encodeURIComponent(key) + '=' + encodeURIComponent(encryptCBC(paramsData[key])))
+ .join('&');
+ const hrefUrl = login_sg_index + "?" + queryString;
+ const newWindow = window.open(hrefUrl, 'newWindow');
+ }
+ })
});
window.addEventListener("resize", function () {
myChart.resize();
@@ -664,7 +701,7 @@ function mapSearch() {
}
function initRiskData() {
- const url = '/screen/largeScreen/scIndex/riskStatistics'
+ const url = 'screen/largeScreen/scIndex/riskStatistics'
loader.get(url, null, function (res) {
const data = res.data
mainMapPointList = data
@@ -673,7 +710,7 @@ function initRiskData() {
})
}
-function initMap(){
+function initMap() {
createMap()
// madeBoundary(); //加载区域图
// addMapControl(); // 添加自定义控件
@@ -682,7 +719,7 @@ function initMap(){
}
// 设置杆塔连线
-function setTowerLine(gtList){
+function setTowerLine(gtList) {
let allOverlayList = terrainMap.getOverlays();
//循坏所有点并清除指定的点
if (allOverlayList.length > 0) {
@@ -693,64 +730,64 @@ function setTowerLine(gtList){
}
}
}
- var points=[];
- for(var i = 0; i < gtList.length; i++) {
- var point=new Object();
- point.lng=gtList[i].lon;
- point.lat=gtList[i].lat;
- point.proName=gtList[i].proName;
- point.img='../../../img/map/bdz.png';
- point.place=gtList[i].gtName;
+ var points = [];
+ for (var i = 0; i < gtList.length; i++) {
+ var point = new Object();
+ point.lng = gtList[i].lon;
+ point.lat = gtList[i].lat;
+ point.proName = gtList[i].proName;
+ point.img = '../../../img/map/bdz.png';
+ point.place = gtList[i].gtName;
points.push(point);
}
console.log(points)
- for(var i=0, len = points.length; i' +
+ (function () {
+ let title = '工程名称:' + points[i].proName + '
' +
'杆塔名称:' + points[i].place + '
' +
- '经度:' +points[i].lat + '
' +
- '维度:' + points[i].lng+ '
';
+ '经度:' + points[i].lat + '
' +
+ '维度:' + points[i].lng + '
';
//创建label图层 points[i].place
- var label = new BMap.Label(title,{position:point});
- marker.addEventListener("mouseover",function() {
+ var label = new BMap.Label(title, { position: point });
+ marker.addEventListener("mouseover", function () {
terrainMap.addOverlay(label);
});
- marker.addEventListener("mouseout",function() {
+ marker.addEventListener("mouseout", function () {
terrainMap.removeOverlay(label);
});
})();
}
//将所有点连线,连线图层polyline
var line = [];
- for(var i=0; i {
- const {orgName, planNum, dangerNum} = item
- xLabel.push(orgName)
- dataValue.push(planNum)
- dataValue1.push(dangerNum)
- })
+ if(res.code === 200){
+ res.data.forEach(item => {
+ const { orgName, planNum, dangerNum } = item
+ xLabel.push(orgName)
+ dataValue.push(planNum)
+ dataValue1.push(dangerNum)
+ })
+ }else if(res.code === 401){
+ loginout(1);
+ }else {
+ console.error("工程安全隐患分析:"+res.msg);
+ }
let option = {
@@ -867,14 +910,14 @@ function initSafetyAnalysis() {
color: "#08A0A3",
},
},
- {
- type: "inside", // 支持内部鼠标滚动平移
- startValue: 0,
- endValue: 4,
- zoomOnMouseWheel: false, // 关闭滚轮缩放
- moveOnMouseWheel: true, // 开启滚轮平移
- moveOnMouseMove: true, // 鼠标移动能触发数据窗口平移
- }],
+ {
+ type: "inside", // 支持内部鼠标滚动平移
+ startValue: 0,
+ endValue: 4,
+ zoomOnMouseWheel: false, // 关闭滚轮缩放
+ moveOnMouseWheel: true, // 开启滚轮平移
+ moveOnMouseMove: true, // 鼠标移动能触发数据窗口平移
+ }],
legend: {
show: true,
top: '15%',
@@ -1070,19 +1113,19 @@ function initSafetyAnalysis() {
normal: {
//线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: '#FE533C30',
- },
- {
- offset: 0.6,
- color: '#FE533C20',
- },
- {
- offset: 1,
- color: '#ffba0010',
- },
- ],
+ {
+ offset: 0,
+ color: '#FE533C30',
+ },
+ {
+ offset: 0.6,
+ color: '#FE533C20',
+ },
+ {
+ offset: 1,
+ color: '#ffba0010',
+ },
+ ],
false
),
},
@@ -1104,13 +1147,19 @@ function initEfficiencyAnalysis() {
let xLabel = []
let data = []
- const url = '/screen/largeScreen/scIndex/efficiencyAnalysis'
+ const url = 'screen/largeScreen/scIndex/efficiencyAnalysis'
loader.get(url, null, function (res) {
- res.data.forEach(item => {
- const {proName, value} = item
- xLabel.push(proName)
- data.push(value)
- })
+ if(res.code === 200){
+ res.data.forEach(item => {
+ const { proName, value } = item
+ xLabel.push(proName)
+ data.push(value)
+ })
+ }else if(res.code === 401){
+ loginout(1);
+ }else{
+ console.error("工人效率分析:" + res.msg);
+ }
let option = {
tooltip,
@@ -1130,7 +1179,7 @@ function initEfficiencyAnalysis() {
moveHandleStyle: {
color: "#08A0A3",
},
- },{
+ }, {
type: "inside", // 支持内部鼠标滚动平移
startValue: 0,
endValue: 3,
@@ -1266,7 +1315,7 @@ function initEfficiencyAnalysis() {
// 资源利用
function initResourceRate() {
- const url = '/screen/largeScreen/scIndex/resourceUse'
+ const url = 'screen/largeScreen/scIndex/resourceUse'
let element = document.getElementsByClassName('resource-rate-item')
const config = [
{
@@ -1292,7 +1341,7 @@ function initResourceRate() {
},
]
loader.get(url, null, function (res) {
- const {personnelRate, deviceRate, energyValue} = res.data
+ const { personnelRate, deviceRate, energyValue } = res.data
config[0].dataNum = personnelRate
config[1].dataNum = deviceRate
config[2].dataNum = energyValue
@@ -1309,7 +1358,7 @@ function initResourceRate() {
})
}
function getResourceChartOption(config) {
- const {dataTitle, dataNum, dataNumColor, dashboardBgc, dashboardColor} = config
+ const { dataTitle, dataNum, dataNumColor, dashboardBgc, dashboardColor } = config
let option = {
series: [
{
@@ -1395,21 +1444,27 @@ function getResourceChartOption(config) {
// 告警提醒
function initAlarmReminder() {
- const url = '/screen/largeScreen/scIndex/alarmReminder'
+ const url = 'screen/largeScreen/scIndex/alarmReminder'
loader.get(url, null, function (res) {
- res.data.forEach((item, index) => {
- const {proName, warningContent} = item
- var newRow = `
- ${proName}
- ${warningContent}
- `;
- $("#alarm-reminder-table").append(newRow);
- })
- if (res.data && res.data.length === 0) {
- $("#alarm-reminder-table").append('无数据
');
+ if(res.code === 200){
+ res.data.forEach((item, index) => {
+ const { proName, warningContent } = item
+ var newRow = `
+ ${proName}
+ ${warningContent}
+ `;
+ $("#alarm-reminder-table").append(newRow);
+ })
+ if (res.data && res.data.length === 0) {
+ $("#alarm-reminder-table").append('无数据
');
+ }
+ }else if(res.code === 401){
+ loginout(1);
+ }else {
+ console.error("告警提醒:"+res.msg);
}
- $("#alarm-reminder-table").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
})
+
}
/* 标段工程数据 */
@@ -1431,16 +1486,16 @@ function loadBidPro() {
errorFn(xhr, status, error)
setData(null);
}, aqEnnable);
-
- function setData(bidCodeList){
+
+ function setData(bidCodeList) {
let html = '';
if (bidCodeList && bidCodeList.length > 0) {
$.each(bidCodeList, function (index, item) {
- if(index === 0){
+ if (index === 0) {
checkBidCode = item.bidCode;
html += ''
- loadBidProTower(item.bidCode,item.proName);
- }else{
+ loadBidProTower(item.bidCode, item.proName);
+ } else {
html += ''
}
})
@@ -1452,7 +1507,7 @@ function loadBidPro() {
}
/* 标段工程杆塔数据 */
-function loadBidProTower(bidCode,proName) {
+function loadBidProTower(bidCode, proName) {
const paramData = 'bidCode=' + bidCode;
let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData);
const url = commonUrl + 'screen/largeScreen/scIndex/getGtList?params=' + montageParam;
@@ -1469,40 +1524,40 @@ function loadBidProTower(bidCode,proName) {
errorFn(xhr, status, error)
}, aqEnnable);
- function setData(data){
- if(data && data.length == 0){
+ function setData(data) {
+ if (data && data.length == 0) {
data = [
{
- lat:118.07138310,
- lon:31.05344367,
- proName:proName,
- gtName:'A1',
+ lat: 118.07138310,
+ lon: 31.05344367,
+ proName: proName,
+ gtName: 'A1',
},
{
- lat:118.07050390,
- lon:31.05571928,
- proName:proName,
- gtName:'A2',
+ lat: 118.07050390,
+ lon: 31.05571928,
+ proName: proName,
+ gtName: 'A2',
},
{
- lat:118.06960770,
- lon:31.05803784,
- proName:proName,
- gtName:'A3',
+ lat: 118.06960770,
+ lon: 31.05803784,
+ proName: proName,
+ gtName: 'A3',
},
{
- lat:118.0684919,
- lon:31.06092441,
- proName:proName,
- gtName:'A4',
+ lat: 118.0684919,
+ lon: 31.06092441,
+ proName: proName,
+ gtName: 'A4',
},
{
- lat:118.07093833,
- lon:31.06312931,
- proName:proName,
- gtName:'A5',
+ lat: 118.07093833,
+ lon: 31.06312931,
+ proName: proName,
+ gtName: 'A5',
}
-
+
]
}
setTimeout(() => {