285 lines
13 KiB
Plaintext
285 lines
13 KiB
Plaintext
<%@ 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">
|
||
function dosave() {
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/sparepart/goods/save.do", $("#subForm").serialize(), function(data) {
|
||
if (data.res == 1){
|
||
document.getElementById("subModal").setAttribute("class", "modal hidden fade");
|
||
$(".modal-backdrop").remove();
|
||
stopBubbleDefaultEvent();
|
||
$.post(ext.contextPath + '/sparepart/goods/edit.do', {id:data.id} , function(data) {
|
||
$("#goodsEditDiv").html(data);
|
||
openModal('subModal');
|
||
});
|
||
if ('${subscribeDetailIds}' != null) {
|
||
// 更新数据接口
|
||
$.post(ext.contextPath + '/sparepart/subscribe/doDetailUpdate.do', {subscribeDetailIds: '${subscribeDetailIds}', goodsId: data.id} , function(data) {
|
||
$("#table").bootstrapTable('refresh');
|
||
});
|
||
}
|
||
$("#table").bootstrapTable('refresh');
|
||
}else if(data.res == 0){
|
||
showAlert('d','保存失败');
|
||
}else if(data.res == 2){
|
||
showAlert('d','编号重复');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
}
|
||
},'json');
|
||
}
|
||
}
|
||
//选择设备,可多选
|
||
var showEquipment4SelectsFun = function(formId,hiddenId,textId) {
|
||
var equipmentIds = $('#equipmentIds').val();
|
||
$.post(ext.contextPath + '/sparepart/goods/showEquipmentCardForGoodsSelects.do', {formId:formId,hiddenId:hiddenId,textId:textId,equipmentIds:equipmentIds} , function(data) {
|
||
$("#equ4SelectDiv").html(data);
|
||
openModal("equipment4SelectModal");
|
||
});
|
||
};
|
||
//输入框验证
|
||
$("#subForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
name: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '物品名称不能为空'
|
||
}
|
||
}
|
||
},
|
||
model: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '物品规格型号不能为空'
|
||
}
|
||
}
|
||
},
|
||
unit: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '物品单位不能为空'
|
||
}
|
||
}
|
||
},
|
||
pname: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '物品类别不能为空'
|
||
}
|
||
}
|
||
},
|
||
number: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '物品编号不能为空'
|
||
}
|
||
}
|
||
},
|
||
/* maxReserve: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '最大存储量不能为空'
|
||
},
|
||
greaterThan:{
|
||
message: '请输入大于1的数字'
|
||
}
|
||
}
|
||
},
|
||
minReserve: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '最小存储量不能为空'
|
||
},
|
||
greaterThan:{
|
||
message: '请输入大于0的数字'
|
||
}
|
||
}
|
||
}, */
|
||
}
|
||
});
|
||
//选择物品类别
|
||
var showGoodsClass4SelectFun = function() {
|
||
$.post(ext.contextPath + '/sparepart/goodsClass/showList4Select.do', {formId:"subForm",hiddenId:"pid",textId:"pname"} , function(data) {
|
||
$("#fault4SelectDiv").html(data);
|
||
openModal('fault4SelectModal');
|
||
});
|
||
};
|
||
//生成编号
|
||
var generationNumber = function() {
|
||
var goodsClassId = $("#pid").val();
|
||
var goodsName = $("#name").val();
|
||
$.post(ext.contextPath + '/sparepart/goods/generationNumber.do', {goodsClassId:goodsClassId,goodsName:goodsName} , function(data) {
|
||
$("#number").val(data);
|
||
});
|
||
};
|
||
$(function() {
|
||
var goodsClassId = $("#pid").val();
|
||
if(goodsClassId!="" && goodsClassId!=null && goodsClassId!=undefined){
|
||
generationNumber();
|
||
}
|
||
})
|
||
//点击空白隐藏树
|
||
$(document).click(function (e) {
|
||
var tbody = $('#tbody'); // 设置目标区域
|
||
if (!tbody.is(e.target) && tbody.has(e.target).length === 0) {
|
||
tbody.hide()
|
||
}
|
||
})
|
||
function Google() {
|
||
setTimeout(() => {
|
||
if ($("#name").val() == "") {
|
||
$("#tbody").hide()
|
||
} else {
|
||
$("#tbody").show()
|
||
//获取到文本框内容
|
||
let obj = document.getElementById("name");
|
||
let tbody = document.getElementById("tbody");
|
||
let name = obj.value; //获得i1中的值
|
||
$.post(ext.contextPath + '/sparepart/goods/getDataList.do', {name: name}, function (data) {
|
||
var dataStr = eval("(" + data + ")");
|
||
if (dataStr.rows.length == 0) {
|
||
$("#tbody").hide()
|
||
} else {
|
||
$("#tbody").show()
|
||
}
|
||
//删除掉原有表格的数据
|
||
removeTbody();
|
||
for (var i = 1; i < dataStr.rows.length; i++) {
|
||
let tr = document.createElement("tr");
|
||
let td = document.createElement("td");
|
||
td.innerText = dataStr.rows[i].name + "( " + dataStr.rows[i].model + " )";
|
||
td.setAttribute("data-v", dataStr.rows[i].name);
|
||
tr.appendChild(td); //将td放入tr中;
|
||
tbody.appendChild(tr); //将tr放入div中
|
||
//手动添加事件(鼠标移入字体和背景变色)
|
||
tr.onmouseover = function () {
|
||
// this.style.color = "blue";
|
||
this.style.backgroundColor = "lightgray";
|
||
}
|
||
tr.onmouseout = function () {
|
||
this.style.color = "";
|
||
this.style.backgroundColor = "";
|
||
}
|
||
td.onclick = function () {
|
||
$("#name").val(this.getAttribute("data-v"))
|
||
$("#tbody").hide()
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}, 130)
|
||
}
|
||
function removeTbody() {
|
||
$("#tbody").find("td").remove();
|
||
}
|
||
</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">
|
||
<input type="hidden" class="form-control" id="id" name ="id" value="${id}">
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></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="pname" placeholder="请选择" autocomplete="off"
|
||
onclick="showGoodsClass4SelectFun();" value="${goodsClass.name}" readonly>
|
||
<input id="pid" name="classId" type="hidden" value="${goodsClass.id}"/>
|
||
</div>
|
||
<label class="col-sm-2 control-label">*物品编号</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="number" name ="number" placeholder="编号" autocomplete="off" value="">
|
||
</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" onkeyup="Google()" id="name" name ="name" placeholder="名称" autocomplete="off" onchange="generationNumber()" value="${subscribeDetail.detailGoodsName}">
|
||
<table style="display: block;">
|
||
<tbody id="tbody" style="
|
||
/* border: 1px gray solid; */
|
||
/* width: 204px; */
|
||
border: 1px solid #D6D6D6;
|
||
display: none;
|
||
/* margin-top: 5px; */
|
||
width: 270px;
|
||
height: 200px;
|
||
overflow-x: hidden;
|
||
overflow-y: auto;
|
||
position: absolute;
|
||
z-index: 1;
|
||
background: white;
|
||
padding: 6px 12px 6px;"
|
||
></tbody>
|
||
</table>
|
||
</div>
|
||
<label class="col-sm-2 control-label">物品品牌</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="brand" name ="brand" placeholder="品牌" value="${subscribeDetail.brand}">
|
||
</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="model" name ="model" placeholder="型号" value="${subscribeDetail.detailGoodsModel}">
|
||
</div>
|
||
<label class="col-sm-2 control-label">*物品单位</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="unit" name ="unit" placeholder="单位">
|
||
</div>
|
||
</div>
|
||
<%-- <div class="form-group">--%>
|
||
<%-- <label class="col-sm-2 control-label">最大存储量</label>--%>
|
||
<%-- <div class="col-sm-6">--%>
|
||
<%-- <input type="number" class="form-control" id="maxReserve" name ="maxReserve" placeholder="最大存储量" step="0.1" min="1" value=0>--%>
|
||
<%-- </div>--%>
|
||
<%-- </div>--%>
|
||
<%-- <div class="form-group">--%>
|
||
<%-- <label class="col-sm-2 control-label">最小存储量</label>--%>
|
||
<%-- <div class="col-sm-6">--%>
|
||
<%-- <input type="number" class="form-control" id="minReserve" name ="minReserve" placeholder="最小存储量" step="0.1" min="0" value=0>--%>
|
||
<%-- </div>--%>
|
||
<%-- </div>--%>
|
||
<!-- <div class="form-group">
|
||
<label class="col-sm-2 control-label">所属设备</label>
|
||
<div class="col-sm-10">
|
||
<input id="equipmentIds" name="equipmentIds" type="hidden" value="" />
|
||
<input class="form-control" id="equipname" name ="equipname" onclick="showEquipment4SelectsFun('subForm','equipmentIds','equipname');" placeholder="请点击选择" readonly>
|
||
</div>
|
||
</div> -->
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">备注</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" rows="2" id ="remark" name ="remark" placeholder="备注..."></textarea>
|
||
</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>
|