| 1 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[93],{"64b5":function(e,t,s){"use strict";s.r(t);var i=function(){var e=this,t=e._self._c;return t("div",{staticClass:"q-pa-md fit column"},[t("q-tabs",{attrs:{dense:"","active-color":"primary","indicator-color":"primary",align:"justify","narrow-indicator":""},model:{value:e.currentTab,callback:function(t){e.currentTab=t},expression:"currentTab"}},[t("q-tab",{attrs:{name:"roles",icon:"groups",label:"角色管理"}}),t("q-tab",{attrs:{name:"staff",icon:"people",label:"成员管理"}}),t("q-tab",{attrs:{name:"permissions",icon:"security",label:"权限管理"}})],1),t("q-separator"),t("q-tab-panels",{staticClass:"col scroll",attrs:{animated:""},model:{value:e.currentTab,callback:function(t){e.currentTab=t},expression:"currentTab"}},[t("q-tab-panel",{staticClass:"fit column",attrs:{name:"roles"}},[t("q-card",{staticClass:"shadow-24 col column"},[t("q-bar",{staticClass:"bg-light-blue-10 text-white"},[t("div",[e._v("角色权限管理")]),t("q-space"),t("q-btn",{attrs:{dense:"",flat:"",icon:"restore"},on:{click:e.resetDefaultPermissions}},[t("q-tooltip",[e._v("恢复默认权限")])],1),t("q-btn",{attrs:{dense:"",flat:"",icon:"add"},on:{click:e.openRoleDialog}},[t("q-tooltip",[e._v("添加新角色")])],1)],1),t("q-card-section",{staticClass:"col"},[t("div",{staticClass:"row q-mb-md"},[t("div",{staticClass:"col-4"},[t("q-select",{attrs:{options:e.roleOptions,label:"选择角色",dense:"",outlined:"","emit-value":"","map-options":""},on:{input:e.loadRolePermissions},model:{value:e.selectedRole,callback:function(t){e.selectedRole=t},expression:"selectedRole"}})],1)]),t("q-table",{staticClass:"my-sticky-header-table",attrs:{data:e.permissions,columns:e.roleColumns,"row-key":"page",separator:"cell",dense:"",flat:"",bordered:"","table-style":{height:e.height},"table-class":"table-scroll","virtual-scroll":""},scopedSlots:e._u([{key:"header-cell",fn:function(s){return[t("q-th",{attrs:{props:s},on:{dblclick:function(t){return e.handleHeaderDblClick("roles",s.col)}}},[e._v("\n "+e._s(s.col.label)+"\n ")])]}},{key:"body",fn:function(s){return[t("q-tr",{attrs:{props:s}},[t("q-td",{key:"page",attrs:{props:s}},[e._v("\n "+e._s(s.row.page)+"\n ")]),t("q-td",{key:"enabled",attrs:{props:s}},[t("q-toggle",{on:{"update:model-value":function(t){return e.updatePageAccess(s.row)}},model:{value:s.row.enabled,callback:function(t){e.$set(s.row,"enabled",t)},expression:"props.row.enabled"}})],1),t("q-td",{key:"components",attrs:{props:s}},[t("q-list",{attrs:{dense:""}},e._l(s.row.components,(function(s,i){return t("q-item",{key:i},[t("q-item-section",[t("div",{staticClass:"row items-center"},[t("div",{staticClass:"col"},[e._v("\n "+e._s(s.name||s.component)+"\n ")]),t("div",{staticClass:"col-auto"},[t("q-toggle",{model:{value:s.enabled,callback:function(t){e.$set(s,"enabled",t)},expression:"comp.enabled"}})],1)])])],1)})),1),t("div",{staticClass:"row q-mt-sm items-center"},[t("div",{staticClass:"col"},[t("q-input",{attrs:{dense:"",outlined:"",placeholder:"组件标识(如: add_btn)"},model:{value:s.row._newComponent,callback:function(t){e.$set(s.row,"_newComponent",t)},expression:"props.row._newComponent"}})],1),t("div",{staticClass:"col-auto"},[t("q-btn",{attrs:{dense:"",flat:"",icon:"add"},on:{click:function(t){return e.addComponentPermission(s.row)}}},[t("q-tooltip",[e._v("添加组件权限")])],1)],1)])],1),t("q-td",{key:"actions",attrs:{props:s}},[t("q-btn",{attrs:{round:"",flat:"",push:"",color:"primary",icon:"save"},on:{click:function(t){return e.savePagePermissions(s.row)}}},[t("q-tooltip",[e._v("保存页面权限")])],1)],1)],1)]}}])})],1)],1)],1),t("q-tab-panel",{attrs:{name:"staff"}},[t("q-card",{staticClass:"shadow-24"},[t("q-bar",{staticClass:"bg-light-blue-10 text-white rounded-borders"},[t("div",[e._v("成员管理")]),t("q-space"),t("q-btn",{attrs:{dense:"",flat:"",icon:"add"},on:{click:e.openStaffDialog}},[t("q-tooltip",[e._v("添加新成员")])],1)],1),t("q-card-section",[t("q-table",{ref:"staffTable",staticClass:"my-sticky-header-table",attrs:{data:e.staffList,columns:e.staffColumns,"row-key":"id",separator:"cell",dense:"",flat:"",bordered:"",filter:e.staffFilter,pagination:e.staffPagination,loading:e.staffLoading,"rows-per-page-options":[]},on:{request:e.onStaffRequest},scopedSlots:e._u([{key:"header-cell",fn:function(s){return[t("q-th",{attrs:{props:s},on:{dblclick:function(t){return e.handleHeaderDblClick("staff",s.col)}}},[e._v("\n "+e._s(s.col.label)+"\n ")])]}},{key:"top-right",fn:function(){return[t("q-input",{staticClass:"q-mb-md",attrs:{outlined:"",dense:"",placeholder:"搜索成员"},scopedSlots:e._u([{key:"append",fn:function(){return[t("q-icon",{attrs:{name:"search"}})]},proxy:!0}]),model:{value:e.staffFilter,callback:function(t){e.staffFilter=t},expression:"staffFilter"}})]},proxy:!0},{key:"body",fn:function(s){return[t("q-tr",{attrs:{props:s}},[t("q-td",{key:"staff_name",attrs:{props:s}},[e._v("\n "+e._s(s.row.staff_name)+"\n ")]),t("q-td",{key:"staff_type",attrs:{props:s}},[t("q-select",{attrs:{options:e.roleOptions,dense:"",outlined:"","emit-value":"","map-options":""},on:{"update:model-value":function(t){return e.updateStaffRole(s.row)}},model:{value:s.row.staff_type,callback:function(t){e.$set(s.row,"staff_type",t)},expression:"props.row.staff_type"}})],1),t("q-td",{key:"is_lock",attrs:{props:s}},[t("q-toggle",{on:{"update:model-value":function(t){return e.updateStaffStatus(s.row)}},model:{value:s.row.is_lock,callback:function(t){e.$set(s.row,"is_lock",t)},expression:"props.row.is_lock"}})],1),t("q-td",{key:"is_look",attrs:{props:s}},[t("q-toggle",{on:{"update:model-value":function(t){return e.updateStaffStatus(s.row)}},model:{value:s.row.is_look,callback:function(t){e.$set(s.row,"is_look",t)},expression:"props.row.is_look"}})],1),t("q-td",{key:"is_edit",attrs:{props:s}},[t("q-toggle",{on:{"update:model-value":function(t){return e.updateStaffStatus(s.row)}},model:{value:s.row.is_edit,callback:function(t){e.$set(s.row,"is_edit",t)},expression:"props.row.is_edit"}})],1),t("q-td",{key:"actions",attrs:{props:s}},[t("q-btn",{attrs:{round:"",flat:"",push:"",color:"primary",icon:"edit"},on:{click:function(t){return e.editStaff(s.row)}}},[t("q-tooltip",[e._v("编辑成员")])],1),t("q-btn",{attrs:{round:"",flat:"",push:"",color:"negative",icon:"delete"},on:{click:function(t){return e.deleteStaff(s.row)}}},[t("q-tooltip",[e._v("删除成员")])],1)],1)],1)]}}])})],1)],1)],1),t("q-tab-panel",{attrs:{name:"permissions"}},[t("q-card",{staticClass:"shadow-24"},[t("q-bar",{staticClass:"bg-light-blue-10 text-white rounded-borders"},[t("div",[e._v("权限管理")]),t("q-space"),t("q-btn",{attrs:{dense:"",flat:"",icon:"add"},on:{click:e.openPermissionDialog}},[t("q-tooltip",[e._v("添加新权限")])],1)],1),t("q-card-section",[t("q-table",{staticClass:"my-sticky-header-table",attrs:{data:e.permissionList,columns:e.permissionColumns,"row-key":"id",separator:"cell",dense:"",flat:"",bordered:"",filter:e.permissionFilter},scopedSlots:e._u([{key:"header-cell",fn:function(s){return[t("q-th",{attrs:{props:s},on:{dblclick:function(t){return e.handleHeaderDblClick("permissions",s.col)}}},[e._v("\n "+e._s(s.col.label)+"\n ")])]}},{key:"top-right",fn:function(){return[t("q-input",{staticClass:"q-mb-md",attrs:{outlined:"",dense:"",placeholder:"搜索权限"},scopedSlots:e._u([{key:"append",fn:function(){return[t("q-icon",{attrs:{name:"search"}})]},proxy:!0}]),model:{value:e.permissionFilter,callback:function(t){e.permissionFilter=t},expression:"permissionFilter"}})]},proxy:!0},{key:"body",fn:function(s){return[t("q-tr",{attrs:{props:s}},[t("q-td",{key:"primary_page",attrs:{props:s}},[e._v(e._s(s.row.primary_page))]),t("q-td",{key:"page",attrs:{props:s}},[e._v(e._s(s.row.page))]),t("q-td",{key:"component",attrs:{props:s}},[e._v(e._s(s.row.component))]),t("q-td",{key:"name",attrs:{props:s}},[e._v(e._s(s.row.name))]),t("q-td",{key:"enabled",attrs:{props:s}},[t("q-badge",{attrs:{color:s.row.enabled?"positive":"grey"}},[e._v(e._s(s.row.enabled?"启用":"禁用"))])],1),t("q-td",{key:"description",attrs:{props:s}},[e._v(e._s(s.row.description))]),t("q-td",{key:"actions",attrs:{props:s}},[t("q-btn",{attrs:{round:"",flat:"",push:"",color:"primary",icon:"edit"},on:{click:function(t){return e.editPermission(s.row)}}},[t("q-tooltip",[e._v("编辑权限")])],1),t("q-btn",{attrs:{round:"",flat:"",push:"",color:"negative",icon:"delete"},on:{click:function(t){return e.deletePermission(s.row)}}},[t("q-tooltip",[e._v("删除权限")])],1)],1)],1)]}}])})],1)],1)],1)],1),t("q-dialog",{model:{value:e.roleDialog,callback:function(t){e.roleDialog=t},expression:"roleDialog"}},[t("q-card",{staticStyle:{"min-width":"350px"}},[t("q-card-section",[t("div",{staticClass:"text-h6"},[e._v("添加新角色")])]),t("q-card-section",[t("q-input",{attrs:{label:"角色名称",dense:"",outlined:"",autofocus:"",rules:[e=>!!e||"角色名称不能为空"]},model:{value:e.newRoleName,callback:function(t){e.newRoleName=t},expression:"newRoleName"}}),t("div",{staticClass:"q-mt-md"},[t("div",{staticClass:"text-subtitle2"},[e._v("初始权限")]),t("q-select",{attrs:{options:e.permissionOptions,multiple:"","use-chips":"",dense:"",outlined:"","emit-value":"","map-options":"",label:"选择权限"},model:{value:e.newRolePermissions,callback:function(t){e.newRolePermissions=t},expression:"newRolePermissions"}})],1)],1),t("q-card-actions",{attrs:{align:"right"}},[t("q-btn",{directives:[{name:"close-popup",rawName:"v-close-popup"}],attrs:{flat:"",label:"取消",color:"primary"}}),t("q-btn",{attrs:{flat:"",label:"确定",color:"primary"},on:{click:e.createNewRole}})],1)],1)],1),t("q-dialog",{model:{value:e.staffDialog,callback:function(t){e.staffDialog=t},expression:"staffDialog"}},[t("q-card",{staticStyle:{"min-width":"500px"}},[t("q-card-section",[t("div",{staticClass:"text-h6"},[e._v("\n "+e._s(e.editStaffMode?"编辑成员":"添加新成员")+"\n ")])]),t("q-card-section",[t("q-input",{attrs:{label:"成员姓名",dense:"",outlined:"",autofocus:"",rules:[e=>!!e||"成员姓名不能为空"]},model:{value:e.staffForm.staff_name,callback:function(t){e.$set(e.staffForm,"staff_name",t)},expression:"staffForm.staff_name"}}),t("q-select",{staticClass:"q-mt-md",attrs:{options:e.roleOptions,label:"角色",dense:"",outlined:"","emit-value":"","map-options":""},model:{value:e.staffForm.staff_type,callback:function(t){e.$set(e.staffForm,"staff_type",t)},expression:"staffForm.staff_type"}}),t("div",{staticClass:"row q-mt-md"},[t("div",{staticClass:"col"},[t("q-toggle",{attrs:{label:"是否锁定"},model:{value:e.staffForm.is_lock,callback:function(t){e.$set(e.staffForm,"is_lock",t)},expression:"staffForm.is_lock"}})],1),t("div",{staticClass:"col"},[t("q-toggle",{attrs:{label:"查看权限"},model:{value:e.staffForm.is_look,callback:function(t){e.$set(e.staffForm,"is_look",t)},expression:"staffForm.is_look"}})],1),t("div",{staticClass:"col"},[t("q-toggle",{attrs:{label:"编辑权限"},model:{value:e.staffForm.is_edit,callback:function(t){e.$set(e.staffForm,"is_edit",t)},expression:"staffForm.is_edit"}})],1)])],1),t("q-card-actions",{attrs:{align:"right"}},[t("q-btn",{directives:[{name:"close-popup",rawName:"v-close-popup"}],attrs:{flat:"",label:"取消",color:"primary"}}),t("q-btn",{attrs:{flat:"",label:"保存",color:"primary"},on:{click:e.saveStaff}})],1)],1)],1),t("q-dialog",{model:{value:e.permissionDialog,callback:function(t){e.permissionDialog=t},expression:"permissionDialog"}},[t("q-card",{staticStyle:{"min-width":"500px"}},[t("q-card-section",[t("div",{staticClass:"text-h6"},[e._v("\n "+e._s(e.editPermissionMode?"编辑权限":"添加新权限")+"\n ")])]),t("q-card-section",[t("q-input",{attrs:{label:"所属主页面(如:staff)",dense:"",outlined:"",autofocus:"",rules:[e=>!!e||"主页面不能为空"]},model:{value:e.permissionForm.primary_page,callback:function(t){e.$set(e.permissionForm,"primary_page",t)},expression:"permissionForm.primary_page"}}),t("q-input",{staticClass:"q-mt-md",attrs:{label:"页面路径(如:/staff/stafflist)",dense:"",outlined:"",rules:[e=>!!e||"页面路径不能为空"]},model:{value:e.permissionForm.page,callback:function(t){e.$set(e.permissionForm,"page",t)},expression:"permissionForm.page"}}),t("q-input",{staticClass:"q-mt-md",attrs:{label:"组件标识(可留空表示页面访问权限)",dense:"",outlined:""},model:{value:e.permissionForm.component,callback:function(t){e.$set(e.permissionForm,"component",t)},expression:"permissionForm.component"}}),t("q-input",{staticClass:"q-mt-md",attrs:{label:"权限名称",dense:"",outlined:"",rules:[e=>!!e||"权限名称不能为空"]},model:{value:e.permissionForm.name,callback:function(t){e.$set(e.permissionForm,"name",t)},expression:"permissionForm.name"}}),t("q-toggle",{staticClass:"q-mt-md",attrs:{label:"是否启用"},model:{value:e.permissionForm.enabled,callback:function(t){e.$set(e.permissionForm,"enabled",t)},expression:"permissionForm.enabled"}}),t("q-input",{staticClass:"q-mt-md",attrs:{label:"权限描述",dense:"",outlined:"",type:"textarea"},model:{value:e.permissionForm.description,callback:function(t){e.$set(e.permissionForm,"description",t)},expression:"permissionForm.description"}})],1),t("q-card-actions",{attrs:{align:"right"}},[t("q-btn",{directives:[{name:"close-popup",rawName:"v-close-popup"}],attrs:{flat:"",label:"取消",color:"primary"}}),t("q-btn",{attrs:{flat:"",label:"保存",color:"primary"},on:{click:e.savePermission}})],1)],1)],1)],1)},a=[],o=(s("ddb0"),s("9861"),s("caad"),s("3004")),n={name:"PermissionManage",data(){return{height:"",currentTab:"roles",selectedRole:null,roleOptions:[],permissions:[],roleDialog:!1,newRoleName:"",newRolePermissions:[],staffList:[],staffFilter:"",staffDialog:!1,editStaffMode:!1,staffForm:{id:null,staff_name:"",staff_type:"",is_lock:!1,is_look:!1,is_edit:!1},permissionList:[],permissionFilter:"",permissionDialog:!1,editPermissionMode:!1,permissionForm:{id:null,primary_page:"",page:"",component:"",name:"",description:"",enabled:!0},roleColumns:[{name:"page",required:!0,label:"界面名称",align:"left",field:"page",sortable:!0},{name:"enabled",label:"访问权限",align:"center",field:"enabled"},{name:"components",label:"组件权限",align:"left",field:"components"},{name:"actions",label:"操作",align:"center"}],staffColumns:[{name:"staff_name",required:!0,label:"成员姓名",align:"left",field:"staff_name",sortable:!0},{name:"staff_type",label:"角色",align:"left",field:"staff_type"},{name:"is_lock",label:"锁定状态",align:"center",field:"is_lock"},{name:"is_look",label:"查看权限",align:"center",field:"is_look"},{name:"is_edit",label:"编辑权限",align:"center",field:"is_edit"},{name:"actions",label:"操作",align:"center"}],permissionColumns:[{name:"primary_page",label:"主页面",align:"left",field:"primary_page"},{name:"page",label:"页面路径",align:"left",field:"page"},{name:"component",label:"组件标识",align:"left",field:"component"},{name:"name",required:!0,label:"权限名称",align:"left",field:"name",sortable:!0},{name:"enabled",label:"启用",align:"center",field:"enabled"},{name:"description",label:"权限描述",align:"left",field:"description"},{name:"actions",label:"操作",align:"center"}],staffPagination:{page:1,rowsPerPage:11,rowsNumber:0},staffLoading:!1,permissionOptions:[],activeSearchField:"",activeSearchLabel:"",roleFilterData:{},staffFilterData:{},permissionFilterData:{},permissionsOriginal:[],permissionListOriginal:[]}},mounted(){this.loadRoles(),this.loadStaffList(),this.loadPermissions(),this.loadPermissionOptions(),this.$q&&this.$q.screen?this.$q.platform&&this.$q.platform.is&&this.$q.platform.is.electron?this.height=String(this.$q.screen.height-320)+"px":this.height=this.$q.screen.height-320+"px":this.height="480px"},methods:{showNotification(e,t="negative"){this.$q?this.$q.notify({message:e,icon:"positive"===t?"check":"close",color:t}):console.log(`${"positive"===t?"✓":"✗"} ${e}`)},async loadRoles(){try{const e=await Object(o["e"])("staff/role-permissions/");this.roleOptions=e.map((e=>({label:e,value:e}))),this.roleOptions.length>0&&(this.selectedRole=this.roleOptions[0].value,this.loadRolePermissions())}catch(e){console.error("加载角色失败:",e),this.showNotification("加载角色失败: "+e.message)}},async loadRolePermissions(){if(this.selectedRole)try{const e=await Object(o["e"])(`staff/role-permissions/${this.selectedRole}/`),t=e.permissions_group.map((e=>({page:e.page,enabled:e.permissions.some((e=>null===e.component)),components:e.permissions.filter((e=>null!==e.component)).map((e=>({id:e.id,component:e.component,name:e.name,description:e.description,enabled:!0}))),_newComponent:""})));this.permissionsOriginal=t,this.applyRoleFilter()}catch(e){console.error("加载权限失败:",e),this.showNotification("加载权限失败: "+e.message)}},async loadStaffList(e=this.staffPagination.page,t=this.staffPagination.rowsPerPage){this.staffLoading=!0;try{const s=new URLSearchParams;e&&s.set("page",String(e)),t&&s.set("page_size",String(t));const i=await Object(o["e"])(`staff/?${s.toString()}`);this.staffList=(i.results||[]).map((e=>({...e,staff_type:e.staff_type||""}))),this.staffPagination={...this.staffPagination,page:e,rowsPerPage:t,rowsNumber:Number(i.count||0)}}catch(s){console.error("加载成员列表失败:",s),this.showNotification("加载成员列表失败: "+s.message)}finally{this.staffLoading=!1}},async onStaffRequest(e){const{page:t,rowsPerPage:s}=e.pagination||{};Object.keys(this.staffFilterData).length>0?await this.loadStaffListWithFilter(t,s):await this.loadStaffList(t,s)},async loadPermissions(){try{const e=await Object(o["e"])("staff/permission/"),t=e.map((e=>({...e})));this.permissionListOriginal=t,this.applyPermissionFilter()}catch(e){console.error("加载权限列表失败:",e),this.showNotification("加载权限列表失败: "+e.message)}},async loadPermissionOptions(){try{const e=await Object(o["e"])("staff/permission/");this.permissionOptions=e.map((e=>({label:e.name,value:e.id})))}catch(e){console.error("加载权限选项失败:",e),this.showNotification("加载权限选项失败: "+e.message)}},async updatePageAccess(e){await this.savePagePermissions(e)},async savePagePermissions(e){if(this.selectedRole)try{const t={permissions:[{page:e.page,component:null,enabled:!!e.enabled},...e.components.map((t=>({page:e.page,component:t.component||t.name,enabled:!!t.enabled})))]};await Object(o["i"])(`staff/role-permissions/${this.selectedRole}/`,t),this.showNotification("页面权限已保存","positive")}catch(t){console.error("保存权限失败:",t),this.showNotification("保存失败: "+t.message)}},addComponentPermission(e){const t=(e._newComponent||"").trim();t&&(e.components.find((e=>(e.component||e.name)===t))||e.components.push({component:t,name:t,enabled:!0}),e._newComponent="")},openRoleDialog(){this.newRoleName="",this.newRolePermissions=[],this.roleDialog=!0},openStaffDialog(){this.staffForm={id:null,staff_name:"",staff_type:this.roleOptions.length>0?this.roleOptions[0].value:"",is_lock:!1,is_look:!1,is_edit:!1},this.editStaffMode=!1,this.staffDialog=!0},openPermissionDialog(){this.permissionForm={id:null,primary_page:"",page:"",component:"",name:"",description:"",enabled:!0},this.editPermissionMode=!1,this.permissionDialog=!0},editStaff(e){this.staffForm={id:e.id,staff_name:e.staff_name,staff_type:e.staff_type,is_lock:e.is_lock,is_look:e.is_look,is_edit:e.is_edit},this.editStaffMode=!0,this.staffDialog=!0},editPermission(e){this.permissionForm={id:e.id,primary_page:e.primary_page||"",page:e.page||"",component:e.component||"",name:e.name||"",description:e.description||"",enabled:!!e.enabled},this.editPermissionMode=!0,this.permissionDialog=!0},async deleteStaff(e){try{await Object(o["c"])(`staff/${e.id}/`),this.showNotification("成员删除成功","positive"),this.loadStaffList(this.staffPagination.page,this.staffPagination.rowsPerPage)}catch(t){console.error("删除成员失败:",t),this.showNotification("删除失败: "+t.message)}},async deletePermission(e){try{await Object(o["c"])(`staff/permission/${e.id}/`),this.showNotification("权限删除成功","positive"),this.loadPermissions()}catch(t){console.error("删除权限失败:",t),this.showNotification("删除失败: "+t.message)}},async saveStaff(){try{this.editStaffMode?(await Object(o["i"])(`staff/${this.staffForm.id}/`,this.staffForm),this.showNotification("成员更新成功","positive")):(await Object(o["h"])("staff/",this.staffForm),this.showNotification("成员添加成功","positive")),this.staffDialog=!1,this.loadStaffList(this.staffPagination.page,this.staffPagination.rowsPerPage)}catch(e){console.error("保存成员失败:",e),this.showNotification("保存失败: "+e.message)}},async savePermission(){try{const e={...this.permissionForm};e.component||(e.component=null),this.editPermissionMode?(await Object(o["i"])(`staff/permission/${e.id}/`,e),this.showNotification("权限更新成功","positive")):(await Object(o["h"])("staff/permission/",e),this.showNotification("权限添加成功","positive")),this.permissionDialog=!1,this.loadPermissions(),this.loadPermissionOptions(),this.loadRolePermissions()}catch(e){console.error("保存权限失败:",e),this.showNotification("保存失败: "+e.message)}},async updateStaffRole(e){try{await Object(o["i"])(`staff/${e.id}/`,{staff_type:e.staff_type}),this.showNotification("成员角色更新成功","positive")}catch(t){console.error("更新角色失败:",t),this.showNotification("更新失败: "+t.message)}},async updateStaffStatus(e){try{await Object(o["i"])(`staff/${e.id}/`,{is_lock:e.is_lock,is_look:e.is_look,is_edit:e.is_edit}),this.showNotification("成员状态更新成功","positive")}catch(t){console.error("更新状态失败:",t),this.showNotification("更新失败: "+t.message)}},async createNewRole(){if(this.newRoleName)try{await Object(o["h"])("staff/role/",{name:this.newRoleName,description:`新角色: ${this.newRoleName}`,permissions:this.newRolePermissions}),this.roleDialog=!1,this.loadRoles(),this.showNotification("角色创建成功","positive")}catch(e){console.error("创建角色失败:",e),this.showNotification("创建失败: "+e.message)}},async resetDefaultPermissions(){try{const e=await Object(o["h"])("staff/role-permissions/reset-default/",{});this.showNotification(`默认权限已恢复成功!创建权限: ${e.created_permissions}, 更新角色: ${e.roles_updated}, 分配权限: ${e.permissions_assigned}`,"positive"),this.loadRoles(),this.selectedRole&&this.loadRolePermissions()}catch(s){var e,t;console.error("恢复默认权限失败:",s),this.showNotification("恢复默认权限失败: "+((null===(e=s.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||s.message),"negative")}},handleHeaderDblClick(e,t){["actions","components","enabled","is_lock","is_look","is_edit"].includes(t.name)||(this.activeSearchField=t.field||t.name,this.activeSearchLabel=t.label,this.$q.dialog({title:`搜索${t.label}`,message:`请输入${t.label}的搜索条件`,prompt:{model:"",type:"text"},cancel:!0,persistent:!0}).onOk((s=>{this.executeColumnSearch(e,t,s)})).onCancel((()=>{this.activeSearchField="",this.activeSearchLabel=""})))},executeColumnSearch(e,t,s){if(s&&""!==s.trim()){const i=t.field||t.name;"roles"===e?(this.roleFilterData[i]=s.trim(),this.applyRoleFilter()):"staff"===e?(this.staffFilterData[i]=s.trim(),this.staffPagination.page=1,this.loadStaffListWithFilter(1,this.staffPagination.rowsPerPage)):"permissions"===e&&(this.permissionFilterData[i]=s.trim(),this.applyPermissionFilter()),this.$q.notify({message:`已搜索 ${this.activeSearchLabel} 含有 "${s}" 的结果`,icon:"search",color:"positive"})}else"roles"===e?(this.roleFilterData={},this.selectedRole&&this.loadRolePermissions()):"staff"===e?(this.staffFilterData={},this.staffPagination.page=1,this.loadStaffList(1,this.staffPagination.rowsPerPage)):"permissions"===e&&(this.permissionFilterData={},this.loadPermissions()),this.$q.notify({message:`已清除 ${this.activeSearchLabel} 的搜索条件`,icon:"clear",color:"info"});this.activeSearchField="",this.activeSearchLabel=""},applyRoleFilter(){0!==Object.keys(this.roleFilterData).length?this.permissions=this.permissionsOriginal.filter((e=>Object.keys(this.roleFilterData).every((t=>{const s=this.roleFilterData[t].toLowerCase(),i=String(e[t]||"").toLowerCase();return i.includes(s)})))):this.permissions=[...this.permissionsOriginal]},applyPermissionFilter(){0!==Object.keys(this.permissionFilterData).length?this.permissionList=this.permissionListOriginal.filter((e=>Object.keys(this.permissionFilterData).every((t=>{const s=this.permissionFilterData[t].toLowerCase(),i=String(e[t]||"").toLowerCase();return i.includes(s)})))):this.permissionList=[...this.permissionListOriginal]},async loadStaffListWithFilter(e=1,t=11){this.staffLoading=!0;try{const s=new URLSearchParams;e&&s.set("page",String(e)),t&&s.set("page_size",String(t)),Object.keys(this.staffFilterData).forEach((e=>{this.staffFilterData[e]&&s.set(`${e}__icontains`,String(this.staffFilterData[e]))}));const i=await Object(o["e"])(`staff/?${s.toString()}`);this.staffList=(i.results||[]).map((e=>({...e,staff_type:e.staff_type||""}))),this.staffPagination={...this.staffPagination,page:e,rowsPerPage:t,rowsNumber:Number(i.count||0)}}catch(s){console.error("加载成员列表失败:",s),this.showNotification("加载成员列表失败: "+s.message)}finally{this.staffLoading=!1}}}},l=n,r=s("42e1"),c=s("429b"),p=s("7460"),f=s("eb85"),d=s("adad"),m=s("823b"),h=s("f09f"),u=s("d847"),g=s("2c91"),b=s("9c40"),_=s("05c0"),w=s("a370"),q=s("ddd8"),v=s("eaac"),y=s("357e"),k=s("bd08"),P=s("db86"),F=s("9564"),S=s("1c1c"),C=s("66e5"),D=s("4074"),$=s("27f9"),x=s("0016"),O=s("58a81"),R=s("24e8"),N=s("4b7e"),L=s("7f67"),j=s("eebe"),Q=s.n(j),T=Object(r["a"])(l,i,a,!1,null,null,null);t["default"]=T.exports;Q()(T,"components",{QTabs:c["a"],QTab:p["a"],QSeparator:f["a"],QTabPanels:d["a"],QTabPanel:m["a"],QCard:h["a"],QBar:u["a"],QSpace:g["a"],QBtn:b["a"],QTooltip:_["a"],QCardSection:w["a"],QSelect:q["a"],QTable:v["a"],QTh:y["a"],QTr:k["a"],QTd:P["a"],QToggle:F["a"],QList:S["a"],QItem:C["a"],QItemSection:D["a"],QInput:$["a"],QIcon:x["a"],QBadge:O["a"],QDialog:R["a"],QCardActions:N["a"]}),Q()(T,"directives",{ClosePopup:L["a"]})}}]);
|