x-php-Admin/dist/static/js/629.8b7c75ac.js
2024-05-01 11:11:09 +08:00

1 line
6.8 KiB
JavaScript

"use strict";(self["webpackChunkx_php_admin"]=self["webpackChunkx_php_admin"]||[]).push([[629],{8629:function(e,t,s){s.r(t),s.d(t,{default:function(){return b}});var l=s(6808),r=s(9511),i=s(1441);const o={key:0,class:"x-user-select__left"},a={class:"x-user-select__search"},h={class:"x-user-select__select"},c={class:"x-user-select__tree"},n={class:"x-user-select__user"},d={class:"x-user-select__user__list"},u={key:1,class:"x-user-select__left x-user-select-role"},p={class:"x-user-select__select"},g={class:"x-user-select__tree"},_={class:"x-user-select__toicon"},k={class:"x-user-select__selected"};function y(e,t,s,y,m,f){const w=(0,l.up)("el-input"),b=(0,l.up)("el-button"),P=(0,l.up)("el-form"),C=(0,l.up)("el-tree"),x=(0,l.up)("el-scrollbar"),v=(0,l.up)("el-pagination"),U=(0,l.up)("el-icon-arrow-right"),W=(0,l.up)("el-icon"),S=(0,l.up)("x-form-table"),V=(0,l.Q2)("loading");return(0,l.wg)(),(0,l.iD)("div",{class:"x-user-select",style:(0,r.j5)({height:f._height,width:f._width})},[1==s.type?((0,l.wg)(),(0,l.iD)("div",o,[(0,l._)("div",a,[(0,l.Wm)(P,{onSubmit:(0,i.iM)(f.search,["prevent"]),onKeyup:(0,i.D2)(f.search,["enter"])},{append:(0,l.w5)((()=>[(0,l.Wm)(b,{icon:"el-icon-search",onClick:f.search},null,8,["onClick"])])),default:(0,l.w5)((()=>[(0,l.Wm)(w,{modelValue:m.keyword,"onUpdate:modelValue":t[0]||(t[0]=e=>m.keyword=e),"prefix-icon":"el-icon-search",placeholder:s.config.placeholder||"搜索用户"},null,8,["modelValue","placeholder"])])),_:1},8,["onSubmit","onKeyup"])]),(0,l._)("div",h,[(0,l.wy)(((0,l.wg)(),(0,l.iD)("div",c,[(0,l.Wm)(x,null,{default:(0,l.w5)((()=>[(0,l.Wm)(C,{class:"menu",ref:"groupTree",data:m.role,"node-key":m.roleProps.key,props:m.roleProps,"highlight-current":"","expand-on-click-node":!1,"current-node-key":m.groupid,onNodeClick:f.groupClick},null,8,["data","node-key","props","current-node-key","onNodeClick"])])),_:1})])),[[V,m.showGrouploading]]),(0,l.wy)(((0,l.wg)(),(0,l.iD)("div",n,[(0,l._)("div",d,[(0,l.Wm)(x,{ref:"userScrollbar"},{default:(0,l.w5)((()=>[(0,l.Wm)(C,{class:"menu",ref:"userTree",data:m.user,"node-key":m.userProps.key,props:m.userProps,"default-checked-keys":f.selectedIds,"show-checkbox":"","check-on-click-node":"",onCheckChange:f.userClick},null,8,["data","node-key","props","default-checked-keys","onCheckChange"])])),_:1},512)]),(0,l._)("footer",null,[(0,l.Wm)(v,{background:"",layout:"prev,next",small:"",total:m.total,"page-size":m.limit,currentPage:m.currentPage,"onUpdate:currentPage":t[1]||(t[1]=e=>m.currentPage=e),onCurrentChange:f.paginationChange},null,8,["total","page-size","currentPage","onCurrentChange"])])])),[[V,m.showUserloading]])])])):((0,l.wg)(),(0,l.iD)("div",u,[(0,l._)("div",p,[(0,l.wy)(((0,l.wg)(),(0,l.iD)("div",g,[(0,l.Wm)(x,null,{default:(0,l.w5)((()=>[(0,l.Wm)(C,{class:"menu",ref:"groupTree",data:m.role,"node-key":m.roleProps.key,props:m.roleProps,"show-checkbox":"","check-strictly":"","check-on-click-node":"","expand-on-click-node":!1,"default-checked-keys":f.selectedIds,onCheckChange:f.roleClick},null,8,["data","node-key","props","default-checked-keys","onCheckChange"])])),_:1})])),[[V,m.showGrouploading]])])])),(0,l._)("div",_,[(0,l.Wm)(W,null,{default:(0,l.w5)((()=>[(0,l.Wm)(U)])),_:1})]),(0,l._)("div",k,[(0,l._)("header",null,"已选 ("+(0,r.zw)(m.selected.length)+")",1),(0,l._)("ul",null,[(0,l.Wm)(x,null,{default:(0,l.w5)((()=>[(0,l.Wm)(S,{modelValue:m.selected,"onUpdate:modelValue":t[2]||(t[2]=e=>m.selected=e),border:!1,hideAdd:!0,placeholder:"暂无数据",column:m.column,onDelete:f.setCheckedKeys},null,8,["modelValue","column","onDelete"])])),_:1})])])],4)}s(8311);var m={name:"xUserSelect",data(){return{userProps:{key:"uid",label:"username"},roleProps:{key:"id",label:"title",children:"children"},showGrouploading:!1,showUserloading:!1,keyword:"",groupid:"",limit:20,total:0,currentPage:1,user:[],role:[],selected:this.modelValue||[],column:[]}},props:{modelValue:{type:Array,default:()=>[]},type:{type:[String,Number],default:1},height:{type:[String,Number],default:280},width:{type:[String,Number],default:"100%"},datatype:{type:[String,Boolean],default:!0},config:{type:Object,default:()=>({config:{}})}},watch:{selectedIds(e){if(!0===this.datatype)return this.$emit("update:modelValue",e),!0;this.$emit("update:modelValue",this.selected)}},computed:{selectedIds(){return this.selected.map((e=>e.__key__))},_height(){return Number(this.height)?Number(this.height)+"px":this.height},_width(){return Number(this.width)?Number(this.width)+"px":this.width}},mounted(){this.userProps=Object.assign(this.userProps,this.config.userProps||{}),this.roleProps=Object.assign(this.roleProps,this.config.roleProps||{}),this.column=this.config.column||[{name:"__key__",label:"ID",component:"text",width:100},{name:1==this.type?this.userProps.label:this.roleProps.label,label:"名称",component:"text"}],this.datatype&&"string"===typeof this.datatype&&this.selected.forEach((e=>{e.__key__=e[this.datatype]})),this.open()},methods:{open(){1==this.type?(this.getGroup(),this.getUser()):2==this.type&&this.getRole()},async getGroup(){this.showGrouploading=!0;var e=await this.$http.get(this.config.roleUrl||"user/group/roleList");this.showGrouploading=!1;var t={[this.roleProps.key]:"",[this.roleProps.label]:"所有"};e.data.unshift(t),this.role=e.data},async getUser(){this.showUserloading=!0;var e={[this.config.keyword||"keyword"]:this.keyword||null,[this.config.groupid||"groupid"]:this.groupid||null,[this.config.page||"page"]:this.currentPage,[this.config.limit||"limit"]:this.limit},t=await this.$http.get(this.config.url||"user/index/lists",e);this.showUserloading=!1,this.user=t.data.data||[],this.total=t.data.count||0,this.$refs.userScrollbar.setScrollTop(0)},async getRole(){this.showGrouploading=!0;var e=await this.$http.get(this.config.roleUrl||"user/group/roleList",{type:"system"});this.showGrouploading=!1,this.role=e.data,this.selected=this.role.filter((e=>this.modelValue.includes(e.id))).map((e=>Object.assign({},e,{__key__:e[this.roleProps.key]})))},groupClick(e){this.keyword="",this.currentPage=1,this.groupid=e[this.roleProps.key],this.getUser()},userClick(e,t){if(t){var s=Object.assign({},e,{__key__:e[this.userProps.key]});this.selected.push(s)}else this.selected=this.selected.filter((t=>t.__key__!=e[this.userProps.key]))},paginationChange(){this.getUser()},search(){this.groupid="",this.$refs.groupTree.setCurrentKey(this.groupid),this.currentPage=1,this.getUser()},setCheckedKeys(){this.$nextTick((()=>{1==this.type?this.$refs.userTree.setCheckedKeys(this.selectedIds):this.$refs.groupTree.setCheckedKeys(this.selectedIds)}))},deleteSelected(e){this.selected.splice(e,1),this.setCheckedKeys()},roleClick(e,t){if(t){var s=Object.assign({},e,{__key__:e[this.roleProps.key]});this.selected.push(s)}else this.selected=this.selected.filter((t=>t.__key__!=e[this.roleProps.key]))}}},f=s(8700);const w=(0,f.Z)(m,[["render",y],["__scopeId","data-v-571cc7b4"]]);var b=w}}]);