"use strict";(self["webpackChunkerp"]=self["webpackChunkerp"]||[]).push([[551],{796:function(e,t,i){i.r(t),i.d(t,{default:function(){return c}});var s=function(){var e=this,t=e._self._c;return t("div",{staticClass:"pageBox"},[t("el-card",[t("div",{staticClass:"opaBox"},[t("el-button",{attrs:{type:"primary",icon:"el-icon-plus"},on:{click:function(t){e.dialogVisible2=!0}}},[e._v("新增")])],1),t("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticStyle:{width:"100%"},attrs:{data:e.tableList,border:""}},[t("el-table-column",{attrs:{prop:"id",label:"ID",width:"100",align:"center"}}),t("el-table-column",{attrs:{prop:"name",label:"角色名称",width:"200",align:"center"}}),t("el-table-column",{attrs:{label:"权限内容"},scopedSlots:e._u([{key:"default",fn:function(i){return e._l(i.row.permissions,(function(i){return t("span",{key:i.id},[e._v(e._s(i.name)),t("span",{staticStyle:{color:"#333"}},[e._v(" | ")])])}))}}])}),t("el-table-column",{attrs:{label:"操作",width:"200",align:"center"},scopedSlots:e._u([{key:"default",fn:function(i){return[t("el-button",{attrs:{type:"primary",icon:"el-icon-edit"},on:{click:function(t){return e.onEdit(i.row)}}},[e._v("编辑权限")])]}}])})],1)],1),t("el-dialog",{attrs:{title:"编辑权限",visible:e.dialogVisible,width:"30%","close-on-click-modal":!1},on:{"update:visible":function(t){e.dialogVisible=t}}},[e.isShowtree?t("el-tree",{ref:"tree",attrs:{data:e.Role_Permission,"show-checkbox":"","default-expand-all":!1,"node-key":"id","highlight-current":"",props:e.defaultProps,"default-checked-keys":e.chekedKeys},model:{value:e.permissionIds,callback:function(t){e.permissionIds=t},expression:"permissionIds"}}):e._e(),t("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(t){return e.cancel()}}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.getCheckedKeys()}}},[e._v("确 定")])],1)],1),t("el-dialog",{attrs:{title:"新增角色",visible:e.dialogVisible2,width:"30%","close-on-click-modal":!1},on:{"update:visible":function(t){e.dialogVisible2=t}}},[t("el-form",{attrs:{"label-width":"80px"}},[t("el-form-item",{attrs:{label:"角色名称"}},[t("el-input",{model:{value:e.newrole,callback:function(t){e.newrole=t},expression:"newrole"}})],1),t("div",{staticClass:"from-btn"},[t("el-button",{on:{click:function(t){e.dialogVisible2=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.onSubmit}},[e._v("确认")])],1)],1)],1)],1)},l=[],n=i(730),o={data(){return{id:"",loading:!0,tableList:[],rolePermissions:[],newrole:"",dialogVisible:!1,dialogVisible2:!1,permissionIds:[],allpermissionIds:{},Role_Permission:[],defaultProps:{children:"children",label:"name"},isShowtree:!1,chekedKeys:[]}},mounted(){this.getroleList(),this.getJurisdiction()},methods:{getroleList(){(0,n.Uy)().then((e=>{this.tableList=e.data.data})),this.loading=!1},getJurisdiction(){(0,n.CI)().then((e=>{this.Role_Permission=e.data.data}))},onSubmit(){let e={name:this.newrole};(0,n.cs)(e).then((e=>{this.dialogVisible2=!1,this.getroleList(),201==e.status&&this.$message({message:"角色添加成功！",type:"success"})}))},onEdit(e){this.id=e.id;let t=e.permissions.map((e=>e.id));this.chekedKeys=t,this.dialogVisible=!0,this.isShowtree=!0},cancel(){this.dialogVisible=!1,this.isShowtree=!1},getCheckedKeys(){let e=this.id;this.permissionIds=this.$refs.tree.getCheckedKeys(),this.allpermissionIds={permissionIds:this.permissionIds},(0,n.VU)(e,this.allpermissionIds).then((e=>{200===e.status&&(this.dialogVisible=!1,this.getroleList(),this.$message({message:"权限修改成功！",type:"success"}))}))}}},r=o,a=i(1001),d=(0,a.Z)(r,s,l,!1,null,"7c920912",null),c=d.exports},730:function(e,t,i){i.d(t,{CI:function(){return o},Uy:function(){return l},VU:function(){return r},Xt:function(){return a},cs:function(){return n}});var s=i(8430);function l(){return(0,s.Z)({url:"/api/roles",method:"get"})}function n(e){return(0,s.Z)({url:"/api/roles",method:"post",data:e})}function o(){return(0,s.Z)({url:"/api/permissions",method:"get"})}function r(e,t){return(0,s.Z)({url:`/api/roles/${e}/permissions`,method:"post",data:t})}function a(){return(0,s.Z)({url:"/api/user/user_roles",method:"get"})}}}]);
//# sourceMappingURL=551.d3396e3a.js.map