(function(){
    X.pageLogic['eventattradminedit'] = {
        init : function(parms){

            var me = this;
            this.parms = parms;
            this.callback = parms.callback; //选择后执行的回调
            var data = parms.extData;//获取到上层弹窗传的数据
            layui.form.render();
            if(data){
                var eventstate
                if(data.is_show){
                    eventstate = 1
                }else {
                    eventstate = 0
                }
                layui.form.val('eventattradmineditexample', {
                    "eventname": data.show_name // "name": "value"
                    ,"eventunit": data.unit
                    ,"eventstate": eventstate
                });
            }
            

            $(".eventattradminedit-but-box .eventattradminedit-qx").click(function(){
                layer.closeAll();
            })
            
            $(".eventattradminedit-but-box .eventattradminedit-qd").click(function(){
                var fromdata = layui.form.val("eventattradmineditexample");
                var is_show;
                if(fromdata.eventstate == "1"){
                    is_show = true;
                }else {
                    is_show = false;
                }
               X.api('data_mana/attr_edit',"post",{name:data.name,show_name: fromdata['eventname'],is_show:is_show,cat:data.cat},function(d){
                    layer.msg('修改成功');
                    me.callback && me.callback(d);
                    layer.closeAll();
               })
            })
        }
    };
})();
