442 lines
20 KiB
Plaintext
442 lines
20 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 doupdate() {
|
|||
|
|
$("#subForm").bootstrapValidator('validate');//提交验证
|
|||
|
|
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
|||
|
|
$.post(ext.contextPath + "/sparepart/goods/update.do", $("#subForm").serialize(), function(data) {
|
|||
|
|
if (data.res == 1){
|
|||
|
|
document.getElementById("subModal").setAttribute("class", "modal hidden fade");
|
|||
|
|
$(".modal-backdrop").remove();
|
|||
|
|
$("#table").bootstrapTable('refresh');
|
|||
|
|
}else if(data.res == 0){
|
|||
|
|
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: {
|
|||
|
|
number: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '物品编号不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
name: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '物品名称不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
model: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '物品规格型号不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
unit: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '物品单位不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
pname: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '物品类别不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
/* maxReserve: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '最大存储量不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
minReserve: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '最小存储量不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}, */
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
//选择物品类别
|
|||
|
|
var showGoodsClass4SelectFun = function() {
|
|||
|
|
var goodsClassId = $("#pid").val();
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goodsClass/showList4Select.do', {formId:"subForm",hiddenId:"pid",textId:"pname",goodsClassId:goodsClassId} , 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);
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var addReserveFun= function() {
|
|||
|
|
var id=$('#id').val();
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goodsReserve/add.do' ,{pid: "${goods.id}", bizId: unitId}, function(data) {
|
|||
|
|
$("#subReserveDiv").html(data);
|
|||
|
|
openModal('subReserveModal');
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var editReserveFun = function(id) {
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goodsReserve/edit.do', {id:id} , function(data) {
|
|||
|
|
$("#subReserveDiv").html(data);
|
|||
|
|
openModal('subReserveModal');
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
var deletesReserveFun = function() {
|
|||
|
|
var checkedItems = $("#table_Reserve").bootstrapTable('getSelections');
|
|||
|
|
var datas="";
|
|||
|
|
$.each(checkedItems, function(index, item){
|
|||
|
|
datas+=item.id+",";
|
|||
|
|
});
|
|||
|
|
if(datas==""){
|
|||
|
|
showAlert('d','请先选择记录','mainAlertDetaildiv');
|
|||
|
|
}else{
|
|||
|
|
if(confirm("信息删除后不能恢复,请问要执行删除操作吗?")){
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goodsReserve/deletes.do', {ids:datas} , function(data) {
|
|||
|
|
if(data>0){
|
|||
|
|
$("#table_Reserve").bootstrapTable('refresh');
|
|||
|
|
}else{
|
|||
|
|
showAlert('d','删除失败','mainAlertDetaildiv');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
var deleteReserveFun = function(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(willDelete =>{
|
|||
|
|
if (willDelete) {
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goodsReserve/delete.do', {id : id}, function(data) {
|
|||
|
|
if(data==1){
|
|||
|
|
$("#table_Reserve").bootstrapTable('refresh');
|
|||
|
|
}else{
|
|||
|
|
showAlert('d','删除失败','mainAlertdiv');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
$(function () {
|
|||
|
|
$("#table_Reserve").bootstrapTable({ // 对应table标签的id
|
|||
|
|
url: ext.contextPath + '/sparepart/goodsReserve/getList.do', // 获取表格数据的url
|
|||
|
|
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
|||
|
|
striped: true, //表格显示条纹,默认为false
|
|||
|
|
pagination: true, // 在表格底部显示分页组件,默认false
|
|||
|
|
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
|
|||
|
|
pageSize: 5, // 页面数据条数
|
|||
|
|
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,
|
|||
|
|
bizId: unitId,
|
|||
|
|
search_code: "${goods.id}"
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onClickRow: function (row) {//单击行事件,执行查看功能
|
|||
|
|
//viewFun(row.id);
|
|||
|
|
},
|
|||
|
|
columns: [
|
|||
|
|
{
|
|||
|
|
checkbox: true, // 显示一个勾选框
|
|||
|
|
}, {
|
|||
|
|
field: 'max', // 返回json数据中的name
|
|||
|
|
title: '物品最大量', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
width: '20%'
|
|||
|
|
}, {
|
|||
|
|
field: 'maxStatus', // 返回json数据中的name
|
|||
|
|
title: '启用状态', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
width: '10%',
|
|||
|
|
formatter: function (value) {
|
|||
|
|
if (value == 0) {
|
|||
|
|
return "禁用";
|
|||
|
|
} else if (value == 1) {
|
|||
|
|
return "启用";
|
|||
|
|
} else {
|
|||
|
|
return "未知";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}, {
|
|||
|
|
field: 'min', // 返回json数据中的name
|
|||
|
|
title: '物品最小量', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
width: '20%'
|
|||
|
|
}, {
|
|||
|
|
field: 'minStatus', // 返回json数据中的name
|
|||
|
|
title: '启用状态', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
width: '10%',
|
|||
|
|
formatter: function (value) {
|
|||
|
|
if (value == 0) {
|
|||
|
|
return "禁用";
|
|||
|
|
} else if (value == 1) {
|
|||
|
|
return "启用";
|
|||
|
|
} else {
|
|||
|
|
return "未知";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}, {
|
|||
|
|
field: 'company.name', // 返回json数据中的name
|
|||
|
|
title: '所属厂', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
width: '20%'
|
|||
|
|
}, {
|
|||
|
|
title: "操作",
|
|||
|
|
align: 'center',
|
|||
|
|
valign: 'middle',
|
|||
|
|
width: '20%', // 定义列的宽度,单位为像素px
|
|||
|
|
formatter: function (value, row, index) {
|
|||
|
|
var buts = '';
|
|||
|
|
buts += '<button class="btn btn-default btn-sm" title="编辑" onclick="editReserveFun(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
|
|||
|
|
buts += '<button class="btn btn-default btn-sm" title="删除" onclick="deleteReserveFun(\'' + 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("table_Detail");
|
|||
|
|
},
|
|||
|
|
onLoadError: function () { //加载失败时执行
|
|||
|
|
console.info("加载数据失败");
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
//点击空白隐藏树
|
|||
|
|
$(document).click(function (e) {
|
|||
|
|
var tbody = $('#tbody'); // 设置目标区域
|
|||
|
|
if (!tbody.is(e.target) && tbody.has(e.target).length === 0) {
|
|||
|
|
tbody.hide()
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
function Google() {
|
|||
|
|
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()
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
function removeTbody() {
|
|||
|
|
$("#tbody").find("td").remove();
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
<div class="modal fade" id="subModal">
|
|||
|
|
<div class="modal-dialog modal-xlg">
|
|||
|
|
<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="${goods.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="请选择" onclick="showGoodsClass4SelectFun();" value="${goods.goodsClass.name}" readonly>
|
|||
|
|
<input id="pid" name="classId" type="hidden" value="${goods.classId}"/>
|
|||
|
|
</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="${goods.number}" readonly>
|
|||
|
|
</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="名称" value="${goods.name}"onchange="generationNumber()">
|
|||
|
|
<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="${goods.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="${goods.model}">
|
|||
|
|
</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="单位" value="${goods.unit}">
|
|||
|
|
</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.0" value="${goods.maxReserve}">--%>
|
|||
|
|
<%-- </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.0" value="${goods.minReserve}">--%>
|
|||
|
|
<%-- </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="${goods.equipmentIds}" />
|
|||
|
|
<input class="form-control" id="equipname" name ="equipname" value="${goods.equipmentNames}" 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="备注...">${goods.remark}</textarea>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</form>
|
|||
|
|
<div class="box box-primary" >
|
|||
|
|
<div id="mainAlertDetaildiv"></div>
|
|||
|
|
<div class="box-header with-border">
|
|||
|
|
<h3 class="box-title">物资报警</h3>
|
|||
|
|
<div class="box-tools pull-right">
|
|||
|
|
<a onclick="addReserveFun()" class="btn btn-box-tool" data-toggle="tooltip" title="新增"><i class="glyphicon glyphicon-plus"></i></a>
|
|||
|
|
<a onclick="deletesReserveFun()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i class="glyphicon glyphicon-minus"></i></a>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="box-body ">
|
|||
|
|
<table id="table_Reserve" data-use-row-attr-func="true" data-reorderable-rows="true"></table>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="modal-footer">
|
|||
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
|||
|
|
<button type="button" class="btn btn-primary" onclick="doupdate()" id="btn_update">保存</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-content -->
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-dialog -->
|
|||
|
|
</div>
|