Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/process/dataVisualSvgEdit.jsp
2026-01-16 14:13:44 +08:00

462 lines
22 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page language="java" pageEncoding="UTF-8" %>
<%@page import="com.sipai.entity.process.DataVisualContent" %>
<%request.setAttribute("Type_Svg", DataVisualContent.Type_Svg); %>
<link rel="stylesheet"
href="<%=request.getContextPath()%>/node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css"/>
<script type="text/javascript"
src="<%=request.getContextPath()%>/node_modules/bootstrap-switch/dist/js/bootstrap-switch.min.js"
charset="utf-8"></script>
<style type="text/css">
</style>
<script type="text/javascript">
$(function () {
$('#fillContainer').colorpicker({format: null});
$('#strokeContainer').colorpicker({format: null});
$('#switchBtnIsFixed').bootstrapSwitch({
onText: '是',
offText: '否',
size: "small",
});
if ('${dataVisualContent.isfixed}' == 'false') {
$('#switchBtnIsFixed').bootstrapSwitch('state', false, true);
} else if ('${dataVisualContent.isfixed}' == 'true') {
$('#switchBtnIsFixed').bootstrapSwitch('state', true, true);
} else {
$('#switchBtnIsFixed').bootstrapSwitch('state', false, true);
}
$('#switchBtnDashedlinetype').bootstrapSwitch({
onText: '是',
offText: '否',
size: "small",
});
if ('${dataVisualSvg.dashedlinetype}' == 'false') {
$('#dashedlineDiv').css('display', 'none');
$('#switchBtnDashedlinetype').bootstrapSwitch('state', false, true);
} else if ('${dataVisualSvg.dashedlinetype}' == 'true') {
$('#dashedlineDiv').css('display', 'block');
$('#switchBtnDashedlinetype').bootstrapSwitch('state', true, true);
} else {
$('#dashedlineDiv').css('display', 'none');
$('#switchBtnDashedlinetype').bootstrapSwitch('state', false, true);
}
$('#switchBtnDashedlinetype').on('switchChange.bootstrapSwitch', function (event, state) {
if (state) {
$('#dashedlineDiv').css('display', 'block');
} else {
$('#dashedlineDiv').css('display', 'none');
}
});
var typeSelectData = JSON.parse("[{\"id\":\"polyline\",\"text\":\"多段线\"},{\"id\":\"polygon\",\"text\":\"多边形\"}]");
var typeSelect = $("#type").select2({
data: typeSelectData,
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;
} // 函数用于呈现当前的选择
});
typeSelect.val('${dataVisualSvg.type}').trigger("change");//设置选中
initDFun();
});
function dosave() {
$("#subForm1").bootstrapValidator('validate');//提交验证
if ($("#subForm1").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
let form = $("#subForm1").serialize();
const isFixedStatus = $('#switchBtnIsFixed').bootstrapSwitch('state');
if (isFixedStatus) {
form = form + "&isfixed=true";
} else {
form = form + "&isfixed=false";
}
$.post(ext.contextPath + "/process/dataVisualContent/doupdate.do", form, function (data) {
if (data.code == 1) {
$("#subForm2").bootstrapValidator('validate');//提交验证
if ($("#subForm2").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
let form2 = $("#subForm2").serialize();
const dashedlinetypeStatus = $('#switchBtnDashedlinetype').bootstrapSwitch('state');
if (dashedlinetypeStatus) {
form2 = form2 + "&dashedlinetype=true";
} else {
form2 = form2 + "&dashedlinetype=false";
}
$.post(ext.contextPath + "/process/dataVisualSvg/doupdate.do", form2, function (data) {
if (data.code == 1) {
closeModal('subModal');
if ('${dataVisualContent.istab}' == 'true') {
showOneContent('${dataVisualContent.id}', 'tab');
} else {
showOneContent('${dataVisualContent.id}');
}
} else if (data.code == 0) {
showAlert('d', '保存失败');
} else {
showAlert('d', data.res);
}
}, 'json');
}
} else if (data.code == 0) {
showAlert('d', '保存失败');
} else {
showAlert('d', data.res);
}
}, 'json');
}
}
function doSvgdel() {
swal({
text: "您确定要删除此记录?",
dangerMode: true,
buttons: {
cancel: {
text: "取消",
value: null,
visible: true,
className: "btn btn-default btn-sm",
closeModal: true,
},
confirm: {
text: "确定",
value: true,
visible: true,
className: "btn btn-danger btn-sm",
closeModal: true
}
}
})
.then(function (willDelete) {
if (willDelete) {
$.post(ext.contextPath + '/process/dataVisualContent/dodelete.do', {
id: '${dataVisualContent.id}',
did: '${dataVisualSvg.id}',
type: '${Type_Svg}'
}, function (data) {
var datajson = JSON.parse(data);
if (datajson.code == 1) {
closeModal('subModal');
$('#${dataVisualContent.id}').remove();
<%--showContent('${param.frameId}');--%>
} else {
showAlert('d', '删除失败', 'mainAlertdiv');
}
});
}
});
}
function initDFun() {
$("#svgAlarmTable").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/process/dataVisualSvgAlarm/getList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
pageSize: 50, // 页面数据条数
pageNumber: 1, // 首页页码
paginationDetailHAlign: ' hidden',//去除分页的显示
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
pid: '${dataVisualSvg.id}'
}
},
// onClickRow: function (row) {//单击行事件,执行查看功能
// viewFun(row.id);
// },
sortName: 'morder', // 要排序的字段
sortOrder: 'asc', // 排序规则
columns: [
{
field: 'jsmethod', // 返回json数据中的name
title: '比较方式', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle'
}, {
field: 'jsvalue', // 返回json数据中的name
title: '比较值', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle'
}, {
title: "操作",
align: 'center',
valign: 'middle',
width: 120, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts = "";
buts += '<button class="btn btn-default btn-sm" type="button" title="编辑" onclick="editSvgAlarmFun(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
buts += '<button class="btn btn-default btn-sm" type="button" title="删除" onclick="deleteSvgAlarmFun(\'' + row.id + '\')"><i class="fa fa fa-trash-o"></i><span class="hidden-md hidden-lg">删除</span></button';
buts = '<div class="btn-group" >' + buts + '</div>';
return buts;
}
}
],
onLoadSuccess: function () { //加载成功时执行
adjustBootstrapTableView("svgAlarmTable");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
},
onReorderRow: function (newData) {
//这里的newData是整个表格数据数组形式
// console.log("data",newData); //调试用代码
$.post(ext.contextPath + '/process/dataVisualSvgAlarm/dosort.do', {jsondata: JSON.stringify(newData)},//将整张表数据 不能分页
function (data) {
if (data == 1) {
//$("#table").bootstrapTable('refresh');
} else {
showAlert('d', '数据错误', 'mainAlertdiv');
}
});
}
});
$("#svgAlarmTable").tableDnD();
}
function addSvgAlarm() {
$.post(ext.contextPath + "/process/dataVisualSvgAlarm/dosave.do", {pid: '${dataVisualSvg.id}'}, function (data) {
if (data.code == 1) {
$("#svgAlarmTable").bootstrapTable('refresh');
} else if (data.code == 0) {
showAlert('d', '保存失败');
} else {
showAlert('d', data.res);
}
}, 'json');
}
function deleteSvgAlarmFun(id) {
stopBubbleDefaultEvent();
swal({
text: "您确定要删除此记录?",
dangerMode: true,
buttons: {
cancel: {
text: "取消",
value: null,
visible: true,
className: "btn btn-default btn-sm",
closeModal: true,
},
confirm: {
text: "确定",
value: true,
visible: true,
className: "btn btn-danger btn-sm",
closeModal: true
}
}
})
.then(function (willDelete) {
if (willDelete) {
$.post(ext.contextPath + '/process/dataVisualSvgAlarm/dodelete.do', {id: id}, function (data) {
if (data.code == "1") {
$("#svgAlarmTable").bootstrapTable('refresh');
} else {
showAlert('d', '删除失败', 'mainAlertdiv');
}
}, 'json');
}
});
}
function editSvgAlarmFun(id) {
stopBubbleDefaultEvent();
$.post(ext.contextPath + '/process/dataVisualSvgAlarm/doedit.do', {id: id}, function (data) {
$("#contentDDiv").html(data);
openModal('svgAlarmSubModal');
});
}
function addHQSvgAlarm() {
$.post(ext.contextPath + "/process/dataVisualSvgAlarm/doHQSvgAlarmSave.do", {pid: '${dataVisualSvg.id}'}, function (data) {
if (data.code >= 1) {
$("#svgAlarmTable").bootstrapTable('refresh');
} else if (data.code == 0) {
showAlert('d', '保存失败');
} else {
showAlert('d', data.res);
}
}, 'json');
}
</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">&times;</span></button>
<h4 class="modal-title">编辑</h4>
</div>
<div class="modal-body">
<div id="alertDiv"></div>
<!-- 新增界面formid强制为subForm -->
<form class="form-horizontal" id="subForm1" autocomplete="off">
<input type="hidden" name="id" id="id" value="${dataVisualContent.id}"/>
<div class="form-group">
<label class="col-sm-2 control-label">左侧距离</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="postx" name="postx" placeholder="左侧距离"
value="${dataVisualContent.postx}">
</div>
<label class="col-sm-2 control-label">上侧距离</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="posty" name="posty" placeholder="上侧距离"
value="${dataVisualContent.posty}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">宽度</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="width" name="width" placeholder="宽度"
value="${dataVisualContent.width}">
</div>
<label class="col-sm-2 control-label">高度</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="height" name="height" placeholder="高度"
value="${dataVisualContent.height}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">固定组件</label>
<div class="col-sm-4">
<div class="switch" data-on="primary" data-off="info">
<input id="switchBtnIsFixed" type="checkbox"/>
</div>
</div>
<label class="col-sm-2 control-label">图层</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="zIndex" name="zIndex" placeholder="图层"
value="${dataVisualContent.zIndex}">
</div>
</div>
</form>
<form class="form-horizontal" id="subForm2" autocomplete="off">
<!-- 界面提醒div强制id为alertDiv -->
<input type="hidden" name="id" id="id" value="${dataVisualSvg.id}"/>
<div class="form-group">
<label class="col-sm-2 control-label">类型</label>
<div class="col-sm-4">
<select class="form-control select2 " id="type" name="type"
style="width: 170px;"></select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">边框</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="strokeWidth" name="strokeWidth" placeholder="边框"
value="${dataVisualSvg.strokeWidth}">
</div>
<label class="col-sm-2 control-label">边框色</label>
<div class="col-sm-4">
<div class="input-group" id="strokeContainer">
<input name="stroke" id="stroke" type="text" class="form-control" placeholder="边框色"
value="${dataVisualSvg.stroke}">
<div class="input-group-addon">
<i></i>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">填充色</label>
<div class="col-sm-4">
<div class="input-group" id="fillContainer">
<input name="fill" id="fill" type="text" class="form-control" placeholder="填充色"
value="${dataVisualSvg.fill}">
<div class="input-group-addon">
<i></i>
</div>
</div>
</div>
<label class="col-sm-2 control-label">是否虚线</label>
<div class="col-sm-4">
<div class="switch" data-on="primary" data-off="info">
<input id="switchBtnDashedlinetype" type="checkbox"/>
</div>
</div>
</div>
<div id="dashedlineDiv" style="display: none;" class="form-group">
<label class="col-sm-2 control-label">实线长度</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="dashedline1" name="dashedline1"
placeholder="实线长度"
value="${dataVisualSvg.dashedline1}">
</div>
<label class="col-sm-2 control-label">虚线长度</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="dashedline2" name="dashedline2"
placeholder="虚线长度"
value="${dataVisualSvg.dashedline2}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">mq主题</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="mqTheme" name="mqTheme" placeholder="mq主题名称"
value="${dataVisualSvg.mqTheme}">
</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="points" name="points" placeholder="点"
value="${dataVisualSvg.points}">
</div>
</div>
</form>
</div>
<div class="modal-body">
<div class="btn-group" style="width: 100px;padding-bottom:10px;">
<button type="button" class="btn btn-default" onclick="addSvgAlarm();"><i
class="fa fa-plus"></i> 添加数据
</button>
</div>
<%-- <div class="btn-group" style="width: 120px;padding-bottom:10px;">--%>
<%-- <button type="button" class="btn btn-default" onclick="addHQSvgAlarm();"><i--%>
<%-- class="fa fa-plus"></i> 初始数据_虹桥--%>
<%-- </button>--%>
<%-- </div>--%>
<table id="svgAlarmTable" data-use-row-attr-func="true" data-reorderable-rows="true"></table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
<button type="button" class="btn" onclick="doSvgdel();">删除</button>
<button type="button" class="btn btn-primary" onclick="dosave()" id="btn_save">保存</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>