Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/safety/EducationBuilderEdit.jsp

336 lines
13 KiB
Plaintext
Raw Permalink Normal View History

2026-01-16 14:13:44 +08:00
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<style type="text/css">
.select2-container .select2-selection--single {
height: 34px;
line-height: 34px;
}
.select2-selection__arrow {
margin-top: 3px;
}
.foot {
display: flex;
padding-left: 50px;
}
/*.layout{*/
/* display: flex;*/
/* padding-left: 15px;*/
/*}*/
.form-horizontal {
padding-top: 20px;
}
.right {
margin-left: 50px;
}
</style>
<script type="text/javascript">
var showImg = function () {
var fileId = '${bean.fileId}';
var fileName = '${fileName}';
if(fileId!=null && fileId!=''){
var fileIds = fileId.split(',');
var fileNames = fileName.split(',');
let str = '';
for(var i=0;i<fileIds.length;i++){
if(fileIds[i]!=null && fileIds[i]!=''){
str += '<a><p readonly onclick="fileDownload(\''+fileIds[i]+'\')" ' +
'style="margin-top: 8px;cursor:pointer;">'+fileNames[i]+'</p></a>';
}
}
$('#fileName').html(str);
}
}
var fileinput = function () {
$('#file').click();
};
var filedel = function (id) {
$('#fileName').empty();
$.post(ext.contextPath + '/safety/SafetyEducationBuilder/deleteFile.do', {id : '${bean.id}'}, function(data) {
let res = JSON.parse(data)
if(res.code==1){
$("#table").bootstrapTable('refresh');
}else{
showAlert('d',res.msg,'alertDiv');
}
});
};
var fileSelected = function () {
var filenames = $('#file')[0].files;
var filename = "";
for( var i=0;i<filenames.length; i++ ){
filename += filenames[i].name+"<br>";
}
$('#fileName').html(filename);
};
function showUser4OneSelectFun() {
$.post(ext.contextPath + '/user/userForOneSelectByStructure.do', {
formId: "editForm",
hiddenId: "userid",
textId: "userName",
bean: "bean"
}, function (data) {
$("#user4SelectDiv").html(data);
openModal('user4SelectModal');
});
}
function userInfoChage() {
var userInfo = JSON.parse($('#bean').val());
var userInfo2;
$('#userCardId').val(userInfo.userCardId);
$('#deptId').val(userInfo.pid);
if (userInfo.sex == '1') {
$('#gender').val('男');
} else {
$('#gender').val('女');
}
$.post(ext.contextPath + '/safety/staffArchives/detail.do?id=' + userInfo.id, function (res) {
console.log(res.result)
if (res.code == 1) {
userInfo2 = res.result;
$('#post').val(userInfo2.post);
$('#deptName').val(userInfo2.deptName);
} else {
}
}, 'json')
}
$(function () {
//培训日期
$("#educationDate").datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
//培训有效日期
$("#deadline").datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
$('#file').val();
$('#gender').val('${bean.gender}').trigger("change");
showImg();
});
function initCompanyCondition(isInit) {
var currentValue = $("#companyCondition").val();
$.post(ext.contextPath + '/safety/SafetyEducationBuilder/companyList.do', function (data) {
$("#companyCondition").empty();
var select_3 = $("#companyCondition").select2({
data: data,
cache: false,
placeholder: '请选择',//默认文字提示
allowClear: true,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
minimumInputLength: 0,
minimumResultsForSearch: 10,//数据超过十个启用搜索框
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
$(".select2-selection--single").css({'height': '30px', 'paddingTop': '4px'});
if (isInit) {
select_3.val('').trigger('change');
} else {
select_3.val(currentValue).trigger('change');
}
},'json');
}
function saveFun() {
//console.log($("#editForm").serialize());
$("#editForm").bootstrapValidator('validate');//提交验证
if ($("#editForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
var formData = new FormData($("#editForm")[0]);
$.ajax({
url: ext.contextPath + "/safety/SafetyEducationBuilder/update.do",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function (data) {
// console.log(data)
if (data.code == 1) {
$("#table").bootstrapTable('refresh');
initCompanyCondition(false);
closeModal('subModal');
} else {
showAlert('d', '保存失败!' + data.msg);
}
},
error: function (data) {
}
});
}
}
$("#editForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
educationDate: {
validators: {
notEmpty: {
message: '培训日期不能为空。'
}
}
},
name: {
validators: {
notEmpty: {
message: '姓名不能为空'
}
}
},
company: {
validators: {
notEmpty: {
message: '请填写施工单位名称'
}
}
},
deadline: {
validators: {
notEmpty: {
message: '请选择培训有效期'
}
}
}
}
});
</script>
<div class="modal fade" id="subModal">
<div class="modal-dialog modal-lg" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">编辑培训记录</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12 col-xs-13">
<!-- 新增界面formid强制为editForm -->
<form class="form-horizontal" id="editForm" enctype="multipart/form-data">
<div id="alertDiv"></div>
<%-- <input type="hidden" name="id" value="${user.id }" />--%>
<!-- 界面提醒div强制id为alertdiv -->
<div class="form-group">
<label class="col-sm-2 control-label">* 培训记录编号:</label>
<div class="col-sm-4">
<input type="text" id="educationCode" name="educationCode" class="form-control"
placeholder="" readonly
value="${bean.educationCode}">
<input type="hidden" id="id" name="id" class="form-control"
placeholder="" readonly
value="${bean.id}">
</div>
<label class="col-sm-2 control-label">* 培训日期:</label>
<div class="col-sm-4 ">
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" id="educationDate" name="educationDate"
placeholder="请选择.."
value="${bean.educationDate.substring(0,10)}">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">* 姓名:</label>
<div class="col-sm-10">
<input type="text" name="name" id="userName" class="form-control" placeholder=""
value="${bean.name}">
</div>
<label class="col-sm-2 control-label hidden">* 性别:</label>
<div class="col-sm-4 hidden ">
<select id="gender" name="gender" class="form-control select2">
<option value="男">男</option>
<option value="女">女</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label ">* 施工单位名称:</label>
<div class="col-sm-4 ">
<input type="text" name="company" id="company" class="form-control" placeholder=""
value="${bean.company}">
</div>
<label class="col-sm-2 control-label ">* 培训有效期:</label>
<div class="col-sm-4">
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" id="deadline" name="deadline"
placeholder="请选择.."
value="${bean.deadline.substring(0,10)}">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label ">附件资料:</label>
<div class="col-sm-8" id="fileName"></div>
<div class="col-sm-2" style="display: flex">
<button type="button" class="btn btn-default btn-file" onclick="fileinput()" id="btn_save"><i
class="fa fa-paperclip"></i></button>
<button type="button" class="btn btn-default btn-file" onclick="filedel()" id="btn_save1"><i
class="fa fa-trash-o"></i></button>
<input type="file" name="files" id="file" multiple class="file-loading" onchange="fileSelected()" accept="image/*" />
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default " data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary" style="margin-left: 10px"
onclick="saveFun()">保存</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>