$(function(){ });var AttendanceDetail = { init:function () { $("#AttendanceDetailTable").bootstrapTable({ columns: [ { field: 'userid', title: '员工卡号' },{ field: 'username', title: '员工姓名' },{ field: 'startDate', title: '第一次打卡' },{ field: 'stopDate', title: '最后一次打卡' },{ field: 'state', title: '状态', formatter: function (value ,row,index) { var colorStyle=""; if(value=="正常"){ colorStyle = "btn-success"; }else if(value=="迟到"){ colorStyle = "btn-warning"; }else if(value=="早退"){ colorStyle = "btn-warning"; }else if(value=="缺卡"){ colorStyle = "btn-purple"; }else if(value=="旷工"){ colorStyle = "btn-danger"; } return "<button class='btn btn-xs "+colorStyle +"'>"+value+"</button>" ; } },{ field: 'deptname', title: '部门' }, ], }) $.ajax({ type: "post", url: "http://127.0.0.1:8080/ikingoa/queryReturnAttendance", dataType: "json", async:false, data:{ dateTime:"month", whole:0, dateTimes:"", state:"全部", deptname:"全部", username:"" }, success:function (data) { console.log("我是第二次请求么?"); $("#AttendanceDetailTable").bootstrapTable("load",data); } }); //查询条件筛选 var flag=0; $(".timeFrameStyle button").click(function () { $(this).addClass("btn-success"); $(this).siblings().removeClass("btn-success"); queryConditionSelected(); }); $("#dateTimeSelected input").on("change",function () { $(".timeFrameStyle button").removeClass("btn-success"); queryConditionSelected(); }); $("#departmentSelected a").click(function () { $("#departmentSelected button:first-of-type").html($(this).text()); $("#departmentSelected button").addClass("btn-success"); queryConditionSelected(); }); $("#userNameSelected .btn-info").click(function () { queryConditionSelected(); }) $(".signInStatusStyle button").click(function () { $(this).addClass("btn-success"); $(this).siblings().removeClass("btn-success"); queryConditionSelected(); }); $(".tableHead .btn-success").click(function () { queryConditionSelected(); }); $("#downMonthData").click(function () { queryConditionSelected(); }) function queryConditionSelected(){ var dateTime = "month"; var whole = 0; var dateTimes = ""; var state = "全部"; var deptname = "全部"; var username = ""; var time = $.trim($(".timeFrameStyle .btn-success").text()); if(time=="昨天"){ dateTime = "day"; whole= 1; }else if(time=="本周"){ dateTime = "week"; whole = 0; }else if(time=="上月"){ dateTime = "month"; whole = 1; }else if(time=="本月"){ dateTime = "month"; whole = 0; } dateTimes = $("#datetimepicker input").val(); state = $(".signInStatusStyle .btn-success").text(); deptname = $("#departmentSelected button:first-of-type").html(); username = $("#userNameSelected input").val(); console.log(dateTime+"--------"+whole+"--------"+dateTimes+"--------"+state+"--------"+deptname+"--------"+username) $.ajax({ type: "post", url: "http://127.0.0.1:8080/ikingoa/queryReturnAttendance", dataType:"json", data:{ dateTime:$.trim(dateTime), whole:$.trim(whole), dateTimes:dateTimes, state:$.trim(state), deptname:$.trim(deptname), username:$.trim(username).toString() }, success:function (data) { $("#AttendanceDetailTable").bootstrapTable("load",data); } }) } }};
1 回答
已采纳
拟人
TA贡献37条经验 获得超15个赞
代码不是看的很懂,不过根据你的问题,我大胆猜测,提交两次是因为bootstrap里button默认就是提交(submit)的,可以通过给buttion设置类型type=button解决
添加回答
举报
0/150
提交
取消