ah_jjzhgd_webscreen/js/consQuality/consQuality.js

668 lines
23 KiB
JavaScript
Raw Normal View History

2024-03-27 14:57:16 +08:00
let element, layer, laydate;
2024-03-30 18:39:06 +08:00
const bidCode = parent.$('#bidPro').val();
var table;
var alarmTableIns;
var qualityInspectionTableIns;
var historyTableIns;
2024-04-03 10:55:14 +08:00
let thePileFoundationIsMadeIntoHoles = 1906002; //桩基成孔
let groundAcceptance = 1906003; //地面验收
let concretePouring = 1906004; //混凝土浇筑
2024-03-27 14:57:16 +08:00
layui.use(['layer', 'element', 'table'], function () {
element = layui.element;
layer = layui.layer;
laydate = layui.laydate;
2024-03-30 18:39:06 +08:00
table = layui.table;
2024-04-01 09:41:26 +08:00
document.getElementById("myButton").addEventListener("click", function() {
// window.location.href = "../consQuality/consQualityList.html";
layer.open({
type: 1,
title: '历史记录', //显示标题栏
closeBtn: 1,
2024-04-23 17:14:48 +08:00
area: ['90%','90%'],
id: 'HISTORY_layui', //设定一个id防止重复弹出
resize: false,
// btn: ['确定'],
btnAlign: 'c',
moveType: 0, //拖拽模式0或者1
skin:"layui-layer-molv",
content: $("#divDialog"),
success: function (layero) {
initHistory()
2024-04-23 17:14:48 +08:00
$('th').css('color','#000');
$('.layui-table').css('color','#000');
},
yes: function (layero, index) {
layer.close('HISTORY_layui')
},
cancel: function () {
// 右上角关闭事件的逻辑
layer.close('HISTORY_layui')
2024-04-23 17:14:48 +08:00
},
end:function(){
$('th').css('color','#fff');
$('.layui-table').css('color','#fff');
}
});
2024-04-01 09:41:26 +08:00
});
// $('#ID-laydate-type-datetime').val(getNowDay());
2024-04-03 10:55:14 +08:00
2024-04-01 09:41:26 +08:00
//下拉选
getConstruction();
getRegion();
2024-03-30 18:39:06 +08:00
//告警列表
AlarmList();
//施工质量列表
ConstructionQualityList();
//检测记录对比
2024-06-17 13:27:06 +08:00
detectionRecord('','A');
2024-03-30 18:39:06 +08:00
//质量检测
qualityInspectionApi();
list = {};
var month = [];
var list1 = [];
var list2 = [];
for (let i = 0; i < list.length; i++) {
}
// laydate.render({
// elem: '#ID-laydate-type-datetime',
// value: getNowDay() // 设置默认值为当天
// });
2024-03-30 18:39:06 +08:00
laydate.render({
elem: '#ID-laydate-rangeLinked',
range: ['#ID-laydate-start-date-1', '#ID-laydate-end-date-1'],
rangeLinked: true // 开启日期范围选择时的区间联动标注模式 --- 2.8+ 新增
});
2024-03-30 18:39:06 +08:00
});
2024-04-01 09:41:26 +08:00
//下拉选
function getConstruction(){
const url = commonUrl + "system/sys/select/getBuildLists"; // 建管单位url
ajaxRequest(url, "get", null , true, function () {
}, function (result) {
if (result.code === 200) {
let html = '';
if (result.data && result.data.length > 0) {
$.each(result.data, function (index, item) {
html += '<option value="' + item.orgId + '">' + item.name + '</option>'
})
}
$('#construction').empty().append(html);
layui.form.render();
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
}, function (xhr) {
error(xhr)
});
}
function getRegion(){
2024-04-03 10:55:14 +08:00
const url = commonUrl + "system/sys/select/getAreaLists"; // 建管单位url
2024-04-01 09:41:26 +08:00
ajaxRequest(url, "get", null , true, function () {
}, function (result) {
if (result.code === 200) {
let html = '';
if (result.data && result.data.length > 0) {
$.each(result.data, function (index, item) {
html += '<option value="' + item.orgId + '">' + item.name + '</option>'
})
}
$('#region').empty().append(html);
layui.form.render();
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
}, function (xhr) {
error(xhr)
});
}
2024-03-30 18:39:06 +08:00
//质量检测
function qualityInspectionApi(){
const url = commonUrl + "screen/largeScreen/constructionQuality/qualityInspection";
const params = {
"roleCode": roleCode,
"orgId": orgId,
"userId": userId,
"bidCode": bidCode
}
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(url, "POST", encryptStr, true, function () {
}, function (result) {
console.log(result);
if (result.code === 200) {
qualityInspection(result.data);
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}else if(result.code === 401){
loginout(1)
}
2024-04-01 09:41:26 +08:00
}, function (xhr, status, error) {
error(xhr, status, error)
}, "application/json",aqEnnable);
2024-03-30 18:39:06 +08:00
}
function qualityInspection(environmentData) {
// 获取存放设备的父元素
var environmentContainer = document.querySelector('.environment');
// 遍历数据,生成设备元素并添加到页面中
for (var i = 0; i < environmentData.length; i += 3) {
// 创建一个新的 div 作为一组设备信息的容器
var groupElement = document.createElement('div');
groupElement.style.width = '100%';
groupElement.style.height = '50%';
groupElement.className = 'layout';
// 将每组四个设备信息添加到容器中
for (var j = i; j < i + 3 && j < environmentData.length; j++) {
var deviceElement = document.createElement('div');
deviceElement.className = 'monitor-data layout';
deviceElement.id = environmentData[j].deviceId;
2024-03-30 18:39:06 +08:00
var monitorIconElement = document.createElement('div');
monitorIconElement.className = 'monitor-icon';
var pElement = document.createElement('p');
pElement.textContent = environmentData[j].deviceName;
2024-04-01 09:41:26 +08:00
if (environmentData[j].status === '0') {
2024-03-30 18:39:06 +08:00
monitorIconElement.style.backgroundImage = `url('../../img/consQuality/QualityInspection-0.png')`;
2024-04-01 09:41:26 +08:00
}else if (environmentData[j].status === '1') {
2024-03-30 18:39:06 +08:00
monitorIconElement.style.backgroundImage = `url('../../img/consQuality/QualityInspection-2.png')`;
2024-04-01 09:41:26 +08:00
}else if (environmentData[j].status === '2') {
monitorIconElement.style.backgroundImage = `url('../../img/consQuality/QualityInspection-1.png')`;
2024-03-30 18:39:06 +08:00
}
deviceElement.appendChild(monitorIconElement);
deviceElement.appendChild(pElement);
groupElement.appendChild(deviceElement);
// 添加点击事件监听器
deviceElement.addEventListener('click', function(event) {
var clickedDeviceId = event.currentTarget.id;
AlarmList(clickedDeviceId)
ConstructionQualityList(clickedDeviceId)
console.log(clickedDeviceId)
});
2024-03-30 18:39:06 +08:00
}
// 将每组设备信息容器添加到父元素中
environmentContainer.appendChild(groupElement);
}
}
//告警列表
function AlarmList(deviceId){
const dId = deviceId||'';
2024-03-30 18:39:06 +08:00
const url = commonUrl + "screen/largeScreen/constructionQuality/getConstructionAlarm";
alarmTableIns = table.render({
2024-03-27 14:57:16 +08:00
elem: '#alarm',
2024-03-30 18:39:06 +08:00
url: url,
2024-03-27 14:57:16 +08:00
skin: 'line',
page: false,
2024-03-30 18:39:06 +08:00
headers:{
decrypt:"decrypt",
"Authorization":token
},
where: {
deviceId:dId,
2024-03-30 18:39:06 +08:00
roleCode: roleCode,
orgId: orgId,
userId: userId,
bidCode: bidCode
},
2024-03-27 14:57:16 +08:00
cols: [[
2024-04-19 15:32:37 +08:00
// {field: 'number', width:80,title: '序号', align: 'center', type: 'numbers'},
2024-03-30 18:39:06 +08:00
{field: 'warningContent', align: 'center', title: '告警内容'},
2024-04-19 15:32:37 +08:00
{field: 'warnTime', align: 'center', title: '告警时间'},
2024-03-30 18:39:06 +08:00
]],
initComplete: function () {
// 在表格渲染完成后,重新渲染序号列
var that = this.elem.next();
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
tool.find("tr").each(function (index, item) {
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
});
},
done:function(res, curr, count, origin){
console.log(res);
}
2024-03-27 14:57:16 +08:00
})
2024-03-30 18:39:06 +08:00
}
//施工质量列表
function ConstructionQualityList(deviceId){
const dId = deviceId||'';
2024-03-30 18:39:06 +08:00
const url = commonUrl + "screen/largeScreen/constructionQuality/getConstructionQualityList";
qualityInspectionTableIns = table.render({
2024-03-27 14:57:16 +08:00
elem: '#demo',
2024-03-30 18:39:06 +08:00
url: url,
2024-03-27 14:57:16 +08:00
skin: 'line',
2024-03-30 18:39:06 +08:00
headers:{
decrypt:"decrypt",
"Authorization":token
},
where: {
deviceId:dId,
2024-03-30 18:39:06 +08:00
roleCode: roleCode,
orgId: orgId,
userId: userId,
2024-04-03 10:55:14 +08:00
bidCode: bidCode,
moduleName: $('#moduleName').val(),
// month: $('#ID-laydate-type-datetime').val(),
2024-03-30 18:39:06 +08:00
},
2024-03-27 14:57:16 +08:00
cols: [[
{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers', fixed: 'left'},
2024-04-20 12:16:02 +08:00
// {field: 'areaName', align: 'center', title: '区域名称'},
2024-03-30 18:39:06 +08:00
{field: 'deviceName', align: 'center', title: '设备名称'},
{field: 'moduleName', align: 'center', title: '施工工艺'},
{field: 'changeVal', align: 'center', title: '变化值'},
2024-03-30 18:39:06 +08:00
{field: 'val', align: 'center', title: '检测值'},
{field: 'createTime', align: 'center', title: '检测时间'},
{field: 'isWarn', align: 'center', title: '是否告警'},
2024-03-27 14:57:16 +08:00
]],
2024-03-30 18:39:06 +08:00
initComplete: function () {
// 在表格渲染完成后,重新渲染序号列
var that = this.elem.next();
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
tool.find("tr").each(function (index, item) {
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
});
},
done:function(res, curr, count, origin){
// console.log(res);
$("[data-field='isWarn']").children().each(function(){
if($(this).text()=='0'){
$(this).text('未告警')
}else if($(this).text()=='1'){
$(this).text('告警')
}
})
2024-03-30 18:39:06 +08:00
},
2024-03-27 14:57:16 +08:00
page: true, //开启分页
loading: true, //数据加载中。。。
limits: [5, 10, 20, 100],
limit: 7
})
2024-03-30 18:39:06 +08:00
}
//渲染历史记录table
function initHistory(){
const url = commonUrl + "screen/largeScreen/constructionQuality/getHistoryList";
2024-04-19 17:05:45 +08:00
let times = ''
if($('#ID-laydate-start-date-1').val()!=''){
times = $('#ID-laydate-start-date-1').val()+' - '+ $('#ID-laydate-end-date-1').val()
}else{
times = ''
}
historyTableIns = table.render({
elem: '#tableDialog',
url: url,
// skin: 'line',
page: true,
headers:{
decrypt:"decrypt",
"Authorization":token
},
where: {
roleCode: roleCode,
orgId: orgId,
userId: userId,
bidCode: bidCode,
deviceName:$('#deviceName').val(),
2024-04-19 17:05:45 +08:00
times: times,
},
cols: [[
{type: 'numbers', title: '序号'}, // 添加序号列
{field: 'areaName', align: 'center', title: '区域名称'},
{field: 'deviceName', align: 'center', title: '设备名称'},
{field: 'moduleName', align: 'center', title: '施工工艺'},
{field: 'changeVal', align: 'center', title: '变化值'},
{field: 'val', align: 'center', title: '检测值'},
{field: 'createTime', align: 'center', title: '检测时间'},
{field: 'isWarn', align: 'center', title: '是否告警'},
]],
initComplete: function () {
// 在表格渲染完成后,重新渲染序号列
var that = this.elem.next();
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
tool.find("tr").each(function (index, item) {
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
});
},
done:function(res, curr, count, origin){
// console.log(res);
$("[data-field='isWarn']").children().each(function(){
if($(this).text()=='0'){
$(this).text('未告警')
}else if($(this).text()=='1'){
$(this).text('告警')
}
})
},
page: true, //开启分页
loading: true, //数据加载中。。。
limits: [5, 10, 20, 100],
limit: 7
})
}
2024-03-30 18:39:06 +08:00
//检测记录对比
2024-04-03 10:55:14 +08:00
function detectionRecord(button,construction){
if(button !== ''){
let buttons = document.getElementsByClassName('button-style');
let isSelected = button.style.color === "rgb(81, 170, 209)";
for (let i = 0; i < buttons.length; i++) {
buttons[i].style.border = '';
buttons[i].style.color = '';
}
if (!isSelected) {
button.style.border = '1px solid #51AAD1';
button.style.color = '#51AAD1';
}else {
button.style.border = '';
button.style.color = '';
detectionRecord('','');
}
}
2024-03-30 18:39:06 +08:00
const params = {
"roleCode": roleCode,
"orgId": orgId,
"userId": userId,
2024-04-03 10:55:14 +08:00
"bidCode": bidCode,
"construction": construction
2024-03-30 18:39:06 +08:00
}
2024-06-04 16:52:12 +08:00
console.log(construction)
console.log(construction=='table')
2024-06-17 13:27:06 +08:00
if(construction=='A' || construction=='B' || construction=='C'){
2024-06-04 16:52:12 +08:00
$(".echarts-div").css("display","none");
$("#data-table-div").css("display","block");
2024-06-17 13:27:06 +08:00
getDataTable(construction);
2024-06-04 16:52:12 +08:00
}else{
$(".echarts-div").css("display","block");
$("#data-table-div").css("display","none");
getDetectionRecord(params);
}
}
//施工质量列表
2024-06-17 13:27:06 +08:00
function getDataTable(type){
2024-06-04 16:52:12 +08:00
const url = commonUrl + "screen/largeScreen/constructionQuality/getDevDataList";
table.render({
elem: '#data-table',
url: url,
skin: 'line',
headers:{
decrypt:"decrypt",
"Authorization":token
},
where: {
roleCode: roleCode,
orgId: orgId,
userId: userId,
bidCode: bidCode,
2024-06-17 13:27:06 +08:00
type:type
2024-06-04 16:52:12 +08:00
},
cols: [[
{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers', fixed: 'left'},
{field: 'name', align: 'center', title: '区域名称'},
{field: 'bidName', align: 'center', title: '工程名称'},
{field: 'val', align: 'center', title: '本次沉降'},
{field: 'hisVal', align: 'center', title: '累计沉降'},
{field: 'createTime', align: 'center', title: '检测时间'},
{field: 'jcUser', align: 'center', title: '检测人'},
{field: 'jhUser', align: 'center', title: '校核人'},
{field: 'devCode', align: 'center', title: '仪器型号计量编号'}
]],
initComplete: function () {
// 在表格渲染完成后,重新渲染序号列
var that = this.elem.next();
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
tool.find("tr").each(function (index, item) {
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
});
},
page: true, //开启分页
loading: true, //数据加载中。。。
limits: [5, 10, 20, 100],
limit: 7
})
}
2024-06-17 13:27:06 +08:00
//施工质量列表
function getDataTable(type){
const url = commonUrl + "screen/largeScreen/constructionQuality/getDevDataList";
let cols;
if(type=='A'){
cols= [[
{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers', fixed: 'left'},
{field: 'name', align: 'center', title: '区域名称'},
{field: 'bidName', align: 'center', title: '工程名称'},
{field: 'val', align: 'center', title: '本次沉降'},
{field: 'hisVal', align: 'center', title: '累计沉降'},
{field: 'createTime', align: 'center', title: '检测时间'},
{field: 'jcUser', align: 'center', title: '检测人'},
{field: 'jhUser', align: 'center', title: '校核人'},
{field: 'devCode', align: 'center', title: '仪器型号计量编号'}
]];
} else if(type=='B' ){
cols= [[
{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers', fixed: 'left'},
{field: 'bidName', align: 'center', title: '工程名称'},
{field: 'local', align: 'center', title: '检测位置'},
{field: 'name', align: 'center', title: '检测点名称'},
{field: 'jcUser', align: 'center', title: '检测人'},
{field: 'val', align: 'center', title: '是否合格'},
{field: 'createTime', align: 'center', title: '检测时间'},
]];
} else if(type=='C' ){
cols= [[
{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers', fixed: 'left'},
{field: 'bidName', align: 'center', title: '工程名称'},
{field: 'local', align: 'center', title: '检测面'},
{field: 'name', align: 'center', title: '测点名称'},
{field: 'jcUser', align: 'center', title: '检测人'},
{field: 'val', align: 'center', title: '是否合格'},
{field: 'createTime', align: 'center', title: '检测时间'},
]];
}
table.render({
elem: '#data-table',
url: url,
skin: 'line',
headers:{
decrypt:"decrypt",
"Authorization":token
},
where: {
roleCode: roleCode,
orgId: orgId,
userId: userId,
bidCode: bidCode,
type:type
},
cols: cols,
initComplete: function () {
// 在表格渲染完成后,重新渲染序号列
var that = this.elem.next();
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
tool.find("tr").each(function (index, item) {
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
});
},
page: true, //开启分页
loading: true, //数据加载中。。。
limits: [5, 10, 20, 100],
limit: 7
})
}
2024-06-04 16:52:12 +08:00
//查询echars
function getDetectionRecord(params){
const url = commonUrl + "screen/largeScreen/constructionQuality/detectionRecord";
2024-03-30 18:39:06 +08:00
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(url, "POST", encryptStr, true, function () {
}, function (result) {
if (result.code === 200) {
let resultData = result.data;
let extractedData = {
months: [],
qualificationNumber: [],
detectionNumbers: []
};
resultData.forEach(data => {
extractedData.months.push(data.month);
extractedData.detectionNumbers.push(parseInt(data.detectionNumber));
extractedData.qualificationNumber.push(parseInt(data.qualificationNumber));
});
2024-03-27 14:57:16 +08:00
2024-03-30 18:39:06 +08:00
console.log(extractedData);
detectionRecordEcharts(extractedData);
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}else if(result.code === 401){
loginout(1)
}
}, function (xhr) {
// error(xhr)
2024-04-02 09:14:29 +08:00
}, "application/json",aqEnnable);
2024-03-30 18:39:06 +08:00
}
2024-03-27 14:57:16 +08:00
2024-06-04 16:52:12 +08:00
2024-03-27 14:57:16 +08:00
//检测记录对比echarts图表
2024-03-30 18:39:06 +08:00
function detectionRecordEcharts(extractedData){
2024-03-27 14:57:16 +08:00
var myChart = echarts.init(document.getElementById('dome'));
option = {
backgroundColor: "transparent",
legend: {
data: ['检测次数','合格次数'],
icon:'circle',
right: "3%",
textStyle: {
color: "white",
fontSize: 12
},
itemWidth: 12, // 设置宽度
itemHeight:16, // 设置高度
itemGap: 12 // 设置间距
},
grid: {
left: '30',
right: '0',
top: '40',
bottom: '20'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: "item",
crossStyle: {
color: '#999'
}
},
confine: true,
formatter:function(params){
2024-03-30 18:39:06 +08:00
// console.log(params)
2024-03-27 14:57:16 +08:00
var html = params[0].name+'月';
for(var i=0;i<params.length;i++){
html+='<br />'+params[i].marker+params[i].seriesName+''+params[i].value;
}
return html;
}
},
xAxis: [{
type: 'category',
name:'月',
2024-03-30 18:39:06 +08:00
data: extractedData.months,
2024-03-27 14:57:16 +08:00
axisPointer: {
type: 'shadow'
},
axisLine: {
show: true,
lineStyle: {
color: '#333'
}
},
axisLabel: {
formatter: '{value}月',
show: true,
color: '#eee'
},
axisTick: {
show: false
}
}],
yAxis: [{
type: 'value',
splitNumber:5,
splitLine: {
show: true,
lineStyle: {
color: '#333'
}
},
axisLine: {
show: false
},
axisTick: {
show: false
}
}],
series: [
{
name: '检测次数',
type: 'bar',
symbol: 'bar',
barWidth: 20,
itemStyle: {
normal: {
color: '#51AAD1'
}
},
2024-03-30 18:39:06 +08:00
data: extractedData.detectionNumbers
2024-03-27 14:57:16 +08:00
},
{
name: '合格次数',
type: 'bar',
symbol: 'circle',
barWidth: 20,
itemStyle: {
normal: {
color: '#70D6B5'
}
},
2024-03-30 18:39:06 +08:00
data: extractedData.qualificationNumber
2024-03-27 14:57:16 +08:00
}
]
};
myChart.setOption(option);
2024-04-01 09:41:26 +08:00
}
function getNowDay() {
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1);
var day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate();
return year + "-" + month + "-" + day;
}