261 lines
9.7 KiB
Plaintext
261 lines
9.7 KiB
Plaintext
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|||
|
|
<!DOCTYPE html>
|
|||
|
|
|
|||
|
|
<script type="text/javascript">
|
|||
|
|
|
|||
|
|
var checkedItem="";
|
|||
|
|
var initTreeView = function() {
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goodsClass/getGoodsClassJson.do', function(data) {
|
|||
|
|
$('#tree').treeview({data: data});
|
|||
|
|
$('#tree').on('nodeSelected', function(event, data) {
|
|||
|
|
$('#classid').val(data.id);
|
|||
|
|
doSearchGoods();
|
|||
|
|
});
|
|||
|
|
},'json');
|
|||
|
|
};
|
|||
|
|
var doSearchGoods = function() {
|
|||
|
|
$("#table_goods").bootstrapTable('refresh');
|
|||
|
|
};
|
|||
|
|
function doSelectGoods() {
|
|||
|
|
//var checkItems = $("#table_goods").bootstrapTable('getAllSelections');
|
|||
|
|
var checkedItems = $("#table_goods").bootstrapTable('getAllSelections');
|
|||
|
|
var datas="";
|
|||
|
|
$.each(checkedItems, function(index, item){
|
|||
|
|
datas = item.id;
|
|||
|
|
});
|
|||
|
|
if (datas == "") {
|
|||
|
|
showAlert('d','请先选择记录','alertDiv');
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
if ('${subscribeDetailIds}' != null) {
|
|||
|
|
// 更新数据接口
|
|||
|
|
$.post(ext.contextPath + '/sparepart/subscribe/doDetailUpdate.do', {subscribeDetailIds: '${subscribeDetailIds}', goodsId: datas} , function(data) {
|
|||
|
|
$("#table").bootstrapTable('refresh');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
closeModal("subDetailModal");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var addGoodsFun = function() {
|
|||
|
|
// var goodsClassId = $('#classid').val();
|
|||
|
|
// $.post(ext.contextPath + '/sparepart/goods/goodsAddInSelects.do', {goodsClassId:goodsClassId} , function(data) {
|
|||
|
|
// $("#goodsAddDiv").html(data);
|
|||
|
|
// openModal('subGoodsModal');
|
|||
|
|
// });
|
|||
|
|
if ('${subscribeDetailIds}' != null) {
|
|||
|
|
$.post(ext.contextPath + '/sparepart/goods/add.do', {subscribeDetailIds: '${subscribeDetailIds}'}, function (data) {
|
|||
|
|
$("#goodsAddDiv").html(data);
|
|||
|
|
openModal('subModal');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function getCheckedIds(){
|
|||
|
|
var ids="";
|
|||
|
|
var check_array =eval('${goodsIds}');
|
|||
|
|
$.each(check_array, function(index, item){
|
|||
|
|
if(ids!=""){
|
|||
|
|
ids+=",";
|
|||
|
|
}
|
|||
|
|
ids+=item.id;
|
|||
|
|
});
|
|||
|
|
return ids;
|
|||
|
|
}
|
|||
|
|
function queryParams(params) {
|
|||
|
|
|
|||
|
|
var temp={
|
|||
|
|
rows: params.limit, // 每页要显示的数据条数
|
|||
|
|
page: params.offset/params.limit+1, // 每页显示数据的开始页码
|
|||
|
|
sort: params.sort, // 要排序的字段
|
|||
|
|
order: params.order,
|
|||
|
|
search_name: $('#search_goodsName').val(),
|
|||
|
|
className: '${param.className}',
|
|||
|
|
classid: $('#classid').val(),
|
|||
|
|
};
|
|||
|
|
/* var status =$('#switchBtn').bootstrapSwitch('state')
|
|||
|
|
if(status){
|
|||
|
|
temp.checkedIds=getCheckedIds();
|
|||
|
|
} */
|
|||
|
|
return temp;
|
|||
|
|
}
|
|||
|
|
$(function() {
|
|||
|
|
$("#search_goodsName").keyup(function(){
|
|||
|
|
if (event.keyCode == 13) {
|
|||
|
|
event.preventDefault();
|
|||
|
|
//回车查询
|
|||
|
|
doSearchGoods();
|
|||
|
|
event.stopPropagation();
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
// initialSelectionIds();
|
|||
|
|
|
|||
|
|
$table=$("#table_goods").bootstrapTable({
|
|||
|
|
url: ext.contextPath + '/sparepart/goods/getList.do', // 获取表格数据的url
|
|||
|
|
clickToSelect:true,
|
|||
|
|
singleSelect:true,
|
|||
|
|
striped: true, //表格显示条纹,默认为false
|
|||
|
|
pagination: true, // 在表格底部显示分页组件,默认false
|
|||
|
|
pageList: [10, 20], // 设置页面可以显示的数据条数
|
|||
|
|
pageSize: 10, // 页面数据条数
|
|||
|
|
pageNumber: 1, // 首页页码
|
|||
|
|
sidePagination: 'server', // 设置为服务器端分页
|
|||
|
|
queryParams:queryParams,
|
|||
|
|
sortName: 'id', // 要排序的字段
|
|||
|
|
sortOrder: 'desc', // 排序规则
|
|||
|
|
columns: [
|
|||
|
|
{
|
|||
|
|
checkbox: true, // 显示一个勾选框
|
|||
|
|
formatter: stateFormatter
|
|||
|
|
},{
|
|||
|
|
field: 'number', // 返回json数据中的name
|
|||
|
|
title: '物品编号', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle' // 上下居中
|
|||
|
|
},{
|
|||
|
|
field: 'name', // 返回json数据中的name
|
|||
|
|
title: '物品名称', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle' // 上下居中
|
|||
|
|
},{
|
|||
|
|
field: 'brand', // 返回json数据中的name
|
|||
|
|
title: '物品品牌', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle' // 上下居中
|
|||
|
|
},{
|
|||
|
|
field: 'model', // 返回json数据中的name
|
|||
|
|
title: '规格型号', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle' // 上下居中
|
|||
|
|
},{
|
|||
|
|
field: 'goodsClass.name', // 返回json数据中的name
|
|||
|
|
title: '物品类别', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
},{
|
|||
|
|
field: 'unit', // 返回json数据中的name
|
|||
|
|
title: '物品单位', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle' // 上下居中
|
|||
|
|
},{
|
|||
|
|
field: 'remark', // 返回json数据中的name
|
|||
|
|
title: '备注', // 表格表头显示文字
|
|||
|
|
align: 'center', // 左右居中
|
|||
|
|
valign: 'middle', // 上下居中
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
onLoadSuccess: function(){ //加载成功时执行
|
|||
|
|
adjustBootstrapTableView("table_goods");
|
|||
|
|
},
|
|||
|
|
onLoadError: function(){ //加载失败时执行
|
|||
|
|
console.info("加载数据失败");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//绑定选中事件、取消事件、全部选中、全部取消
|
|||
|
|
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e,rows, obj) {
|
|||
|
|
if('check'==e.type){
|
|||
|
|
$('#table_goods .checked').removeClass("checked");
|
|||
|
|
obj.parent().addClass("checked");
|
|||
|
|
checkedItem = rows;
|
|||
|
|
}else{
|
|||
|
|
obj.parent().removeClass("checked");
|
|||
|
|
checkedItem = "";
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
initTreeView();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
//显示已经勾选的数据
|
|||
|
|
function stateFormatter(value, row, index) {
|
|||
|
|
var flag=false;
|
|||
|
|
if(row.id=='${goodsIds}'){
|
|||
|
|
flag=true;
|
|||
|
|
checkedItem = row;
|
|||
|
|
}
|
|||
|
|
if (flag)
|
|||
|
|
return {
|
|||
|
|
checked : true//设置选中
|
|||
|
|
};
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//选中事件操作数组
|
|||
|
|
var union = function(array,ids){
|
|||
|
|
$.each(ids, function (i, id) {
|
|||
|
|
if($.inArray(id,array)==-1){
|
|||
|
|
array[array.length] = id;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return array;
|
|||
|
|
};
|
|||
|
|
//取消选中事件操作数组
|
|||
|
|
var difference = function(array,ids){
|
|||
|
|
$.each(ids, function (i, id) {
|
|||
|
|
var index = $.inArray(id,array);
|
|||
|
|
if(index!=-1){
|
|||
|
|
array.splice(index, 1);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return array;
|
|||
|
|
};
|
|||
|
|
var _ = {"union":union,"difference":difference};
|
|||
|
|
|
|||
|
|
//表格分页之前处理多选框数据
|
|||
|
|
function responseHandler(res) {
|
|||
|
|
$.each(res.rows, function (i, row) {
|
|||
|
|
row.checkStatus = $.inArray(row.id, selectionIds) != -1; //判断当前行的数据id是否存在与选中的数组,存在则将多选框状态变为true
|
|||
|
|
});
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<div class="modal fade" id="subDetailModal">
|
|||
|
|
<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 " style="width:100%">
|
|||
|
|
<div id="alertDiv"></div>
|
|||
|
|
<div class="row">
|
|||
|
|
<div class="col-lg-3 col-md-4">
|
|||
|
|
<input type="hidden" id="classid" name="classid" class="form-control">
|
|||
|
|
<div id="tree" style="height:550px;overflow:auto; "></div>
|
|||
|
|
</div>
|
|||
|
|
<div class="col-lg-9 col-md-8">
|
|||
|
|
<div class="btn-group" style="width: 220px;padding-bottom:10px;">
|
|||
|
|
<security:authorize buttonUrl="sparepart/goods/add.do">
|
|||
|
|
<button type="button" class="btn btn-default btn-sm" onclick="addGoodsFun();"><i class="fa fa-plus"></i> 新增物品</button>
|
|||
|
|
</security:authorize>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-group pull-right form-inline" >
|
|||
|
|
<div class="input-group input-group-sm" style="width: 250px;">
|
|||
|
|
<input type="text" id="search_goodsName" name="search_goodsName" class="form-control pull-right" placeholder="物品名称">
|
|||
|
|
<div class="input-group-btn">
|
|||
|
|
<button class="btn btn-default" onclick="doSearchGoods();"><i class="fa fa-search"></i></button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div>
|
|||
|
|
<table id="table_goods"></table>
|
|||
|
|
</div>
|
|||
|
|
</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="doSelectGoods()">确认</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-content -->
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-dialog -->
|
|||
|
|
</div>
|