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

192 lines
7.6 KiB
Plaintext
Raw Permalink 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" %>
<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(/'&nbsp;'/g, '')
str = str.replace(/''/g, ':')
return str
}
editor.txt.html('${processSectionInformation.content}') // 重新设置编辑器内容
editor.config.uploadImgHooks = {
customInsert: function (insertImgFn, result) {
// result 即服务端返回的接口
//console.log('customInsert', result)
// insertImgFn 可把图片插入到编辑器,传入图片 src ,执行函数即可
insertImgFn(result.data[0])
}
}
getProcessSection();
$("#subForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
processSectionId: {
validators: {
notEmpty: {
message: '工艺段不能为空'
}
}
},
content: {
validators: {
notEmpty: {
message: '介绍内容不能为空'
}
}
},
}
});
});
function dosave() {
var editorText = editor.txt.html();
$("#content").val(editorText);
$("#subForm").bootstrapValidator('validate');//提交验证
if ($("#subForm").data('bootstrapValidator').isValid()) {
//获取验证结果,如果成功,执行下面代码
$.post(ext.contextPath + "/process/processSectionInformation/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');
}
}
//工艺段 - (方法在用) sj 2021-07-28
function getProcessSection() {
var selectType = $("#processsectionCode").select2({minimumResultsForSearch: 10})
$.post(ext.contextPath + "/user/processSection/getList4EquipmentCard.do", {unitId: '${param.unitId}'}, 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,//数据超过10个启用搜索框
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
selelct_.val('${processSectionInformation.processSectionId}').trigger("change");
selelct_.on('change', function (e) {
$('#processSectionId').val(e.target.value);
})
}, '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">&times;</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="${id}" />
<input type="hidden" name="bizid" id="bizid" 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="processsectionCode"
name="processsectionCode" style="width: 100%;"></select>
<input type="hidden" class="form-control" id="processSectionId"
name="processSectionId"
value="${processSectionInformation.processSectionId}"/>
</div>
<label class="col-sm-2 control-label">*启用状态</label>
<div class="col-sm-4">
<select class="form-control select2" id="state"
name="state">
<option value="1">是</option>
<option value="0" selected="selected">否</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="${processSectionInformation.morder}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*介绍信息</label>
<div class="col-sm-10 hidden">
<textarea class="form-control" rows="5" id ="content" name ="content" placeholder="介绍信息">${processSectionInformation.content}</textarea>
</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>