451 lines
22 KiB
HTML
451 lines
22 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<base href="/inspection/">
|
||
<meta charset="utf-8">
|
||
<meta name="renderer" content="webkit">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||
<style>
|
||
.check-item-option-number-box {display: inline-block; vertical-align: middle; margin-top: 6px; margin-right: 20px;}
|
||
.check-item-option-text-box {display: inline-block; vertical-align: middle; margin-top: 6px; margin-right: 20px;}
|
||
.check-item-option-number-input {width: 50px; height: 24px; text-align: center;}
|
||
.check-item-option-text-input {width: 200px; height: 24px; text-align: center;}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="layui-anim layui-anim-fadein">
|
||
<div class="layui-card">
|
||
<div class="layui-card-body" style="padding: 15px;">
|
||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">企业</label>
|
||
<div class="layui-input-block layui-form">
|
||
<input type="hidden" id="enterpriseId" name="enterpriseId" class="layui-input">
|
||
<input type="text" id="enterpriseName" name="enterpriseName" class="layui-input" readonly>
|
||
</div>
|
||
</div>
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">是否配合</label>
|
||
<div class="layui-input-block">
|
||
<select id="isCoordination" name="isCoordination" lay-verify="required" lay-filter="isCoordination">
|
||
<option value="">请选择</option>
|
||
<option value="0">未整改</option>
|
||
<option value="1">配合</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div id="checkItemReportBox" class="layui-form-item layui-form-text" style="display: none;">
|
||
<div class="layui-input-block" id="checkItemTemplateBox"></div>
|
||
<script id="checkItemTemplate" type="text/html">
|
||
<table class="layui-table">
|
||
<thead>
|
||
<tr>
|
||
<th style="width: 300px;">检查项</th>
|
||
<th>检查结果</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{{# for(var i = 0, item; item = d[i++]; ) { }}
|
||
{{# if(item.type == 0) {continue;} }}
|
||
<tr>
|
||
<td>{{item.nameJoinByCheckItemId}}({{item.type == '1' ? '必查': '选查'}})</td>
|
||
<td>
|
||
{{# for(var j = 0, jItem; jItem = item.checkItemOptions[j++]; ) { }}
|
||
{{# if(jItem.type == 1) { }}
|
||
<input type="radio" name="hd_checkResult_{{item.checkItemId}}_{{item.checkItemParentId}}" value="{{jItem.checkItemOptionId}}" title="{{jItem.name}}" data-checktype="{{item.type}}" data-type="{{jItem.type}}" data-iswrong="{{jItem.isWrong}}" lay-filter="checkItemOptionCheckResult" lay-verify="otherReq">
|
||
{{# } else if(jItem.type == 2) { }}
|
||
<div class="check-item-option-number-box"><span>{{jItem.name}}</span>:<input class="check-item-option-number-input" id="hd_checkNumber_{{item.checkItemId}}_{{jItem.checkItemOptionId}}_{{item.checkItemParentId}}" name="hd_checkNumber_{{item.checkItemId}}_{{jItem.checkItemOptionId}}_{{item.checkItemParentId}}" type="number" step="1" lay-verify="requiredInput"/> <span>{{jItem.unit}}</span></div>
|
||
{{# } else if(jItem.type == 3) { }}
|
||
<div class="check-item-option-text-box"><span>{{jItem.name}}</span>:<input class="check-item-option-text-input" id="hd_checkText_{{item.checkItemId}}_{{jItem.checkItemOptionId}}_{{item.checkItemParentId}}" name="hd_checkText_{{item.checkItemId}}_{{jItem.checkItemOptionId}}_{{item.checkItemParentId}}" type="text" lay-verify="requiredInput"/> <span>{{jItem.unit}}</span></div>
|
||
{{# } }}
|
||
{{# } }}
|
||
</td>
|
||
<tr id="hd_scenePhotos_{{item.checkItemId}}_Box">
|
||
<td></td>
|
||
<td>
|
||
<input type="hidden" id="hd_scenePhotos_{{item.checkItemId}}" name="hd_scenePhotos_{{item.checkItemId}}"/>
|
||
<div id="hd_scenePhotos_{{item.checkItemId}}_ImageBox" style="display: inline-block"></div>
|
||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||
<a href="javascript:void(0);" lay-form-button data-explain="佐证图片" data-name="hd_scenePhotos_{{item.checkItemId}}" lay-filter="scenePhotosUploadFiles">
|
||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||
</a>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tr>
|
||
{{# } }}
|
||
</tbody>
|
||
</table>
|
||
<table id="handleTable" class="layui-table" style="display: none;">
|
||
<thead>
|
||
<tr>
|
||
<th>整改处理</th>
|
||
</tr>
|
||
</thead>
|
||
</thead>
|
||
<tbody>
|
||
<tr id="hd_checkResult">
|
||
<td>
|
||
<input type="radio" name="rectificationType" value="1" title="立即整改" lay-filter="checkResultFilter" checked>
|
||
<input type="radio" name="rectificationType" value="2" title="限期整改" lay-filter="checkResultFilter">
|
||
</td>
|
||
</tr>
|
||
<tr id="hd_immediatelyChangeType">
|
||
<td>
|
||
<input type="radio" name="immediatelyChangeType" value="1" title="当场" checked>
|
||
<input type="radio" name="immediatelyChangeType" value="2" title="当天">
|
||
</td>
|
||
</tr>
|
||
<tr id="hd_rectificationDays" style="display: none;">
|
||
<td>
|
||
<input type="radio" name="rectificationDays" value="1" title="1天" checked>
|
||
<input type="radio" name="rectificationDays" value="5" title="5天">
|
||
<input type="radio" name="rectificationDays" value="15" title="15天">
|
||
<input type="radio" name="rectificationDays" value="20" title="20天">
|
||
<input type="radio" name="rectificationDays" value="25" title="25天">
|
||
<input type="radio" name="rectificationDays" value="30" title="30天">
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</script>
|
||
</div>
|
||
<div class="layui-form-item layui-layout-admin">
|
||
<div class="layui-input-block">
|
||
<div class="layui-footer" style="left: 0;">
|
||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||
<script>
|
||
layui.config({
|
||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||
}).extend({
|
||
index: 'lib/index' //主入口模块
|
||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||
var $ = layui.$;
|
||
var form = layui.form;
|
||
var laytpl = layui.laytpl;
|
||
var laydate = layui.laydate;
|
||
var taskCheckId = top.restAjax.params(window.location.href).taskCheckId;
|
||
var checkItemArray = [];
|
||
var wrongCheckItemArray = [];
|
||
|
||
|
||
function closeBox() {
|
||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||
}
|
||
|
||
/**
|
||
* 初始化检查项
|
||
*
|
||
* @param data
|
||
*/
|
||
function initCheckItem(natureId) {
|
||
if(!natureId) {
|
||
laytpl(document.getElementById("checkItemTemplate").innerHTML).render([], function(html) {
|
||
document.getElementById("checkItemTemplateBox").innerHTML = html;
|
||
});
|
||
return;
|
||
}
|
||
top.restAjax.get(top.restAjax.path('api/industrycheckitem/listindustrycheckitem', []), {
|
||
natureId: natureId
|
||
}, null, function(code, data) {
|
||
checkItemArray = data;
|
||
laytpl(document.getElementById("checkItemTemplate").innerHTML).render(data, function(html) {
|
||
document.getElementById("checkItemTemplateBox").innerHTML = html;
|
||
});
|
||
form.render('radio');
|
||
}, function(code, data) {
|
||
top.dialog.msg(data.msg);
|
||
});
|
||
}
|
||
|
||
// 初始化内容
|
||
function initData() {
|
||
var loadLayerIndex;
|
||
top.restAjax.get(top.restAjax.path('api/taskcheck/gettaskcheckbyid/{taskCheckId}', [taskCheckId]), {}, null, function(code, data) {
|
||
var dataFormData = {
|
||
enterpriseId: data.enterpriseId,
|
||
enterpriseName: data.enterpriseName,
|
||
};
|
||
form.val('dataForm', dataFormData);
|
||
form.render(null, 'dataForm');
|
||
initCheckItem(data.enterpriseNature);
|
||
}, function(code, data) {
|
||
top.dialog.msg(data.msg);
|
||
}, function() {
|
||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||
}, function() {
|
||
top.dialog.close(loadLayerIndex);
|
||
});
|
||
}
|
||
initData();
|
||
|
||
// 提交表单
|
||
form.on('submit(submitForm)', function(formData) {
|
||
var field = formData.field;
|
||
// 获取隐患项列表
|
||
var hdFieldArray = [];
|
||
for(var i in field) {
|
||
if(i.indexOf('hd_') > -1) {
|
||
hdFieldArray.push({
|
||
k: i,
|
||
v: field[i]
|
||
});
|
||
delete field[i];
|
||
}
|
||
}
|
||
// 筛选隐藏项
|
||
var hiddenDangerReports = [];
|
||
var temp;
|
||
for(var i = 0; i < hdFieldArray.length; i++) {
|
||
var removeItemCount = 0;
|
||
for(var j = 0; j < hdFieldArray.length; j++) {
|
||
var checkItem = hdFieldArray[j];
|
||
var checkItemKey = checkItem.k;
|
||
var hiddenDangerReportArray = checkItemKey.split('_');
|
||
var checkItemId = hiddenDangerReportArray[2];
|
||
var scenePhotos = $('#hd_scenePhotos_'+ checkItemId).val();
|
||
if(checkItemKey.indexOf(checkItemId) > -1) {
|
||
if(checkItemKey.indexOf('checkResult') > -1) {
|
||
hiddenDangerReports.push({
|
||
checkItemParentId: hiddenDangerReportArray[3],
|
||
checkItemId: checkItemId,
|
||
checkItemOptionId: checkItem.v,
|
||
scenePhotos: scenePhotos,
|
||
checkResult: checkItem.v
|
||
});
|
||
hdFieldArray.splice(j, 1);
|
||
j--;
|
||
removeItemCount++;
|
||
} else if(checkItemKey.indexOf('checkNumber') > -1) {
|
||
hiddenDangerReports.push({
|
||
checkItemParentId: hiddenDangerReportArray[4],
|
||
checkItemId: checkItemId,
|
||
checkItemOptionId: hiddenDangerReportArray[3],
|
||
scenePhotos: scenePhotos,
|
||
checkResult: checkItem.v
|
||
});
|
||
hdFieldArray.splice(j, 1);
|
||
j--;
|
||
removeItemCount++;
|
||
} else if(checkItemKey.indexOf('checkText') > -1) {
|
||
hiddenDangerReports.push({
|
||
checkItemParentId: hiddenDangerReportArray[4],
|
||
checkItemId: checkItemId,
|
||
checkItemOptionId: hiddenDangerReportArray[3],
|
||
scenePhotos: scenePhotos,
|
||
checkResult: checkItem.v
|
||
});
|
||
hdFieldArray.splice(j, 1);
|
||
j--;
|
||
removeItemCount++;
|
||
} else if(checkItemKey.indexOf('scenePhotos') > -1) {
|
||
hdFieldArray.splice(j, 1);
|
||
j--;
|
||
removeItemCount++;
|
||
}
|
||
}
|
||
}
|
||
if(removeItemCount > 0) {
|
||
i--;
|
||
}
|
||
}
|
||
field.hiddenDangerReports = hiddenDangerReports;
|
||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||
top.dialog.close(index);
|
||
var loadLayerIndex;
|
||
formData.field.taskCheckId = taskCheckId;
|
||
top.restAjax.post(top.restAjax.path('api/check/savecheck', []), formData.field, null, function(code, data) {
|
||
var layerIndex = top.dialog.msg('提交成功', {
|
||
time: 0,
|
||
btn: [top.dataMessage.button.yes],
|
||
shade: 0.3,
|
||
yes: function(index) {
|
||
top.dialog.close(index);
|
||
closeBox();
|
||
},
|
||
});
|
||
}, function(code, data) {
|
||
top.dialog.msg(data.msg);
|
||
}, function() {
|
||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||
}, function() {
|
||
top.dialog.close(loadLayerIndex);
|
||
});
|
||
});
|
||
return false;
|
||
});
|
||
|
||
$('.close').on('click', function() {
|
||
closeBox();
|
||
});
|
||
|
||
// 校验
|
||
form.verify({
|
||
otherReq: function(value, item) {
|
||
if($('#isCoordination').val() != '1') {
|
||
return;
|
||
}
|
||
var verifyName = $(item).attr('name')
|
||
,verifyType = $(item).attr('type')
|
||
,formElem = $(item).parents('.layui-form')//获取当前所在的form元素,如果存在的话
|
||
,verifyElem = formElem.find('input[name='+verifyName+']')//获取需要校验的元素
|
||
,isTrue = verifyElem.is(':checked')//是否命中校验
|
||
,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
|
||
if(!isTrue || !value){
|
||
//定位焦点
|
||
focusElem.css(verifyType=='radio' ? {"color":"#FF5722"} : {"border-color":"#FF5722"});
|
||
//对非输入框设置焦点
|
||
focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
|
||
focusElem.css(verifyType=='radio' ? {"color":""} : {"border-color":""});
|
||
}).focus();
|
||
return '必填项不能为空';
|
||
}
|
||
},
|
||
requiredInput: function(value, item) {
|
||
if($('#isCoordination').val() != '1') {
|
||
return;
|
||
}
|
||
if(!value) {
|
||
return '必填项不能为空'
|
||
}
|
||
}
|
||
});
|
||
|
||
form.on('select(isCoordination)', function(data) {
|
||
if(data.value == 1) {
|
||
$('#checkItemReportBox').show();
|
||
} else {
|
||
$('#checkItemReportBox').hide();
|
||
}
|
||
});
|
||
|
||
form.on('radio(checkItemOptionCheckResult)', function(data) {
|
||
var name = data.elem.name;
|
||
var checkItemId = name.split('_')[2];
|
||
if(this.dataset.checktype == 1 && this.dataset.iswrong == 1) {
|
||
wrongCheckItemArray.push(checkItemId);
|
||
} else {
|
||
for(var i = 0; i < wrongCheckItemArray.length; i++) {
|
||
if(checkItemId == wrongCheckItemArray[i]) {
|
||
wrongCheckItemArray.splice(i, 1);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(wrongCheckItemArray.length > 0) {
|
||
$('#handleTable').show();
|
||
} else {
|
||
$('#handleTable').hide();
|
||
}
|
||
});
|
||
|
||
form.on('radio(checkResultFilter)', function(data) {
|
||
if(data.value == 1) {
|
||
$('#hd_rectificationDays').hide();
|
||
$('#hd_immediatelyChangeType').show();
|
||
} else {
|
||
$('#hd_immediatelyChangeType').hide();
|
||
$('#hd_rectificationDays').show();
|
||
}
|
||
});
|
||
|
||
function refreshDownloadTemplet(fileName, file) {
|
||
var dataRander = {};
|
||
dataRander[fileName] = file;
|
||
var photos = '';
|
||
for(var i = 0, item; item = file[i++];) {
|
||
photos += '<div class="upload-image-box">'+
|
||
'<span class="upload-image-span">'+
|
||
'<img src="route/file/downloadfile/false/'+ item.fileId +'" align="加载失败">'+
|
||
'</span>'+
|
||
'<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="'+ item.fileId +'" data-name="'+ fileName +'" lay-filter="scenePhotosRemoveFile">'+
|
||
'<i class="fa fa-trash-o"></i>'+
|
||
'</a>'+
|
||
'</div>';
|
||
}
|
||
$('#'+ fileName +'_ImageBox').empty();
|
||
$('#'+ fileName +'_ImageBox').append(photos);
|
||
}
|
||
|
||
// 初始化文件列表
|
||
function initFileList(fileName, ids, callback) {
|
||
var dataForm = {};
|
||
dataForm[fileName] = ids;
|
||
form.val('dataForm', dataForm);
|
||
|
||
if(!ids) {
|
||
refreshDownloadTemplet(fileName, []);
|
||
if(callback) {
|
||
callback(fileName, []);
|
||
}
|
||
return;
|
||
}
|
||
|
||
top.restAjax.get(top.restAjax.path('api/file/listfilebyfileid', []), {
|
||
ids: ids
|
||
}, null, function(code, data) {
|
||
refreshDownloadTemplet(fileName, data);
|
||
if(callback) {
|
||
callback(fileName, data);
|
||
}
|
||
}, function(code, data) {
|
||
top.dialog.msg(data.msg);
|
||
});
|
||
}
|
||
|
||
// 上传图片
|
||
form.on('button(scenePhotosUploadFiles)', function(obj) {
|
||
var name = this.dataset.name;
|
||
var explain = this.dataset.explain;
|
||
top.dialog.file({
|
||
type: 'image',
|
||
title: '上传'+ explain,
|
||
width: '400px',
|
||
height: '420px',
|
||
maxFileCount: '1',
|
||
onClose: function() {
|
||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||
var files = $('#'+ name).val();
|
||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||
if(files.length > 0) {
|
||
files += ',';
|
||
}
|
||
files += file.data;
|
||
}
|
||
initFileList(name, files, function(fileName) {});
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
form.on('button(scenePhotosRemoveFile)', function(obj) {
|
||
var name = this.dataset.name;
|
||
var id = this.dataset.id;
|
||
var files = $('#'+ name).val().replace(id, '');
|
||
files = files.replace(/\,+/g, ',');
|
||
if(files.charAt(0) == ',') {
|
||
files = files.substring(1);
|
||
}
|
||
if(files.charAt(files.length - 1) == ',') {
|
||
files = files.substring(0, files.length - 1);
|
||
}
|
||
initFileList(name, files, function(fileName) {});
|
||
});
|
||
});
|
||
</script>
|
||
</body>
|
||
</html> |