Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/structure/structureCardPictureEdit.jsp

279 lines
13 KiB
Plaintext
Raw Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" pageEncoding="UTF-8" %>
<style type="text/css">
.select2-container .select2-selection--single {
height: 34px;
line-height: 34px;
}
.select2-selection__arrow {
margin-top: 3px;
}
</style>
<script type="text/javascript">
var masterId = $('#pictureId').val();
var tbName = 'TB_EM_StructureCard_picture_file'; //数据表
var nameSpace = 'StructureCardPicture';//保存文件夹
var previews = new Array();
var previewConfigs = new Array();
/* var student = {
"caption":"lilei",
}
previewConfigs[0]=student; */
//初始化fileinput控件第一次初始化
function showFileInput(ctrlName, uploadUrl, flag) {
var control = $('#' + ctrlName);
control.fileinput('destroy');
control.fileinput({
language: 'zh', //设置语言
uploadUrl: uploadUrl,
showUpload: false, //是否显示上传按钮
showRemove: false,
showCaption: false,//是否显示标题
showBrowse: flag,//选择按钮
showClose: false,//右上角关闭按钮
dropZoneEnabled: flag,//是否显示拖拽区域
fileActionSettings: {
showDrag: false
},
browseClass: "btn btn-primary", //按钮样式
maxFileCount: 1, //表示允许同时上传的最大文件个数
enctype: 'multipart/form-data',
validateInitialCount: true,
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
initialPreviewAsData: true,
initialPreview: previews,
initialPreviewConfig: previewConfigs,
autoReplace: true,
dropZoneTitle: '可拖拽文件到选区',
uploadExtraData: function (previewId, index) { //传参
//var data = $("#subForm_floor").serialize();
//console.info(data)
var data = {
"masterId": masterId, //此处自定义传参
"tbName": tbName,
"nameSpace": nameSpace
};
return data;
},
layoutTemplates: {
actionUpload: ''
},
deleteUrl: ext.contextPath + "/base/deleteInputFile.do",
deleteExtraData: function () { //传参
var data = {
"tbName": tbName
};
return data;
},
});
if (flag) {
control.css('display', 'block'); //否则选择按钮无法点击
}
//导入文件上传完成之后的事件
control.on("fileuploaded", function (event, data, previewId, index) {
console.info(data)
if (data.response.suc) {
closeModal('subModal_floor');
}
});
control.on("filedeleted", function (event, id) {
console.info('ssss');
getFileList('filelist', ext.contextPath + "/base/inputFile.do");
});
$('#kvFileinputModal').on("hidden.bs.modal", function () {
$(this).removeData("bs.modal");
//modal重复打开会导致前面的滚动条失去作用
$('.modal').css("overflow", "auto");
});
}
//名称定义不可修改
var getFileList = function (ctrlName, uploadUrl) {
$.post(ext.contextPath + '/base/getInputFileList.do', { masterId: masterId, tbName: tbName }, function (data) {
previews = new Array();
for (var i = 0; i < data.length; i++) {
var path = data[i].abspath;
path = path.substring(path.indexOf('webapps') + 7, path.length);
path = ext.basePath.replace(ext.contextPath, '') + path.replace(/\\/g, "\/");;
var previewConfig = new Object();
previews.push(path);
previewConfig['width'] = '50px';
previewConfig['caption'] = data[i].filename;
previewConfig['key'] = data[i].id;
previewConfigs.push(previewConfig);
}
var flag = true;
if (data.length >= 1) {
flag = false;
}
showFileInput(ctrlName, uploadUrl, flag);
}, 'json');
};
function doUpdateFloor() {
$("#subForm_floor").bootstrapValidator('validate');//提交验证
if ($("#subForm_floor").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
$.post(ext.contextPath + "/structure/structureCardPicture/update.do", $("#subForm_floor").serialize(), function (data) {
if (data.code == 1) {
$("#filelist").fileinput("upload");
$("#table_picture").bootstrapTable('refresh');
closeModal('subModal_floor');
} else if (data.code == 0) {
showAlert('d', '保存失败', 'alertDiv_floor');
} else {
showAlert('d', data.res, 'alertDiv_floor');
}
}, 'json');
};
}
$("#subForm_floor").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
name: {
validators: {
notEmpty: {
message: '名称不能为空'
}
}
},
floor: {
validators: {
notEmpty: {
message: '楼层不能为空'
}
}
},
morder: {
validators: {
notEmpty: {
message: '顺序不能为空'
}
}
}
}
});
function showmagic(){
var type = "${structureCardPicture.type}";
console.log(type);
if (type == "line") {
$("#safeLevelLabel").hide();
$("#safeLevelDiv").hide();
$("#safeContentDiv").hide();
} else if (type == "area") {
$("#safeLevelLabel").show();
$("#safeLevelDiv").show();
$("#safeContentDiv").show();
}
}
$(function () {
showmagic();
$("#type").select2({ minimumResultsForSearch: -1 }).val("${structureCardPicture.type}").trigger("change");
$("#safeLevel").select2({ minimumResultsForSearch: -1 }).val("${structureCardPicture.safeLevel}").trigger("change");
getFileList('filelist', ext.contextPath + "/base/inputFile.do");
$("#type").change(function () {
if (this.value == "line") {
$("#safeLevelLabel").hide();
$("#safeLevelDiv").hide();
$("#safeContentDiv").hide();
} else if (this.value == "area") {
$("#safeLevelLabel").show();
$("#safeLevelDiv").show();
$("#safeContentDiv").show();
}
});
});
</script>
<div class="modal fade" id="subModal_floor">
<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">&times;</span></button>
<h4 class="modal-title">编辑底图界面</h4>
</div>
<div class="modal-body">
<!-- 新增界面formid强制为subForm -->
<form class="form-horizontal" id="subForm_floor" enctype="multipart/form-data">
<input name="id" id="pictureId" type="hidden" value="${structureCardPicture.id}" />
<input name="structureId" type="hidden" value="${structureCardPicture.structureId}" />
<!-- 界面提醒div强制id为alertDiv -->
<div id="alertDiv_floor"></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="name" name="name" placeholder="名称"
value="${structureCardPicture.name }">
</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="floor" name="floor" placeholder="楼层"
value="${structureCardPicture.floor }">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*顺序</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="morder" name="morder" placeholder="顺序"
value="${structureCardPicture.morder }">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">类型</label>
<div class="col-sm-4">
<select id="type" name="type" class="form-control select2">
<option value="line">巡检路线</option>
<option value="area">安全区域</option>
</select>
</div>
<label id="safeLevelLabel" class="col-sm-2 control-label"
style="display: none;">安全等级</label>
<div id="safeLevelDiv" class="col-sm-4" style="display: none;">
<select id="safeLevel" name="safeLevel" class="form-control select2">
<option value="A">A级</option>
<option value="B">B级</option>
<option value="C">C级</option>
<option value="D">D级</option>
<option value="S">施工</option>
</select>
</div>
</div>
<div id="safeContentDiv" class="form-group" style="display: none;">
<label class="col-sm-2 control-label">安全备注</label>
<div class="col-sm-10">
<textarea class="form-control" rows="2" id="safeContent" name="safeContent"
placeholder="安全备注...">${structureCardPicture.safeContent}</textarea>
</div>
</div>
<div class="form-group" style="margin:8px;">
<input type="file" name="filelist" id="filelist" multiple class="file-loading" />
</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="doUpdateFloor()">保存</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>