btyjj-inspection/src/main/resources/static/route/check/save-recheck-mine.html
2020-04-02 22:50:09 +08:00

359 lines
17 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">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>复查内容</cite></a>
</span>
</div>
<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" lay-verify="required" class="layui-input" placeholder="请选择企业" style="cursor: pointer;">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否配合</label>
<div class="layui-input-block">
<select name="isCoordination" lay-verify="required">
<option value="">请选择</option>
<option value="0">不配合</option>
<option value="1">配合</option>
</select>
</div>
</div>
<div class="layui-form-item layui-form-text">
<div class="layui-input-block" id="checkItemTemplateBox"></div>
<script id="checkItemTemplate" type="text/html">
<table class="layui-table">
<thead>
<tr>
<th>检查项</th>
<th>检查结果</th>
</tr>
</thead>
<tbody>
{{# for(var i = 0, item; item = d[i++]; ) { }}
<tr>
<td>{{item.name}}({{item.type == '1' ? '必查': '选查'}})</td>
<td>
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="0" title="未检查" lay-filter="checkResultFilter" checked>
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="1" title="通过" lay-filter="checkResultFilter">
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="2" title="立即整改" lay-filter="checkResultFilter">
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="3" title="限期整改" lay-filter="checkResultFilter">
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="4" title="不配合" lay-filter="checkResultFilter">
</td>
</tr>
<tr id="hd_immediatelyChangeType_{{item.checkItemId}}_Box" style="display: none;">
<td></td>
<td>
<input type="radio" name="hd_immediatelyChangeType_{{item.checkItemId}}" value="1" title="当场" checked>
<input type="radio" name="hd_immediatelyChangeType_{{item.checkItemId}}" value="2" title="当天">
</td>
</tr>
<tr id="hd_rectificationDays_{{item.checkItemId}}_Box" style="display: none;">
<td></td>
<td>
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="1" title="1天" checked>
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="5" title="5天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="15" title="15天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="20" title="20天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="25" title="25天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="30" title="30天">
</td>
</tr>
<tr id="hd_scenePhotos_{{item.checkItemId}}_Box" style="display: none;">
<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>
{{# } }}
</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 checkId = top.restAjax.params(window.location.href).checkId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
/**
* 初始化检查项
*
* @param data
*/
function initReCheckItem(checkId) {
top.restAjax.get(top.restAjax.path('api/check/listcheckitemunpassbycheckid/{checkId}', [checkId]), {}, null, function(code, 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/check/getcheckbyid/{checkId}', [checkId]), {}, null, function(code, data) {
var dataFormData = {
enterpriseId: data.enterpriseId,
enterpriseName: data.nameJoinByEnterpriseId,
};
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
initReCheckItem(data.checkId);
}, 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, item; item = hdFieldArray[i]; i++) {
var hiddenDangerReportArray = item.k.split('_');
var checkItemId = hiddenDangerReportArray[2];
var removeItemCount = 0;
var hiddenDangerReport = {
checkItemId: checkItemId
};
for(var j = 0, checkItem; checkItem = hdFieldArray[j]; j++) {
var checkItemKey = checkItem.k;
if(checkItemKey.indexOf(checkItemId) > -1) {
if(checkItemKey.indexOf('checkResult') > -1) {
hiddenDangerReport.checkResult = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
} else if(checkItemKey.indexOf('immediatelyChangeType') > -1) {
hiddenDangerReport.immediatelyChangeType = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
} else if(checkItemKey.indexOf('rectificationDays') > -1) {
hiddenDangerReport.rectificationDays = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
} else if(checkItemKey.indexOf('scenePhotos') > -1) {
hiddenDangerReport.scenePhotos = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
}
}
}
hiddenDangerReports.push(hiddenDangerReport);
if(removeItemCount > 0) {
i--;
}
}
field.hiddenDangerReports = hiddenDangerReports;
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/check/saverecheck/{checkId}', [checkId]), 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({
});
form.on('radio(checkResultFilter)', function(data) {
var name = data.elem.name;
var checkItemId = name.split('_')[2];
if(data.value == 2) {
$('#hd_immediatelyChangeType_'+ checkItemId +'_Box').show();
$('#hd_rectificationDays_'+ checkItemId +'_Box').hide();
} else if(data.value == 3) {
$('#hd_rectificationDays_'+ checkItemId +'_Box').show();
$('#hd_immediatelyChangeType_'+ checkItemId +'_Box').hide();
} else {
$('#hd_rectificationDays_'+ checkItemId +'_Box').hide();
$('#hd_immediatelyChangeType_'+ checkItemId +'_Box').hide();
}
if(data.value != 0) {
$('#hd_scenePhotos_'+ checkItemId +'_Box').show();
} else {
$('#hd_scenePhotos_'+ checkItemId +'_Box').hide();
}
form.render('radio');
});
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 - 2);
}
initFileList(name, files, function(fileName) {});
});
});
</script>
</body>
</html>