/** * 项目统计报表 * */ var curentPage = 1; //当前的页数 var myDate = new Date(); var currentYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????) var currentMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月) $(function() { $('.tool_bars').authorizeButton(); //项目下拉 helper.getDropList.getProlistDrop($('#energy_pro')); laydate.render({ type:'year', elem: '#year_times', theme: '#249fea', showBottom :false, //关闭底部框 去掉取消、确定、清空按钮 change: function(value, date, endDate){         $("#year_times").val(value);         if($(".layui-laydate").length){             $(".layui-laydate").remove();         }     } }); $('#month_times').val(currentMonth); $('#year_times').val(currentYear); initTable(); //搜索 $("#sc_btns").click(function() { curentPage = 1; initTable(); }) }); function initTable() { //先销毁表格 $('#table_all').bootstrapTable('destroy'); //初始化表格,动态从服务器加载数据 $('#table_all').bootstrapTable({ method: "get", //使用get请求到服务器获取数据 url: huayi.config.callcenter_url + "plcautomationapi/api/plcdata/getdatalist", //获取数据的Servlet地址 contentType: "application/x-www-form-urlencoded", striped: true, //表格显示条纹 pagination: true, //启动分页 pageSize: 20, //每页显示的记录数 pageNumber: curentPage, //当前第几页 pageList: [10, 20, 50, 100], //记录数可选列表 search: false, //是否启用查询 showColumns: false, //显示下拉框勾选要显示的列 showRefresh: false, //显示刷新按钮 sidePagination: "server", //表示服务端请求 //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder //设置为limit可以获取limit, offset, search, sort, order queryParamsType: "undefined", queryParams: function queryParams(params) { //设置查询参数 var param = { pageindex: params.pageNumber, pagesize: params.pageSize, projectname:$("#energy_pro").find("option:selected").text(), //项目名称 checkyear:$('#year_times').val(), //年 checkmonth:$('#month_times').val() //月 //start: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[0], //end: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[1], }; return param; }, onPageChange: function(number, size) { curentPage = number; }, onLoadSuccess: function(res) { //加载成功时执行 //layer.msg("加载成功"); if(res.state.toLowerCase() == "success") { var newData = {}; newData.state = res.state; newData.message = res.message; newData.rows = res.data; newData.total = res.data.length; $('#table_all').bootstrapTable('load', newData); //$('#proTotal').text(res.data.rows.procount); } //$('.tool_down').authorizeOperateButton(); }, onLoadError: function() { //加载失败时执行 //layer.msg("加载数据失败", { time: 1500, icon: 2 }); } }); } //格式化序号 function setCode(val, row, index) { return ++index; } //导出 function btn_export(obj) { var energyPro=$("#energy_pro").find("option:selected").text(); var yearTimes=$("#year_times").val(); var monthTimes=$("#month_times").val(); var url = huayi.config.callcenter_url + "plcautomationapi/api/plcdata/exportexcel?projectname="+energyPro+"&checkyear="+yearTimes+"&checkmonth="+monthTimes; obj.href = url; }