cd-personselector 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +225 -210
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/PersonSelector.vue +30 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(p,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(p=typeof globalThis<"u"?globalThis:p||self,e(p.CdPersonSelector={},p.Vue))})(this,function(p,e){"use strict";const j={class:"cd-ps-container"},J={key:0,class:"cd-ps-tips"},q={key:1,class:"cd-ps-search"},A={key:0,class:"cd-ps-org-select"},G={class:"cd-ps-search-input"},H={class:"cd-ps-content"},K={class:"cd-ps-left"},Q={key:0,class:"cd-ps-search-results"},X={class:"cd-ps-search-header"},Y={key:0,class:"cd-ps-loading"},Z={key:1,class:"cd-ps-empty"},v={key:2,class:"cd-ps-result-list"},ee=["onClick"],te={class:"cd-ps-avatar"},oe={class:"cd-ps-info"},le={class:"cd-ps-name"},ne={class:"cd-ps-meta"},se={key:0},ae={key:1},ce={key:2},de={class:"cd-ps-tree"},re={key:0,class:"cd-ps-count"},ie={key:1,class:"cd-ps-empty"},pe={class:"cd-ps-right"},me={class:"cd-ps-right-header"},ke={class:"cd-ps-num"},he={class:"cd-ps-right-list"},fe={key:0,class:"cd-ps-empty"},_e={key:1,class:"cd-ps-selected-list"},ye={class:"cd-ps-item-info"},Ne={class:"cd-ps-info"},Ve={class:"cd-ps-name"},Be={class:"cd-ps-meta"},Ce={key:0},ge={key:1},Ee={key:2},ue={key:3},P=((h,U)=>{const x=h.__vccOpts||h;for(const[a,k]of U)x[a]=k;return x})(e.defineComponent({__name:"PersonSelector",props:{visible:{type:Boolean,default:!1},tabs:{default:()=>[]},organizations:{default:()=>[]},modelValue:{default:()=>[]},dialogWidth:{default:"900px"},tips:{default:""},showSearch:{type:Boolean,default:!0}},emits:["update:visible","update:modelValue","confirm","load-users","search"],setup(h,{expose:U,emit:x}){var F,W;const a=h,k=x,f=e.ref(a.visible),_=e.ref(((W=(F=a.tabs)==null?void 0:F[0])==null?void 0:W.key)||""),C=e.ref(null),y=e.ref(""),c=e.ref([]),w=e.ref({}),D=e.ref(!1),S=e.ref(!1),N=e.ref([]),Se=e.computed(()=>a.tabs||[]),O=e.computed(()=>a.organizations||[]),R=e.computed(()=>a.tips||""),be=e.computed(()=>a.showSearch),Ue=e.computed(()=>a.dialogWidth),g=e.ref({});e.watch(()=>a.tabs,l=>{if(l&&l.length>0){const t={};l.forEach(n=>{t[n.key]=JSON.parse(JSON.stringify(n.tree))}),g.value=t,(!_.value||!l.find(n=>n.key===_.value))&&(_.value=l[0].key)}},{immediate:!0,deep:!0}),e.watch(()=>a.visible,l=>{f.value=l,l&&(c.value=a.modelValue?[...a.modelValue]:[],a.organizations.length>0&&!C.value&&(C.value=a.organizations[0].id))}),e.watch(f,l=>{k("update:visible",l)});function we(l,t){t&&(w.value[l]=t)}function L(l,t){for(const n of l){if(n.id===t)return n;if(n.children){const s=L(n.children,t);if(s)return s}}return null}const E=e.computed(()=>{const l=[];return c.value.forEach(t=>{const n=N.value.find(s=>s.id===t);if(n){l.push({...n,typeName:"搜索结果"});return}for(const s of a.tabs){const d=g.value[s.key]||[],i=L(d,t);if(i){l.push({...i,typeName:s.name});break}}}),l}),De=()=>{y.value=""},ze=()=>{};let V=null;const Te=()=>{if(V&&clearTimeout(V),!y.value.trim()){z();return}D.value=!0,S.value=!0,V=setTimeout(()=>Ie(),300)},Ie=()=>{N.value=[];const l=t=>{N.value=t.map(n=>({...n,isUser:!0})),S.value=!1};k("search",{keyword:y.value,orgId:C.value||void 0,callback:l})},z=()=>{V&&(clearTimeout(V),V=null),D.value=!1,y.value="",N.value=[],S.value=!1},Pe=l=>{const t=c.value.indexOf(l.id);t>-1?c.value.splice(t,1):c.value.push(l.id)};function Oe(l){const t=[],n=s=>{for(const d of s)t.push(d.id),d.children&&n(d.children)};return n(l),t}const Re=l=>{const t=g.value[_.value]||[],n=Oe(t),s=c.value.filter(d=>!n.includes(d));c.value=[...s,...l]};async function Le(l,t){const n=l.value,s=w.value[t];k("load-users",{tabKey:t,nodeId:n,node:l,callback:async i=>{if(i.length>0){const m=i.map(B=>{const{id:u,name:T,...I}=B;return{...I,id:u,name:B.displayName||T,isUser:!0}});if(s){s.appendTo(n,m),l.data.loaded=!0,await e.nextTick();try{s.setItem(n,{expanded:!0})}catch{}}}else l.data.loaded=!0}})}const Me=l=>{c.value=c.value.filter(t=>t!==l)},M=()=>{c.value=[]},Fe=()=>{k("update:modelValue",c.value),k("confirm",E.value),f.value=!1},We=()=>{f.value=!1};return U({clearSelection:M,appendUsers:(l,t,n)=>{const s=w.value[l];if(s&&n.length>0){const d=n.map(i=>{const{id:m,name:B,...u}=i;return{...u,id:m,name:i.displayName||B,isUser:!0}});s.appendTo(t,d)}}}),(l,t)=>{const n=e.resolveComponent("t-icon"),s=e.resolveComponent("t-option"),d=e.resolveComponent("t-select"),i=e.resolveComponent("t-input"),m=e.resolveComponent("t-button"),B=e.resolveComponent("t-loading"),u=e.resolveComponent("t-checkbox"),T=e.resolveComponent("t-tree"),I=e.resolveComponent("t-tab-panel"),$e=e.resolveComponent("t-tabs"),je=e.resolveComponent("t-dialog");return e.openBlock(),e.createBlock(je,{visible:f.value,"onUpdate:visible":t[4]||(t[4]=o=>f.value=o),header:"选择人员",width:Ue.value,footer:!0,"destroy-on-close":"",onConfirm:Fe,onClose:We},{default:e.withCtx(()=>[e.createElementVNode("div",j,[R.value?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(n,{name:"info-circle"}),e.createElementVNode("span",null,e.toDisplayString(R.value),1)])):e.createCommentVNode("",!0),be.value?(e.openBlock(),e.createElementBlock("div",q,[O.value.length>0?(e.openBlock(),e.createElementBlock("div",A,[e.createVNode(d,{modelValue:C.value,"onUpdate:modelValue":t[0]||(t[0]=o=>C.value=o),placeholder:"选择组织",style:{width:"200px"},onChange:ze},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.value,o=>(e.openBlock(),e.createBlock(s,{key:o.id,value:o.id,label:o.displayName||o.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createElementVNode("div",G,[e.createVNode(i,{modelValue:y.value,"onUpdate:modelValue":t[1]||(t[1]=o=>y.value=o),placeholder:"搜索",clearable:"",onInput:Te,onClear:z},{"prefix-icon":e.withCtx(()=>[e.createVNode(n,{name:"search"})]),_:1},8,["modelValue"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",H,[e.createElementVNode("div",K,[D.value?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",X,[t[6]||(t[6]=e.createElementVNode("span",null,"搜索结果",-1)),e.createVNode(m,{size:"small",variant:"text",onClick:z},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("返回",-1)])]),_:1})]),S.value?(e.openBlock(),e.createElementBlock("div",Y,[e.createVNode(B),t[7]||(t[7]=e.createElementVNode("span",null,"搜索中...",-1))])):N.value.length===0?(e.openBlock(),e.createElementBlock("div",Z,[e.createVNode(n,{name:"search",size:"48px",style:{color:"#ddd"}}),t[8]||(t[8]=e.createElementVNode("p",null,"未找到匹配的人员",-1))])):(e.openBlock(),e.createElementBlock("div",v,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id,class:e.normalizeClass(["cd-ps-result-item",{"cd-ps-selected":c.value.includes(o.id)}]),onClick:b=>Pe(o)},[e.createVNode(u,{checked:c.value.includes(o.id),onClick:t[2]||(t[2]=e.withModifiers(()=>{},["stop"]))},null,8,["checked"]),e.createElementVNode("div",te,[e.createVNode(n,{name:"user"})]),e.createElementVNode("div",oe,[e.createElementVNode("div",le,e.toDisplayString(o.displayName||o.name),1),e.createElementVNode("div",ne,[o.position?(e.openBlock(),e.createElementBlock("span",se,e.toDisplayString(o.position),1)):e.createCommentVNode("",!0),o.department?(e.openBlock(),e.createElementBlock("span",ae,e.toDisplayString(o.department),1)):e.createCommentVNode("",!0),o.phone?(e.openBlock(),e.createElementBlock("span",ce,e.toDisplayString(o.phone),1)):e.createCommentVNode("",!0)])])],10,ee))),128))]))])):(e.openBlock(),e.createBlock($e,{key:1,modelValue:_.value,"onUpdate:modelValue":t[3]||(t[3]=o=>_.value=o),onChange:De},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Se.value,o=>(e.openBlock(),e.createBlock(I,{key:o.key,value:o.key,label:o.name},{default:e.withCtx(()=>{var b;return[e.createElementVNode("div",de,[((b=g.value[o.key])==null?void 0:b.length)>0?(e.openBlock(),e.createBlock(T,{key:0,ref_for:!0,ref:r=>we(o.key,r),data:g.value[o.key],keys:{value:"id",label:"name",children:"children"},hover:"",checkable:"","expand-all":!1,value:c.value,onChange:Re},{label:e.withCtx(({node:r})=>{var $;return[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-node",{"cd-ps-node-user":r.data.isUser}])},[e.createVNode(n,{name:r.data.isUser?"user":o.icon||"folder"},null,8,["name"]),e.createElementVNode("span",null,e.toDisplayString(r.label),1),r.data.userCount&&!r.data.isUser?(e.openBlock(),e.createElementBlock("span",re,"("+e.toDisplayString(r.data.userCount)+")",1)):e.createCommentVNode("",!0),!r.data.isUser&&!(($=r.data.children)!=null&&$.length)&&!r.data.loaded?(e.openBlock(),e.createBlock(m,{key:1,size:"small",variant:"text",class:"cd-ps-load-btn",onClick:e.withModifiers(Ae=>Le(r,o.key),["stop"])},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("显示人员",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)],2)]}),_:2},1032,["data","value"])):(e.openBlock(),e.createElementBlock("div",ie,[e.createVNode(n,{name:o.icon||"folder-open",size:"48px",style:{color:"#ddd"}},null,8,["name"]),t[10]||(t[10]=e.createElementVNode("p",null,"暂无数据",-1))]))])]}),_:2},1032,["value","label"]))),128))]),_:1},8,["modelValue"]))]),e.createElementVNode("div",pe,[e.createElementVNode("div",me,[t[12]||(t[12]=e.createElementVNode("span",{class:"cd-ps-title"},"已选择",-1)),e.createElementVNode("span",ke,e.toDisplayString(E.value.length)+" 项",1),E.value.length>0?(e.openBlock(),e.createBlock(m,{key:0,size:"small",variant:"text",onClick:M},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("清空",-1)])]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",he,[E.value.length===0?(e.openBlock(),e.createElementBlock("div",fe,[e.createVNode(n,{name:"user-checked",size:"64px",style:{color:"#ddd"}}),t[13]||(t[13]=e.createElementVNode("p",null,"暂无选择",-1))])):(e.openBlock(),e.createElementBlock("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id,class:e.normalizeClass(["cd-ps-selected-item",{"cd-ps-dept-item":!o.isUser}])},[e.createElementVNode("div",ye,[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-avatar",{"cd-ps-avatar-dept":!o.isUser}])},[e.createVNode(n,{name:o.isUser?"user":"folder"},null,8,["name"])],2),e.createElementVNode("div",Ne,[e.createElementVNode("div",Ve,e.toDisplayString(o.displayName||o.name),1),e.createElementVNode("div",Be,[o.isUser&&o.position?(e.openBlock(),e.createElementBlock("span",Ce,e.toDisplayString(o.position),1)):e.createCommentVNode("",!0),o.isUser&&o.department?(e.openBlock(),e.createElementBlock("span",ge,e.toDisplayString(o.department),1)):e.createCommentVNode("",!0),o.isUser?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Ee,e.toDisplayString(o.typeName||"部门"),1)),!o.isUser&&o.userCount?(e.openBlock(),e.createElementBlock("span",ue,e.toDisplayString(o.userCount)+"人",1)):e.createCommentVNode("",!0)])])]),e.createVNode(m,{size:"small",variant:"text",shape:"circle",onClick:b=>Me(o.id)},{icon:e.withCtx(()=>[e.createVNode(n,{name:"close"})]),_:1},8,["onClick"])],2))),128))]))])])])])]),_:1},8,["visible","width"])}}}),[["__scopeId","data-v-c8a828cf"]]),xe={install(h){h.component("PersonSelector",P)}};p.PersonSelector=P,p.default=xe,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(f,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(f=typeof globalThis<"u"?globalThis:f||self,e(f.CdPersonSelector={},f.Vue))})(this,function(f,e){"use strict";const q={class:"cd-ps-container"},A={key:0,class:"cd-ps-tips"},G={key:1,class:"cd-ps-search"},H={key:0,class:"cd-ps-org-select"},Q={class:"cd-ps-search-input"},X={class:"cd-ps-content"},Y={class:"cd-ps-left"},Z={key:0,class:"cd-ps-search-results"},K={class:"cd-ps-search-header"},v={key:0,class:"cd-ps-loading"},ee={key:1,class:"cd-ps-empty"},te={key:2,class:"cd-ps-result-list"},oe=["onClick"],le={class:"cd-ps-avatar"},ne={class:"cd-ps-info"},se={class:"cd-ps-name"},ae={class:"cd-ps-meta"},ce={key:0},de={key:1},re={key:2},ie={class:"cd-ps-tree"},pe={key:0,class:"cd-ps-count"},me={key:1,class:"cd-ps-empty"},fe={class:"cd-ps-right"},ke={class:"cd-ps-right-header"},he={class:"cd-ps-num"},_e={class:"cd-ps-right-list"},ye={key:0,class:"cd-ps-empty"},Ne={key:1,class:"cd-ps-selected-list"},Ve={class:"cd-ps-item-info"},Be={class:"cd-ps-info"},Ce={class:"cd-ps-name"},ge={class:"cd-ps-meta"},ue={key:0},Ee={key:1},xe={key:2},Se={key:3},R=((_,U)=>{const x=_.__vccOpts||_;for(const[a,k]of U)x[a]=k;return x})(e.defineComponent({__name:"PersonSelector",props:{visible:{type:Boolean,default:!1},tabs:{default:()=>[]},organizations:{default:()=>[]},modelValue:{default:()=>[]},dialogWidth:{default:"900px"},tips:{default:""},showSearch:{type:Boolean,default:!0}},emits:["update:visible","update:modelValue","confirm","load-users","search"],setup(_,{expose:U,emit:x}){var $,j;const a=_,k=x,y=e.ref(a.visible),N=e.ref(((j=($=a.tabs)==null?void 0:$[0])==null?void 0:j.key)||""),u=e.ref(null),V=e.ref(""),c=e.ref([]),w=e.ref({}),D=e.ref(!1),S=e.ref(!1),B=e.ref([]),Ue=e.computed(()=>a.tabs||[]),L=e.computed(()=>a.organizations||[]),M=e.computed(()=>a.tips||""),we=e.computed(()=>a.showSearch),De=e.computed(()=>a.dialogWidth),h=e.ref({});e.watch(()=>a.tabs,n=>{if(n&&n.length>0){const t={};n.forEach(l=>{t[l.key]=JSON.parse(JSON.stringify(l.tree))}),h.value=t,(!N.value||!n.find(l=>l.key===N.value))&&(N.value=n[0].key)}},{immediate:!0,deep:!0}),e.watch(()=>a.visible,n=>{y.value=n,n&&(c.value=a.modelValue?[...a.modelValue]:[],a.organizations.length>0&&!u.value&&(u.value=a.organizations[0].id))}),e.watch(y,n=>{k("update:visible",n)});function Te(n,t){t&&(w.value[n]=t)}function T(n,t){for(const l of n){if(l.id===t)return l;if(l.children){const s=T(l.children,t);if(s)return s}}return null}const E=e.computed(()=>{const n=[];return c.value.forEach(t=>{const l=B.value.find(s=>s.id===t);if(l){n.push({...l,typeName:"搜索结果"});return}for(const s of a.tabs){const d=h.value[s.key]||[],p=T(d,t);if(p){n.push({...p,typeName:s.name});break}}}),n}),ze=()=>{V.value=""},Ie=()=>{};let C=null;const Pe=()=>{if(C&&clearTimeout(C),!V.value.trim()){z();return}D.value=!0,S.value=!0,C=setTimeout(()=>Oe(),300)},Oe=()=>{B.value=[];const n=t=>{B.value=t.map(l=>({...l,isUser:!0})),S.value=!1};k("search",{keyword:V.value,orgId:u.value||void 0,callback:n})},z=()=>{C&&(clearTimeout(C),C=null),D.value=!1,V.value="",B.value=[],S.value=!1},Re=n=>{const t=c.value.indexOf(n.id);t>-1?c.value.splice(t,1):c.value.push(n.id)};function Le(n){const t=[],l=s=>{for(const d of s)t.push(d.id),d.children&&l(d.children)};return l(n),t}const Me=n=>{const t=h.value[N.value]||[],l=Le(t),s=c.value.filter(d=>!l.includes(d));c.value=[...s,...n]};function F(n,t,l){for(const s of n){if(s.id===t)return s.children=s.children||[],s.children.push(...l),s.loaded=!0,!0;if(s.children&&F(s.children,t,l))return!0}return!1}async function Fe(n,t){const l=n.value,s=w.value[t];k("load-users",{tabKey:t,nodeId:l,node:n,callback:async p=>{if(p.length>0){const r=p.map(g=>{const{id:I,name:P,...O}=g;return{...O,id:I,name:g.displayName||P,isUser:!0}}),m=h.value[t];if(m&&F(m,l,r),s){s.appendTo(l,r),n.data.loaded=!0,await e.nextTick();try{s.setItem(l,{expanded:!0})}catch{}}}else{n.data.loaded=!0;const r=h.value[t];if(r){const m=T(r,l);m&&(m.loaded=!0)}}}})}const We=n=>{c.value=c.value.filter(t=>t!==n)},W=()=>{c.value=[]},$e=()=>{k("update:modelValue",c.value),k("confirm",E.value),y.value=!1},je=()=>{y.value=!1};return U({clearSelection:W,appendUsers:(n,t,l)=>{const s=w.value[n];if(s&&l.length>0){const d=l.map(p=>{const{id:r,name:m,...g}=p;return{...g,id:r,name:p.displayName||m,isUser:!0}});s.appendTo(t,d)}}}),(n,t)=>{const l=e.resolveComponent("t-icon"),s=e.resolveComponent("t-option"),d=e.resolveComponent("t-select"),p=e.resolveComponent("t-input"),r=e.resolveComponent("t-button"),m=e.resolveComponent("t-loading"),g=e.resolveComponent("t-checkbox"),I=e.resolveComponent("t-tree"),P=e.resolveComponent("t-tab-panel"),O=e.resolveComponent("t-tabs"),Je=e.resolveComponent("t-dialog");return e.openBlock(),e.createBlock(Je,{visible:y.value,"onUpdate:visible":t[4]||(t[4]=o=>y.value=o),header:"选择人员",width:De.value,footer:!0,"destroy-on-close":"",onConfirm:$e,onClose:je},{default:e.withCtx(()=>[e.createElementVNode("div",q,[M.value?(e.openBlock(),e.createElementBlock("div",A,[e.createVNode(l,{name:"info-circle"}),e.createElementVNode("span",null,e.toDisplayString(M.value),1)])):e.createCommentVNode("",!0),we.value?(e.openBlock(),e.createElementBlock("div",G,[L.value.length>0?(e.openBlock(),e.createElementBlock("div",H,[e.createVNode(d,{modelValue:u.value,"onUpdate:modelValue":t[0]||(t[0]=o=>u.value=o),placeholder:"选择组织",style:{width:"200px"},onChange:Ie},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,o=>(e.openBlock(),e.createBlock(s,{key:o.id,value:o.id,label:o.displayName||o.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createElementVNode("div",Q,[e.createVNode(p,{modelValue:V.value,"onUpdate:modelValue":t[1]||(t[1]=o=>V.value=o),placeholder:"搜索",clearable:"",onInput:Pe,onClear:z},{"prefix-icon":e.withCtx(()=>[e.createVNode(l,{name:"search"})]),_:1},8,["modelValue"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",X,[e.createElementVNode("div",Y,[D.value?(e.openBlock(),e.createElementBlock("div",Z,[e.createElementVNode("div",K,[t[6]||(t[6]=e.createElementVNode("span",null,"搜索结果",-1)),e.createVNode(r,{size:"small",variant:"text",onClick:z},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("返回",-1)])]),_:1})]),S.value?(e.openBlock(),e.createElementBlock("div",v,[e.createVNode(m),t[7]||(t[7]=e.createElementVNode("span",null,"搜索中...",-1))])):B.value.length===0?(e.openBlock(),e.createElementBlock("div",ee,[e.createVNode(l,{name:"search",size:"48px",style:{color:"#ddd"}}),t[8]||(t[8]=e.createElementVNode("p",null,"未找到匹配的人员",-1))])):(e.openBlock(),e.createElementBlock("div",te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id,class:e.normalizeClass(["cd-ps-result-item",{"cd-ps-selected":c.value.includes(o.id)}]),onClick:b=>Re(o)},[e.createVNode(g,{checked:c.value.includes(o.id),onClick:t[2]||(t[2]=e.withModifiers(()=>{},["stop"]))},null,8,["checked"]),e.createElementVNode("div",le,[e.createVNode(l,{name:"user"})]),e.createElementVNode("div",ne,[e.createElementVNode("div",se,e.toDisplayString(o.displayName||o.name),1),e.createElementVNode("div",ae,[o.position?(e.openBlock(),e.createElementBlock("span",ce,e.toDisplayString(o.position),1)):e.createCommentVNode("",!0),o.department?(e.openBlock(),e.createElementBlock("span",de,e.toDisplayString(o.department),1)):e.createCommentVNode("",!0),o.phone?(e.openBlock(),e.createElementBlock("span",re,e.toDisplayString(o.phone),1)):e.createCommentVNode("",!0)])])],10,oe))),128))]))])):(e.openBlock(),e.createBlock(O,{key:1,modelValue:N.value,"onUpdate:modelValue":t[3]||(t[3]=o=>N.value=o),onChange:ze},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ue.value,o=>(e.openBlock(),e.createBlock(P,{key:o.key,value:o.key,label:o.name},{default:e.withCtx(()=>{var b;return[e.createElementVNode("div",ie,[((b=h.value[o.key])==null?void 0:b.length)>0?(e.openBlock(),e.createBlock(I,{key:0,ref_for:!0,ref:i=>Te(o.key,i),data:h.value[o.key],keys:{value:"id",label:"name",children:"children"},hover:"",checkable:"","expand-all":!1,value:c.value,onChange:Me},{label:e.withCtx(({node:i})=>{var J;return[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-node",{"cd-ps-node-user":i.data.isUser}])},[e.createVNode(l,{name:i.data.isUser?"user":o.icon||"folder"},null,8,["name"]),e.createElementVNode("span",null,e.toDisplayString(i.label),1),i.data.userCount&&!i.data.isUser?(e.openBlock(),e.createElementBlock("span",pe,"("+e.toDisplayString(i.data.userCount)+")",1)):e.createCommentVNode("",!0),!i.data.isUser&&!((J=i.data.children)!=null&&J.length)&&!i.data.loaded?(e.openBlock(),e.createBlock(r,{key:1,size:"small",variant:"text",class:"cd-ps-load-btn",onClick:e.withModifiers(Ge=>Fe(i,o.key),["stop"])},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("显示人员",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)],2)]}),_:2},1032,["data","value"])):(e.openBlock(),e.createElementBlock("div",me,[e.createVNode(l,{name:o.icon||"folder-open",size:"48px",style:{color:"#ddd"}},null,8,["name"]),t[10]||(t[10]=e.createElementVNode("p",null,"暂无数据",-1))]))])]}),_:2},1032,["value","label"]))),128))]),_:1},8,["modelValue"]))]),e.createElementVNode("div",fe,[e.createElementVNode("div",ke,[t[12]||(t[12]=e.createElementVNode("span",{class:"cd-ps-title"},"已选择",-1)),e.createElementVNode("span",he,e.toDisplayString(E.value.length)+" 项",1),E.value.length>0?(e.openBlock(),e.createBlock(r,{key:0,size:"small",variant:"text",onClick:W},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("清空",-1)])]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",_e,[E.value.length===0?(e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(l,{name:"user-checked",size:"64px",style:{color:"#ddd"}}),t[13]||(t[13]=e.createElementVNode("p",null,"暂无选择",-1))])):(e.openBlock(),e.createElementBlock("div",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id,class:e.normalizeClass(["cd-ps-selected-item",{"cd-ps-dept-item":!o.isUser}])},[e.createElementVNode("div",Ve,[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-avatar",{"cd-ps-avatar-dept":!o.isUser}])},[e.createVNode(l,{name:o.isUser?"user":"folder"},null,8,["name"])],2),e.createElementVNode("div",Be,[e.createElementVNode("div",Ce,e.toDisplayString(o.displayName||o.name),1),e.createElementVNode("div",ge,[o.isUser&&o.position?(e.openBlock(),e.createElementBlock("span",ue,e.toDisplayString(o.position),1)):e.createCommentVNode("",!0),o.isUser&&o.department?(e.openBlock(),e.createElementBlock("span",Ee,e.toDisplayString(o.department),1)):e.createCommentVNode("",!0),o.isUser?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",xe,e.toDisplayString(o.typeName||"部门"),1)),!o.isUser&&o.userCount?(e.openBlock(),e.createElementBlock("span",Se,e.toDisplayString(o.userCount)+"人",1)):e.createCommentVNode("",!0)])])]),e.createVNode(r,{size:"small",variant:"text",shape:"circle",onClick:b=>We(o.id)},{icon:e.withCtx(()=>[e.createVNode(l,{name:"close"})]),_:1},8,["onClick"])],2))),128))]))])])])])]),_:1},8,["visible","width"])}}}),[["__scopeId","data-v-70933f0f"]]),be={install(_){_.component("PersonSelector",R)}};f.PersonSelector=R,f.default=be,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as ge, ref as k, computed as w, watch as H, resolveComponent as f, createBlock as x, openBlock as n, withCtx as y, createElementVNode as o, createElementBlock as d, createCommentVNode as u, createVNode as i, toDisplayString as p, Fragment as E, renderList as L, createTextVNode as Q, normalizeClass as W, withModifiers as le, nextTick as Ce } from "vue";
|
|
2
|
+
const be = { class: "cd-ps-container" }, xe = {
|
|
3
3
|
key: 0,
|
|
4
4
|
class: "cd-ps-tips"
|
|
5
|
-
},
|
|
5
|
+
}, Ne = {
|
|
6
6
|
key: 1,
|
|
7
7
|
class: "cd-ps-search"
|
|
8
8
|
}, Ue = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "cd-ps-org-select"
|
|
11
|
-
},
|
|
11
|
+
}, Se = { class: "cd-ps-search-input" }, Ve = { class: "cd-ps-content" }, ze = { class: "cd-ps-left" }, Ie = {
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "cd-ps-search-results"
|
|
14
|
-
},
|
|
14
|
+
}, Te = { class: "cd-ps-search-header" }, we = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "cd-ps-loading"
|
|
17
|
-
},
|
|
17
|
+
}, De = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "cd-ps-empty"
|
|
20
20
|
}, Re = {
|
|
21
21
|
key: 2,
|
|
22
22
|
class: "cd-ps-result-list"
|
|
23
|
-
}, Be = ["onClick"], Oe = { class: "cd-ps-avatar" },
|
|
23
|
+
}, Be = ["onClick"], Oe = { class: "cd-ps-avatar" }, Pe = { class: "cd-ps-info" }, Ee = { class: "cd-ps-name" }, Le = { class: "cd-ps-meta" }, We = { key: 0 }, $e = { key: 1 }, Je = { key: 2 }, Me = { class: "cd-ps-tree" }, Ae = {
|
|
24
24
|
key: 0,
|
|
25
25
|
class: "cd-ps-count"
|
|
26
|
-
},
|
|
26
|
+
}, Fe = {
|
|
27
27
|
key: 1,
|
|
28
28
|
class: "cd-ps-empty"
|
|
29
|
-
},
|
|
29
|
+
}, je = { class: "cd-ps-right" }, qe = { class: "cd-ps-right-header" }, Ge = { class: "cd-ps-num" }, He = { class: "cd-ps-right-list" }, Qe = {
|
|
30
30
|
key: 0,
|
|
31
31
|
class: "cd-ps-empty"
|
|
32
|
-
},
|
|
32
|
+
}, Xe = {
|
|
33
33
|
key: 1,
|
|
34
34
|
class: "cd-ps-selected-list"
|
|
35
|
-
},
|
|
35
|
+
}, Ye = { class: "cd-ps-item-info" }, Ze = { class: "cd-ps-info" }, Ke = { class: "cd-ps-name" }, et = { class: "cd-ps-meta" }, tt = { key: 0 }, st = { key: 1 }, lt = { key: 2 }, nt = { key: 3 }, at = /* @__PURE__ */ ge({
|
|
36
36
|
__name: "PersonSelector",
|
|
37
37
|
props: {
|
|
38
38
|
visible: { type: Boolean, default: !1 },
|
|
@@ -44,153 +44,168 @@ const Ce = { class: "cd-ps-container" }, be = {
|
|
|
44
44
|
showSearch: { type: Boolean, default: !0 }
|
|
45
45
|
},
|
|
46
46
|
emits: ["update:visible", "update:modelValue", "confirm", "load-users", "search"],
|
|
47
|
-
setup(
|
|
48
|
-
var
|
|
49
|
-
const c =
|
|
50
|
-
|
|
51
|
-
if (
|
|
47
|
+
setup(N, { expose: $, emit: B }) {
|
|
48
|
+
var ee, te;
|
|
49
|
+
const c = N, C = B, U = k(c.visible), S = k(((te = (ee = c.tabs) == null ? void 0 : ee[0]) == null ? void 0 : te.key) || ""), D = k(null), V = k(""), r = k([]), J = k({}), M = k(!1), O = k(!1), z = k([]), ne = w(() => c.tabs || []), X = w(() => c.organizations || []), Y = w(() => c.tips || ""), ae = w(() => c.showSearch), oe = w(() => c.dialogWidth), b = k({});
|
|
50
|
+
H(() => c.tabs, (l) => {
|
|
51
|
+
if (l && l.length > 0) {
|
|
52
52
|
const e = {};
|
|
53
|
-
|
|
54
|
-
e[
|
|
55
|
-
}),
|
|
53
|
+
l.forEach((s) => {
|
|
54
|
+
e[s.key] = JSON.parse(JSON.stringify(s.tree));
|
|
55
|
+
}), b.value = e, (!S.value || !l.find((s) => s.key === S.value)) && (S.value = l[0].key);
|
|
56
56
|
}
|
|
57
|
-
}, { immediate: !0, deep: !0 }),
|
|
58
|
-
|
|
59
|
-
}),
|
|
60
|
-
|
|
57
|
+
}, { immediate: !0, deep: !0 }), H(() => c.visible, (l) => {
|
|
58
|
+
U.value = l, l && (r.value = c.modelValue ? [...c.modelValue] : [], c.organizations.length > 0 && !D.value && (D.value = c.organizations[0].id));
|
|
59
|
+
}), H(U, (l) => {
|
|
60
|
+
C("update:visible", l);
|
|
61
61
|
});
|
|
62
|
-
function
|
|
63
|
-
e && (J.value[
|
|
62
|
+
function de(l, e) {
|
|
63
|
+
e && (J.value[l] = e);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
for (const
|
|
67
|
-
if (
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
65
|
+
function A(l, e) {
|
|
66
|
+
for (const s of l) {
|
|
67
|
+
if (s.id === e) return s;
|
|
68
|
+
if (s.children) {
|
|
69
|
+
const a = A(s.children, e);
|
|
70
|
+
if (a) return a;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
const R =
|
|
76
|
-
const
|
|
75
|
+
const R = w(() => {
|
|
76
|
+
const l = [];
|
|
77
77
|
return r.value.forEach((e) => {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
|
|
78
|
+
const s = z.value.find((a) => a.id === e);
|
|
79
|
+
if (s) {
|
|
80
|
+
l.push({ ...s, typeName: "搜索结果" });
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
for (const
|
|
84
|
-
const v =
|
|
83
|
+
for (const a of c.tabs) {
|
|
84
|
+
const v = b.value[a.key] || [], m = A(v, e);
|
|
85
85
|
if (m) {
|
|
86
|
-
|
|
86
|
+
l.push({ ...m, typeName: a.name });
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
}),
|
|
91
|
-
}),
|
|
92
|
-
|
|
93
|
-
},
|
|
90
|
+
}), l;
|
|
91
|
+
}), ce = () => {
|
|
92
|
+
V.value = "";
|
|
93
|
+
}, ie = () => {
|
|
94
94
|
};
|
|
95
|
-
let
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
|
|
95
|
+
let I = null;
|
|
96
|
+
const re = () => {
|
|
97
|
+
if (I && clearTimeout(I), !V.value.trim()) {
|
|
98
|
+
F();
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
M.value = !0,
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
101
|
+
M.value = !0, O.value = !0, I = setTimeout(() => ue(), 300);
|
|
102
|
+
}, ue = () => {
|
|
103
|
+
z.value = [];
|
|
104
|
+
const l = (e) => {
|
|
105
|
+
z.value = e.map((s) => ({ ...s, isUser: !0 })), O.value = !1;
|
|
106
106
|
};
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
const e = r.value.indexOf(
|
|
112
|
-
e > -1 ? r.value.splice(e, 1) : r.value.push(
|
|
107
|
+
C("search", { keyword: V.value, orgId: D.value || void 0, callback: l });
|
|
108
|
+
}, F = () => {
|
|
109
|
+
I && (clearTimeout(I), I = null), M.value = !1, V.value = "", z.value = [], O.value = !1;
|
|
110
|
+
}, pe = (l) => {
|
|
111
|
+
const e = r.value.indexOf(l.id);
|
|
112
|
+
e > -1 ? r.value.splice(e, 1) : r.value.push(l.id);
|
|
113
113
|
};
|
|
114
|
-
function
|
|
115
|
-
const e = [],
|
|
116
|
-
for (const v of
|
|
117
|
-
e.push(v.id), v.children &&
|
|
114
|
+
function ve(l) {
|
|
115
|
+
const e = [], s = (a) => {
|
|
116
|
+
for (const v of a)
|
|
117
|
+
e.push(v.id), v.children && s(v.children);
|
|
118
118
|
};
|
|
119
|
-
return l
|
|
119
|
+
return s(l), e;
|
|
120
120
|
}
|
|
121
|
-
const
|
|
122
|
-
const e =
|
|
123
|
-
r.value = [...
|
|
121
|
+
const he = (l) => {
|
|
122
|
+
const e = b.value[S.value] || [], s = ve(e), a = r.value.filter((v) => !s.includes(v));
|
|
123
|
+
r.value = [...a, ...l];
|
|
124
124
|
};
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
125
|
+
function Z(l, e, s) {
|
|
126
|
+
for (const a of l) {
|
|
127
|
+
if (a.id === e)
|
|
128
|
+
return a.children = a.children || [], a.children.push(...s), a.loaded = !0, !0;
|
|
129
|
+
if (a.children && Z(a.children, e, s))
|
|
130
|
+
return !0;
|
|
131
|
+
}
|
|
132
|
+
return !1;
|
|
133
|
+
}
|
|
134
|
+
async function _e(l, e) {
|
|
135
|
+
const s = l.value, a = J.value[e];
|
|
136
|
+
C("load-users", { tabKey: e, nodeId: s, node: l, callback: async (m) => {
|
|
128
137
|
if (m.length > 0) {
|
|
129
|
-
const
|
|
130
|
-
const { id:
|
|
131
|
-
return { ...
|
|
132
|
-
});
|
|
133
|
-
if (
|
|
134
|
-
|
|
138
|
+
const h = m.map((T) => {
|
|
139
|
+
const { id: j, name: q, ...G } = T;
|
|
140
|
+
return { ...G, id: j, name: T.displayName || q, isUser: !0 };
|
|
141
|
+
}), g = b.value[e];
|
|
142
|
+
if (g && Z(g, s, h), a) {
|
|
143
|
+
a.appendTo(s, h), l.data.loaded = !0, await Ce();
|
|
135
144
|
try {
|
|
136
|
-
|
|
145
|
+
a.setItem(s, { expanded: !0 });
|
|
137
146
|
} catch {
|
|
138
147
|
}
|
|
139
148
|
}
|
|
140
|
-
} else
|
|
141
|
-
|
|
149
|
+
} else {
|
|
150
|
+
l.data.loaded = !0;
|
|
151
|
+
const h = b.value[e];
|
|
152
|
+
if (h) {
|
|
153
|
+
const g = A(h, s);
|
|
154
|
+
g && (g.loaded = !0);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
142
157
|
} });
|
|
143
158
|
}
|
|
144
|
-
const
|
|
145
|
-
r.value = r.value.filter((e) => e !==
|
|
146
|
-
},
|
|
159
|
+
const fe = (l) => {
|
|
160
|
+
r.value = r.value.filter((e) => e !== l);
|
|
161
|
+
}, K = () => {
|
|
147
162
|
r.value = [];
|
|
148
|
-
}, he = () => {
|
|
149
|
-
g("update:modelValue", r.value), g("confirm", R.value), x.value = !1;
|
|
150
163
|
}, me = () => {
|
|
151
|
-
|
|
164
|
+
C("update:modelValue", r.value), C("confirm", R.value), U.value = !1;
|
|
165
|
+
}, ke = () => {
|
|
166
|
+
U.value = !1;
|
|
152
167
|
};
|
|
153
168
|
return $({
|
|
154
|
-
clearSelection:
|
|
155
|
-
appendUsers: (
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const v =
|
|
159
|
-
const { id:
|
|
160
|
-
return { ...
|
|
169
|
+
clearSelection: K,
|
|
170
|
+
appendUsers: (l, e, s) => {
|
|
171
|
+
const a = J.value[l];
|
|
172
|
+
if (a && s.length > 0) {
|
|
173
|
+
const v = s.map((m) => {
|
|
174
|
+
const { id: h, name: g, ...T } = m;
|
|
175
|
+
return { ...T, id: h, name: m.displayName || g, isUser: !0 };
|
|
161
176
|
});
|
|
162
|
-
|
|
177
|
+
a.appendTo(e, v);
|
|
163
178
|
}
|
|
164
179
|
}
|
|
165
|
-
}), (
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
visible:
|
|
169
|
-
"onUpdate:visible": e[4] || (e[4] = (t) =>
|
|
180
|
+
}), (l, e) => {
|
|
181
|
+
const s = f("t-icon"), a = f("t-option"), v = f("t-select"), m = f("t-input"), h = f("t-button"), g = f("t-loading"), T = f("t-checkbox"), j = f("t-tree"), q = f("t-tab-panel"), G = f("t-tabs"), ye = f("t-dialog");
|
|
182
|
+
return n(), x(ye, {
|
|
183
|
+
visible: U.value,
|
|
184
|
+
"onUpdate:visible": e[4] || (e[4] = (t) => U.value = t),
|
|
170
185
|
header: "选择人员",
|
|
171
|
-
width:
|
|
186
|
+
width: oe.value,
|
|
172
187
|
footer: !0,
|
|
173
188
|
"destroy-on-close": "",
|
|
174
|
-
onConfirm:
|
|
175
|
-
onClose:
|
|
189
|
+
onConfirm: me,
|
|
190
|
+
onClose: ke
|
|
176
191
|
}, {
|
|
177
|
-
default:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
i(
|
|
181
|
-
|
|
192
|
+
default: y(() => [
|
|
193
|
+
o("div", be, [
|
|
194
|
+
Y.value ? (n(), d("div", xe, [
|
|
195
|
+
i(s, { name: "info-circle" }),
|
|
196
|
+
o("span", null, p(Y.value), 1)
|
|
182
197
|
])) : u("", !0),
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
ae.value ? (n(), d("div", Ne, [
|
|
199
|
+
X.value.length > 0 ? (n(), d("div", Ue, [
|
|
185
200
|
i(v, {
|
|
186
|
-
modelValue:
|
|
187
|
-
"onUpdate:modelValue": e[0] || (e[0] = (t) =>
|
|
201
|
+
modelValue: D.value,
|
|
202
|
+
"onUpdate:modelValue": e[0] || (e[0] = (t) => D.value = t),
|
|
188
203
|
placeholder: "选择组织",
|
|
189
204
|
style: { width: "200px" },
|
|
190
|
-
onChange:
|
|
205
|
+
onChange: ie
|
|
191
206
|
}, {
|
|
192
|
-
default:
|
|
193
|
-
(
|
|
207
|
+
default: y(() => [
|
|
208
|
+
(n(!0), d(E, null, L(X.value, (t) => (n(), x(a, {
|
|
194
209
|
key: t.id,
|
|
195
210
|
value: t.id,
|
|
196
211
|
label: t.displayName || t.name
|
|
@@ -199,120 +214,120 @@ const Ce = { class: "cd-ps-container" }, be = {
|
|
|
199
214
|
_: 1
|
|
200
215
|
}, 8, ["modelValue"])
|
|
201
216
|
])) : u("", !0),
|
|
202
|
-
|
|
217
|
+
o("div", Se, [
|
|
203
218
|
i(m, {
|
|
204
|
-
modelValue:
|
|
205
|
-
"onUpdate:modelValue": e[1] || (e[1] = (t) =>
|
|
219
|
+
modelValue: V.value,
|
|
220
|
+
"onUpdate:modelValue": e[1] || (e[1] = (t) => V.value = t),
|
|
206
221
|
placeholder: "搜索",
|
|
207
222
|
clearable: "",
|
|
208
|
-
onInput:
|
|
209
|
-
onClear:
|
|
223
|
+
onInput: re,
|
|
224
|
+
onClear: F
|
|
210
225
|
}, {
|
|
211
|
-
"prefix-icon":
|
|
212
|
-
i(
|
|
226
|
+
"prefix-icon": y(() => [
|
|
227
|
+
i(s, { name: "search" })
|
|
213
228
|
]),
|
|
214
229
|
_: 1
|
|
215
230
|
}, 8, ["modelValue"])
|
|
216
231
|
])
|
|
217
232
|
])) : u("", !0),
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
M.value ? (
|
|
221
|
-
|
|
222
|
-
e[6] || (e[6] =
|
|
223
|
-
i(
|
|
233
|
+
o("div", Ve, [
|
|
234
|
+
o("div", ze, [
|
|
235
|
+
M.value ? (n(), d("div", Ie, [
|
|
236
|
+
o("div", Te, [
|
|
237
|
+
e[6] || (e[6] = o("span", null, "搜索结果", -1)),
|
|
238
|
+
i(h, {
|
|
224
239
|
size: "small",
|
|
225
240
|
variant: "text",
|
|
226
|
-
onClick:
|
|
241
|
+
onClick: F
|
|
227
242
|
}, {
|
|
228
|
-
default:
|
|
229
|
-
|
|
243
|
+
default: y(() => [...e[5] || (e[5] = [
|
|
244
|
+
Q("返回", -1)
|
|
230
245
|
])]),
|
|
231
246
|
_: 1
|
|
232
247
|
})
|
|
233
248
|
]),
|
|
234
|
-
|
|
235
|
-
i(
|
|
236
|
-
e[7] || (e[7] =
|
|
237
|
-
])) :
|
|
238
|
-
i(
|
|
249
|
+
O.value ? (n(), d("div", we, [
|
|
250
|
+
i(g),
|
|
251
|
+
e[7] || (e[7] = o("span", null, "搜索中...", -1))
|
|
252
|
+
])) : z.value.length === 0 ? (n(), d("div", De, [
|
|
253
|
+
i(s, {
|
|
239
254
|
name: "search",
|
|
240
255
|
size: "48px",
|
|
241
256
|
style: { color: "#ddd" }
|
|
242
257
|
}),
|
|
243
|
-
e[8] || (e[8] =
|
|
244
|
-
])) : (
|
|
245
|
-
(
|
|
258
|
+
e[8] || (e[8] = o("p", null, "未找到匹配的人员", -1))
|
|
259
|
+
])) : (n(), d("div", Re, [
|
|
260
|
+
(n(!0), d(E, null, L(z.value, (t) => (n(), d("div", {
|
|
246
261
|
key: t.id,
|
|
247
262
|
class: W(["cd-ps-result-item", { "cd-ps-selected": r.value.includes(t.id) }]),
|
|
248
|
-
onClick: (P) =>
|
|
263
|
+
onClick: (P) => pe(t)
|
|
249
264
|
}, [
|
|
250
|
-
i(
|
|
265
|
+
i(T, {
|
|
251
266
|
checked: r.value.includes(t.id),
|
|
252
|
-
onClick: e[2] || (e[2] =
|
|
267
|
+
onClick: e[2] || (e[2] = le(() => {
|
|
253
268
|
}, ["stop"]))
|
|
254
269
|
}, null, 8, ["checked"]),
|
|
255
|
-
|
|
256
|
-
i(
|
|
270
|
+
o("div", Oe, [
|
|
271
|
+
i(s, { name: "user" })
|
|
257
272
|
]),
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
t.position ? (
|
|
262
|
-
t.department ? (
|
|
263
|
-
t.phone ? (
|
|
273
|
+
o("div", Pe, [
|
|
274
|
+
o("div", Ee, p(t.displayName || t.name), 1),
|
|
275
|
+
o("div", Le, [
|
|
276
|
+
t.position ? (n(), d("span", We, p(t.position), 1)) : u("", !0),
|
|
277
|
+
t.department ? (n(), d("span", $e, p(t.department), 1)) : u("", !0),
|
|
278
|
+
t.phone ? (n(), d("span", Je, p(t.phone), 1)) : u("", !0)
|
|
264
279
|
])
|
|
265
280
|
])
|
|
266
281
|
], 10, Be))), 128))
|
|
267
282
|
]))
|
|
268
|
-
])) : (
|
|
283
|
+
])) : (n(), x(G, {
|
|
269
284
|
key: 1,
|
|
270
|
-
modelValue:
|
|
271
|
-
"onUpdate:modelValue": e[3] || (e[3] = (t) =>
|
|
272
|
-
onChange:
|
|
285
|
+
modelValue: S.value,
|
|
286
|
+
"onUpdate:modelValue": e[3] || (e[3] = (t) => S.value = t),
|
|
287
|
+
onChange: ce
|
|
273
288
|
}, {
|
|
274
|
-
default:
|
|
275
|
-
(
|
|
289
|
+
default: y(() => [
|
|
290
|
+
(n(!0), d(E, null, L(ne.value, (t) => (n(), x(q, {
|
|
276
291
|
key: t.key,
|
|
277
292
|
value: t.key,
|
|
278
293
|
label: t.name
|
|
279
294
|
}, {
|
|
280
|
-
default:
|
|
295
|
+
default: y(() => {
|
|
281
296
|
var P;
|
|
282
297
|
return [
|
|
283
|
-
|
|
284
|
-
((P =
|
|
298
|
+
o("div", Me, [
|
|
299
|
+
((P = b.value[t.key]) == null ? void 0 : P.length) > 0 ? (n(), x(j, {
|
|
285
300
|
key: 0,
|
|
286
301
|
ref_for: !0,
|
|
287
|
-
ref: (_) =>
|
|
288
|
-
data:
|
|
302
|
+
ref: (_) => de(t.key, _),
|
|
303
|
+
data: b.value[t.key],
|
|
289
304
|
keys: { value: "id", label: "name", children: "children" },
|
|
290
305
|
hover: "",
|
|
291
306
|
checkable: "",
|
|
292
307
|
"expand-all": !1,
|
|
293
308
|
value: r.value,
|
|
294
|
-
onChange:
|
|
309
|
+
onChange: he
|
|
295
310
|
}, {
|
|
296
|
-
label:
|
|
297
|
-
var
|
|
311
|
+
label: y(({ node: _ }) => {
|
|
312
|
+
var se;
|
|
298
313
|
return [
|
|
299
|
-
|
|
314
|
+
o("div", {
|
|
300
315
|
class: W(["cd-ps-node", { "cd-ps-node-user": _.data.isUser }])
|
|
301
316
|
}, [
|
|
302
|
-
i(
|
|
317
|
+
i(s, {
|
|
303
318
|
name: _.data.isUser ? "user" : t.icon || "folder"
|
|
304
319
|
}, null, 8, ["name"]),
|
|
305
|
-
|
|
306
|
-
_.data.userCount && !_.data.isUser ? (
|
|
307
|
-
!_.data.isUser && !((
|
|
320
|
+
o("span", null, p(_.label), 1),
|
|
321
|
+
_.data.userCount && !_.data.isUser ? (n(), d("span", Ae, "(" + p(_.data.userCount) + ")", 1)) : u("", !0),
|
|
322
|
+
!_.data.isUser && !((se = _.data.children) != null && se.length) && !_.data.loaded ? (n(), x(h, {
|
|
308
323
|
key: 1,
|
|
309
324
|
size: "small",
|
|
310
325
|
variant: "text",
|
|
311
326
|
class: "cd-ps-load-btn",
|
|
312
|
-
onClick:
|
|
327
|
+
onClick: le((ct) => _e(_, t.key), ["stop"])
|
|
313
328
|
}, {
|
|
314
|
-
default:
|
|
315
|
-
|
|
329
|
+
default: y(() => [...e[9] || (e[9] = [
|
|
330
|
+
Q("显示人员", -1)
|
|
316
331
|
])]),
|
|
317
332
|
_: 1
|
|
318
333
|
}, 8, ["onClick"])) : u("", !0)
|
|
@@ -320,13 +335,13 @@ const Ce = { class: "cd-ps-container" }, be = {
|
|
|
320
335
|
];
|
|
321
336
|
}),
|
|
322
337
|
_: 2
|
|
323
|
-
}, 1032, ["data", "value"])) : (
|
|
324
|
-
i(
|
|
338
|
+
}, 1032, ["data", "value"])) : (n(), d("div", Fe, [
|
|
339
|
+
i(s, {
|
|
325
340
|
name: t.icon || "folder-open",
|
|
326
341
|
size: "48px",
|
|
327
342
|
style: { color: "#ddd" }
|
|
328
343
|
}, null, 8, ["name"]),
|
|
329
|
-
e[10] || (e[10] =
|
|
344
|
+
e[10] || (e[10] = o("p", null, "暂无数据", -1))
|
|
330
345
|
]))
|
|
331
346
|
])
|
|
332
347
|
];
|
|
@@ -337,61 +352,61 @@ const Ce = { class: "cd-ps-container" }, be = {
|
|
|
337
352
|
_: 1
|
|
338
353
|
}, 8, ["modelValue"]))
|
|
339
354
|
]),
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
e[12] || (e[12] =
|
|
343
|
-
|
|
344
|
-
R.value.length > 0 ? (
|
|
355
|
+
o("div", je, [
|
|
356
|
+
o("div", qe, [
|
|
357
|
+
e[12] || (e[12] = o("span", { class: "cd-ps-title" }, "已选择", -1)),
|
|
358
|
+
o("span", Ge, p(R.value.length) + " 项", 1),
|
|
359
|
+
R.value.length > 0 ? (n(), x(h, {
|
|
345
360
|
key: 0,
|
|
346
361
|
size: "small",
|
|
347
362
|
variant: "text",
|
|
348
|
-
onClick:
|
|
363
|
+
onClick: K
|
|
349
364
|
}, {
|
|
350
|
-
default:
|
|
351
|
-
|
|
365
|
+
default: y(() => [...e[11] || (e[11] = [
|
|
366
|
+
Q("清空", -1)
|
|
352
367
|
])]),
|
|
353
368
|
_: 1
|
|
354
369
|
})) : u("", !0)
|
|
355
370
|
]),
|
|
356
|
-
|
|
357
|
-
R.value.length === 0 ? (
|
|
358
|
-
i(
|
|
371
|
+
o("div", He, [
|
|
372
|
+
R.value.length === 0 ? (n(), d("div", Qe, [
|
|
373
|
+
i(s, {
|
|
359
374
|
name: "user-checked",
|
|
360
375
|
size: "64px",
|
|
361
376
|
style: { color: "#ddd" }
|
|
362
377
|
}),
|
|
363
|
-
e[13] || (e[13] =
|
|
364
|
-
])) : (
|
|
365
|
-
(
|
|
378
|
+
e[13] || (e[13] = o("p", null, "暂无选择", -1))
|
|
379
|
+
])) : (n(), d("div", Xe, [
|
|
380
|
+
(n(!0), d(E, null, L(R.value, (t) => (n(), d("div", {
|
|
366
381
|
key: t.id,
|
|
367
382
|
class: W(["cd-ps-selected-item", { "cd-ps-dept-item": !t.isUser }])
|
|
368
383
|
}, [
|
|
369
|
-
|
|
370
|
-
|
|
384
|
+
o("div", Ye, [
|
|
385
|
+
o("div", {
|
|
371
386
|
class: W(["cd-ps-avatar", { "cd-ps-avatar-dept": !t.isUser }])
|
|
372
387
|
}, [
|
|
373
|
-
i(
|
|
388
|
+
i(s, {
|
|
374
389
|
name: t.isUser ? "user" : "folder"
|
|
375
390
|
}, null, 8, ["name"])
|
|
376
391
|
], 2),
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
t.isUser && t.position ? (
|
|
381
|
-
t.isUser && t.department ? (
|
|
382
|
-
t.isUser ? u("", !0) : (
|
|
383
|
-
!t.isUser && t.userCount ? (
|
|
392
|
+
o("div", Ze, [
|
|
393
|
+
o("div", Ke, p(t.displayName || t.name), 1),
|
|
394
|
+
o("div", et, [
|
|
395
|
+
t.isUser && t.position ? (n(), d("span", tt, p(t.position), 1)) : u("", !0),
|
|
396
|
+
t.isUser && t.department ? (n(), d("span", st, p(t.department), 1)) : u("", !0),
|
|
397
|
+
t.isUser ? u("", !0) : (n(), d("span", lt, p(t.typeName || "部门"), 1)),
|
|
398
|
+
!t.isUser && t.userCount ? (n(), d("span", nt, p(t.userCount) + "人", 1)) : u("", !0)
|
|
384
399
|
])
|
|
385
400
|
])
|
|
386
401
|
]),
|
|
387
|
-
i(
|
|
402
|
+
i(h, {
|
|
388
403
|
size: "small",
|
|
389
404
|
variant: "text",
|
|
390
405
|
shape: "circle",
|
|
391
|
-
onClick: (P) =>
|
|
406
|
+
onClick: (P) => fe(t.id)
|
|
392
407
|
}, {
|
|
393
|
-
icon:
|
|
394
|
-
i(
|
|
408
|
+
icon: y(() => [
|
|
409
|
+
i(s, { name: "close" })
|
|
395
410
|
]),
|
|
396
411
|
_: 1
|
|
397
412
|
}, 8, ["onClick"])
|
|
@@ -406,17 +421,17 @@ const Ce = { class: "cd-ps-container" }, be = {
|
|
|
406
421
|
}, 8, ["visible", "width"]);
|
|
407
422
|
};
|
|
408
423
|
}
|
|
409
|
-
}),
|
|
410
|
-
const
|
|
411
|
-
for (const [c,
|
|
412
|
-
|
|
413
|
-
return
|
|
414
|
-
},
|
|
415
|
-
install(
|
|
416
|
-
|
|
424
|
+
}), ot = (N, $) => {
|
|
425
|
+
const B = N.__vccOpts || N;
|
|
426
|
+
for (const [c, C] of $)
|
|
427
|
+
B[c] = C;
|
|
428
|
+
return B;
|
|
429
|
+
}, dt = /* @__PURE__ */ ot(at, [["__scopeId", "data-v-70933f0f"]]), rt = {
|
|
430
|
+
install(N) {
|
|
431
|
+
N.component("PersonSelector", dt);
|
|
417
432
|
}
|
|
418
433
|
};
|
|
419
434
|
export {
|
|
420
|
-
|
|
421
|
-
|
|
435
|
+
dt as PersonSelector,
|
|
436
|
+
rt as default
|
|
422
437
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.cd-ps-container[data-v-
|
|
1
|
+
.cd-ps-container[data-v-70933f0f]{display:flex;flex-direction:column;gap:16px;min-height:500px}.cd-ps-tips[data-v-70933f0f]{display:flex;align-items:center;gap:8px;padding:12px;background-color:#e8f4ff;border-radius:4px;font-size:13px;color:#0052d9}.cd-ps-search[data-v-70933f0f]{display:flex;gap:12px;align-items:center}.cd-ps-org-select[data-v-70933f0f]{flex-shrink:0}.cd-ps-search-input[data-v-70933f0f]{flex:1}.cd-ps-content[data-v-70933f0f]{display:flex;gap:0;height:450px;border:1px solid #dfe1e6;border-radius:4px;overflow:hidden}.cd-ps-left[data-v-70933f0f]{width:480px;flex-shrink:0;border-right:1px solid #dfe1e6;display:flex;flex-direction:column;background-color:#fafafa}.cd-ps-left[data-v-70933f0f] .t-tabs__nav-container{padding:0 8px;background-color:#fff}.cd-ps-left[data-v-70933f0f] .t-tabs__content{flex:1;overflow:hidden}.cd-ps-tree[data-v-70933f0f]{height:100%;overflow-y:auto;padding:8px}.cd-ps-tree[data-v-70933f0f]::-webkit-scrollbar{width:6px}.cd-ps-tree[data-v-70933f0f]::-webkit-scrollbar-track{background:#f1f1f1}.cd-ps-tree[data-v-70933f0f]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.cd-ps-node[data-v-70933f0f]{display:flex;align-items:center;gap:6px;font-size:14px;width:100%}[data-v-70933f0f] .t-tree__label{flex:1}[data-v-70933f0f] .t-checkbox__label{width:100%}.cd-ps-node-user[data-v-70933f0f]{font-size:13px;color:#666}.cd-ps-count[data-v-70933f0f]{color:#999;font-size:12px}.cd-ps-load-btn[data-v-70933f0f]{margin-left:auto;color:#0052d9;font-size:12px;flex-shrink:0}.cd-ps-empty[data-v-70933f0f]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;color:#999}.cd-ps-empty p[data-v-70933f0f]{margin-top:16px;font-size:14px}.cd-ps-search-results[data-v-70933f0f]{display:flex;flex-direction:column;height:100%}.cd-ps-search-header[data-v-70933f0f]{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:#fff;border-bottom:1px solid #dfe1e6;font-weight:500}.cd-ps-loading[data-v-70933f0f]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;gap:12px;color:#999}.cd-ps-result-list[data-v-70933f0f]{flex:1;overflow-y:auto;padding:8px}.cd-ps-result-item[data-v-70933f0f]{display:flex;align-items:center;gap:10px;padding:10px 12px;background:#fff;border-radius:4px;border:1px solid #e5e7eb;margin-bottom:8px;cursor:pointer;transition:all .2s}.cd-ps-result-item[data-v-70933f0f]:hover{border-color:#0052d9;background:#f0f5ff}.cd-ps-result-item.cd-ps-selected[data-v-70933f0f]{border-color:#0052d9;background:#e8f4ff}.cd-ps-avatar[data-v-70933f0f]{width:32px;height:32px;border-radius:50%;background:#667eea;display:flex;align-items:center;justify-content:center;color:#fff;font-size:16px;flex-shrink:0}.cd-ps-result-item .cd-ps-avatar[data-v-70933f0f]{width:36px;height:36px}.cd-ps-avatar-dept[data-v-70933f0f]{background:linear-gradient(135deg,#f5af19,#f12711)}.cd-ps-info[data-v-70933f0f]{flex:1;min-width:0}.cd-ps-name[data-v-70933f0f]{font-size:13px;font-weight:500;color:#333;margin-bottom:4px}.cd-ps-result-item .cd-ps-name[data-v-70933f0f]{font-size:14px}.cd-ps-meta[data-v-70933f0f]{display:flex;flex-wrap:wrap;gap:6px;font-size:11px;color:#999}.cd-ps-result-item .cd-ps-meta[data-v-70933f0f]{font-size:12px}.cd-ps-meta span[data-v-70933f0f]:before{content:"•";margin-right:4px}.cd-ps-meta span[data-v-70933f0f]:first-child:before{display:none}.cd-ps-right[data-v-70933f0f]{flex:1;display:flex;flex-direction:column;overflow:hidden;background-color:#fafafa}.cd-ps-right-header[data-v-70933f0f]{display:flex;align-items:center;padding:12px 16px;border-bottom:1px solid #dfe1e6;background-color:#fff}.cd-ps-title[data-v-70933f0f]{font-weight:500;font-size:14px;color:#333}.cd-ps-num[data-v-70933f0f]{font-size:13px;color:#0052d9;font-weight:600;margin-left:8px;flex:1}.cd-ps-right-list[data-v-70933f0f]{flex:1;overflow-y:auto;padding:8px}.cd-ps-right-list[data-v-70933f0f]::-webkit-scrollbar{width:6px}.cd-ps-right-list[data-v-70933f0f]::-webkit-scrollbar-track{background:#f1f1f1}.cd-ps-right-list[data-v-70933f0f]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.cd-ps-selected-list[data-v-70933f0f]{display:flex;flex-direction:column;gap:8px}.cd-ps-selected-item[data-v-70933f0f]{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:#fff;border-radius:4px;border:1px solid #e5e7eb;transition:all .2s}.cd-ps-selected-item[data-v-70933f0f]:hover{border-color:#0052d9;box-shadow:0 2px 4px #0052d91a}.cd-ps-dept-item[data-v-70933f0f]{border-color:#f5af19}.cd-ps-item-info[data-v-70933f0f]{flex:1;min-width:0;display:flex;align-items:center;gap:10px}
|
package/package.json
CHANGED
package/src/PersonSelector.vue
CHANGED
|
@@ -274,6 +274,21 @@ const handleTreeCheck = (checkedIds: (number | string)[]) => {
|
|
|
274
274
|
const otherSelectedIds = selectedIds.value.filter(id => !currentTreeNodeIds.includes(id));
|
|
275
275
|
selectedIds.value = [...otherSelectedIds, ...checkedIds];
|
|
276
276
|
};
|
|
277
|
+
// 递归更新 internalTreeData 中的节点
|
|
278
|
+
function addChildrenToNode(tree: TreeNode[], parentId: number | string, children: TreeNode[]): boolean {
|
|
279
|
+
for (const node of tree) {
|
|
280
|
+
if (node.id === parentId) {
|
|
281
|
+
node.children = node.children || [];
|
|
282
|
+
node.children.push(...children);
|
|
283
|
+
node.loaded = true;
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
if (node.children && addChildrenToNode(node.children, parentId, children)) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
277
292
|
async function handleLoadUsers(node: any, tabKey: string) {
|
|
278
293
|
const nodeId = node.value;
|
|
279
294
|
const treeRef = treeRefs.value[tabKey];
|
|
@@ -283,13 +298,27 @@ async function handleLoadUsers(node: any, tabKey: string) {
|
|
|
283
298
|
const { id, name, ...rest } = user;
|
|
284
299
|
return { ...rest, id, name: user.displayName || name, isUser: true };
|
|
285
300
|
});
|
|
301
|
+
// 同步更新 internalTreeData
|
|
302
|
+
const treeData = internalTreeData.value[tabKey];
|
|
303
|
+
if (treeData) {
|
|
304
|
+
addChildrenToNode(treeData, nodeId, userNodes);
|
|
305
|
+
}
|
|
306
|
+
// 更新 UI 树
|
|
286
307
|
if (treeRef) {
|
|
287
308
|
treeRef.appendTo(nodeId, userNodes);
|
|
288
309
|
node.data.loaded = true;
|
|
289
310
|
await nextTick();
|
|
290
311
|
try { treeRef.setItem(nodeId, { expanded: true }); } catch { /* ignore */ }
|
|
291
312
|
}
|
|
292
|
-
} else {
|
|
313
|
+
} else {
|
|
314
|
+
node.data.loaded = true;
|
|
315
|
+
// 标记节点已加载
|
|
316
|
+
const treeData = internalTreeData.value[tabKey];
|
|
317
|
+
if (treeData) {
|
|
318
|
+
const targetNode = findNodeById(treeData, nodeId);
|
|
319
|
+
if (targetNode) targetNode.loaded = true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
293
322
|
};
|
|
294
323
|
emit('load-users', { tabKey, nodeId, node, callback });
|
|
295
324
|
}
|