(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-60ea34e1"],{"2c6e":function(e,t,s){"use strict";s.r(t);var i=s("9ab4"),r=s("1b40"),a=s("68eb"),n=s("4201");let o=class extends r.e{constructor(){super(...arguments),this.mode=n.e.ADD,this.identity=null,this.form={name:"",auth_keys:[],desc:""},this.permissionsTree=[],this.rules={name:[{required:!0,message:"必填项不可为空",trigger:"blur"}]}}handlePermissionsCheckChange(e,t){if(!e.auth_key)return;const s=this.form.auth_keys.findIndex(t=>t==e.auth_key);t?-1==s&&this.form.auth_keys.push(e.auth_key):-1!=s&&this.form.auth_keys.splice(s,1)}submitForm(e){this.$refs[e].validate(e=>{if(!e)return this.$message.error("请完善信息");switch(this.mode){case n.e.ADD:return this.handleRoleAdd();case n.e.EDIT:return this.handleRoleEdit()}})}handleRoleAdd(){const e=this.form;Object(a.g)(e).then(()=>{setTimeout(()=>this.$router.go(-1),500)}).catch(()=>{})}handleRoleEdit(){const e=this.form,t=this.identity;Object(a.j)({...e,id:t}).then(()=>{setTimeout(()=>this.$router.go(-1),500)}).catch(()=>{})}initFormDataForRoleEdit(){const e=this.identity;Object(a.i)({id:e}).then(e=>{Object.keys(e).map(t=>{this.$set(this.form,t,e[t])}),this.form.auth_keys=[];this.$refs.permissionsTree.setCheckedKeys(e.auth_keys)}).catch(()=>{})}getAuthMenu(){Object(a.f)().then(e=>{this.permissionsTree=e,this.allAuthKey=this.getAuthKey()})}allSelect(){this.$refs.permissionsTree.setCheckedKeys(this.allAuthKey)}cancelAllSelect(){this.$refs.permissionsTree.setCheckedKeys([])}getAuthKey(e=this.permissionsTree){return e.reduce((e,t)=>(t.auth_key&&e.push(t.auth_key),t.sons&&e.push(...this.getAuthKey(t.sons)),e),[])}created(){const e=this.$route.query;e.mode&&(this.mode=e.mode),this.mode===n.e.EDIT&&(this.identity=1*e.id,this.initFormDataForRoleEdit()),this.getAuthMenu()}};o=Object(i.a)([r.a],o);var l=o,u=(s("d40c"),s("2877")),c=Object(u.a)(l,(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"ls-add-role"},[s("div",{staticClass:"ls-card"},[s("el-page-header",{attrs:{content:"编辑角色"},on:{back:function(t){return e.$router.go(-1)}}})],1),s("div",{staticClass:"ls-card m-t-10"},[s("el-form",{ref:"form",attrs:{model:e.form,rules:e.rules,"label-width":"120px",size:"small"}},[s("el-form-item",{attrs:{label:"名称",required:"",prop:"name"}},[s("el-input",{staticClass:"ls-input",attrs:{maxlength:"8","show-word-limit":"",placeholder:"请输入名称"},model:{value:e.form.name,callback:function(t){e.$set(e.form,"name",t)},expression:"form.name"}})],1),s("el-form-item",{attrs:{label:"描述"}},[s("el-input",{staticClass:"ls-input",attrs:{type:"textarea",autosize:{minRows:3,maxRows:4},placeholder:"请描述一下该角色"},model:{value:e.form.desc,callback:function(t){e.$set(e.form,"desc",t)},expression:"form.desc"}})],1),s("el-form-item",{attrs:{label:"权限"}},[s("div",[s("el-button",{attrs:{type:"text"},on:{click:e.allSelect}},[e._v("全选")]),s("el-button",{attrs:{type:"text"},on:{click:e.cancelAllSelect}},[e._v("不全选")])],1),s("el-tree",{ref:"permissionsTree",attrs:{data:e.permissionsTree,"node-key":"auth_key","icon-class":"el-icon-arrow-right",props:{children:"sons",label:"name"},"empty-text":"","show-checkbox":"","default-expand-all":""},on:{"check-change":e.handlePermissionsCheckChange}})],1)],1)],1),s("div",{staticClass:"bg-white ls-fixed-footer"},[s("div",{staticClass:"row-center flex",staticStyle:{height:"100%"}},[s("el-button",{attrs:{size:"small"},on:{click:function(t){return e.$router.go(-1)}}},[e._v("取消")]),s("el-button",{attrs:{size:"small",type:"primary"},on:{click:function(t){return e.submitForm("form")}}},[e._v("保存")])],1)])])}),[],!1,null,"1965775e",null);t.default=c.exports},"51f7":function(e,t,s){},"68eb":function(e,t,s){"use strict";s.d(t,"e",(function(){return r})),s.d(t,"c",(function(){return a})),s.d(t,"a",(function(){return n})),s.d(t,"b",(function(){return o})),s.d(t,"d",(function(){return l})),s.d(t,"k",(function(){return u})),s.d(t,"i",(function(){return c})),s.d(t,"g",(function(){return h})),s.d(t,"j",(function(){return d})),s.d(t,"h",(function(){return m})),s.d(t,"f",(function(){return f}));var i=s("f175");const r=e=>i.a.get("/auth.admin/lists",{params:e}),a=e=>i.a.get("/auth.admin/detail",{params:e}),n=e=>i.a.post("/auth.admin/add",e),o=e=>i.a.post("/auth.admin/delete",e),l=e=>i.a.post("/auth.admin/edit",e),u=e=>i.a.get("/auth.role/lists",{params:e}),c=e=>i.a.get("/auth.role/detail",{params:e}),h=e=>i.a.post("/auth.role/add",e),d=e=>i.a.post("/auth.role/edit",e),m=e=>i.a.post("/auth.role/delete",e),f=()=>i.a.post("/config/getMenu")},d40c:function(e,t,s){"use strict";s("51f7")}}]);