(function(){
    X.pageLogic['zidingyizhibiao'] = {
        init : function(parms){
            var me = this;
            this.parms = parms;
            this.callback = parms.callback;
            var datalist = [
                {
                    title:'基础指标',
                    id:'basicindex',
                    checked: true,
                    list:[
                        { title:'累计充值', checked:true,id:'cumulativerecharge'},
                        { title:'活跃数', checked:true,id:'active'},
                        { title:'付费数', checked:true,id:'paunum'},
                        { title:'付费率', checked:true,id:'paurate'},
                        { title:'付费arpu', checked:true,id:'pauarpu'},
                        { title:'活跃arpu', checked:true,id:'activearpu'},
                    ]
                },{
                    title:'注册新增指标',
                    id:'registernew',
                    checked: false,
                    list:[
                        { title:'新增', checked:true,id:'newadd'},
                        { title:'新增付费金额', checked:true,id:'newaddmoney'},
                        { title:'新增付费数', checked:true,id:'newaddnum'},
                        { title:'新增付费率', checked:true,id:'newaddrate'},
                        { title:'新增付费arpu', checked:true,id:'newaddpayarpu'},
                        { title:'新增arpu', checked:false,id:'newaddaru'},
                    ]
                },{
                    title:'留存指标',
                    id:'retained',
                    checked: false,
                    list:[
                        { title:'1日留存', checked:false,id:'retained1'},
                        { title:'2日留存', checked:false,id:'retained2'},
                        { title:'3日留存', checked:false,id:'retained3'},
                        { title:'7日留存', checked:false,id:'retained7'},
                        { title:'14日留存', checked:false,id:'retained14'},
                        { title:'30日留存', checked:false,id:'retained30'},
                    ]
                },{
                    title:'Ltv指标',
                    id:'ltv',
                    checked: false,
                    list:[
                        { title:'Ltv1', checked:false,id:'ltv1'},
                        { title:'Ltv2', checked:false,id:'ltv2'},
                        { title:'Ltv3', checked:false,id:'ltv3'},
                        { title:'Ltv7', checked:false,id:'ltv7'},
                        { title:'Ltv14', checked:false,id:'ltv14'},
                        { title:'Ltv30', checked:false,id:'ltv30'},
                    ]
                }
            ];

            X.laytpldata("#zhibiao-list-dot",datalist,".zidingyizhibiao-list-box");

            layui.form.render();

            layui.form.on('checkbox(checkboxexample)', function(d){
                var data = layui.form.val('zidingyiexample');
                if(data[d.value]){
                    for(let i in datalist){
                        if(datalist[i]['id'] == d.value){
                            datalist[i]['checked'] = true;
                            for(let z in datalist[i]['list']){
                                datalist[i]['list'][z]['checked'] = true;
                            }
                        }
                    }
                }else{
                    for(let i in datalist){
                        if(datalist[i]['id'] == d.value){
                            datalist[i]['checked'] = false;
                            for(let z in datalist[i]['list']){
                                datalist[i]['list'][z]['checked'] = false;
                            }
                        }
                    }
                }

                X.laytpldata("#zhibiao-list-dot",datalist,".zidingyizhibiao-list-box");
                layui.form.render();
            });

            $(document).off('click','.adduser-btn').on('click','.adduser-btn',function(){
                layer.closeAll();
            })

            $(document).off('click','.adduser-top-box img').on('click','.adduser-top-box img',function(){
                layer.closeAll();
            })

            $(document).off('click','.adduser-btn2').on('click','.adduser-btn2',function(){
                var data = layui.form.val('zidingyiexample');
                me.callback && me.callback(data);
                layer.closeAll();
            })
            
            

        }
    };
})();