354 lines
12 KiB
JavaScript
354 lines
12 KiB
JavaScript
let form, layer, laydate, pageNum = 1, pageSize = 10, warType, formSelects, voiTypeList;
|
||
// 图片预览
|
||
let viewer, isViewer = false;
|
||
let viewer2, isViewer2 = false;
|
||
layui.config({
|
||
base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
|
||
}).extend({
|
||
formSelects: 'formSelects-v4'
|
||
}).use(['form', 'layer', 'laydate', 'formSelects','laypage'], function () {
|
||
form = layui.form;
|
||
layer = layui.layer;
|
||
laypage = layui.laypage; //分页
|
||
laydate = layui.laydate;
|
||
formSelects = layui.formSelects;
|
||
laydate.render({
|
||
elem: '#createTime', //指定元素 元素选择器
|
||
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
||
trigger: 'click',
|
||
range: true,
|
||
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
||
btns: ['now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
|
||
done: function (value, date) { //时间回调
|
||
}
|
||
});
|
||
$('#createTime').val(getStartTime() + " - " + getEndTime())
|
||
voiTypeList = getRiskLevelSelect('disType');
|
||
setWarType(1, null);
|
||
form.render();
|
||
pages(1, 50, 1);
|
||
})
|
||
|
||
/*查询、重置*/
|
||
function query(type) {
|
||
let pattern = new RegExp("[%_<>]");
|
||
if (pattern.test($("#proName").val())) {
|
||
$("#proName").val('');
|
||
return layer.msg('工程名称查询包含特殊字符,请重新输入', {
|
||
icon: 2,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
});
|
||
}
|
||
if (pattern.test($("#teamName").val())) {
|
||
$("#teamName").val('');
|
||
return layer.msg('班组名称查询包含特殊字符,请重新输入', {
|
||
icon: 2,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
});
|
||
}
|
||
pageNum = 1;
|
||
if (type === 2) {
|
||
$("#proName").val("");
|
||
$("#teamName").val("");
|
||
$('#createTime').val(getStartTime() + " - " + getEndTime());
|
||
formSelects.value('warType', []);
|
||
form.render();
|
||
}
|
||
pages(1, pageSize);
|
||
}
|
||
|
||
/*获取参数*/
|
||
function getReqParams(page, limit, type) {
|
||
let obj = {};
|
||
if (!type) {
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
proName: $("#proName").val(),
|
||
teamName: $("#teamName").val(),
|
||
createTime: $("#createTime").val(),
|
||
warType: formSelects.value('warType', 'val').toString()
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: '1',
|
||
limit: '10',
|
||
proName: '',
|
||
teamName: '',
|
||
createTime: '',
|
||
warType: ''
|
||
};
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
function pages(pageNum, pageSize, typeNum) {
|
||
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
||
let params = getReqParams(pageNum, pageSize, typeNum);
|
||
$.ajax({
|
||
headers: {
|
||
"encrypt": sm3(JSON.stringify(params))
|
||
},
|
||
url: dataUrl + 'proteam/pot/voiPhotoLibrary/getVoiPhotoLibraryList?token=' + token,
|
||
data: params,
|
||
type: 'POST',
|
||
async: false,
|
||
success: function (result) {
|
||
layer.close(loadingMsg);
|
||
if (result.code === 200) {
|
||
if (result.data) {
|
||
let html = '';
|
||
$.each(result.data, function (index, item) {
|
||
var warnType=item.analyseResults;
|
||
if(item.warTypeName){
|
||
warnType=item.warTypeName;
|
||
}
|
||
|
||
html += '<li><div class="voi-photo-info">' +
|
||
'<div class="voi-img-type layout">' +
|
||
'<div class="voi-img layout">' +
|
||
'<img src="data:imge/jpg;base64,' + item.image + '" data-original="data:imge/jpg;base64,'+ item.image +'" >' +
|
||
'</div>' +
|
||
'<div class="voi-type layout">' +
|
||
'<p>' + warnType + '</p>' +
|
||
'</div>' +
|
||
'</div>' +
|
||
'<div class="voi-basic-info layout">' +
|
||
'<p>' + setIsNull(item.proName) + '</p>' +
|
||
'<p>' + setIsNull1(item.teamName) + '</p>' +
|
||
'<div class="comfirm-status layout">' +
|
||
'<p>' + item.analyseTime + '</p>' +
|
||
isSure(item) +
|
||
'</div>' +
|
||
'</div>' +
|
||
'</div></li>'
|
||
});
|
||
if (result.data.length > 0) {
|
||
$('#voi-photo-ul').empty().append(html);
|
||
} else {
|
||
$('#voi-photo-ul').empty().append('<li style="width: 100%;text-align: center;color: #999"><p style="padding: 30px 15px">无数据</p></li>');
|
||
}
|
||
console.log(result.count, result.curr, result.limit);
|
||
laypages(result.count, result.curr, result.limit)
|
||
}
|
||
} else if (result.code === 500) {
|
||
layer.alert(result.msg, {icon: 2})
|
||
} else if (result.code === 401) {
|
||
logout(1);
|
||
}
|
||
}, error: function () {
|
||
layer.close(loadingMsg);
|
||
}
|
||
});
|
||
|
||
|
||
viewer = new Viewer(document.getElementById('voi-photo-ul'), {
|
||
url: 'data-original',
|
||
toolbar: true,
|
||
show: function () {
|
||
viewer.update();
|
||
},
|
||
shown: function () {
|
||
isViewer = true;
|
||
},
|
||
hidden: function () {
|
||
isViewer = false;
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function setIsNull(item){
|
||
if(item==null || item=='null' || item=='Null' ||item=='NULL'){
|
||
return '未匹配到施工工程';
|
||
}
|
||
return item;
|
||
}
|
||
function setIsNull1(item){
|
||
if(item==null || item=='null' || item=='Null' ||item=='NULL'){
|
||
return '无施工班组';
|
||
}
|
||
return item;
|
||
}
|
||
function laypages(total, page, limit) {
|
||
layui.use(['laypage'], function () {
|
||
laypage.render({
|
||
elem: 'voi-page',
|
||
count: total,
|
||
curr: page,
|
||
limit: limit,
|
||
limits: [10,20,30],
|
||
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
||
groups: 5,
|
||
jump: function (obj, first) {
|
||
if (!first) {
|
||
pageNum = obj.curr, pageSize = obj.limit;
|
||
// pageNum = obj.curr, limitSize = obj.limit;
|
||
console.log(obj.curr, obj.limit);
|
||
pages(obj.curr, obj.limit,null);
|
||
}
|
||
}
|
||
});
|
||
})
|
||
}
|
||
|
||
/* 违章类型 */
|
||
function setWarType(type, selValue) {
|
||
let html = '', keys = [];
|
||
$.each(voiTypeList, function (index, item) {
|
||
if (type === 1) {
|
||
let temp = {
|
||
"name": item.name,
|
||
"value": item.code
|
||
};
|
||
keys.push(temp);
|
||
}
|
||
if (selValue === item.code) {
|
||
html += '<option value="' + item.code + '" selected>' + item.name + '</option>';
|
||
} else {
|
||
html += '<option value="' + item.code + '">' + item.name + '</option>';
|
||
}
|
||
})
|
||
if (type === 1) {
|
||
formSelects.data('warType', 'local', {
|
||
arr: keys
|
||
});
|
||
} else {
|
||
$('#warTypes').empty().append(html);
|
||
}
|
||
layui.form.render();
|
||
}
|
||
|
||
/*违章照片是否确认*/
|
||
function isSure(item) {
|
||
console.log(item);
|
||
if (item.isSu ==null || item.isSu =='' || item.isSu === '0' ) {
|
||
return "<p style='cursor: pointer;background-color: #F9770F;color: #fff;border-radius: 6px;width: 88px;height: 30px;line-height: 30px;text-align: center;' onclick='sureVoi(" + JSON.stringify(item) + ")'>未确认</p>"
|
||
} else if (item.isSu === '1') {
|
||
// return '<p style="color:#2F82FB">已确认</p>';
|
||
return "<p style='background-color: #2F82FB;color: #fff;border-radius: 6px;width: 88px;height: 30px;line-height: 30px;text-align: center;' >已确认</p>"
|
||
}else if (item.isSu === '2'){
|
||
return "<p style='background-color: #03b615;color: #fff;border-radius: 6px;width: 88px;height: 30px;line-height: 30px;text-align: center;' >未违章</p>"
|
||
}
|
||
}
|
||
|
||
/*确认违章*/
|
||
function sureVoi(item) {
|
||
let layerIndex = layer.open({
|
||
id: "moreOption",
|
||
title: ['<div style="border-left: 3px solid #2F82FB;display: flex;align-items: center;height: 20px;padding: 0 10px;">照片确认</div>', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'],
|
||
type: 1,
|
||
maxmin: false,
|
||
content: setPhotoConfirmHtml(item),
|
||
area: ['664px', '450px'],
|
||
move: false,
|
||
shade: 0.1,
|
||
success: function (layero, index) {
|
||
viewer2 = new Viewer(document.getElementById('tt-image'), {
|
||
url: 'data-original',
|
||
toolbar: true,
|
||
show: function () {
|
||
viewer2.update();
|
||
},
|
||
shown: function () {
|
||
isViewer2 = true;
|
||
},
|
||
hidden: function () {
|
||
isViewer2 = false;
|
||
}
|
||
});
|
||
|
||
setWarType(2, item.warType);
|
||
layui.form.render();
|
||
form.on('select(warTypes)', function (data) {
|
||
warType = data.value;
|
||
})
|
||
},
|
||
end: function () {
|
||
warType = '';
|
||
}
|
||
});
|
||
}
|
||
|
||
/*照片确认*/
|
||
function setPhotoConfirmHtml(item) {
|
||
let html = '<div class="photo-comfirm">' +
|
||
'<div class="basic-info layout">' +
|
||
'<div id="tt-image" class="confirm-voi-img layout">' +
|
||
'<img src="data:imge/jpg;base64,' + item.image + '" data-original="data:imge/jpg;base64,' + item.image + '" >' +
|
||
'</div>' +
|
||
'<div class="confirm-voi-info layout">' +
|
||
'<p>' + setIsNull(item.proName) + '</p>' +
|
||
'<div class="layout" style="width: 100%;justify-content: space-between;">' +
|
||
'<p>' +setIsNull1( item.teamName) + '</p>' +
|
||
'<p>' + item.analyseResults + '</p>' +
|
||
'</div>' +
|
||
'</div>' +
|
||
'</div>' +
|
||
'<div class="confirm-form">' +
|
||
'<form class="layui-form" onsubmit="return false;">' +
|
||
'<div class="layui-form-item">' +
|
||
'<div class="layui-inline" style="margin-left: 12%">' +
|
||
'<label class="layui-form-label" style="font-size: 14px;">违章类型:</label>' +
|
||
'<div class="layui-input-inline" style="width: 200px;">' +
|
||
'<select class="layui-select" lay-search id="warTypes" lay-filter="warTypes">' +
|
||
'</select>' +
|
||
'</div>' +
|
||
'</div>' +
|
||
'<div class="layui-inline">' +
|
||
"<button class='layui-btn layui-btn-normal layui-btn-sm btn1' onclick='sure(" + JSON.stringify(item) + ",2)'>不属于违章</button>" +
|
||
'</div>' +
|
||
'</div>' +
|
||
'</form>' +
|
||
'</div>' +
|
||
'<div class="confirm-btn">' +
|
||
"<button class='layui-btn layui-btn-normal layui-btn-sm' onclick='sure(" + JSON.stringify(item) + ",1)'>确定</button>" +
|
||
'<button class="layui-btn layui-btn-primary layui-btn-sm" onclick="layer.closeAll()">取消</button>' +
|
||
'</div>' +
|
||
'</div>';
|
||
|
||
|
||
|
||
return html;
|
||
}
|
||
|
||
/*确定、不属于违章*/
|
||
function sure(item, type) {
|
||
if (!warType) {
|
||
warType = item.warType;
|
||
}
|
||
let params = {
|
||
'id': item.id,
|
||
'isSu': type + '',
|
||
'warType': warType
|
||
}
|
||
let loadingMsg = layer.msg('照片确认中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||
$.ajax({
|
||
headers: {
|
||
"encrypt": sm3(JSON.stringify(params))
|
||
},
|
||
url: dataUrl + 'proteam/pot/voiPhotoLibrary/confirmVoiImg?token=' + token,
|
||
data: params,
|
||
type: 'POST',
|
||
async: true,
|
||
success: function (result) {
|
||
console.log(result)
|
||
layer.close(loadingMsg); // 关闭提示层
|
||
if (result.code === 200) {
|
||
layer.msg('确认成功', {icon: 1})
|
||
pages(pageNum, pageSize);
|
||
layer.closeAll('page');
|
||
} else if (result.code === 500) {
|
||
layer.alert(result.msg, {icon: 2})
|
||
} else if (result.code === 401) {
|
||
logout(1);
|
||
}
|
||
}, error: function () {
|
||
layer.close(loadingMsg); // 关闭提示层
|
||
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
||
}
|
||
});
|
||
}
|
||
|
||
|