123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- layui.use([ 'layer', 'table', 'element','form','laydate'], function(){
- var layer = layui.layer //弹层
- ,table = layui.table //表格
- ,element = layui.element //元素操作
- ,form = layui.form,
- laydate = layui.laydate;
- // laydate.render({
- // elem: '#date1'
- // });
- // laydate.render({
- // elem: '#date2'
- // });
- //年月选择器
- laydate.render({
- elem: '#date1'
- ,type: 'month'
- });
- //第一个实例
- var tableIns = table.render({
- elem: '#userlist'
- ,url: '/usersignup/statisticaform' //数据接口
- ,where:{token:csrfToken}
- ,method:'post'
- ,id:'tablerReload'
- ,totalRow:true
- ,text:'数据加载中'
- ,cols: [[ //表头
- // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'},
- {type:'numbers',fixed:"left",title:'序号'}
- ,{field:'time', title:'时间',width:150,align:'center',totalRowText:'合计'}
- ,{field:'dim_count', title:'模糊统计',width:150,align:'center',totalRow:true}
- ,{field:'precise', title:'精准统计',width:150,align:'center',totalRow:true}
- ,{field:'pc', title:'PC端',width:150,align:'center',totalRow:true,templet:function (d) {
- if(d.pc){
- return d.pc;
- }else{
- return 0;
- }
- }}
- ,{field:'m', title:'移动端',width:150,align:'center',totalRow:true,templet:function (d) {
- if(d.m){
- return d.m;
- }else{
- return 0;
- }
- }}
- // ,{fixed: 'right',title:'操作', width: 150, align:'center', toolbar: '#signupBar'}
- ]],done:function (res, curr, count) {
- var date= new Date();
- var year=date.getFullYear();//获取年
- var month=date.getMonth()+1;//获取月
- var day=date.getDate();//获取日
- var date_time = year+'-'+month+'-'+day;
- this.elem.next().find('td[data-field="time"]:contains("'+date_time+'")').parent('tr').css({"color": "#ccc"});
- }
- });
- tableIns.reload('tablerReload'); //重新加载
- var $ = layui.$, active = {
- reset:function(){
- // table.reload('tablerReload');
- window.location.reload();
- },
- reload:function () {
- var form = pfgs_serialize($('form'));
- // console.log(form);
- // var a = compareTime(form.start_time,form.end_time);
- // if(a === false) {
- // layer.msg('开始时间不能大于结束时间');
- // return ;
- // }
- table.reload('tablerReload',{
- where:{
- date_month:form.start_time
- }
- })
- }
- };
- //
- // function compareTime(a, b) {
- // var arr = a.split("-"); //log [2016,04,06]
- // var start = new Date(arr[0], (arr[1] - 1), arr[2]);
- // var starts = start.getTime(); //输出时间戳进行对比
- // var arrs = b.split("-");
- // var end = new Date(arrs[0], (arrs[1] - 1), arrs[2]);
- // var ends = end.getTime();
- // if (starts > ends) return false ;
- // }
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- });
- function Layui_SetDataTableRowColor(TabDivId,RowIndex, ColorString)
- {
- try
- {
- var div = document.getElementById(TabDivId);
- if(div != null) //找到对象了
- {
- var table_main = div.getElementsByClassName('layui-table-main'); //通过class获取table_main
- if (table_main != null && table_main.length > 0)
- {
- var table = table_main[0].getElementsByClassName('layui-table'); //通过class获取table
- if (table != null && table.length > 0) {
- var trs = table[0].querySelectorAll("tr");
- if (trs != null && trs.length > 0) {
- trs[RowIndex].style.color = ColorString;
- }
- }
- }
- }
- }
- catch(e)
- {
- console.log(e.message);
- }
- }
|