hb_zhgd_screen/js/consQuality/dialog.js

211 lines
6.7 KiB
JavaScript
Raw Permalink Normal View History

2025-10-17 16:10:55 +08:00
let element, layer, laydate;
const bidCode = parent.parent.$("#bidPro").val();
var table;
var alarmTableIns;
var qualityInspectionTableIns;
layui.use(["layer", "element", "table"], function () {
element = layui.element;
layer = layui.layer;
laydate = layui.laydate;
table = layui.table;
//下拉选
getConstruction();
getRegion();
//施工质量列表
ConstructionQualityList();
// laydate.render({
// elem: "#ID-laydate-type-datetime",
// });
laydate.render({
elem: "#ID-laydate-rangeLinked",
range: ["#ID-laydate-start-date-1", "#ID-laydate-end-date-1"],
rangeLinked: true, // 开启日期范围选择时的区间联动标注模式 --- 2.8+ 新增
});
});
//下拉选
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() {
const url = commonUrl + "system/sys/select/getAreaLists"; // 建管单位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>";
});
}
$("#region").empty().append(html);
layui.form.render();
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
},
function (xhr) {
error(xhr);
}
);
}
function ConstructionQualityList() {
const url = commonUrl + "screen/sj/twoPage/getEnvironmentList";
console.log("bidCode", bidCode);
let times = "";
let startTime = "";
let endTime = "";
if ($("#ID-laydate-start-date-1").val() != "") {
times =
$("#ID-laydate-start-date-1").val() +
" - " +
$("#ID-laydate-end-date-1").val();
startTime = $("#ID-laydate-start-date-1").val();
endTime = $("#ID-laydate-end-date-1").val();
} else {
times = "";
startTime = "";
endTime = "";
}
console.log("times", times);
qualityInspectionTableIns = table.render({
elem: "#demo",
url: url,
skin: "line",
headers: {
decrypt: "decrypt",
Authorization: token,
},
where: {
roleCode: roleCode,
orgId: orgId,
userId: userId,
bidCode: bidCode,
deviceType: "1901",
startTime,
endTime,
deviceName: $("#deviceName").val(),
modelName: $("#modelName").val(),
// month: $('#ID-laydate-type-datetime').val(),
},
cols: [
[
{
field: "number",
width: 80,
title: "序号",
align: "center",
type: "numbers",
fixed: "left",
},
{ field: "bdName", align: "center", title: "边带名称" },
{ field: "deviceName", align: "center", title: "设备名称" },
{ field: "modelName", align: "center", title: "检测属性" },
{
field: "val",
align: "center",
title: "检测值",
templet: function (d) {
// 自定义检测值显示
if (d.val !== null && d.val !== undefined) {
// 根据检测值添加单位或特殊格式
return (
'<span style=" font-weight: bold;">' +
d.val +
" " +
d.unit +
"</span>"
);
}
return '<span style="color: #999;">--</span>';
},
},
{ field: "createTime", align: "center", title: "检测时间" },
{ field: "changeVal", align: "center", title: "变化值" },
{
field: "isWarn",
align: "center",
title: "是否告警",
templet: function (d) {
// 自定义是否告警显示
if (d.isWarn == 1) {
return '<span style="color: #ff0000; font-weight: bold;">是</span>';
} else if (d.isWarn === 0) {
return '<span style="color: #00ff00;">否</span>';
}
return '<span style="color: #999;">--</span>';
},
},
],
],
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);
},
page: true, //开启分页
loading: true, //数据加载中。。。
limits: [5, 10, 20, 100],
limit: 20,
});
}