144 lines
5.7 KiB
Plaintext
144 lines
5.7 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8" %>
|
||
|
||
<style type="text/css">
|
||
|
||
</style>
|
||
<script type="text/javascript">
|
||
const E = window.wangEditor;
|
||
const editor = new E('#editor');
|
||
$(function () {
|
||
/*
|
||
* wangEditor富文本初始化
|
||
*/
|
||
//设置高度
|
||
var div3 = document.getElementById('editor');
|
||
editor.config.height = div3.clientHeight - 120;
|
||
//取消自动 focus
|
||
editor.config.focus = false
|
||
// 配置全屏功能按钮是否展示
|
||
editor.config.showFullScreen = true
|
||
// 隐藏菜单栏提示
|
||
editor.config.showMenuTooltips = false
|
||
// 配置 onchange 回调函数
|
||
editor.config.onchange = function (newHtml) {
|
||
//console.log('change 之后最新的 html', newHtml)
|
||
}
|
||
// 配置触发 onchange 的时间频率,默认为 200ms
|
||
editor.config.onchangeTimeout = 500 // 修改为 500ms
|
||
|
||
//图片上传
|
||
editor.config.uploadFileName = 'myFile'; //设置文件上传的参数名称
|
||
editor.config.uploadImgServer = ext.contextPath + "/command/emergencyConfigure/upload4WangEditor.do";
|
||
editor.config.uploadImgAccept = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']// 图片格式限制
|
||
editor.config.uploadImgMaxSize = 10 * 1024 * 1024 // 图片大小限制10M
|
||
editor.config.uploadImgMaxLength = 1; // 一次最多上传 1 个图片
|
||
|
||
editor.create();
|
||
|
||
editor.config.pasteTextHandle = function (content) {
|
||
// content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
|
||
if (content == '' && !content) return ''
|
||
var str = content
|
||
str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
|
||
str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
|
||
str = str.replace(/<\/?[^>]*>/g, '')
|
||
str = str.replace(/[ | ]*\n/g, '\n')
|
||
str = str.replace(/' '/g, '')
|
||
str = str.replace(/':'/g, ':')
|
||
|
||
return str
|
||
}
|
||
|
||
editor.txt.html('${visitSafetyCommitment.content}') // 重新设置编辑器内容
|
||
|
||
editor.config.uploadImgHooks = {
|
||
customInsert: function (insertImgFn, result) {
|
||
// result 即服务端返回的接口
|
||
//console.log('customInsert', result)
|
||
// insertImgFn 可把图片插入到编辑器,传入图片 src ,执行函数即可
|
||
insertImgFn(result.data[0])
|
||
}
|
||
}
|
||
});
|
||
function dosave() {
|
||
var editorText = editor.txt.html();
|
||
$("#content").val(editorText);
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {
|
||
//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/visit/visitSafetyCommitment/dosave.do", $("#subForm").serialize(), function (data) {
|
||
if (data.res == 1) {
|
||
$("#table").bootstrapTable('refresh');
|
||
closeModal("subModal");
|
||
} else if (data.res == 0) {
|
||
showAlert('d', '保存失败');
|
||
} else {
|
||
showAlert('d', data.res);
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
|
||
</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">×</span></button>
|
||
<h4 class="modal-title">新增</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<!-- 新增界面formid强制为subForm -->
|
||
<form class="form-horizontal" id="subForm" autocomplete="off">
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<input type="hidden" name="id" id="id" value="${visitSafetyCommitment.id}" />
|
||
<textarea class="form-control hidden" id ="content" name ="content">${visitSafetyCommitment.content}</textarea>
|
||
<input type="hidden" name="unitId" id="unitId" value="${param.unitId}" />
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*人群类型</label>
|
||
<div class="col-sm-4">
|
||
<select class="form-control select2" id="edition"
|
||
name="edition" style="width: 100%;">
|
||
<option value="adult">成人</option>
|
||
<option value="children">青少年</option>
|
||
</select>
|
||
</div>
|
||
<label class="col-sm-2 control-label">*启用状态</label>
|
||
<div class="col-sm-4">
|
||
<select class="form-control select2" id="state"
|
||
name="state" style="width: 100%;">
|
||
<option value="1">是</option>
|
||
<option value="0">否</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">顺序</label>
|
||
<div class="col-sm-4">
|
||
<input type="number" class="form-control" id="morder" name="morder" placeholder="顺序"
|
||
value="${visitSafetyCommitment.morder}">
|
||
</div>
|
||
<label class="col-sm-2 control-label">说明</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="remark" name="remark" placeholder="说明"
|
||
value="${visitSafetyCommitment.remark}">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<div class="col-sm-12" id="editor" >
|
||
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="dosave()" id="btn_save">保存</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div> |