/** * 站点路径设置 */ $(function(){ getCrnList(); $('#test-table').bootstrapTable('destroy') $('#test-table').bootstrapTable({ method : 'GET', url: "basic/staDescList.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 : "type_id", title : "路径ID", align : "center", valign : "middle", sortable : "true", visible : false }, { field : "type_no", title : "入出代号", class : 'col-md-1', align : "center", valign : "middle", sortable : "true", visible : false }, { field : "type_desc", title : "作业类型", align : "center", valign : "middle", sortable : "true" }, { field : "stn_no", title : "作业站点", align : "center", valign : "middle", sortable : "true" }, { field : "stn_desc", title : "站点名称", align : "center", valign : "middle", sortable : "true" }, { field : "crn_no", title : "堆垛机号", align : "center", valign : "middle", sortable : "true" }, { field : "crn_stn", title : "堆垛机站点", align : "center", valign : "middle", sortable : "true" }, { field : "memo", title : "备注", align : "center", valign : "middle", sortable : "true", visible : false }, { field : "modi_user", title : "修改人员", align : "center", valign : "middle", sortable : "true", visible : false }, { field : "modi_time", title : "修改时间", align : "center", valign : "middle", sortable : "true", visible : false }, { field: 'operate', title: '操作', class : 'col-md-2', align: 'center', valign: 'middle', formatter: operateFormatter, }], queryParamsType: "undefined", queryParams: function queryParams(params) { //设置查询参数 var param = { pageNumber: params.pageNumber, pageSize: params.pageSize // searchText: params.searchText }; return param; }, formatLoadingMessage : function() { return "请稍等,正在加载中..."; }, formatNoMatches : function() { return '无符合条件的记录'; }, //注册加载子表的事件。注意下这里的三个参数! onExpandRow: function (index, row, $detail) { oInit.InitSubTable(index, row, $detail); } }); }); function getCrnList(){ $.ajax({ url:'basic/getCrn.action', dataType:'json', type:'post', data:{ pageNumber:1, pageSize:1000 }, success:function(data){ $("#crn_no").empty(); if(data.rows.length>1){ $("#crn_no").append(""); } $.each(data.rows,function(){ $("#crn_no").append(""); }); $("#crn_no1").empty(); if(data.rows.length>1){ $("#crn_no1").append(""); } $.each(data.rows,function(){ $("#crn_no1").append(""); }); }, error:function(){ alert("请求失败!"); } }); } function operateFormatter(value, row, index) { return [ '', '   ' ].join(''); } function formValidator(){ $("#addForm").bootstrapValidator({ message: 'This value is not valid', feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields:{ type_no:{ message: '验证失败', validators:{ notEmpty:{message:'不能为空'}, numeric:{message:'只能输入数字'} } }, stn_no:{ message: '验证失败', validators:{ notEmpty:{message:'不能为空'}, numeric:{message:'只能输入数字'} } }, crn_stn:{ message: '验证失败', validators:{ notEmpty:{message:'不能为空'}, numeric:{message:'只能输入数字'} } } } }); $("#myform").bootstrapValidator({ message: 'This value is not valid', feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { type_no:{ message: '验证失败', validators:{ notEmpty:{message:'不能为空'}, numeric:{message:'只能输入数字'} } }, stn_no:{ message: '验证失败', validators:{ notEmpty:{message:'不能为空'}, numeric:{message:'只能输入数字'} } }, crn_stn:{ message: '验证失败', validators:{ notEmpty:{message:'不能为空'}, numeric:{message:'只能输入数字'} } } } }); } //表单验证 $(function(){ formValidator(); }); //添加部门,打开模态框 function addStaDesc(){ $("#addDlg").modal('show'); } //添加工作状态时验证是否唯一 function checkStnNo1(type){ var x; if(type==1){ x=$("#stn_no1").val(); }else if(type==2){ x=$("#crn_stn1").val(); }else if(type==3){ x=$("#stn_no").val(); }else if(type==4){ x=$("#crn_stn").val(); } if(x!="" && !isNaN(x)){ $.ajax({ url:'basic/checkStnNo1.action', dataType:'json', type:'post', data:{ did:x }, success:function(data){ if(type==1){ $("#info_stn_no1").text(data.msg); }else if(type==2){ $("#info_crn_stn1").text(data.msg); }else if(type==3){ $("#info_stn_no").text(data.msg); }else if(type==4){ $("#info_crn_stn").text(data.msg); } }, error:function(){ alert("请求失败"); } }); }else{ return false; } }; // 提交插入 function insertStaDesc(){ if($("#type_no1").val()!=null && $("#type_no1").val()!="" && $("#info_stn_no1").text()=="站点可用" && $("#info_crn_stn1").text()=="站点可用"){ if($("#addForm").data('bootstrapValidator').validate().isValid()){ $.ajax({ url:'basic/addStaDesc.action', type:'post', dataType:'json', data:$("#addForm").serialize(), success:function(info){ if(info>0){ alert("添加成功"); }else{ alert("添加失败"); } $("#test-table").bootstrapTable('refresh'); closedlg(); }, error:function(){ alert('请求失败'); } }); }else{ return false; } }else{ alert("输入不正确"); } } //打开模态框,数据回写 function getvalue(id){ $.ajax({ url:'basic/queryStaDescById.action', type:'post', dataType:'json', data:{did:id}, success:function(data){ $("#type_id").val(data.type_id); $("#type_no").val(data.type_no); $("#stn_no").val(data.stn_no); $("#stn_desc").val(data.stn_desc); $("#crn_no").val(data.crn_no); $("#crn_stn").val(data.crn_stn); $("#memo").val(data.memo); }, error:function(){ alert("请求失败"); } }); $("#mydlg").modal("show"); } //保存修改内容 function upStaDesc(){ if($("#type_no").val()!=null && $("#type_no").val()!="" && ($("#info_stn_no").text()=="站点可用" || $("#info_stn_no").text()=="") && ($("#info_crn_stn").text()=="站点可用" || $("#info_crn_stn").text()=="") ){ if($("#myform").data('bootstrapValidator').validate().isValid()){ $.ajax({ url:'basic/upStaDesc.action', type:'post', dataType:'json', data:$("#myform").serialize(), success:function(data){ if(data>0){ alert("修改成功"); }else{ alert("修改失败"); } $("#test-table").bootstrapTable('refresh'); closedlg(); }, error:function(){ alert("请求失败"); } }); }else{ return false; } }else{ alert("输入不正确"); } } //关闭模态框 function closedlg(){ $("#mydlg").modal("hide"); $("#addDlg").modal("hide") $("#info_stn_no").text(""); $("#info_stn_no1").text(""); $("#info_crn_stn").text(""); $("#info_crn_stn1").text(""); $('#myform').data('bootstrapValidator', null); $("#addForm").data('bootstrapValidator',null); formValidator(); //$('#mydlg').data('bootstrapValidator').resetForm(true); $("input[type=reset]").trigger("click"); } //单个删除 function delStaDesc(id){ if(confirm('确定删除')){ $.ajax({ url:'basic/delStaDesc.action', type:'post', dataType:'json', data:{did:id}, success:function(data){ if(data>0){ alert("删除成功"); }else{ alert("删除失败"); } $("#test-table").bootstrapTable('refresh'); }, error:function(){ alert("请求失败"); } }); } }