/**
|
* 工作状态
|
*/
|
$(function(){
|
var curRow = {};
|
$('#test-table').bootstrapTable('destroy')
|
$('#test-table').bootstrapTable({
|
method : 'GET',
|
url: "basic/workStatusList.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 : "wrk_sts",
|
title : "工作状态代号",
|
class : 'col-md-1',
|
align : "center",
|
valign : "middle",
|
sortable : "true"
|
}, {
|
field : "wrk_desc",
|
title : "工作状态描述",
|
align : "left",
|
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 : "qty",
|
title : "行内编辑",
|
formatter: function (value, row, index) {
|
if(value==null || value==""){
|
return "<a href=\"#\" name=\"UserName\" data-type=\"text\" data-pk=\""+row.Id+"\" data-title=\"入库数量\">0</a>";
|
}
|
return "<a href=\"#\" name=\"UserName\" data-type=\"text\" data-pk=\""+row.Id+"\" data-title=\"用户名\">" + value + "</a>";
|
}
|
}, {
|
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 '无符合条件的记录';
|
},
|
onClickRow: function (row, $element) {
|
curRow = row;
|
},
|
onLoadSuccess: function (aa, bb, cc) {
|
$("#test-table a").editable({
|
url: function (params) {
|
// var sName = $(this).attr("name");
|
// curRow[sName] = params.value;
|
//// $.ajax({
|
//// type: 'POST',
|
//// url: "/Editable/Edit",
|
//// data: curRow,
|
//// dataType: 'JSON',
|
//// success: function (data, textStatus, jqXHR) {
|
//// alert('保存成功!');
|
//// },
|
//// error: function () { alert("error");}
|
//// });
|
},
|
type: 'text'
|
});
|
},
|
// onClickCell:function(field, value, row, $element){
|
// alert(field + '@@' + value + '@@' + row.wrk_sts);
|
// },
|
//注册加载子表的事件。注意下这里的三个参数!
|
onExpandRow: function (index, row, $detail) {
|
oInit.InitSubTable(index, row, $detail);
|
}
|
|
});
|
});
|
|
function operateFormatter(value, row, index) {
|
return [
|
'<button type="button" class=" btn btn-info" onclick="getvalue('+row.wrk_sts+')">修改</button>',
|
' <button class=" btn btn-danger" type="button" onclick="delWorkStatus('+row.wrk_sts+')">删除</button>'
|
].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:{
|
wrk_sts:{
|
message: '工作代号验证失败',
|
validators:{
|
notEmpty:{message:'不能为空'},
|
numeric:{message:'只能输入数字'}
|
}
|
},
|
wrk_desc:{
|
message: '状态描述验证失败',
|
validators:{
|
notEmpty:{message:'不能为空'},
|
stringLength:{max:30,message:'字符长度不能超过30'}
|
}
|
}
|
}
|
});
|
|
$("#myform").bootstrapValidator({
|
message: 'This value is not valid',
|
feedbackIcons: {
|
valid: 'glyphicon glyphicon-ok',
|
invalid: 'glyphicon glyphicon-remove',
|
validating: 'glyphicon glyphicon-refresh'
|
},
|
|
fields: {
|
wrk_sts:{
|
message: '工作代号验证失败',
|
validators:{
|
notEmpty:{message:'不能为空'},
|
numeric:{message:'只能输入数字'}
|
}
|
},
|
wrk_desc:{
|
message: '状态描述验证失败',
|
validators:{
|
notEmpty:{message:'状态描述不能为空'},
|
stringLength:{max:30,message:'字符长度不能超过30'}
|
}
|
}
|
}
|
});
|
}
|
//表单验证
|
$(function(){
|
formValidator();
|
|
});
|
|
//添加部门,打开模态框
|
function addWorkStatus(){
|
$("#addDlg").modal('show');
|
}
|
|
//添加工作状态时验证是否唯一
|
function checkWorkStatus(){
|
var x=$("#wrk_sts1").val();
|
if(x!="" && !isNaN(x)){
|
$.ajax({
|
url:'basic/checkWorkStatus.action',
|
dataType:'json',
|
type:'post',
|
data:{
|
did:$("#wrk_sts1").val()
|
},
|
success:function(data){
|
$("#info").text(data.msg);
|
},
|
error:function(){
|
alert("请求失败");
|
}
|
});
|
}else{
|
return false;
|
}
|
};
|
|
// 提交插入
|
function insertWorkStatus(){
|
var msg=$("#info").text();
|
if(msg=="代号可用"){
|
if($("#addForm").data('bootstrapValidator').validate().isValid()){
|
$.ajax({
|
url:'basic/addWorkStatus.action',
|
type:'post',
|
dataType:'json',
|
data:$("#addForm").serialize(),
|
success:function(info){
|
if(info>0){
|
alert("添加成功");
|
}else{
|
alert("添加失败");
|
}
|
$("#test-table").bootstrapTable('refresh');
|
$("#addDlg").modal('hide');
|
$("#wrk_sts1").val("");
|
$("#wrk_desc1").val("");
|
},
|
error:function(){
|
alert('请求失败');
|
}
|
});
|
}else{
|
return false;
|
}
|
}else{
|
alert("代号不可用");
|
}
|
// var name=$("#f_GroupName1").val();
|
// $.ajax({//部门名称唯一验证
|
// url:'group/valid.action',
|
// dataType:'json',
|
// type:'post',
|
// data:{name:name},
|
// success:function(data){
|
// if(data.i>0){
|
// if($("#addForm").data('bootstrapValidator').validate().isValid()){
|
// $.ajax({
|
// url:'group/addGroup.action',
|
// type:'post',
|
// dataType:'json',
|
// data:$("#addForm").serialize(),
|
// success:function(info){
|
// if(info>0){
|
// alert("添加成功");
|
// }else{
|
// alert("添加失败");
|
// }
|
// $("#test-table").bootstrapTable('refresh');
|
// $("#addDlg").modal('hide');
|
// $("#f_GroupName1").val("");
|
// $("#f_GroupNO").val("");
|
// },
|
// error:function(){
|
// alert('请求失败');
|
// }
|
// });
|
// }else{
|
// return false;
|
// }
|
// }else{
|
// $("#info").text(data.msg);
|
// }
|
// },
|
// error:function(){
|
// alert("请求失败");
|
// }
|
// });
|
}
|
|
|
//打开模态框,数据回写
|
function getvalue(id){
|
$.ajax({
|
url:'basic/queryWorkStatusById.action',
|
type:'post',
|
dataType:'json',
|
data:{did:id},
|
success:function(data){
|
$("#wrk_sts").val(data.wrk_sts);
|
$("#wrk_desc").val(data.wrk_desc);
|
},
|
error:function(){
|
alert("请求失败");
|
}
|
});
|
$("#mydlg").modal("show");
|
}
|
|
//保存修改内容
|
function upWorkStatus(){
|
if($("#myform").data('bootstrapValidator').validate().isValid()){
|
$.ajax({
|
url:'basic/upWorkStatus.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;
|
}
|
// var name=$("#f_GroupName").val();
|
// var id=$("#f_GroupID").val();
|
// $.ajax({//部门名称唯一验证
|
// url:'group/valid.action',
|
// dataType:'json',
|
// type:'post',
|
// data:{name:name,id:id},
|
// success:function(data){
|
// if(data.i>0){
|
// if($("#myform").data('bootstrapValidator').validate().isValid()){
|
// $.ajax({
|
// url:'group/upGroup.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;
|
// }
|
// }else{
|
// $("#infos").text(data.msg);
|
// }
|
// },
|
// error:function(){
|
// alert("请求失败");
|
// }
|
// });
|
}
|
//关闭模态框
|
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");
|
|
|
}
|
|
//单个删除
|
function delWorkStatus(id){
|
if(confirm('您确定要删除这条数据吗')){
|
$.ajax({
|
url:'basic/delWorkStatus.action',
|
type:'post',
|
dataType:'json',
|
data:{did:id},
|
success:function(data){
|
if(data>0){
|
alert("删除成功");
|
}else{
|
alert("删除失败");
|
}
|
$("#test-table").bootstrapTable('refresh');
|
},
|
error:function(){
|
alert("请求失败");
|
}
|
});
|
}
|
}
|