/**
* 库位
*/
$(function(){
getLocStatusList();
getWhsTypeList();
$('#test-table').bootstrapTable('destroy');
$('#test-table').bootstrapTable({
method : 'GET',
url: "basic/locationList.action",
cache : false,
striped : true,
pagination : true, //在表格底部显示分页工具栏
pageSize : 10, //默认每页条数
pageNumber : 1, //默认分页
pageList : [ 10, 20, 50, 100, 200, 500 ],//分页数
showColumns : true, //显示隐藏列
showRefresh : false, //显示刷新按钮
showExport : false,
toolbar:"#toolbar",
singleselect : true,
clickToSelect: true, // 单击行即可以选中
search : false,//显示搜素表单
silent : true, //刷新事件必须设置
sidePagination : "server", //表示服务端请求
columns : [ {
field : "loc_no",
title : "库位号",
class : 'col-md-1',
align : "center",
valign : "middle",
sortable : "true"
}, {
field : "loc_sts_name",
title : "库位状态",
align : "center",
valign : "middle",
}, {
field : "crn_no",
title : "堆垛机号",
align : "center",
valign : "middle",
}, {
field : "row1",
title : "排",
align : "center",
valign : "middle",
sortable : "true"
}, {
field : "bay1",
title : "列",
align : "center",
valign : "middle",
sortable : "true"
}, {
field : "lev1",
title : "层",
align : "center",
valign : "middle",
sortable : "true"
}, {
field : "full_plt",
title : "满板",
align : "center",
valign : "middle",
visible : false,
sortable : "true",
formatter : function(value, row, index) {
var result = 'N';
if(value=='Y')
result='';
else
result='';
return result
}
}, {
field : "loc_type_desc",
title : "库位别",
align : "center",
valign : "middle",
sortable : "true"
}, {
field : "modi_user",
title : "修改人员",
align : "center",
valign : "middle",
sortable : "true"
}, {
field : "modi_time",
title : "修改时间",
align : "center",
valign : "middle",
sortable : "true"
}, {
field: 'operate',
title: '操作',
class : 'col-md-1',
align: 'center',
valign: 'middle',
formatter: operateFormatter,
}],
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
pageNumber: params.pageNumber,
pageSize: params.pageSize,
loc_no:$("#loc_no").val(),
loc_sts:$("#loc_sts").val(),
crn_no:$("#crn_no").val(),
row1:$("#row1").val(),
bay1:$("#bay1").val(),
lev1:$("#lev1").val()
// searchText: params.searchText
};
return param;
},
formatLoadingMessage : function() {
return "请稍等,正在加载中...";
},
formatNoMatches : function() {
return '无符合条件的记录';
},
//注册加载子表的事件。注意下这里的三个参数!
onExpandRow: function (index, row, $detail) {
oInit.InitSubTable(index, row, $detail);
}
});
});
function operateFormatter(value, row, index) {
return [
''//,
// ' '
].join('');
}
/**
* 库位状态
* @returns
*/
function getLocStatusList(){
$.ajax({
url:'basic/getLocStatus.action',
dataType:'json',
type:'post',
data:{
pageNumber:1,
pageSize:1000
},
success:function(data){
$("#loc_sts").empty();
$("#loc_sts").append("");
$.each(data.rows,function(){
$("#loc_sts").append("");
});
$("#loc_sts1").empty();
$("#loc_sts1").append("");
$.each(data.rows,function(){
$("#loc_sts1").append("");
});
},
error:function(){
alert("请求失败!");
}
});
}
/**
* 仓库类型
* @returns
*/
function getWhsTypeList(){
$.ajax({
url:'basic/getWhsType.action',
dataType:'json',
type:'post',
data:{
pageNumber:1,
pageSize:1000
},
success:function(data){
$("#whs_type").empty();
$("#whs_type").append("");
$.each(data.rows,function(){
$("#whs_type").append("");
});
},
error:function(){
alert("请求失败!");
}
});
}
/**
* 条件查询库位
* @returns
*/
function getLocationByCon(){
// $("#test-table").bootstrapTable('refresh');
$("#test-table").bootstrapTable('refreshOptions',{pageNumber:1}); //分页后重新搜索时,初始化页码为1
}
function formValidator(){
$("#addForm").bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields:{
s_row:{
message: '起始排验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'}
}
},
e_row:{
message: '终止排验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'}
}
},
s_bay:{
message: '起始列验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'}
}
},
e_bay:{
message: '终止列验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'}
}
},
s_lev:{
message: '起始层验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'}
}
},
e_lev:{
message: '终止层验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'}
}
},
whs_type:{
message: '验证失败',
validators:{
notEmpty:{message:'不能为空'},
numeric:{message:'只能输入数字'},
callback: {
message: '不能为空',
callback:function(value, validator,$field,options){
var whs_type = $("#whs_type").val();
if(whs_type=='0')
return false;
else{
$("#initLoc").attr("disabled", false);
return true;
}
}
}
}
}
}
});
$("#myform").bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
loc_sts:{
message: '验证失败',
validators:{
notEmpty:{message:'不能为空'},
callback: {
message: '不能与原库位状态相同',
callback:function(value, validator,$field,options){
var old_sts = $("#loc_sts_old").val();
if(old_sts==value)
return false;
else
return true;
}
}
}
}
}
});
}
//表单验证
$(function(){
formValidator();
});
//添加,打开模态框
function addLocation(){
$("#addDlg").modal('show');
}
//添加时验证是否唯一
function checkLocation(){
var x=$("#loc_no1").val();
if(x!=""){
$.ajax({
url:'basic/checkLocation.action',
dataType:'json',
type:'post',
data:{
did:$("#loc_no1").val()
},
success:function(data){
$("#info").text(data.msg);
},
error:function(){
alert("请求失败");
}
});
}else{
return false;
}
};
// 提交插入
function insertLocation(){
// var msg=$("#info").text();
// if(msg=="代号可用"){
if(confirm('确定初始化?')){
$("#initLoc").attr("disabled", true);
if($("#addForm").data('bootstrapValidator').validate().isValid()){
$.ajax({
url:'basic/addLocation.action',
type:'post',
dataType:'json',
data:$("#addForm").serialize(),
success:function(info){
if(info>0){
alert("初始化成功!共" + info + "个库位");
}else{
alert("初始化失败");
}
$("#test-table").bootstrapTable('refresh');
$("#addDlg").modal('hide');
$("#loc_no1").val("");
$("#s_row").val("");
$("#e_row").val("");
$("#s_bay").val("");
$("#e_bay").val("");
$("#s_lev").val("");
$("#e_lev").val("");
$("#loc_type").val("");
},
error:function(){
alert('请求失败');
}
});
}else{
return false;
}
$("#initLoc").attr("disabled", false);
}
// }else{
// alert("代号不可用");
// }
}
//打开模态框,数据回写
function getvalue(id){
$.ajax({
url:'basic/queryLocationById.action',
type:'post',
dataType:'json',
data:{did:id},
success:function(data){
$("#loc_no1").val(data.loc_no);
$("#loc_sts_old").val(data.loc_sts);
$("#loc_sts_name").val(data.loc_sts_name);
$("#loc_sts1").val(data.loc_sts);
},
error:function(){
alert("请求失败");
}
});
$("#mydlg").modal("show");
}
//保存修改内容
function upLocation(){
if($("#myform").data('bootstrapValidator').validate().isValid()){
$.ajax({
url:'basic/upLocation.action',
type:'post',
dataType:'json',
data:$("#myform").serialize(),
success:function(data){
if(data>0){
alert("修改成功");
}else{
alert("修改失败");
}
$("#test-table").bootstrapTable('refresh');
$("#mydlg").modal("hide");
},
error:function(){
alert("请求失败");
}
});
}else{
return false;
}
}
//关闭模态框
function closedlg(){
$("#mydlg").modal("hide");
$("#addDlg").modal("hide");
$("#info").text("");
$("#infos").text("");
$('#myform').data('bootstrapValidator', null);
$("#addForm").data('bootstrapValidator',null);
formValidator();
//$('#mydlg').data('bootstrapValidator').resetForm(true);
$("input[type=reset]").trigger("click");
$("#initLoc").attr("disabled", false);
}
//单个删除
function resetLocation(){
if(confirm('确定重置库位?将清空所有库位数据')){
$.ajax({
url:'basic/resetLocation.action',
type:'post',
dataType:'json',
// data:{did:id},
success:function(data){
if(data>0){
alert("重置成功");
}else{
alert("重置失败");
}
$("#test-table").bootstrapTable('refresh');
},
error:function(){
alert("请求失败");
}
});
}
}