var data=utils.init({roleId:utils.getQueryInt("roleId"),siteId:utils.getQueryInt("siteId"),isSite:!1,site:null,permissionInfo:null,treeData:[],defaultExpandedKeys:[]}),methods={getPermissionInfo:function(s){for(var e=s.sitePermissions||[],n=[],i=[],t=0;t<e.length;t++)i.push(e[t].name),e[t].selected&&n.push(e[t].name);var o=s.channelPermissions||[],h=[],r=[];for(t=0;t<o.length;t++)r.push(o[t].name),o[t].selected&&h.push(o[t].name);var m=s.contentPermissions||[],a=[],l=[];for(t=0;t<m.length;t++)l.push(m[t].name),m[t].selected&&a.push(m[t].name);var c=s.channel,f=s.checkedChannelIds||[];return{siteId:this.siteId,sitePermissions:e,siteCheckAll:!1,isSiteIndeterminate:!0,allSitePermissions:i,checkedSitePermissions:n,channelPermissions:o,channelCheckAll:!1,isChannelIndeterminate:!0,allChannelPermissions:r,checkedChannelPermissions:h,contentPermissions:m,contentCheckAll:!1,isContentIndeterminate:!0,allContentPermissions:l,checkedContentPermissions:a,channel:c,checkedChannelIds:f}},handleSiteCheckAllChange:function(s){if(this.permissionInfo.checkedSitePermissions=[],s)for(var e=0;e<this.permissionInfo.sitePermissions.length;e++)this.permissionInfo.checkedSitePermissions.push(this.permissionInfo.sitePermissions[e].name);this.permissionInfo.isSiteIndeterminate=!1},handleCheckedSitePermissionsChange:function(s){var e=s.length;this.permissionInfo.siteCheckAll=e===this.permissionInfo.sitePermissions.length,this.permissionInfo.isSiteIndeterminate=e>0&&e<this.permissionInfo.sitePermissions.length},getSitePermissionText:function(s){for(var e=0;e<this.permissionInfo.sitePermissions.length;e++)if(this.permissionInfo.sitePermissions[e].name===s)return this.permissionInfo.sitePermissions[e].text;return""},handleChannelCheckAllChange:function(s){if(this.permissionInfo.checkedChannelPermissions=[],s)for(var e=0;e<this.permissionInfo.channelPermissions.length;e++)this.permissionInfo.checkedChannelPermissions.push(this.permissionInfo.channelPermissions[e].name);this.permissionInfo.isChannelIndeterminate=!1},handleContentCheckAllChange:function(s){if(this.permissionInfo.checkedContentPermissions=[],s)for(var e=0;e<this.permissionInfo.contentPermissions.length;e++)this.permissionInfo.checkedContentPermissions.push(this.permissionInfo.contentPermissions[e].name);this.permissionInfo.isContentIndeterminate=!1},handleTreeChanged:function(){this.permissionInfo.checkedChannelIds=this.$refs.tree.getCheckedKeys()},handleCheckedChannelPermissionsChange:function(s){var e=s.length;this.permissionInfo.channelCheckAll=e===this.permissionInfo.channelPermissions.length,this.permissionInfo.isChannelIndeterminate=e>0&&e<this.permissionInfo.channelPermissions.length},handleCheckedContentPermissionsChange:function(s){var e=s.length;this.permissionInfo.contentCheckAll=e===this.permissionInfo.contentPermissions.length,this.permissionInfo.isContentIndeterminate=e>0&&e<this.permissionInfo.contentPermissions.length},getChannelPermissionText:function(s){for(var e=0;e<this.permissionInfo.channelPermissions.length;e++)if(this.permissionInfo.channelPermissions[e].name===s)return this.permissionInfo.channelPermissions[e].text;return""},getContentPermissionText:function(s){for(var e=0;e<this.permissionInfo.contentPermissions.length;e++)if(this.permissionInfo.contentPermissions[e].name===s)return this.permissionInfo.contentPermissions[e].text;return""},setValues:function(s,e){this.site=s.site,this.permissionInfo=this.getPermissionInfo(s),this.treeData=[this.permissionInfo.channel],this.defaultExpandedKeys=[this.permissionInfo.channel.id],utils.loading(this,!1),this.isSite=!!e,this.isSite&&(this.permissionInfo.checkedChannelIds=e.channelIds,this.permissionInfo.checkedChannelPermissions=e.channelPermissions,this.permissionInfo.checkedContentPermissions=e.contentPermissions,this.permissionInfo.checkedSitePermissions=e.permissions)},btnSubmitClick:function(){for(var s=[],e=0;e<parent.$vue.sitePermissions.length;e++)parent.$vue.sitePermissions[e].siteId!=this.siteId&&s.push(parent.$vue.sitePermissions[e]);this.isSite&&s.push({siteId:this.siteId,channelIds:this.permissionInfo.checkedChannelIds,channelPermissions:this.permissionInfo.checkedChannelPermissions,contentPermissions:this.permissionInfo.checkedContentPermissions,permissions:_.union(this.permissionInfo.checkedSitePermissions)}),parent.$vue.sitePermissions=s,utils.closeLayer()},btnCancelClick:function(){utils.closeLayer()}},$vue=new Vue({el:"#main",data:data,methods:methods});