import{A as o}from"./ActionBar.1725b1a3.js";import{F as s}from"./FormLayout.c7820bdd.js";import{T as n}from"./TableLayout.05a39499.js";import{D as c}from"./DialogLayout.e3af3567.js";import{S as u}from"./SearchTreeMenu.cf3d6165.js";import{f as h,d as f,c as m,u as d}from"./role.e124e505.js";import{c as _}from"./index.51e15757.js";import{a as p}from"./user.529e3486.js";import{n as v}from"./vueComponentNormalizer.9ef17bb1.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */var b=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("div",{staticClass:"v-page role_page"},[t("SearchTreeMenu",{ref:"treeMenuRef",attrs:{title:"\u89D2\u8272\u5206\u7C7B\u5217\u8868","tree-data":e.role_list},on:{"current-change":e.toChangeRole,onCreate:e.toCreateRole,onDelete:e.toDeleteRole}}),e.active_role?t("div",{staticClass:"v-ctx"},[t("h2",{staticClass:"v-title"},[e._v("\u89D2\u8272\u4FE1\u606F\u7BA1\u7406")]),t("FormLayout",{ref:"formLayoutRef",attrs:{items:e.formItems,model:e.active_role,rules:e.rules,"label-width":"110px","label-position":"right",inline:""},scopedSlots:e._u([{key:"people",fn:function(){return[t("el-button",{attrs:{type:"text",icon:"el-icon-user-solid"},on:{click:function(a){e.show_role_mumber_dialog=!0}}},[e._v(e._s(e.pageInfo.total)+"\u4EBA")])]},proxy:!0}],null,!1,4107167458)}),t("h2",{staticClass:"v-title"},[e._v("\u529F\u80FD\u6743\u9650")]),e.isSystemRole?e._e():t("div",{staticStyle:{"margin-top":"16px"}},[e._v(" \u5728 "),t("el-radio-group",{attrs:{size:"mini"},on:{change:e.changeBaseRole},model:{value:e.active_role.base,callback:function(a){e.$set(e.active_role,"base",a)},expression:"active_role.base"}},e._l(e.role_list[0].children,function(a){return t("el-radio-button",{key:a.id,attrs:{label:a.id}},[e._v(" "+e._s(a.name)+" ")])}),1),e._v(" \u7684\u57FA\u7840\u4E0A\u7F16\u8F91\u6743\u9650 ")],1),e.active_role.base?e._l(e.feature_data,function(a){return t("div",{key:a.name,staticClass:"feature_layout"},[t("div",{staticClass:"feature_title"},[t("el-checkbox",{staticClass:"feature",attrs:{value:a.children.length?a.isCheckAll=e.hasCheckAll(a):e.hasChecked(a,a),label:a.label},on:{change:function(i){a.children.length?e.checkAllFeature(a):e.checkFeature(a)}}})],1),t("div",{staticClass:"feature_children"},e._l(a.children,function(i){return t("el-checkbox",{key:i.name,staticClass:"feature",attrs:{value:e.hasChecked(a,i),label:i.label},on:{change:function(k){return e.checkFeature(i)}}})}),1)])}):e._e(),e.active_role.base?t("ActionBar",{attrs:{center:""},on:{onConfirm:e.onConfirm,onCancel:e.onCancel}}):e._e()],2):e._e(),t("DialogLayout",{attrs:{title:"\u89D2\u8272\u4EBA\u5458\u5217\u8868",width:"60vw",shadowBar:!1,visible:e.show_role_mumber_dialog,actionBarOption:{noCencel:!0,noConfirm:!0}},on:{onCancel:function(a){e.show_role_mumber_dialog=!1}}},[t("TableLayout",{ref:"tableRef",attrs:{height:"50vh",column:e.column,data:e.role_mumber,pageInfo:e.pageInfo},on:{"page-info-change":e.findRoleMember},scopedSlots:e._u([{key:"sex",fn:function(a){var i=a.row;return[e._v(e._s(String(i.sex)?["\u5973","\u7537"][i.sex]:""))]}},{key:"birthday",fn:function(a){var i=a.row;return[e._v(e._s(i.birthday?new Date(i.birthday).format("yyyy-MM-dd"):""))]}},{key:"photo",fn:function(a){var i=a.row;return[i.photoResource?t("img",{attrs:{src:i.photoResource.diskname.fileLinkTransfer(),width:"50",height:"50"}}):e._e()]}}])})],1)],1)},y=[];const g={components:{SearchTreeMenu:u,FormLayout:s,ActionBar:o,DialogLayout:c,TableLayout:n},data:()=>({search:"",role_list:[],feature_data:[],active_role:null,role_mumber:[],show_role_mumber_dialog:!1,pageInfo:{current:1,size:10,total:0}}),computed:{isSystemRole(){return this.active_role&&this.active_role.creator==="SYSTEM"}},watch:{active_role:"findRoleMember"},created(){this.formItems=[{prop:"name",width:"30%",label:"\u89D2\u8272\u540D\u79F0",model:{tag:"el-input"}},{prop:"desc",label:"\u89D2\u8272\u63CF\u8FF0",model:{tag:"el-input",type:"textarea"}},{prop:"people",label:"\u89D2\u8272\u4EBA\u5458"}],this.rules={name:{required:!0,message:"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0",trigger:"blur"}},this.column=[{prop:"username",label:"\u7528\u6237\u540D"},{prop:"name",label:"\u59D3\u540D"},{prop:"photo",label:"\u7167\u7247"},{prop:"sex",label:"\u6027\u522B"},{prop:"birthday",width:"90px",label:"\u51FA\u751F\u5E74\u6708"},{prop:"idcard",label:"\u8EAB\u4EFD\u8BC1\u53F7"},{prop:"identity",label:"\u804C\u4F4D"},{prop:"phone",label:"\u7535\u8BDD"},{prop:"email",label:"\u90AE\u7BB1"}],this.findAllRole()},methods:{async findAllRole(){const{data:e}=await h(),r=[{id:"system",name:"\u7CFB\u7EDF\u9ED8\u8BA4",disabled:!0,children:[]},{id:"custom",name:"\u81EA\u5B9A\u4E49\u89D2\u8272",disabled:!0,children:[]}];this.systemRoleMap={};for(const t of e)t.features=t.features.map(a=>a.name),t.creator==="SYSTEM"?(r[0].children.push(t),this.systemRoleMap[t.id]=t):r[1].children.push(t);this.role_list=r,this.feature_data=_()},async findRoleMember(e){if(!e.id)return this.role_mumber=[];const{data:{list:r,total:t}}=await p({role:e.id,...this.pageInfo});this.role_mumber=r,this.pageInfo.total=t},changeBaseRole(e){this.active_role.features=[...this.systemRoleMap[e].features]},toChangeRole(e){if(e.disabled)return this.onCancel();this.active_role=JSON.parse(JSON.stringify(e))},hasCheckAll(e){if(!this.active_role)return!1;let r=0;for(const i of e.children)this.active_role.features.includes(i.name)&&r++;const t=e.children.length===r,a=this.active_role.features.indexOf(e.name);return r?a===-1&&this.active_role.features.push(e.name):a!==-1&&this.active_role.features.splice(a,1),t},hasChecked(e,r){return this.active_role?this.active_role.features.includes(r.name):!1},checkAllFeature(e){for(const r of e.children){const t=this.active_role.features.indexOf(r.name);e.isCheckAll?t!==-1&&this.active_role.features.splice(t,1):t===-1&&this.active_role.features.push(r.name)}},checkFeature(e){const r=this.active_role.features.indexOf(e.name);r===-1?this.active_role.features.push(e.name):this.active_role.features.splice(r,1)},toCreateRole(){this.$refs.treeMenuRef.setCurrentKey(),this.active_role={name:"",desc:"",base:null,features:[]}},async toDeleteRole(e){if(this.isSystemRole)return this.$message.error("\u7CFB\u7EDF\u9ED8\u8BA4\u89D2\u8272\u4E0D\u53EF\u4EE5\u5220\u9664");await this.$confirm("\u5C06\u5220\u9664\u4E00\u4E2A\u89D2\u8272\uFF0C\u662F\u5426\u7EE7\u7EED\uFF1F","\u64CD\u4F5C\u63D0\u793A",{type:"warning"}),await f(e.id),this.onCancel(),this.findAllRole()},async onConfirm(){if(!this.active_role.features.length)return this.$message.error("\u529F\u80FD\u6743\u9650\u4E0D\u80FD\u4E3A\u7A7A");await this.$refs.formLayoutRef.validate(),await(this.active_role.id?d:m)({...this.active_role,features:this.active_role.features.map(e=>({name:e,type:1}))}),this.onCancel(),this.findAllRole()},onCancel(){this.active_role=null,this.$refs.treeMenuRef.setCurrentKey()}}},l={};var C=v(g,b,y,!1,R,null,null,null);function R(e){for(let r in l)this[r]=l[r]}const E=function(){return C.exports}();export{E as default};