safesite/safesite/templates/addtrouble.html

532 lines
29 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="easyui-layout" style="width:100%;height: 100%;">
<div data-options="region:'center'" style="width:100%;height:100%;padding:15px 15px;">
<form id="yhff" method="post" style="font-size:16px;" enctype="multipart/form-data">
<div id="pgyjdiv" style="margin-bottom:5px;display:none">
<div id="pgyjh" class='labeldiv'>提交的隐患被退回</div>
<input id="pgyj" class="easyui-textbox" name="pgyj" style="width:480px;" value="" data-options="label:'退回原因'">
</div>
<div style="margin-bottom:5px">
<input editable="false" required=true name="yhdj" id="yhdj" style="width:480px;" data-options="
label:'隐患等级',
method: 'get',
valueField:'value',
textField:'text',
" />
</div>
<div style="margin-bottom:5px">
<input editable="false" required=true name="jclx" id="jclx" style="width:480px" data-options="
label:'检查类型',
method: 'get',
valueField:'value',
textField:'text',
" />
</div>
<div style="margin-bottom:5px">
<input id="fxsj" editable="false" type="text" name="fxsj" class="easyui-datetimebox" style="width:480px"
data-options="label:'发现时间',currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
</div>
<div style="margin-bottom:5px">
<input editable="false" name="yhqy" id="yhqy" style="width:480px" data-options="
label:'发现区域',
method: 'get',
valueField:'id',
textField:'name',
" />
</div>
<div style="margin-bottom:5px">
<input id="yhdd" class="easyui-textbox" name="yhdd" style="width:480px" data-options="label:'隐患地点'"
required=true />
</div>
<div style="margin-bottom:5px">
<input id="yhms" class="easyui-textbox" name="yhms" style="width:480px;height:60px" data-options="label:'隐患描述',multiline:true"
required=true />
<!-- <a id="duibiaoadd" class='easyui-linkbutton' onclick="duibiaoadd()" style="width:auto" >对标</a> -->
</div>
<div style="text-align: left;margin-left: 46px;margin-top: 30px;">
<input type="hidden" name="yhtp" id="yhtp" />
<label>隐患图片</label><input type="file" id="file" name="" accept="image/*" style="margin-left:30px;" />
<span id='ps' style="display:none">
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
<span id="percentage"></span><span id="time"></span></span>
<ul id="addImage" class="imgul"></ul>
</div>
<div id="yzgb" style="text-align: left;margin-left: 46px;margin-top: 30px;">
<input type="checkbox" onclick="shide1()" id="checkboxid1" />
<label id="sfzp1">现场已经立即完成整改</label>
</div>
<div id="zprb" style="text-align: left;margin-left: 46px;margin-top: 30px;">
<input type="checkbox" onclick="shide()" id="checkboxid" />
<label id="sfzp">需要指派整改</label>
</div>
<script>
$.get('api/user?a=checkaqy',function(data){
if(data.code==1){}else{$('#zprb').remove()}
})
</script>
<div id="pg">
<div style="margin-top:10px;margin-bottom:5px">
<input editable="false" name="yhpg" id="yhpg" style="width:480px" data-options="
label:'隐患评估',
method: 'get',
valueField:'value',
textField:'text',
"
required=true />
</div>
<div style="margin-bottom:5px">
<input class="easyui-combotree" editable="false" required=true name="yhlxo" id="yhlxo" style="width:480px;" data-options="
url:'getdickey?dicclass=56&a=combobox',
label:'隐患因素',
method: 'get',
valueField:'value',
textField:'text',
" />
</div>
<div style="margin-bottom:5px">
<input name="yhlx" id="yhlx" style="width:480px" editable="false" data-options="
label:'隐患大类',
method: 'get',
valueField:'value',
textField:'text',
groupField:'group',
"
required=true /></div>
<div style="margin-bottom:5px">
<input name="yhlb" id="yhlb" class="easyui-textbox" style="width:480px" editable="false"
data-options="
label:'隐患类别',
method: 'get',
valueField:'value',
textField:'text',
groupField:'group'
"
required=true />
</div>
</div>
<!-- <div id="fxcscheck">
<label >原因分析/整改措施</label>
<input type="checkbox" onclick="shide2()" id="checkboxid2" />
<HR width="480px" color='blue' SIZE=2 align='left'>
</div> -->
<div id="zpzgr">
<div style="margin-bottom:5px">
<input id="zgbm" name="zgbm" style="width:480px;" editable="false" data-options="
label:'整改部门',
method: 'get',
loadFilter: function(rows){
return convert(rows);
},
formatter:function(node){
var s = node.text;
if (node.children){
s += '&nbsp;<span style=\'color:blue\'>(' + node.children.length + ')</span>';
}
return s;
},
"
required=true /></div>
<div style="margin-bottom:5px">
<input id="zgr" name="zgr" editable="false" class="easyui-textbox" style="width:480px" data-options="label:'整改人员:',prompt:'如不选择将指派到部门'"
>
</div>
<input id="zgqx" editable="false" type="text" name="zgqx" class="easyui-datetimebox" style="width:480px"
data-options="label:'整改期限',currentText:'今天',closeText:'关闭'" required=true>
</div>
<div id="fxcs" width="100%">
<div style="margin-top:5px;margin-bottom:5px">
<input id="yyfx" class="easyui-textbox" name="yyfx" style="width:480px;height:60px" data-options="label:'原因分析',multiline:true,prompt:'如不填写将由整改人填写'" />
</div>
<div style="margin-bottom:5px">
<input id="zgcs" class="easyui-textbox" name="zgcs" style="width:480px;height:60px" data-options="label:'整改措施',multiline:true,prompt:'如不填写将由整改人填写'" />
</div>
</div>
<div id="zghxq">
<div style="margin-bottom:5px">
<input id="zgms" class="easyui-textbox" name="zgms" style="width:480px;height:60px" data-options="label:'整改描述',multiline:true"
required=true></div>
<div style="margin-bottom:5px">
<input type="hidden" name="zghtp" id="zghtp" />
<label>整改后图片</label><input type="file" id="file2" name="" accept="image/*" style="margin-left:20px;" />
<span id='ps2' style="display:none">
<progress id="progressBar2" value="0" max="100" style="width: 100px;"></progress>
<span id="percentage2"></span><span id="time2"></span></span>
</div>
<ul id="addImage2" class="imgul"></ul>
</div>
<input id="troubleid" name="troubleid" value="" style="display:none;" />
</form>
</div>
<div id='southdiv' data-options="region:'south'" style="width:100%;height:50px;text-align:center;padding:5px">
<a iconCls="fa-check" class="easyui-linkbutton" onclick="submitFormyh()" id="submitb">提交</a>
<a iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">取消</a>
</div>
<script>
var xhr;
//$(function () {
var a = GetQueryString("a");
var b = GetQueryString("troubleid");
//console.log(a,b)
$("#yhdj").combobox({
url: 'getdickey?dicclass=18&a=combobox',
onSelect: function (node) {
if (node.text == '无隐患') {
$('#yzgb,#zprb').hide();
}
else if (node.text == '重大隐患') {
$('#zprb').show(); $('#yzgb').hide();
}
else if (node.text == '一般隐患') { $('#yzgb,#zprb').show(); }
}
});
$("#jclx").combobox({ url: 'getdickey?dicclass=14&a=combobox', });
$("#yhqy").combobox({ url: 'api/area?a=tree', });
$('#pg,#zghxq,#fxcs,#zpzgr').hide();
if (a == 'edityh') {
$.ajax({
type: "POST",
url: 'getyh?troubleid=' + b,
datatype: "json",
beforeSend: function () { },
success: function (data) {
$("#yhdj").combobox('setValue', data.yhdj__dickeyid);
$("#jclx").combobox('setValue', data.jclx__dickeyid);
$("#yhdd").textbox('setValue', data.yhdd);
$("#yhms").textbox('setValue', data.yhms);
$("#fxsj").datetimebox('setValue', data.fxsj);
$("#yhqy").combobox('setValue', data.yhqy__id);
if (data.yhtp != '') {
var yhtp = data.yhtp
for (var i = 0; i < yhtp.length; i++) { $("#addImage").append('<li ><img style="display:block;" onclick ="bigger(this)" class = "yhtpimg" width="120" height="120" filepath="' + yhtp[i] + '" src="http://' + window.location.host + '/' + yhtp[i] + '"/><button onclick="removep(this)" >删除</button></li>'); }
}
if (data.zgms != '') {
$('#yzgb,#zprb,#pg,#zgxq').show(); $('#checkboxid1').prop('checked', true); shide1();
$("#yhpg").combobox('setValue', data.yhpg__dickeyid);
$("#yhlx").combobox('setValue', data.yhlx__dicid);
$("#yyfx").textbox('setValue', data.yyfx);
$("#zgcs").textbox('setValue', data.zgcs);
$("#zgms").textbox('setValue', data.zgms);
if (data.zghtp != '') {
var zghtp = data.zghtp.split('?');
for (var i = 0; i < zghtp.length; i++) { $("#addImage2").append('<li ><img style="display:block;" onclick="bigger(this)" class = "zghtpimg" width="120" height="120" filepath="' + zghtp[i] + '" src="http://' + window.location.host + '/' + zghtp[i] + '"/><button onclick="removep(this)" >删除</button></li>'); }
}
} else if (data.zgr != '') {
$('#yzgb,#zprb,#pg,#zpzgr').show(); $('#checkboxid').prop('checked', true); shide();
$("#yhpg").combobox('setValue', data.yhpg__dickeyid);
$("#yyfx").textbox('setValue', data.yyfx);
$("#zgcs").textbox('setValue', data.zgcs);
$("#zgqx").datetimebox('setValue', data.zgqx);
}
$("#troubleid").attr("value", b);
if(data.shresult == 5){
$('#pgyjdiv').show();$('#yzgb,#zprb').hide()
$('#pgyj').textbox('setValue', data.pgyj).textbox('disable');
}
}
});
}
document.getElementById('file').onchange = function () {
var fileObj = this.files[0];
var url = 'upfile'
var form = new FormData();
if (fileObj.size / 1024 > 500) { //大于500k进行压缩上传
$("#file").after('<span id="tip" style="color:blue">图片大于500k,正在压缩...</span>');
photoCompress(fileObj, {}, function (base64Codes) {
//console.log("压缩后:" + base.length / 1024 + " " + base);
var bl = convertBase64UrlToBlob(base64Codes);
form.append("upfile", bl, fileObj.name); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
$("#tip").remove();
$('#ps').show();
xhr.onload = function (evt) { //服务断接收完文件返回的结果
var data = JSON.parse(evt.target.responseText);
if (data.code = 1) {
$('#ps').hide();
$("#addImage").append('<li ><img title="点击放大" style="display:block;" onclick="bigger(this)" class = "yhtpimg" width="120" height="120" filepath="' + data.filepath + '" src="http://' + window.location.host + '/' + data.filepath + '"/><button onclick="removep(this)" >删除</button></li>');
document.getElementById('file').value = '';
} else { alert("上传失败!"); }
}; //请求完成
xhr.onerror = function (evt) { alert("上传失败!"); $('#ps').hide(); };; //请求失败
xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
xhr.upload.onloadstart = function () {//上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0;//设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
});
} else { //小于等于500k 原图上传
form.append("upfile", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = function (evt) { //服务断接收完文件返回的结果
var data = JSON.parse(evt.target.responseText);
if (data.code = 1) {
$('#ps').hide();
$("#addImage").append('<li ><img title="点击放大" style="display:block;" onclick="bigger(this)" class = "yhtpimg" width="120" height="120" filepath="' + data.filepath + '" src="http://' + window.location.host + '/' + data.filepath + '"/><button onclick="removep(this)" >删除</button></li>');
document.getElementById('file').value = '';
} else { alert("上传失败!"); }
}; //请求完成
xhr.onerror = function (evt) { alert("上传失败!"); $('#ps').hide(); };; //请求失败
xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
xhr.upload.onloadstart = function () {//上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0;//设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
}
function progressFunction(evt) {
var progressBar = document.getElementById("progressBar");
var percentageDiv = document.getElementById("percentage");
// event.total是需要传输的总字节event.loaded是已经传输的字节。如果event.lengthComputable不为真则event.total等于0
if (evt.lengthComputable) {//
progressBar.max = evt.total;
progressBar.value = evt.loaded;
percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";
}
var time = document.getElementById("time");
var nt = new Date().getTime();//获取当前时间
var pertime = (nt - ot) / 1000; //计算出上次调用该方法时到现在的时间差单位为s
ot = new Date().getTime(); //重新赋值时间,用于下次计算
var perload = evt.loaded - oloaded; //计算该分段上传的文件大小单位b
oloaded = evt.loaded;//重新赋值已上传文件大小,用以下次计算
//上传速度计算
var speed = perload / pertime;//单位b/s
var bspeed = speed;
var units = 'b/s';//单位名称
if (speed / 1024 > 1) {
speed = speed / 1024;
units = 'k/s';
}
if (speed / 1024 > 1) {
speed = speed / 1024;
units = 'M/s';
}
speed = speed.toFixed(1);
//剩余时间
var resttime = ((evt.total - evt.loaded) / bspeed).toFixed(1);
time.innerHTML = ',速度:' + speed + units + ',剩余时间:' + resttime + 's';
//if(bspeed==0) time.innerHTML = '上传已取消';
}
}
document.getElementById('file2').onchange = function () {
var fileObj = this.files[0];
var url = 'upfile'
var form = new FormData();
if (fileObj.size / 1024 > 500) { //大于500k进行压缩上传
$("#file2").after('<span id="tip" style="color:blue">图片大于500k,正在压缩...</span>');
photoCompress(fileObj, {}, function (base64Codes) {//quality: 0.2
//console.log("压缩后:" + base.length / 1024 + " " + base);
var bl = convertBase64UrlToBlob(base64Codes);
form.append("upfile", bl, fileObj.name); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
$("#tip").remove();
$('#ps2').show();
xhr.onload = function (evt) { //服务断接收完文件返回的结果
var data = JSON.parse(evt.target.responseText);
if (data.code = 1) {
$('#ps2').hide();
$("#addImage2").append('<li ><img title="点击放大" style="display:block;" onclick="bigger(this)" class = "zghtpimg" width="120" height="120" filepath="' + data.filepath + '" src="http://' + window.location.host + '/' + data.filepath + '"/><button onclick="removep(this)" >删除</button></li>');
document.getElementById('file2').value = '';
} else { alert("上传失败!"); }
}; //请求完成
xhr.onerror = function (evt) { alert("上传失败!"); $('#ps2').hide(); };; //请求失败
xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
xhr.upload.onloadstart = function () {//上传开始执行方法
ot = new Date().getTime(); //设置上传开始时间
oloaded = 0;//设置上传开始时以上传的文件大小为0
};
xhr.send(form); //开始上传发送form数据
});
} else { //小于等于1M 原图上传
form.append("upfile", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.onload = function (evt) { //服务断接收完文件返回的结果
var data = JSON.parse(evt.target.responseText);
if (data.code = 1) {
$('#ps2').hide();
$("#addImage2").append('<li ><img title="点击放大" style="display:block;" onclick="bigger(this)" class = "zghtpimg" width="120" height="120" filepath="' + data.filepath + '" src="http://' + window.location.host + '/' + data.filepath + '"/><button onclick="removep(this)" >删除</button></li>');
document.getElementById('file2').value = '';
} else { alert("上传失败!"); }
}; //请求完成
xhr.onerror = function (evt) { alert("上传失败!"); $('#ps2').hide(); };; //请求失败
xhr.send(form); //开始上传发送form数据
}
//上传进度实现方法,上传过程中会频繁调用该方法
function progressFunction(evt) {
var progressBar = document.getElementById("progressBar2");
var percentageDiv = document.getElementById("percentage2");
// event.total是需要传输的总字节event.loaded是已经传输的字节。如果event.lengthComputable不为真则event.total等于0
if (evt.lengthComputable) {//
progressBar.max = evt.total;
progressBar.value = evt.loaded;
percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";
}
var time = document.getElementById("time2");
var nt = new Date().getTime();//获取当前时间
var pertime = (nt - ot) / 1000; //计算出上次调用该方法时到现在的时间差单位为s
ot = new Date().getTime(); //重新赋值时间,用于下次计算
var perload = evt.loaded - oloaded; //计算该分段上传的文件大小单位b
oloaded = evt.loaded;//重新赋值已上传文件大小,用以下次计算
//上传速度计算
var speed = perload / pertime;//单位b/s
var bspeed = speed;
var units = 'b/s';//单位名称
if (speed / 1024 > 1) {
speed = speed / 1024;
units = 'k/s';
}
if (speed / 1024 > 1) {
speed = speed / 1024;
units = 'M/s';
}
speed = speed.toFixed(1);
//剩余时间
var resttime = ((evt.total - evt.loaded) / bspeed).toFixed(1);
time.innerHTML = ',速度:' + speed + units + ',剩余时间:' + resttime + 's';
if (bspeed == 0) time.innerHTML = '上传已取消';
}
}
function shide() {
if ($('#checkboxid').prop('checked') == true) {
$("#pg,#zpzgr,#fxcs").show();
$(".pgb").show();
$("#yhpg").combobox({ url: 'getdickey?dicclass=19&a=combobox', });
$("#yhlx").combobox({ url: 'getdicclass?dicid=15', onSelect: function (node) { $('#yhlb').combotree({ url: 'getdickey?dicclass=' + node.value + '&a=combobox', }); } });
$("#zgbm").combotree({ url: 'parthandle?a=tree3', onSelect: function (node) { $('#zgr').combobox({ url: 'getuser?partid=' + node.id + '&a=combobox', }); } });
$('#checkboxid1').attr("disabled", "disabled");
} else { $("#pg,#zpzgr,#fxcs").hide(); $("#zgr").textbox('clear'); $("#zgqx").datetimebox('clear'); $('#checkboxid1').removeAttr("disabled"); }
}
function shide1() {
if ($('#checkboxid1').prop('checked') == true) {
$("#pg,#fxcs,#zghxq").show();
$(".pgb").hide();
$("#yhpg").combobox({ url: 'getdickey?dicclass=19&a=combobox', });
$("#yhlx").combobox({ url: 'getdicclass?dicid=15', onSelect: function (node) { $('#yhlb').combotree({ url: 'getdickey?dicclass=' + node.value + '&a=combobox', }); } });
$('#checkboxid').attr("disabled", "disabled");
$('#yyfx').textbox({required:true,prompt:''});
$('#zgcs').textbox({required:true,prompt:''});
} else {
$("#pg,#fxcs,#zghxq").hide(); $('#checkboxid').removeAttr("disabled");
$('#yyfx').textbox({required:false,prompt:'如不填写将由整改人填写'});
$('#zgcs').textbox({required:false,prompt:'如不填写将由整改人填写'});
}
}
function submitFormyh() {
var yhdata = $('#yhff').serializeJSON();
//var form = new FormData(document.getElementById("yhff"));
var yhtp = new Array();
$(".yhtpimg").each(function () {
yhtp.push($(this).attr("filepath"));
});
yhdata['yhtp']=yhtp
var zghtp = new Array();
$(".zghtpimg").each(function () {
zghtp.push($(this).attr("filepath"));
});
yhdata['zghtp']=zghtp
if ($('#checkboxid').prop('checked') == true) {
var checkarray = [yhdata['yhdj'], yhdata['yhpg'], yhdata['jclx'], yhdata['yhlx'], yhdata['yhlb'], yhdata['fxsj'], yhdata['yhdd'], yhdata['yhms'], yhdata['zgbm'], yhdata['zgqx']];
}
else if ($('#checkboxid1').prop('checked') == true) {
var checkarray = [yhdata['yhdj'], yhdata['jclx'], yhdata['fxsj'], yhdata['yhdd'], yhdata['yhms'], yhdata['zgcs'], yhdata['zgms']];
}
else {
var checkarray = [yhdata['yhdj'], yhdata['jclx'], yhdata['fxsj'], yhdata['yhdd'], yhdata['yhms']]
}
if (myCheck(checkarray)) {
$('#submitb').linkbutton('disable');
$.ajax({
type: "POST",
url: 'addyh',
data: JSON.stringify(yhdata),
datatype: "json",
contentType: "application/json;charset=utf-8",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
//var href = top.$('#main').attr('src');
//top.$('#main').attr('src', href);
$("#yhtable").datagrid('reload');
$("#dd").dialog("close");
}
else if (data.code == 0) { $.messager.alert('提示', '填报人部门无安全员或主管!'); }
else if (data.code == 101) { $.messager.alert('提示', '整改部门无安全员或主管!'); }
else { $.messager.alert('提示', '失败!'); }
$('#submitb').linkbutton('enable');
},
});
} else { $.messager.alert('提示', '缺少必填项!'); }
}
function duibiaoadd(){
var yhmsdata = $('#yhms').val()
// $.ajax({
// type: "POST",
// url: 'api/duibiao',
// data: {'yhms':yhmsdata},
// datatype: "json",
// //contentType: "application/x-www-form-urlencoded",默认格式
// beforeSend: function () { },
// success: function (data) {
// if (data.code == 1) {
// //var href = top.$('#main').attr('src');
// //top.$('#main').attr('src', href);
// console.log(data.data)
// }
// },
// });
loading('正在比对,请稍等..');
$.post('api/duibiao', { 'yhms': yhmsdata }, function (result, status) {
if (result.code = 1) {
html = '<p style="color:red;margin-left: 10px">根据您的描述,搜索到以下安标结果:</p>'
for (var j = 0, len = result.data.length; j < len; j++) {
html = html + '<p style="margin-left: 10px;margin-right: 10px">' + result.data[j] + '</p>'
}
$("<div/>").dialog({
title: '对标结果',
width: 800,
height: 400,
closed: false,
cache: false,
content: html,
modal: true,
border: false,
onClose: function () {
$(this).dialog('close');
}
});
}
removeLoading()
});
}
</script>
</div>