//cc
(function(){
    X.pageLogic['userinfolist'] = {
        init : function(){

            // 当X.DATA.traceid部位空时，是从路径分析进入
            if(X.DATA['trace_query_cond'] && X.DATA['trace_query_cond'] != ''){
                var trace_query_cond = X.DATA['trace_query_cond'];
                $(".userinfolist-type").html("路径分析");
                var sumlist = 0;
                var configpagestype = 0;
                updatatraceuserlist();
                function updatatraceuserlist(){
                    X.api("ck/trace_user_info_model","post",trace_query_cond,function(d){
                        $("#userinfolist-table-box").html("");
                        $(".userinfolist_body_line_left_num span").html(d.user_num);
                        sumlist = d.user_num;
                        X.laytpldata("#userinfolist-table-box-dot",d,".userinfolist-table-box",function(){
                            var tableMul = new FixedTable("dataTableMul-userlist", 1);
                            if(configpagestype == 0){
                                configpages();
                                configpagestype++
                            }

                        });
                    })
                }
                configpages();
                function configpages(){
                    layui.laypage.render({
                        elem: 'laypages' //注意，这里的 test1 是 ID，不用加 # 号
                        ,count: sumlist, //数据总数，从服务端得到
                        limit:10,   //每页条数设置
                        jump: function(obj, first){

                            trace_query_cond['events']['page']=obj.curr;  //改变当前页码

                            //首次不执行
                            if(!first){
                                updatatraceuserlist();  //加载数据
                            }
                        }
                    });
                };

                $(document).off('click',".userinfolist-type").on('click','.userinfolist-type',function(){
                    X.gourl('routeanalysis','conetnt');
                })

            }else {
                //从用户搜索进入
                var data = X['ueser_search_data'];

                updatauserlist();
                X.api('ck/seek_user_count','post', X['ueser_search_data'] ,function (d){

                    $(".userinfolist_body_line_left_num span").html(d);
                    layui.laypage.render({
                        elem: 'laypages' //注意，这里的 test1 是 ID，不用加 # 号
                        ,count: d, //数据总数，从服务端得到
                        limit:10,   //每页条数设置
                        jump: function(obj, first){

                            data['pages']=obj.curr;  //改变当前页码

                            //首次不执行
                            if(!first){
                                updatauserlist();  //加载数据
                            }
                        }
                    });
                });

                $(document).off("click",'.userinfolist-page_table .table-fixed tbody tr td').on("click",".userinfolist-page_table .table-fixed tbody tr td",function(){
                    var id = $(this).attr("data-id");
                    X['DATA']['search-user-id'] = id;
                    X.gourl('userinfo','conetnt');
                });
                
                function updatauserlist(){
                    X.api('ck/seek_user','post', data ,function (val){
                        $("#userinfolist-table-box").html("");
                        X.laytpldata("#userinfolist-table-box-dot",val,".userinfolist-table-box",function(){
                            var tableMul = new FixedTable("dataTableMul-userlist", 1);
                        });

                        // X.laytpldata("#userinfolist-title-box-dot",val.details_data.new_columns,".userinfolist-title-box");
                        // X.laytpldata("#userinfolist-list-box-dot",val.details_data.new_values,".userinfolist-list-box",function(){
                        //     var tableMul = new FixedTable("dataTableMul-userlist", 1);
                        // });
                    });
                
                };

                //下载
                $(document).off("click",'.download-user-data').on("click",".download-user-data",function(){
                    
                    X.download('ck/download_user',data,'用户报表');

                });
            }

            
        

        },
    };
})();
