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