text: (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-e275651a"],{7197:function(e,t,n){},cc5e:function(e,t,n){"use strict";n.d(t,"d",(function(){return l})),n.d(t,"c",(function(){return u})),n.d(t,"a",(function(){return d})),n.d(t,"e",(function(){return h})),n.d(t,"b",(function(){return f}));var r=n("2909"),i=(n("99af"),n("b775")),a=n("a18c"),o=n("ed08"),s=o.deepClone,c=s([].concat(Object(r["a"])(a["b"]),Object(r["a"])(a["a"])));function l(){return{data:c}}function u(){return Object(i["a"])({url:"/api/auth/roles",method:"get"})}function d(e){return Object(i["a"])({url:"/api/auth/roles",method:"post",data:e})}function h(e,t){return Object(i["a"])({url:"/api/auth/roles",method:"put",data:t})}function f(e){return Object(i["a"])({url:"/api/auth/roles/".concat(e),method:"delete"})}},d78e:function(e,t,n){"use strict";n.r(t);var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-container"},[n("el-button",{attrs:{type:"primary"},on:{click:e.handleAddRole}},[e._v(" "+e._s(e.$t("permission.addRole"))+" ")]),n("el-table",{staticStyle:{width:"100%","margin-top":"30px"},attrs:{data:e.rolesList,border:""}},[n("el-table-column",{attrs:{align:"center",label:"Role Key",width:"220"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.key)+" ")]}}])}),n("el-table-column",{attrs:{align:"center",label:"Role Name",width:"220"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.name)+" ")]}}])}),n("el-table-column",{attrs:{align:"header-center",label:"Description"},scopedSlots:e._u([{key:"default",fn:function(t){return[e._v(" "+e._s(t.row.description)+" ")]}}])}),n("el-table-column",{attrs:{align:"center",label:"Operations"},scopedSlots:e._u([{key:"default",fn:function(t){return[n("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(n){return e.handleEdit(t)}}},[e._v(" "+e._s(e.$t("permission.editPermission"))+" ")]),n("el-button",{attrs:{type:"danger",size:"small"},on:{click:function(n){return e.handleDelete(t)}}},[e._v(" "+e._s(e.$t("permission.delete"))+" ")])]}}])})],1),n("el-dialog",{attrs:{visible:e.dialogVisible,title:"edit"===e.dialogType?"Edit Role":"New Role"},on:{"update:visible":function(t){e.dialogVisible=t}}},[n("el-form",{attrs:{model:e.role,"label-width":"80px","label-position":"left"}},[n("el-form-item",{attrs:{label:"Name"}},[n("el-input",{attrs:{placeholder:"Role Name"},model:{value:e.role.name,callback:function(t){e.$set(e.role,"name",t)},expression:"role.name"}})],1),n("el-form-item",{attrs:{label:"Desc"}},[n("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),n("el-form-item",{attrs:{label:"Menus"}},[n("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),n("div",{staticStyle:{"text-align":"right"}},[n("el-button",{attrs:{type:"danger"},on:{click:function(t){e.dialogVisible=!1}}},[e._v(" "+e._s(e.$t("permission.cancel"))+" ")]),n("el-button",{attrs:{type:"primary"},on:{click:e.confirmRole}},[e._v(" "+e._s(e.$t("permission.confirm"))+" ")])],1)],1)],1)},i=[],a=n("5530"),o=n("2909"),s=n("b85c"),c=n("1da1"),l=(n("d81d"),n("159b"),n("99af"),n("a434"),n("caad"),n("2532"),n("b0c0"),n("a4d3"),n("e01a"),n("4de4"),n("96cf"),n("df7c")),u=n.n(l),d=n("ed08"),h=n("cc5e"),f=n("9923"),p={key:"",name:"",description:"",routes:[]},m={data:function(){return{role:Object.assign({},p),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=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,Object(h["d"])();case 2:n=t.sent,e.serviceRoutes=n.data,r=e.generateRoutes(n.data),e.routes=e.i18n(r);case 6:case"end":return t.stop()}}),t)})))()},getRoles:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,Object(h["c"])();case 2:n=t.sent,e.rolesList=n;case 4:case"end":return t.stop()}}),t)})))()},i18n:function(e){var t=this,n=e.map((function(e){return e.title=f["a"].t("route.".concat(e.title)),e.children&&(e.children=t.i18n(e.children)),e}));return n},generateRoutes:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",r=[],i=Object(s["a"])(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;if(!a.hidden){var o=this.onlyOneShowingChild(a.children,a);a.children&&o&&!a.alwaysShow&&(a=o);var c={path:u.a.resolve(n,a.path),title:a.meta&&a.meta.title};a.children&&(c.children=this.generateRoutes(a.children,c.path)),r.push(c)}}}catch(l){i.e(l)}finally{i.f()}return r},generateArr:function(e){var t=this,n=[];return e.forEach((function(e){if(n.push(e),e.children){var r=t.generateArr(e.children);r.length>0&&(n=[].concat(Object(o["a"])(n),Object(o["a"])(r)))}})),n},handleAddRole:function(){this.role=Object.assign({},p),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(d["deepClone"])(e.row),this.$nextTick((function(){if(t.$refs.tree.setCheckedNodes([]),t.role.routes){var e=JSON.parse(t.role.routes),n=t.generateRoutes(e);t.$refs.tree.setCheckedNodes(t.generateArr(n)),t.checkStrictly=!1}}))},handleDelete:function(e){var t=this,n=e.$index,r=e.row;this.$confirm("Confirm to remove the role?","Warning",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"warning"}).then(Object(c["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(h["b"])(r.key);case 2:t.rolesList.splice(n,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,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",r=arguments.length>2?arguments[2]:void 0,i=[],a=Object(s["a"])(e);try{for(a.s();!(t=a.n()).done;){var o=t.value,c=u.a.resolve(n,o.path);o.children&&(o.children=this.generateTree(o.children,c,r)),(r.includes(c)||o.children&&o.children.length>=1)&&i.push(o)}}catch(l){a.e(l)}finally{a.f()}return i},confirmRole:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n,r,i,a,o,s,c,l;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(n="edit"===e.dialogType,r=e.$refs.tree.getCheckedKeys(),e.role.routes=e.generateTree(Object(d["deepClone"])(e.serviceRoutes),"/",r),e.role.routes.map((function(e){if(e.meta&&e.meta.permissions){var t=[];e.children[0].children.map((function(e){t.push(e.name)})),e.meta.permissions=t}})),!n){t.next=17;break}return t.next=7,Object(h["e"])(e.role.key,e.role);case 7:i=0;case 8:if(!(i<e.rolesList.length)){t.next=15;break}if(e.rolesList[i].key!==e.role.key){t.next=12;break}return e.rolesList.splice(i,1,Object.assign({},e.role)),t.abrupt("break",15);case 12:i++,t.next=8;break;case 15:t.next=22;break;case 17:return t.next=19,Object(h["a"])(e.role);case 19:a=t.sent,e.role.key=a.key,e.rolesList.push(e.role);case 22:o=e.role,s=o.description,c=o.key,l=o.name,e.dialogVisible=!1,e.$notify({title:"Success",dangerouslyUseHTMLString:!0,message:"\n            <div>Role Key: ".concat(c,"</div>\n            <div>Role Name: ").concat(l,"</div>\n            <div>Description: ").concat(s,"</div>\n          "),type:"success"});case 25:case"end":return t.stop()}}),t)})))()},onlyOneShowingChild:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=null,r=e.filter((function(e){return!e.hidden}));return 1===r.length?(n=r[0],n.path=u.a.resolve(t.path,n.path),n):0===r.length&&(n=Object(a["a"])(Object(a["a"])({},t),{},{path:"",noShowingChildren:!0}),n)}}},b=m,g=(n("e880"),n("2877")),v=Object(g["a"])(b,r,i,!1,null,"3fcaeeae",null);t["default"]=v.exports},e880:function(e,t,n){"use strict";n("7197")}}]);