Files
aiot-platform-ui/apps/web-antd/dist/js/user-select-modal-BOyvkWkp.js

2 lines
6.9 KiB
JavaScript
Raw Normal View History

2025-12-28 01:40:21 +08:00
var oe=Object.defineProperty,re=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var P=(u,r,l)=>r in u?oe(u,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[r]=l,L=(u,r)=>{for(var l in r||(r={}))se.call(r,l)&&P(u,l,r[l]);if(E)for(var l of E(r))ue.call(r,l)&&P(u,l,r[l]);return u},T=(u,r)=>re(u,ie(r));var x=(u,r,l)=>new Promise((y,U)=>{var k=c=>{try{m(l.next(c))}catch(d){U(d)}},C=c=>{try{m(l.throw(c))}catch(d){U(d)}},m=c=>c.done?y(c.value):Promise.resolve(c.value).then(k,C);m((l=l.apply(u,r)).next())});import{g as ce}from"./index-DJ8TudF9.js";import{a as $}from"./index-m3Rh1swI.js";import{c1 as K,bD as de,cF as pe,cG as ve,bV as O,c0 as ge,ay as R,a9 as fe,ac as he}from"./bootstrap-DZnIDovD.js";import{m as me,b9 as S,d8 as Se,aa as A,ab as we,b2 as B,u as g,bJ as w,j as h,ae as N,ad as j,ac as q,bp as V,ai as F}from"../jse/index-index-DaIpbNAe.js";import{u as ye}from"./use-modal-DIW0D7tm.js";const Ce={class:"h-[500px] overflow-auto rounded border"},ke={class:"border-b p-2"},ze={key:0},xe={key:1},Ue=me({name:"UserSelectModal",__name:"user-select-modal",props:{cancelText:{default:"取消"},confirmText:{default:"确定"},multiple:{type:Boolean,default:!0},title:{default:"选择用户"},value:{default:()=>[]}},emits:["cancel","closed","confirm","update:value"],setup(u,{emit:r}){const l=r,y=S([]),U=S([]),k=S([]),C=S(),m=S(""),c=S([]),d=S([]),[G,z]=ye({onCancel:_,onClosed:le,onOpenChange(a){return x(this,null,function*(){var t;if(!a){I();return}const e=z.getData();if(e){z.lock();try{const n=yield ce();U.value=n;const s=Se(n);if(y.value=s.map(v=>M(v)),k.value=y.value.map(v=>v.key),yield D(1,o.value.pagination.pageSize),(t=e.userIds)!=null&&t.length){d.value=e.userIds.map(String);const{list:v}=yield $({pageNo:1,pageSize:100,userIds:e.userIds}),f=new Map(c.value.map(p=>[p.id,p]));v.forEach(p=>{f.has(p.id)||f.set(p.id,p)}),c.value=[...f.values()],b()}z.open()}finally{z.unlock()}}})},destroyOnClose:!0}),o=S({searchValue:"",dataSource:[],pagination:{current:1,pageSize:10,total:0}}),i=S({searchValue:"",dataSource:[],pagination:{current:1,pageSize:10,total:0}}),J=A(()=>[...o.value.dataSource,...i.value.dataSource]),H=A(()=>{if(!m.value)return y.value;const a=(e,t=0)=>{var v;if(t>100)return null;const n=(v=e==null?void 0:e.name)==null?void 0:v.toLowerCase(),s=m.value.toLowerCase();if(n!=null&&n.includes(s))return T(L({},e),{children:e.children});if(e.children){const f=e.children.map(p=>a(p,t+1)).filter(Boolean);if(f.length>0)return T(L({},e),{children:f})}return null};return y.value.map(e=>a(e)).filter(Boolean)});function D(a,e){return x(this,null,function*(){try{const{list:t,total:n}=yield $({pageNo:a,pageSize:e,deptId:C.value,username:o.value.searchValue||void 0});o.value.dataSource=t,o.value.pagination.total=n,o.value.pagination.current=a,o.value.pagination.pageSize=e;const s=t.filter(v=>!c.value.some(f=>f.id===v.id));s.length>0&&c.value.push(...s)}finally{}})}function b(){const a=new Set(d.value),e=c.value.filter(p=>a.has(String(p.id))),t=i.value.searchValue?e.filter(p=>p.nickname.toLowerCase().includes(i.value.searchValue.toLowerCase())):e;i.value.pagination.total=new Set(t.map(p=>p.id)).size;const{current:n,pageSize:s}=i.value.pagination,v=(n-1)*s,f=v+s;i.value.dataSource=t.slice(v,f)}function Q(a,e){return x(this,null,function*(){yield D(a,e)})}function W(a,e){i.value.pagination.current=a,i.value.pagination.pageSize=e,b()}function X(a,e){return x(this,null,function*(){a==="left"?(o.value.searchValue=e,o.value.pagination.current=1,yield D(1,o.value.pagination.pageSize)):(i.value.searchValue=e,i.value.pagination.current=1,b())})}function Y(a){d.value=[...new Set(a)],l("update:value",d.value.map(Number)),b()}function I(){c.value=[],d.value=[],C.value=void 0,d.value=[],o.value={searchValue:"",dataSource:[],pagination:{current:1,pageSize:10,total:0}},i.value={searchValue:"",dataSource:[],pagination:{current:1,pageSize:10,total:0}}}function Z(a,e){return e.username.toLowerCase().includes(a.toLowerCas