318 lines
12 KiB
Plaintext
318 lines
12 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8"%>
|
||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||
<!-- 文件上传-->
|
||
<link rel="stylesheet" href="<%=request.getContextPath()%>/node_modules/bootstrap-fileinput/css/fileinput.min.css"/>
|
||
<script type="text/javascript"
|
||
src="<%=request.getContextPath()%>/node_modules/bootstrap-fileinput/js/fileinput.min.js"
|
||
charset="utf-8"></script>
|
||
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/bootstrap-fileinput/js/locales/zh.js"
|
||
charset="utf-8"></script>
|
||
<script type="text/javascript">
|
||
var filelist = new Array();
|
||
|
||
var previews = new Array();
|
||
var previewConfigs = new Array();
|
||
var tbName = 'tb_doc_file';
|
||
|
||
function showFileInput(ctrlName) {
|
||
control = $('#' + ctrlName);
|
||
|
||
//control.fileinput('destroy');
|
||
control.fileinput({
|
||
language: 'zh', //设置语言
|
||
uploadUrl: ext.contextPath+ "/document/inputFile.do", //上传的地址
|
||
uploadAsync: true,
|
||
allowedFileExtensions : ['jpg', 'png', 'svg', 'jpeg', 'gif'],//接收的文件后缀
|
||
showUpload: false, //是否显示上传按钮
|
||
showRemove: false,
|
||
showCaption: true,//是否显示标题
|
||
showClose:false,//右上角关闭按钮
|
||
browseClass: "btn btn-primary", //按钮样式
|
||
maxFileCount: 2, //表示允许同时上传的最大文件个数
|
||
maxFileSize: 1048576,
|
||
enctype: 'multipart/form-data',
|
||
dropZoneEnabled: false ,//是否显示拖拽区域
|
||
validateInitialCount:true,
|
||
previewFileIcon: "<i class='fa fa-file'></i>",
|
||
preferIconicPreview: true,//是否强制相关文件展示icon
|
||
initialPreviewAsData: true,
|
||
overwriteInitial: false,
|
||
previewFileIconSettings: {
|
||
'doc': '<i class="fa fa-file-word-o" style="color:#3c8dbc;"></i>',
|
||
'docx': '<i class="fa fa-file-word-o" style="color:#3c8dbc;"></i>',
|
||
'xls': '<i class="fa fa-file-excel-o" style="color:#00a65a ;"></i>',
|
||
|
||
'xlsx': '<i class="fa fa-file-excel-o" style="color:#00a65a ;"></i>',
|
||
'pptx': '<i class="fa fa-file-powerpoint-o" style="color:#f39c12; "></i>',
|
||
'ppt': '<i class="fa fa-file-powerpoint-o" style="color:#f39c12; "></i>',
|
||
//'jpg': '<i class="fa fa-file-image-o" style="color:#00a65a "></i>',
|
||
'pdf': '<i class="fa fa-file-pdf-o" style="color:#dd4b39 ;"></i>',
|
||
'zip': '<i class="fa fa-file-zip-o" ></i>',
|
||
},
|
||
|
||
uploadExtraData:function (previewId, index) {
|
||
//传参
|
||
var data = {
|
||
"masterId": '${channelPortConfig.id}', //此处自定义传参
|
||
"tbName": 'tb_doc_file',
|
||
"nameSpace": 'Document',
|
||
};
|
||
return data;
|
||
},
|
||
//设置缩略图上的按钮,为空不显示,默认显示
|
||
layoutTemplates:{
|
||
//actionDelete:'',
|
||
actionUpload:''
|
||
},
|
||
slugCallback: function (data,data2) {
|
||
console.log(data2);
|
||
return data;
|
||
},
|
||
initialPreview: previews,
|
||
initialPreviewConfig: previewConfigs,
|
||
deleteUrl: ext.contextPath + "/base/deleteInputFile.do",
|
||
deleteExtraData: function () { //传参
|
||
var data = {
|
||
"tbName": tbName
|
||
};
|
||
return data;
|
||
}
|
||
});
|
||
control.on('filezoomhide', function (event, params) {
|
||
//关闭预览模态框后清空内部,防止音视频继续播放
|
||
$(params.modal).find('.kv-zoom-body').empty();
|
||
});
|
||
$('#kvFileinputModal').on("hidden.bs.modal", function () {
|
||
$(this).removeData("bs.modal");
|
||
//modal重复打开会导致前面的滚动条失去作用
|
||
$('.modal').css("overflow", "auto");
|
||
});
|
||
//导入文件上传完成之后的事件
|
||
control.on("fileuploaded", function (event, data, previewId, index) {
|
||
if(data.response.suc) {
|
||
closeModal('fileInputEditModal');
|
||
$("#fileTable").bootstrapTable('refresh');
|
||
}
|
||
if(!data.response.pdf) {
|
||
closeModal('fileInputModal');
|
||
$("#fileTable").bootstrapTable('refresh');
|
||
showAlert('d','上传的文件转换为预览PDF格式失败!');
|
||
}
|
||
});
|
||
}
|
||
|
||
//名称定义不可修改
|
||
var getFileList = function () {
|
||
$.post(ext.contextPath + '/base/getInputFileListById.do', {
|
||
id: '${channelPortConfig.id}',
|
||
masterId: '${channelPortConfig.id}',
|
||
tbName: tbName
|
||
}, function (data) {
|
||
//console.info(data)
|
||
if (data.length > 0) {
|
||
previews = new Array();
|
||
$('#maintenancefile').show();
|
||
for (var i = 0; i < data.length; i++) {
|
||
var previewConfig = new Object();
|
||
var path = data[i].abspath;
|
||
path = path.substring(path.indexOf('webapps') + 7, path.length);
|
||
path = ext.basePath.replace(ext.contextPath, '') + path.replace(/\\/g, "\/");
|
||
;
|
||
previews.push(path);
|
||
previewConfig['width'] = '2500px';
|
||
previewConfig['caption'] = data[i].filename;
|
||
previewConfig['key'] = data[i].id;
|
||
if (data[i].type.split("/")[0] == 'application') {
|
||
previewConfig['type'] = 'pdf';
|
||
} else {
|
||
previewConfig['type'] = data[i].type.split("/")[0];
|
||
}
|
||
previewConfig['size'] = data[i].size;
|
||
previewConfig['filetype'] = data[i].type;
|
||
previewConfigs.push(previewConfig);
|
||
}
|
||
}
|
||
|
||
showFileInput("filelist");
|
||
/*else {
|
||
$('#filelist').hide();
|
||
}*/
|
||
}, 'json');
|
||
|
||
};
|
||
|
||
function dosave() {
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/work/channelPortConfig/doUpdate.do", $("#subForm").serialize(), function(data) {
|
||
if (data.result == 1) {
|
||
closeModal('subModal')
|
||
$("#table").bootstrapTable('refresh');
|
||
control.fileinput("upload");
|
||
}else if(data.result == 0){
|
||
showAlert('d','保存失败');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
}
|
||
},'json');
|
||
}
|
||
|
||
}
|
||
|
||
$("#subForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
name: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '用户名不能为空'
|
||
}
|
||
}
|
||
},
|
||
// processid: {
|
||
// validators: {
|
||
// notEmpty: {
|
||
// message: '请选择工艺段'
|
||
// }
|
||
// }
|
||
// },
|
||
status: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '请选择状态'
|
||
}
|
||
}
|
||
},
|
||
}
|
||
});
|
||
|
||
var getProcessList = function() {
|
||
$.post(ext.contextPath + "/user/processSection/getSelectList.do", {}, function (data) {
|
||
$("#processsectionCode").empty();
|
||
var selelct_ = $("#processsectionCode").select2({
|
||
data: data,
|
||
placeholder: '请选择',//默认文字提示
|
||
allowClear: false,//允许清空
|
||
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;
|
||
} // 函数用于呈现当前的选择
|
||
});
|
||
selelct_.val('${channelPortConfig.processid}').trigger("change");
|
||
selelct_.on('change', function (e) {
|
||
$('#processid').val(e.target.value);
|
||
})
|
||
}, 'json');
|
||
|
||
};
|
||
|
||
//获取巡检区域
|
||
var selectAreaFun = function () {
|
||
$.post(ext.contextPath + '/timeEfficiency/patrolPoint/selectAreaLayer.do', {
|
||
|
||
}, function (data) {
|
||
$("#areaSubDiv").html(data);
|
||
openModal('areaSubModal');
|
||
});
|
||
};
|
||
|
||
$(function(){
|
||
$("#unitid").val(unitId)
|
||
getFileList();
|
||
getProcessList();
|
||
});
|
||
|
||
</script>
|
||
<div class="modal fade" id="subModal">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">编辑出入口配置</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<!-- 新增界面formid强制为subForm -->
|
||
<form class="form-horizontal" id="subForm">
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<input type="hidden" id="unitid" name="unitid">
|
||
<input type="hidden" id="id" name="id" value="${channelPortConfig.id}">
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">名称</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" id="name" name="name" class="form-control pull-right" value="${channelPortConfig.name}">
|
||
</div>
|
||
<label class="col-sm-2 control-label">类型</label>
|
||
<div class="col-sm-4">
|
||
<select type="text" id="type" class="form-control pull-right" name="type" >
|
||
<option value="1" <c:if test="${channelPortConfig.type=='1'}">selected</c:if>>安全出入口</option>
|
||
<option value="2" <c:if test="${channelPortConfig.type=='2'}">selected</c:if>>出入口</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">启用状态</label>
|
||
<div class="col-sm-4">
|
||
<select type="text" id="status" class="form-control pull-right" name="status" >
|
||
<option value="1" <c:if test="${channelPortConfig.status=='1'}">selected</c:if>>启用</option>
|
||
<option value="0" <c:if test="${channelPortConfig.status=='0'}">selected</c:if>>禁用</option>
|
||
</select>
|
||
</div>
|
||
<label class="col-sm-2 control-label">排序</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" id="sort" name="sort" class="form-control pull-right" oninput="value=value.replace(/[^\d]/g,'')" value="${channelPortConfig.sort}">
|
||
</div>
|
||
</div>
|
||
<%-- <div class="form-group">--%>
|
||
<%-- <label class="col-sm-2 control-label">工艺段</label>--%>
|
||
<%-- <div class="col-sm-10">--%>
|
||
<%-- <select class="form-control select2" id="processsectionCode" name="processsectionCode"></select>--%>
|
||
<%-- <input type="hidden" class="form-control" id="processid" name="processid" value="${channelPortConfig.processid}"/>--%>
|
||
<%-- </div>--%>
|
||
<%-- </div>--%>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">所在地址</label>
|
||
<div class="col-sm-10">
|
||
<input type="text" class="form-control" id="areaName" name="areaName" value="${channelPortConfig.area.name}"
|
||
onclick="selectAreaFun()" placeholder="点击选择">
|
||
<input type="hidden" class="form-control" id="address" name="address" value="${channelPortConfig.area.id}">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">出入口描述</label>
|
||
<div class="col-sm-10">
|
||
<textarea maxlength="200" class="form-control " id="describe" name="describe" rows="2" placeholder="出入口描述">${channelPortConfig.describe}</textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">图片坐标</label>
|
||
<div class="col-sm-10">
|
||
<input type="text" id="channelPortConfigPic" name="remarks" class="form-control pull-right" value="${channelPortConfig.remarks}" onclick="channelPortConfigPicDiv()">
|
||
<%--<textarea maxlength="200" class="form-control " id="remarks" name="remarks" rows="2" placeholder="备注">${channelPortConfig.remarks}</textarea>--%>
|
||
</div>
|
||
</div>
|
||
<div class="form-group" >
|
||
<label class="col-sm-2 control-label">上传图片</label>
|
||
<div class="col-sm-10">
|
||
<input type="file" name="filelist" id="filelist" multiple class="file-loading" />
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="dosave()" id="btn_save">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|