(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-0db5e511"],{"0feb":function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return o})),n.d(t,"a",(function(){return s}));var r=n("b775");function i(e){return Object(r["b"])({url:"/permissions",method:"get",params:e})}function a(e){return Object(r["b"])({url:"/permissions",method:"post",data:e})}function o(e,t){return Object(r["b"])({url:"/permissions/"+e,method:"put",data:t})}function s(e){return Object(r["b"])({url:"/permissions/"+e,method:"delete"})}},2619: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("a-card",{attrs:{bordered:!1}},[n("div",{staticClass:"table-page-search-wrapper"},[n("a-form",{attrs:{layout:"inline"}},[n("a-row",{attrs:{gutter:48}},[n("a-col",{attrs:{md:4,sm:24}},[n("a-input",{attrs:{placeholder:"请输入角色名"},model:{value:e.queryParam.role_name,callback:function(t){e.$set(e.queryParam,"role_name",t)},expression:"queryParam.role_name"}})],1),n("a-col",{attrs:{md:4,sm:24}},[n("span",{staticClass:"table-page-search-submitButtons"},[n("a-button",{attrs:{type:"primary"},on:{click:function(t){return e.$refs.table.refresh(!0)}}},[e._v("查询")]),n("a-button",{staticStyle:{"margin-left":"8px"},on:{click:function(){return e.queryParam={}}}},[e._v("重置")])],1)])],1)],1)],1),n("div",{staticClass:"table-operator"},[n("a-button",{attrs:{type:"primary",icon:"plus"},on:{click:function(t){return e.$refs.roleModal.add()}}},[e._v("新建")])],1),n("s-table",{ref:"table",attrs:{size:"default",rowKey:"id",bordered:!0,columns:e.columns,data:e.loadData,showPagination:!1},scopedSlots:e._u([{key:"action",fn:function(t,r){return n("span",{},[[n("a",{on:{click:function(t){return e.handleEdit(r)}}},[e._v("编辑")]),n("a-divider",{attrs:{type:"vertical"}}),n("a",{on:{click:function(t){return e.handleAddSon(r)}}},[e._v("新增子角色")]),n("a-divider",{attrs:{type:"vertical"}}),n("a",{on:{click:function(t){return e.handleDel(r)}}},[e._v("删除")])]],2)}}])}),n("create-role",{ref:"roleModal",on:{ok:e.handleOk}})],1)},i=[],a=(n("0d03"),n("c1df")),o=n.n(a),s=n("2af9"),c=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("a-modal",{attrs:{title:e.title,width:640,visible:e.visible,confirmLoading:e.confirmLoading},on:{ok:e.handleSubmit,cancel:e.handleCancel}},[n("a-spin",{attrs:{spinning:e.confirmLoading}},[n("a-form",{attrs:{form:e.form}},[n("a-form-item",{attrs:{label:"角色名称",type:"text",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[n("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["role_name",{rules:[{required:!0,min:3,message:"请输入至少3个字符!"}]}],expression:"['role_name', {rules: [{required: true, min: 3, message: '请输入至少3个字符!'}]}]"}]})],1),n("a-form-item",{attrs:{label:"描述",type:"textarea",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[n("a-textarea",{directives:[{name:"decorator",rawName:"v-decorator",value:["description"],expression:"['description']"}]})],1),n("a-form-item",{attrs:{label:"权限",labelCol:e.labelCol,wrapperCol:e.wrapperCol}},[n("a-tree",{attrs:{checkable:"",checkStrictly:"",treeData:e.permissions,checkedKeys:e.permissionids},on:{check:this.onCheck}})],1)],1)],1)],1)},l=[],u=(n("99af"),n("4de4"),n("4160"),n("c975"),n("d81d"),n("159b"),n("cc5e")),d=n("88bc"),f=n.n(d),h=n("0feb"),m={data:function(){return{labelCol:{xs:{span:24},sm:{span:7}},wrapperCol:{xs:{span:24},sm:{span:13}},visible:!1,title:"新建角色",confirmLoading:!1,id:null,parent_id:0,form:this.$form.createForm(this),permissions:[],permissionids:[]}},methods:{add:function(){this.visible=!0,this.title="新增角色",this.getPermissions()},edit:function(e){this.visible=!0,this.title="编辑角色";var t=this.form.setFieldsValue;this.id=e.id,this.getRolePermissions(this.id),this.getPermissions(e.parent_id>0?{role_id:e.parent_id}:{}),t(f()(e,["role_name","description","permissions"]))},addSon:function(e){this.visible=!0,this.title="新增子角色 ("+e.role_name+")",this.parent_id=e.id,this.getPermissions({role_id:this.parent_id})},getRolePermissions:function(e){var t=this;Object(u["c"])(e).then((function(e){var n=e.data.permissions;n.map((function(e){t.permissionids.push(e.id)}))}))},getPermissions:function(e){var t=this;Object(h["b"])(e).then((function(e){t.permissions=t.resetPermissions(e.data)}))},handleSubmit:function(){var e=this,t=this.form.validateFields;this.confirmLoading=!0,this.id?t((function(t,n){t||(n["permissions"]=e.permissionids,Object(u["e"])(e.id,n).then((function(t){e.refresh(t.message)})).catch((function(t){return e.failed(t)})))})):t((function(t,n){t||(n["permissions"]=e.permissionids,e.parent_id>0&&(n["parent_id"]=e.parent_id),Object(u["d"])(n).then((function(t){e.refresh(t.message)})).catch((function(t){return e.failed(t)})))}))},failed:function(e){this.$notification["error"]({message:e.message,duration:4}),this.handleCancel()},handleCancel:function(){this.visible=!1,this.id=null,this.confirmLoading=!1,this.parent_id=0,this.permissionids=[],this.form.resetFields()},refresh:function(e){this.$notification["success"]({message:e,duration:4}),this.handleCancel(),this.$parent.$parent.handleOk()},resetPermissions:function(e){var t=this;return e.map((function(e){e.title=e.permission_name,e.key=e.id,e.children&&t.resetPermissions(e.children)})),e},onCheck:function(e,t){var n=t.node.dataRef,r=[];r.push(n.id),n.hasOwnProperty("children")&&this.getAllLeaf(n.children,r),t.checked?this.permissionids=this.permissionids.concat(r):this.permissionids=this.permissionids.filter((function(e){return-1===r.indexOf(e)}))},getAllLeaf:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.forEach((function(e){n.push(e.id),e.hasOwnProperty("children")&&t.getAllLeaf(e.children,n)}))}}},p=m,b=n("2877"),v=Object(b["a"])(p,c,l,!1,null,null,null),g=v.exports,y={name:"Roles",components:{STable:s["f"],CreateRole:g},data:function(){var e=this;return{queryParam:{},columns:[{title:"角色名称",dataIndex:"role_name"},{title:"描述",dataIndex:"description"},{title:"创建时间",dataIndex:"created_at",sorter:!0},{title:"更新时间",dataIndex:"updated_at",sorter:!0},{title:"操作",dataIndex:"action",width:"150px",scopedSlots:{customRender:"action"}}],loadData:function(t){return Object(u["b"])(Object.assign(t,e.queryParam)).then((function(e){return e}))}}},methods:{handleEdit:function(e){this.$refs.roleModal.edit(e)},handleAddSon:function(e){this.$refs.roleModal.addSon(e)},handleDel:function(e){var t=this;this.$confirm({title:"确定删除"+e.username+"吗?",okText:"确定",okType:"danger",cancelText:"取消",onOk:function(){Object(u["a"])(e.id).then((function(e){t.$notification["success"]({message:e.message,duration:4}),t.handleOk()})).catch((function(e){return t.failed(e)}))},onCancel:function(){}})},handleOk:function(){this.$refs.table.refresh(!0)},failed:function(e){this.$notification["error"]({message:e.message,duration:4}),this.handleCancel()},resetSearchForm:function(){this.queryParam={date:o()(new Date)}}}},O=y,_=Object(b["a"])(O,r,i,!1,null,null,null);t["default"]=_.exports},"88bc":function(e,t,n){(function(t){var n=1/0,r=9007199254740991,i="[object Arguments]",a="[object Function]",o="[object GeneratorFunction]",s="[object Symbol]",c="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,u=c||l||Function("return this")();function d(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function f(e,t){var n=-1,r=e?e.length:0,i=Array(r);while(++n0&&n(s)?t>1?_(s,t-1,n,r,i):h(i,s):r||(i[i.length]=s)}return i}function j(e,t){return e=Object(e),w(e,t,(function(t,n){return n in e}))}function w(e,t,n){var r=-1,i=t.length,a={};while(++r-1&&e%1==0&&e<=r}function F(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function D(e){return!!e&&"object"==typeof e}function E(e){return"symbol"==typeof e||D(e)&&b.call(e)==s}var I=k((function(e,t){return null==e?{}:j(e,f(_(t,1),x))}));e.exports=I}).call(this,n("c8ba"))},cc5e:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"d",(function(){return a})),n.d(t,"c",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n("b775");function i(e){return Object(r["b"])({url:"/roles",method:"get",params:e})}function a(e){return Object(r["b"])({url:"/roles",method:"post",data:e})}function o(e){return Object(r["b"])({url:"/roles/"+e,method:"get"})}function s(e,t){return Object(r["b"])({url:"/roles/"+e,method:"put",data:t})}function c(e){return Object(r["b"])({url:"/roles/"+e,method:"delete"})}}}]);