(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5ccefbbb"],{"1de5":function(t,e,a){},4635:function(t,e,a){"use strict";a.r(e);var s=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("Card",[t.isOperator?t._e():a("div",{attrs:{slot:"title"},slot:"title"},[a("Select",{staticStyle:{width:"200px"},attrs:{placeholder:"请选择要授权的应用"},on:{"on-change":t.onchange},model:{value:t.selAppId,callback:function(e){t.selAppId=e},expression:"selAppId"}},t._l(t.myapps,(function(e){return a("Option",{key:e.title,attrs:{value:e.id}},[t._v(t._s(e.title))])})),1)],1),a("Tree",{staticClass:"ptree",attrs:{data:t.treedata,render:t.renderContent}})],1)],1)},n=[],o=a("aca2"),r=o["a"],i=(a("83d8"),a("9ca4")),c=Object(i["a"])(r,s,n,!1,null,null,null);e["default"]=c.exports},"83d8":function(t,e,a){"use strict";var s=a("1de5"),n=a.n(s);n.a},aca2:function(t,e,a){"use strict";(function(t){a("e697"),a("9a33"),a("6d57");var s=a("60b7"),n=a("e247");a("f121");e["a"]={name:"roleauth_page",data:function(){return{myapps:JSON.parse(localStorage.getItem("myapps")),selAppId:"",roleid:-1,rolecode:"",roleauths:null,treedata:[],buttonProps:{type:"default",size:"small"}}},components:{Checks:n["a"]},computed:{authdic:function(){var t={};return this.roleauths.forEach((function(e){t[e.bizcode]=e.authstrs.split(",")})),t},isOperator:function(){return 1==this.$store.state.user.userobj.company.id}},mounted:function(){this.roleid=this.$route.query.roleid,this.rolecode=this.$route.query.rolecode,this.isOperator&&this.initTree()},methods:{onchange:function(t){var e=this,a=this.myapps.filter((function(e){return e.id==t}));this.treedata=JSON.parse(a[0].functionJSON),Object(s["c"])([this.roleid]).then((function(t){var a=t.data;0==a.status?(e.roleauths=a.data,e.setAuthData(e.treedata)):console.log("fetch auths fails.....---------------------------------------------------------")}))},initTree:function(){var t=this;Object(s["d"])().then((function(e){var a=e.data;0==a.status&&(t.treedata=a.data.funcJson,Object(s["c"])([t.roleid]).then((function(e){var a=e.data;0==a.status?(t.roleauths=a.data,t.setAuthData(t.treedata)):console.log("fetch auths fails.....---------------------------------------------------------")})))}))},setAuthData:function(t){var e=this;t.forEach((function(t){t.children&&t.children.length>0?e.setAuthData(t.children):t.sels?t.sels=e.authdic[t.code]?e.authdic[t.code]:[]:t.sels=[]}))},makeauths:function(t,e){var a=this;console.log(t,"makeauths"),t.forEach((function(t){if(t.children&&t.children.length>0)a.makeauths(t.children,e);else if(t.sels){var s={role_id:a.roleid,rolecode:a.rolecode,bizcode:t.code,codepath:t.orgpath,authstrs:t.sels.join(",")};e.push(s)}}))},saveAuths:function(){var t=this,e=[];this.makeauths(this.treedata,e),Object(s["h"])(e).then((function(e){var a=e.data;0==a.status?(t.roleauths=a.data,t.$Message.success("当前操作成功完成")):t.$Message.success("当前操作未完成，请稍后重试或联系管理员")}))},refreshFunc:function(){},renderContent:function(e,a){var s=this,n=a.root,o=a.node,r=a.data,i=n.find((function(t){return t===o})).parent;return console.log(i),e("span",{style:{display:"inline-block",width:"100%",cursor:"pointer"},on:{click:function(e){t("span",".ptree").removeClass("spansel"),t(e.target).addClass("spansel")}}},[e("span",[e("Icon",{props:{type:r.auths?"ios-paper-outline":"ios-folder-outline"},style:{marginRight:"8px"}}),e("span",r.title)]),e("span",{style:{display:"inline-block",float:"right",marginRight:"100px"}},[r.auths&&r.auths.length>0?e("Checkbox",{on:{"on-change":function(t){t?(console.log(r.auths),r.sels=r.auths):r.sels=[]}},style:{display:"inline-block",float:"left",marginRight:"10px",marginTop:"3px"}},[e("span",["all"])]):r.code.indexOf("root")>=0?e("span",[e("Button",{props:{type:"primary"},on:{click:function(){s.saveAuths()}}},["保存"]),e("Button",{props:{type:"text"},on:{click:function(){s.refreshFunc()}}},["刷新"])]):"",r.auths&&r.auths.length>0?e("CheckboxGroup",{props:{value:r.sels},on:{"on-change":function(t){r.sels=t}}},[r.auths.map((function(t){return e("Checkbox",{props:{label:t}},[e("span",[t])])}))]):""])])}}}}).call(this,a("a336"))}}]);