text: (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-edacdbae"],{b852:function(e,t,r){"use strict";var n=r("ddc0"),i=r.n(n);i.a},d78e:function(e,t,r){"use strict";r.r(t);var n=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"app-container"},[r("el-button",{attrs:{type:"primary"},on:{click:e.handleAddRole}},[e._v("新站点")]),e._v(" "),r("el-table",{staticStyle:{width:"100%","margin-top":"30px"},attrs:{data:e.rolesList,border:""}},[r("el-table-column",{attrs:{align:"center",label:"站点名称",width:"220"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v("\n        "+e._s(t.row.key)+"\n      ")]}}])}),e._v(" "),r("el-table-column",{attrs:{align:"center",label:"Role Name",width:"220"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v("\n        "+e._s(t.row.name)+"\n      ")]}}])}),e._v(" "),r("el-table-column",{attrs:{align:"header-center",label:"描述"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v("\n        "+e._s(t.row.description)+"\n      ")]}}])}),e._v(" "),r("el-table-column",{attrs:{align:"center",label:"管理 "},scopedSlots:e._u([{key:"default",fn:function(t){return[r("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(r){return e.handleEdit(t)}}},[e._v("编辑")]),e._v(" "),r("el-button",{attrs:{type:"danger",size:"small"},on:{click:function(r){return e.handleDelete(t)}}},[e._v("删除")])]}}])})],1),e._v(" "),r("el-dialog",{attrs:{visible:e.dialogVisible,title:"edit"===e.dialogType?"Edit Role":"New Role"},on:{"update:visible":function(t){e.dialogVisible=t}}},[r("el-form",{attrs:{model:e.role,"label-width":"80px","label-position":"left"}},[r("el-form-item",{attrs:{label:"Name"}},[r("el-input",{attrs:{placeholder:"Role Name"},model:{value:e.role.name,callback:function(t){e.$set(e.role,"name",t)},expression:"role.name"}})],1),e._v(" "),r("el-form-item",{attrs:{label:"Desc"}},[r("el-input",{attrs:{autosize:{minRows:2,maxRows:4},type:"textarea",placeholder:"Role Description"},model:{value:e.role.description,callback:function(t){e.$set(e.role,"description",t)},expression:"role.description"}})],1),e._v(" "),r("el-form-item",{attrs:{label:"Menus"}},[r("el-tree",{ref:"tree",staticClass:"permission-tree",attrs:{"check-strictly":e.checkStrictly,data:e.routesData,props:e.defaultProps,"show-checkbox":"","node-key":"path"}})],1)],1),e._v(" "),r("div",{staticStyle:{"text-align":"right"}},[r("el-button",{attrs:{type:"danger"},on:{click:function(t){e.dialogVisible=!1}}},[e._v("取消")]),e._v(" "),r("el-button",{attrs:{type:"primary"},on:{click:e.confirmRole}},[e._v("确定")])],1)],1)],1)},i=[],a=r("db72"),o=(r("7f7f"),r("6762"),r("2fdb"),r("75fc")),l=(r("ac4d"),r("8a81"),r("ac6a"),r("96cf"),r("3b8d")),s=r("df7c"),c=r.n(s),u=r("ed08"),d=r("b775");function h(){return Object(d["a"])({url:"/routes",method:"get"})}function f(){return Object(d["a"])({url:"/roles",method:"get"})}function p(e){return Object(d["a"])({url:"/role",method:"post",data:e})}function v(e,t){return Object(d["a"])({url:"/role/".concat(e),method:"put",data:t})}function g(e){return Object(d["a"])({url:"/role/".concat(e),method:"delete"})}var b={key:"",name:"",description:"",routes:[]},m={data:function(){return{role:Object.assign({},b),routes:[],rolesList:[],dialogVisible:!1,dialogType:"new",checkStrictly:!1,defaultProps:{children:"children",label:"title"}}},computed:{routesData:function(){return this.routes}},created:function(){this.getRoutes(),this.getRoles()},methods:{getRoutes:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,h();case 2:t=e.sent,this.serviceRoutes=t.data,this.routes=this.generateRoutes(t.data);case 5:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}(),getRoles:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,f();case 2:t=e.sent,this.rolesList=t.data;case 4:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}(),generateRoutes:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",r=[],n=!0,i=!1,a=void 0;try{for(var o,l=e[Symbol.iterator]();!(n=(o=l.next()).done);n=!0){var s=o.value;if(!s.hidden){var u=this.onlyOneShowingChild(s.children,s);s.children&&u&&!s.alwaysShow&&(s=u);var d={path:c.a.resolve(t,s.path),title:s.meta&&s.meta.title};s.children&&(d.children=this.generateRoutes(s.children,d.path)),r.push(d)}}}catch(h){i=!0,a=h}finally{try{n||null==l.return||l.return()}finally{if(i)throw a}}return r},generateArr:function(e){var t=this,r=[];return e.forEach((function(e){if(r.push(e),e.children){var n=t.generateArr(e.children);n.length>0&&(r=[].concat(Object(o["a"])(r),Object(o["a"])(n)))}})),r},handleAddRole:function(){this.role=Object.assign({},b),this.$refs.tree&&this.$refs.tree.setCheckedNodes([]),this.dialogType="new",this.dialogVisible=!0},handleEdit:function(e){var t=this;this.dialogType="edit",this.dialogVisible=!0,this.checkStrictly=!0,this.role=Object(u["c"])(e.row),this.$nextTick((function(){var e=t.generateRoutes(t.role.routes);t.$refs.tree.setCheckedNodes(t.generateArr(e)),t.checkStrictly=!1}))},handleDelete:function(e){var t=this,r=e.$index,n=e.row;this.$confirm("Confirm to remove the role?","Warning",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"warning"}).then(Object(l["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,g(n.key);case 2:t.rolesList.splice(r,1),t.$message({type:"success",message:"Delete succed!"});case 4:case"end":return e.stop()}}),e)})))).catch((function(e){console.error(e)}))},generateTree:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",r=arguments.length>2?arguments[2]:void 0,n=[],i=!0,a=!1,o=void 0;try{for(var l,s=e[Symbol.iterator]();!(i=(l=s.next()).done);i=!0){var u=l.value,d=c.a.resolve(t,u.path);u.children&&(u.children=this.generateTree(u.children,d,r)),(r.includes(d)||u.children&&u.children.length>=1)&&n.push(u)}}catch(h){a=!0,o=h}finally{try{i||null==s.return||s.return()}finally{if(a)throw o}}return n},confirmRole:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(){var t,r,n,i,a,o,l,s,c;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(t="edit"===this.dialogType,r=this.$refs.tree.getCheckedKeys(),this.role.routes=this.generateTree(Object(u["c"])(this.serviceRoutes),"/",r),!t){e.next=16;break}return e.next=6,v(this.role.key,this.role);case 6:n=0;case 7:if(!(n<this.rolesList.length)){e.next=14;break}if(this.rolesList[n].key!==this.role.key){e.next=11;break}return this.rolesList.splice(n,1,Object.assign({},this.role)),e.abrupt("break",14);case 11:n++,e.next=7;break;case 14:e.next=22;break;case 16:return e.next=18,p(this.role);case 18:i=e.sent,a=i.data,this.role.key=a.key,this.rolesList.push(this.role);case 22:o=this.role,l=o.description,s=o.key,c=o.name,this.dialogVisible=!1,this.$notify({title:"Success",dangerouslyUseHTMLString:!0,message:"\n            <div>Role Key: ".concat(s,"</div>\n            <div>Role Name: ").concat(c,"</div>\n            <div>Description: ").concat(l,"</div>\n          "),type:"success"});case 25:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}(),onlyOneShowingChild:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=null,n=e.filter((function(e){return!e.hidden}));return 1===n.length?(r=n[0],r.path=c.a.resolve(t.path,r.path),r):0===n.length&&(r=Object(a["a"])({},t,{path:"",noShowingChildren:!0}),r)}}},y=m,k=(r("b852"),r("2877")),w=Object(k["a"])(y,n,i,!1,null,"65acf81f",null);t["default"]=w.exports},ddc0:function(e,t,r){}}]);