cd-personselector 1.2.4 → 1.2.5
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 +82 -82
- package/dist/style.css +1 -1
- package/package.json +52 -51
- package/src/InputSelect.vue +1 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(w,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(w=typeof globalThis<"u"?globalThis:w||self,e(w.CdPersonSelector={},w.Vue))})(this,function(w,e){"use strict";const se={class:"cd-ps-container"},ce={key:0,class:"cd-ps-tips"},de={key:1,class:"cd-ps-search"},ie={key:0,class:"cd-ps-org-select"},re={class:"cd-ps-search-input"},pe={class:"cd-ps-content"},me={class:"cd-ps-left"},fe={key:0,class:"cd-ps-search-results"},he={class:"cd-ps-search-header"},ue={key:0,class:"cd-ps-loading"},ke={key:1,class:"cd-ps-empty"},_e={key:2,class:"cd-ps-result-list"},Ve=["onClick"],ge={class:"cd-ps-avatar"},ye={class:"cd-ps-info"},Ce={class:"cd-ps-name"},Be={class:"cd-ps-meta"},Ne={key:0},Ee={key:1},Se={key:2},be={class:"cd-ps-tree"},xe={class:"cd-ps-node-name"},we={key:0,class:"cd-ps-position"},Ue={key:0,class:"cd-ps-count"},Ie={key:1,class:"cd-ps-empty"},De={class:"cd-ps-right"},ze={class:"cd-ps-right-header"},Te={class:"cd-ps-num"},Pe={class:"cd-ps-right-list"},Oe={key:0,class:"cd-ps-empty"},$e={key:1,class:"cd-ps-selected-list"},Le={class:"cd-ps-item-info"},Re={class:"cd-ps-info"},Me={class:"cd-ps-name"},Ae={class:"cd-ps-meta"},Fe={key:0},je={key:1},We={key:2},Je={key:3},qe=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},showOrg:{type:Boolean,default:!0},multiple:{type:Boolean,default:!0}},emits:["update:visible","update:modelValue","confirm","load-users","search","org-change"],setup(h,{expose:$,emit:u}){var le,ae;const c=h,g=u,y=e.ref(c.visible),B=e.ref(((ae=(le=c.tabs)==null?void 0:le[0])==null?void 0:ae.key)||""),C=e.ref(null),b=e.ref(""),r=e.ref([]),f=e.ref(new Map),T=e.ref({}),L=e.ref(!1),P=e.ref(!1),D=e.ref([]),G=e.computed(()=>c.tabs||[]),M=e.computed(()=>c.organizations||[]),A=e.computed(()=>c.tips||""),F=e.computed(()=>c.showSearch),H=e.computed(()=>c.showOrg),Q=e.computed(()=>c.dialogWidth),U=e.ref({});e.watch(()=>c.tabs,o=>{if(o&&o.length>0){const t={};o.forEach(a=>{t[a.key]=JSON.parse(JSON.stringify(a.tree))}),U.value=t,(!B.value||!o.find(a=>a.key===B.value))&&(B.value=o[0].key)}},{immediate:!0,deep:!0});function j(){if(c.modelValue&&c.modelValue.length>0){const o=c.modelValue[0];typeof o=="object"&&o!==null&&"id"in o?(r.value=c.modelValue.map(t=>t.id),f.value.clear(),c.modelValue.forEach(t=>{f.value.set(t.id,t)})):r.value=[...c.modelValue]}else r.value=[],f.value.clear()}e.watch(()=>c.modelValue,o=>{y.value&&o&&j()},{deep:!0}),e.watch(()=>c.visible,o=>{y.value=o,o&&(j(),c.organizations.length>0&&!C.value&&(C.value=c.organizations[0].id))}),e.watch(y,o=>{g("update:visible",o)});function n(o,t){t&&(T.value[o]=t)}function i(o,t){for(const a of o){if(a.id===t)return a;if(a.children){const p=i(a.children,t);if(p)return p}}return null}const d=e.computed(()=>r.value.map(o=>f.value.get(o)).filter(Boolean));function k(o,t){r.value.includes(o)||r.value.push(o),f.value.set(o,t)}function S(o){r.value=r.value.filter(t=>t!==o),f.value.delete(o)}const m=()=>{b.value=""},s=o=>{const t={};c.tabs.forEach(a=>{t[a.key]=[]}),U.value=t,g("org-change",o)};let z=null;const X=()=>{if(z&&clearTimeout(z),!b.value.trim()){Y();return}L.value=!0,P.value=!0,z=setTimeout(()=>tt(),300)},tt=()=>{D.value=[];const o=t=>{D.value=t.map(a=>({...a,isUser:!0})),P.value=!1};g("search",{keyword:b.value,orgId:C.value||void 0,callback:o})},Y=()=>{z&&(clearTimeout(z),z=null),L.value=!1,b.value="",D.value=[],P.value=!1},ot=o=>{r.value.indexOf(o.id)>-1?S(o.id):(c.multiple||(r.value=[],f.value.clear()),k(o.id,{...o,isUser:!0,typeName:"搜索结果",orgId:C.value}),c.multiple||Z())};function lt(o){const t=[],a=p=>{for(const x of p)t.push(x.id),x.children&&a(x.children)};return a(o),t}const at=(o,t)=>{var _,N;const a=t==null?void 0:t.node;if(a){const E=a.value??((_=a.data)==null?void 0:_.id);if(E!==void 0){if(a.checked){c.multiple||(r.value=[],f.value.clear());const O=c.tabs.find(K=>K.key===B.value),R=O?O.name.replace(/^按/,""):"";k(E,{...a.data,typeName:R,orgId:C.value}),!c.multiple&&((N=a.data)!=null&&N.isUser)&&Z()}else S(E);return}}const p=U.value[B.value]||[],x=lt(p),I=r.value.filter(E=>!x.includes(E));r.value=[...I,...o]};function te(o,t,a){for(const p of o){if(p.id===t)return p.children=p.children||[],p.children.push(...a),p.loaded=!0,!0;if(p.children&&te(p.children,t,a))return!0}return!1}async function nt(o,t){const a=o.value,p=T.value[t];g("load-users",{tabKey:t,nodeId:a,node:o,callback:async I=>{if(I.length>0){const _=I.map(E=>{const{id:W,name:O,...R}=E;return{...R,id:W,name:E.displayName||O,isUser:!0}}),N=U.value[t];if(N&&te(N,a,_),p){p.appendTo(a,_),o.data.loaded=!0,await e.nextTick();try{p.setItem(a,{expanded:!0})}catch{}}}else{o.data.loaded=!0;const _=U.value[t];if(_){const N=i(_,a);N&&(N.loaded=!0)}}}})}const st=o=>{S(o)},oe=()=>{r.value=[],f.value.clear()},Z=()=>{g("update:modelValue",r.value),g("confirm",d.value),y.value=!1},ct=()=>{y.value=!1};return $({clearSelection:oe,appendUsers:(o,t,a)=>{const p=T.value[o];if(p&&a.length>0){const x=a.map(I=>{const{id:_,name:N,...E}=I;return{...E,id:_,name:I.displayName||N,isUser:!0}});p.appendTo(t,x)}}}),(o,t)=>{const a=e.resolveComponent("t-icon"),p=e.resolveComponent("t-option"),x=e.resolveComponent("t-select"),I=e.resolveComponent("t-input"),_=e.resolveComponent("t-button"),N=e.resolveComponent("t-loading"),E=e.resolveComponent("t-checkbox"),W=e.resolveComponent("t-tree"),O=e.resolveComponent("t-tab-panel"),R=e.resolveComponent("t-tabs"),K=e.resolveComponent("t-dialog");return e.openBlock(),e.createBlock(K,{visible:y.value,"onUpdate:visible":t[4]||(t[4]=l=>y.value=l),header:"选择人员",width:Q.value,footer:!0,placement:"center","destroy-on-close":"",onConfirm:Z,onClose:ct},{default:e.withCtx(()=>[e.createElementVNode("div",se,[A.value?(e.openBlock(),e.createElementBlock("div",ce,[e.createVNode(a,{name:"info-circle"}),e.createElementVNode("span",null,e.toDisplayString(A.value),1)])):e.createCommentVNode("",!0),F.value?(e.openBlock(),e.createElementBlock("div",de,[H.value&&M.value.length>0?(e.openBlock(),e.createElementBlock("div",ie,[e.createVNode(x,{modelValue:C.value,"onUpdate:modelValue":t[0]||(t[0]=l=>C.value=l),placeholder:"选择组织",style:{width:"200px"},onChange:s},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,l=>(e.openBlock(),e.createBlock(p,{key:l.id,value:l.id,label:l.displayName||l.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createElementVNode("div",re,[e.createVNode(I,{modelValue:b.value,"onUpdate:modelValue":t[1]||(t[1]=l=>b.value=l),placeholder:"输入手机号/工号/姓名/部门/职位搜索",clearable:"",onInput:X,onClear:Y},{"prefix-icon":e.withCtx(()=>[e.createVNode(a,{name:"search"})]),_:1},8,["modelValue"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",pe,[e.createElementVNode("div",me,[L.value?(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("div",he,[t[6]||(t[6]=e.createElementVNode("span",null,"搜索结果",-1)),e.createVNode(_,{size:"small",variant:"text",onClick:Y},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("返回",-1)])]),_:1})]),P.value?(e.openBlock(),e.createElementBlock("div",ue,[e.createVNode(N),t[7]||(t[7]=e.createElementVNode("span",null,"搜索中...",-1))])):D.value.length===0?(e.openBlock(),e.createElementBlock("div",ke,[e.createVNode(a,{name:"search",size:"48px",style:{color:"#ddd"}}),t[8]||(t[8]=e.createElementVNode("p",null,"未找到匹配的人员",-1))])):(e.openBlock(),e.createElementBlock("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:e.normalizeClass(["cd-ps-result-item",{"cd-ps-selected":r.value.includes(l.id)}]),onClick:J=>ot(l)},[e.createVNode(E,{checked:r.value.includes(l.id),onClick:t[2]||(t[2]=e.withModifiers(()=>{},["stop"]))},null,8,["checked"]),e.createElementVNode("div",ge,[e.createVNode(a,{name:"user"})]),e.createElementVNode("div",ye,[e.createElementVNode("div",Ce,e.toDisplayString(l.displayName||l.name),1),e.createElementVNode("div",Be,[l.position?(e.openBlock(),e.createElementBlock("span",Ne,e.toDisplayString(l.position),1)):e.createCommentVNode("",!0),l.department?(e.openBlock(),e.createElementBlock("span",Ee,e.toDisplayString(l.department),1)):e.createCommentVNode("",!0),l.phone?(e.openBlock(),e.createElementBlock("span",Se,e.toDisplayString(l.phone),1)):e.createCommentVNode("",!0)])])],10,Ve))),128))]))])):(e.openBlock(),e.createBlock(R,{key:1,modelValue:B.value,"onUpdate:modelValue":t[3]||(t[3]=l=>B.value=l),onChange:m},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,l=>(e.openBlock(),e.createBlock(O,{key:l.key,value:l.key,label:l.name},{default:e.withCtx(()=>{var J;return[e.createElementVNode("div",be,[((J=U.value[l.key])==null?void 0:J.length)>0?(e.openBlock(),e.createBlock(W,{key:0,ref_for:!0,ref:V=>n(l.key,V),data:U.value[l.key],keys:{value:"id",label:"name",children:"children"},hover:"",checkable:"","expand-all":!1,value:r.value,onChange:at},{label:e.withCtx(({node:V})=>{var ne;return[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-node",{"cd-ps-node-user":V.data.isUser}])},[e.createVNode(a,{name:V.data.isUser?"user":l.icon||"folder"},null,8,["name"]),e.createElementVNode("span",xe,[e.createTextVNode(e.toDisplayString(V.label)+" ",1),V.data.isUser&&V.data.position?(e.openBlock(),e.createElementBlock("span",we,e.toDisplayString(V.data.position),1)):e.createCommentVNode("",!0)]),V.data.userCount&&!V.data.isUser?(e.openBlock(),e.createElementBlock("span",Ue,"("+e.toDisplayString(V.data.userCount)+")",1)):e.createCommentVNode("",!0),!V.data.isUser&&!((ne=V.data.children)!=null&&ne.length)&&!V.data.loaded?(e.openBlock(),e.createBlock(_,{key:1,size:"small",variant:"text",class:"cd-ps-load-btn",onClick:e.withModifiers(it=>nt(V,l.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(a,{name:l.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",De,[e.createElementVNode("div",ze,[t[12]||(t[12]=e.createElementVNode("span",{class:"cd-ps-title"},"已选择",-1)),e.createElementVNode("span",Te,e.toDisplayString(d.value.length)+" 项",1),d.value.length>0?(e.openBlock(),e.createBlock(_,{key:0,size:"small",variant:"text",onClick:oe},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("清空",-1)])]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",Pe,[d.value.length===0?(e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(a,{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(d.value,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:e.normalizeClass(["cd-ps-selected-item",{"cd-ps-dept-item":!l.isUser}])},[e.createElementVNode("div",Le,[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-avatar",{"cd-ps-avatar-dept":!l.isUser}])},[e.createVNode(a,{name:l.isUser?"user":"folder"},null,8,["name"])],2),e.createElementVNode("div",Re,[e.createElementVNode("div",Me,e.toDisplayString(l.displayName||l.name),1),e.createElementVNode("div",Ae,[l.isUser&&l.position?(e.openBlock(),e.createElementBlock("span",Fe,e.toDisplayString(l.position),1)):e.createCommentVNode("",!0),l.isUser&&l.department?(e.openBlock(),e.createElementBlock("span",je,e.toDisplayString(l.department),1)):e.createCommentVNode("",!0),l.isUser?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",We,e.toDisplayString(l.typeName||"部门"),1)),!l.isUser&&l.userCount?(e.openBlock(),e.createElementBlock("span",Je,e.toDisplayString(l.userCount)+"人",1)):e.createCommentVNode("",!0)])])]),e.createVNode(_,{size:"small",variant:"text",shape:"circle",onClick:J=>st(l.id)},{icon:e.withCtx(()=>[e.createVNode(a,{name:"close"})]),_:1},8,["onClick"])],2))),128))]))])])])])]),_:1},8,["visible","width"])}}}),v=(h,$)=>{const u=h.__vccOpts||h;for(const[c,g]of $)u[c]=g;return u},q=v(qe,[["__scopeId","data-v-1e0585c3"]]),Ge={class:"cd-input-select"},He={class:"cd-input-select__option-content"},Qe={key:0,class:"cd-input-select__option-avatar"},Xe=["src","alt"],Ye={class:"cd-input-select__option-info"},Ze={class:"cd-input-select__option-name"},Ke={key:0,class:"cd-input-select__option-desc"},ve={key:2,class:"ri-building-line cd-input-select__option-icon"},ee=v(e.defineComponent({name:"CdInputPersonSelector",__name:"InputSelect",props:{modelValue:{},multiple:{type:Boolean,default:!0},placeholder:{default:"搜索用户、部门、职位"},tabs:{},organizations:{}},emits:["update:modelValue","search","load-users"],setup(h,{emit:$}){const u=h,c=$,g=e.ref(!1),y=e.ref([]),B=e.ref(void 0),C=e.ref(!1),b=e.ref([]),r=e.ref([]),f=e.ref(!1),T=e.computed(()=>{const n=new Set(r.value.map(d=>d.id));return[...r.value,...y.value.filter(d=>!n.has(d.id))]}),L=n=>n?n.substring(0,2).toUpperCase():"",P=n=>{const i=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#13c2c2","#eb2f96","#fa8c16"];let d=0;for(let k=0;k<n.length;k++)d=n.charCodeAt(k)+((d<<5)-d);return i[Math.abs(d)%i.length]},D=n=>{n&&n.trim()?(f.value=!0,g.value=!0,c("search",{keyword:n,callback:i=>{y.value=i,g.value=!1}})):(y.value=[],g.value=!1,f.value=!1)},G=n=>{n&&y.value.length===0&&(f.value=!1)},M=n=>{const i=Array.isArray(n)?n:n?[n]:[],d=u.modelValue.map(m=>m.id),k=i.filter(m=>!d.includes(m)),S=d.filter(m=>!i.includes(m));if(k.length>0){const m=k.map(s=>T.value.find(X=>X.id===s)).filter(Boolean);if(!u.multiple)c("update:modelValue",m),r.value=m,y.value=[],f.value=!1;else{const s=[...u.modelValue,...m];c("update:modelValue",s),r.value=s}}if(S.length>0){const m=u.modelValue.filter(s=>!S.includes(s.id));c("update:modelValue",m),r.value=m}},A=n=>{const i=u.modelValue.filter(d=>d.id!==n);c("update:modelValue",i),r.value=i},F=n=>{n&&typeof n.stopPropagation=="function"&&n.stopPropagation(),n&&typeof n.preventDefault=="function"&&n.preventDefault(),f.value=!1,H()},H=()=>{C.value=!0},Q=n=>{const i=n.map(d=>{const k=d.displayName||d.name||d.title||String(d.id);return{id:d.id,name:k,avatar:d.avatar||"",department:d.department||"",position:d.position||"",phone:d.phone||"",isUser:d.isUser!==!1}});if(!u.multiple)c("update:modelValue",i.slice(0,1)),r.value=i.slice(0,1);else{const d=new Set(u.modelValue.map(m=>m.id)),k=i.filter(m=>!d.has(m.id)),S=[...u.modelValue,...k];c("update:modelValue",S),r.value=S}C.value=!1},U=n=>{c("load-users",n)},j=n=>{c("search",{keyword:n.keyword,callback:n.callback})};return e.watch(()=>u.modelValue,n=>{u.multiple?B.value=n.map(i=>i.id):B.value=n.length>0?n[0].id:void 0,b.value=n.map(i=>i.id),r.value=n},{immediate:!0,deep:!0}),(n,i)=>{const d=e.resolveComponent("t-icon"),k=e.resolveComponent("t-tag"),S=e.resolveComponent("t-option"),m=e.resolveComponent("t-select");return e.openBlock(),e.createElementBlock("div",Ge,[e.createVNode(m,{ref:"selectRef",modelValue:B.value,"onUpdate:modelValue":i[0]||(i[0]=s=>B.value=s),multiple:h.multiple,placeholder:h.placeholder,filterable:!0,filter:()=>!0,loading:g.value,"reserve-keyword":!1,"allow-input":!0,"popup-visible":f.value,"onUpdate:popupVisible":i[1]||(i[1]=s=>f.value=s),size:"medium",class:"cd-input-select__select",onSearch:D,onChange:M,onPopupVisibleChange:G},{suffix:e.withCtx(()=>[e.createVNode(d,{name:"search",onClick:F})]),valueDisplay:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,s=>(e.openBlock(),e.createBlock(k,{key:s.id,closable:"",size:"medium",variant:s.isUser===!1?"outline":"light",theme:s.isUser===!1?"primary":"default",onClose:()=>A(s.id),class:"cd-input-select__tag"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.name),1)]),_:2},1032,["variant","theme","onClose"]))),128))]),suffixIcon:e.withCtx(()=>[e.createElementVNode("i",{class:"ri-add-circle-line cd-input-select__add-icon",onClick:F})]),default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,s=>(e.openBlock(),e.createBlock(S,{key:s.id,value:s.id,label:s.name,class:"cd-input-select__option"},{default:e.withCtx(()=>[e.createElementVNode("div",He,[s.avatar?(e.openBlock(),e.createElementBlock("div",Qe,[e.createElementVNode("img",{src:s.avatar,alt:s.name},null,8,Xe)])):(e.openBlock(),e.createElementBlock("div",{key:1,class:"cd-input-select__option-avatar cd-input-select__option-avatar--placeholder",style:e.normalizeStyle({backgroundColor:s.isUser===!1?"#e6f4ff":P(s.name),color:s.isUser===!1?"#0052d9":"#fff"})},e.toDisplayString(L(s.name)),5)),e.createElementVNode("div",Ye,[e.createElementVNode("div",Ze,e.toDisplayString(s.name),1),s.department||s.position?(e.openBlock(),e.createElementBlock("div",Ke,e.toDisplayString(s.department)+e.toDisplayString(s.department&&s.position?" · ":"")+e.toDisplayString(s.position),1)):e.createCommentVNode("",!0)]),s.isUser===!1?(e.openBlock(),e.createElementBlock("i",ve)):e.createCommentVNode("",!0)])]),_:2},1032,["value","label"]))),128))]),_:1},8,["modelValue","multiple","placeholder","loading","popup-visible"]),h.tabs&&h.tabs.length>0&&C.value?(e.openBlock(),e.createBlock(q,{key:0,visible:C.value,"onUpdate:visible":i[2]||(i[2]=s=>C.value=s),modelValue:b.value,"onUpdate:modelValue":i[3]||(i[3]=s=>b.value=s),tabs:h.tabs,organizations:h.organizations||[],"show-org":!1,"show-search":!0,multiple:h.multiple,tips:"选择要添加的人员",onConfirm:Q,onLoadUsers:U,onSearch:j},null,8,["visible","modelValue","tabs","organizations","multiple"])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-b41b3bc1"]]),et={install(h){h.component("PersonSelector",q),h.component("CdInputPersonSelector",ee)}};w.InputSelect=ee,w.PersonSelector=q,w.default=et,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(w,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(w=typeof globalThis<"u"?globalThis:w||self,e(w.CdPersonSelector={},w.Vue))})(this,function(w,e){"use strict";const se={class:"cd-ps-container"},ce={key:0,class:"cd-ps-tips"},de={key:1,class:"cd-ps-search"},ie={key:0,class:"cd-ps-org-select"},re={class:"cd-ps-search-input"},pe={class:"cd-ps-content"},me={class:"cd-ps-left"},fe={key:0,class:"cd-ps-search-results"},he={class:"cd-ps-search-header"},ue={key:0,class:"cd-ps-loading"},ke={key:1,class:"cd-ps-empty"},_e={key:2,class:"cd-ps-result-list"},Ve=["onClick"],ge={class:"cd-ps-avatar"},ye={class:"cd-ps-info"},Ce={class:"cd-ps-name"},Be={class:"cd-ps-meta"},Ne={key:0},Ee={key:1},Se={key:2},be={class:"cd-ps-tree"},xe={class:"cd-ps-node-name"},we={key:0,class:"cd-ps-position"},Ue={key:0,class:"cd-ps-count"},Ie={key:1,class:"cd-ps-empty"},De={class:"cd-ps-right"},ze={class:"cd-ps-right-header"},Te={class:"cd-ps-num"},Pe={class:"cd-ps-right-list"},Oe={key:0,class:"cd-ps-empty"},$e={key:1,class:"cd-ps-selected-list"},Le={class:"cd-ps-item-info"},Re={class:"cd-ps-info"},Me={class:"cd-ps-name"},Ae={class:"cd-ps-meta"},Fe={key:0},je={key:1},We={key:2},Je={key:3},qe=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},showOrg:{type:Boolean,default:!0},multiple:{type:Boolean,default:!0}},emits:["update:visible","update:modelValue","confirm","load-users","search","org-change"],setup(h,{expose:$,emit:u}){var le,ae;const c=h,g=u,y=e.ref(c.visible),B=e.ref(((ae=(le=c.tabs)==null?void 0:le[0])==null?void 0:ae.key)||""),C=e.ref(null),b=e.ref(""),r=e.ref([]),f=e.ref(new Map),T=e.ref({}),L=e.ref(!1),P=e.ref(!1),D=e.ref([]),G=e.computed(()=>c.tabs||[]),M=e.computed(()=>c.organizations||[]),A=e.computed(()=>c.tips||""),F=e.computed(()=>c.showSearch),H=e.computed(()=>c.showOrg),Q=e.computed(()=>c.dialogWidth),U=e.ref({});e.watch(()=>c.tabs,o=>{if(o&&o.length>0){const t={};o.forEach(a=>{t[a.key]=JSON.parse(JSON.stringify(a.tree))}),U.value=t,(!B.value||!o.find(a=>a.key===B.value))&&(B.value=o[0].key)}},{immediate:!0,deep:!0});function j(){if(c.modelValue&&c.modelValue.length>0){const o=c.modelValue[0];typeof o=="object"&&o!==null&&"id"in o?(r.value=c.modelValue.map(t=>t.id),f.value.clear(),c.modelValue.forEach(t=>{f.value.set(t.id,t)})):r.value=[...c.modelValue]}else r.value=[],f.value.clear()}e.watch(()=>c.modelValue,o=>{y.value&&o&&j()},{deep:!0}),e.watch(()=>c.visible,o=>{y.value=o,o&&(j(),c.organizations.length>0&&!C.value&&(C.value=c.organizations[0].id))}),e.watch(y,o=>{g("update:visible",o)});function n(o,t){t&&(T.value[o]=t)}function i(o,t){for(const a of o){if(a.id===t)return a;if(a.children){const p=i(a.children,t);if(p)return p}}return null}const d=e.computed(()=>r.value.map(o=>f.value.get(o)).filter(Boolean));function k(o,t){r.value.includes(o)||r.value.push(o),f.value.set(o,t)}function S(o){r.value=r.value.filter(t=>t!==o),f.value.delete(o)}const m=()=>{b.value=""},s=o=>{const t={};c.tabs.forEach(a=>{t[a.key]=[]}),U.value=t,g("org-change",o)};let z=null;const X=()=>{if(z&&clearTimeout(z),!b.value.trim()){Y();return}L.value=!0,P.value=!0,z=setTimeout(()=>tt(),300)},tt=()=>{D.value=[];const o=t=>{D.value=t.map(a=>({...a,isUser:!0})),P.value=!1};g("search",{keyword:b.value,orgId:C.value||void 0,callback:o})},Y=()=>{z&&(clearTimeout(z),z=null),L.value=!1,b.value="",D.value=[],P.value=!1},ot=o=>{r.value.indexOf(o.id)>-1?S(o.id):(c.multiple||(r.value=[],f.value.clear()),k(o.id,{...o,isUser:!0,typeName:"搜索结果",orgId:C.value}),c.multiple||Z())};function lt(o){const t=[],a=p=>{for(const x of p)t.push(x.id),x.children&&a(x.children)};return a(o),t}const at=(o,t)=>{var _,N;const a=t==null?void 0:t.node;if(a){const E=a.value??((_=a.data)==null?void 0:_.id);if(E!==void 0){if(a.checked){c.multiple||(r.value=[],f.value.clear());const O=c.tabs.find(K=>K.key===B.value),R=O?O.name.replace(/^按/,""):"";k(E,{...a.data,typeName:R,orgId:C.value}),!c.multiple&&((N=a.data)!=null&&N.isUser)&&Z()}else S(E);return}}const p=U.value[B.value]||[],x=lt(p),I=r.value.filter(E=>!x.includes(E));r.value=[...I,...o]};function te(o,t,a){for(const p of o){if(p.id===t)return p.children=p.children||[],p.children.push(...a),p.loaded=!0,!0;if(p.children&&te(p.children,t,a))return!0}return!1}async function nt(o,t){const a=o.value,p=T.value[t];g("load-users",{tabKey:t,nodeId:a,node:o,callback:async I=>{if(I.length>0){const _=I.map(E=>{const{id:W,name:O,...R}=E;return{...R,id:W,name:E.displayName||O,isUser:!0}}),N=U.value[t];if(N&&te(N,a,_),p){p.appendTo(a,_),o.data.loaded=!0,await e.nextTick();try{p.setItem(a,{expanded:!0})}catch{}}}else{o.data.loaded=!0;const _=U.value[t];if(_){const N=i(_,a);N&&(N.loaded=!0)}}}})}const st=o=>{S(o)},oe=()=>{r.value=[],f.value.clear()},Z=()=>{g("update:modelValue",r.value),g("confirm",d.value),y.value=!1},ct=()=>{y.value=!1};return $({clearSelection:oe,appendUsers:(o,t,a)=>{const p=T.value[o];if(p&&a.length>0){const x=a.map(I=>{const{id:_,name:N,...E}=I;return{...E,id:_,name:I.displayName||N,isUser:!0}});p.appendTo(t,x)}}}),(o,t)=>{const a=e.resolveComponent("t-icon"),p=e.resolveComponent("t-option"),x=e.resolveComponent("t-select"),I=e.resolveComponent("t-input"),_=e.resolveComponent("t-button"),N=e.resolveComponent("t-loading"),E=e.resolveComponent("t-checkbox"),W=e.resolveComponent("t-tree"),O=e.resolveComponent("t-tab-panel"),R=e.resolveComponent("t-tabs"),K=e.resolveComponent("t-dialog");return e.openBlock(),e.createBlock(K,{visible:y.value,"onUpdate:visible":t[4]||(t[4]=l=>y.value=l),header:"选择人员",width:Q.value,footer:!0,placement:"center","destroy-on-close":"",onConfirm:Z,onClose:ct},{default:e.withCtx(()=>[e.createElementVNode("div",se,[A.value?(e.openBlock(),e.createElementBlock("div",ce,[e.createVNode(a,{name:"info-circle"}),e.createElementVNode("span",null,e.toDisplayString(A.value),1)])):e.createCommentVNode("",!0),F.value?(e.openBlock(),e.createElementBlock("div",de,[H.value&&M.value.length>0?(e.openBlock(),e.createElementBlock("div",ie,[e.createVNode(x,{modelValue:C.value,"onUpdate:modelValue":t[0]||(t[0]=l=>C.value=l),placeholder:"选择组织",style:{width:"200px"},onChange:s},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,l=>(e.openBlock(),e.createBlock(p,{key:l.id,value:l.id,label:l.displayName||l.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),e.createElementVNode("div",re,[e.createVNode(I,{modelValue:b.value,"onUpdate:modelValue":t[1]||(t[1]=l=>b.value=l),placeholder:"输入手机号/工号/姓名/部门/职位搜索",clearable:"",onInput:X,onClear:Y},{"prefix-icon":e.withCtx(()=>[e.createVNode(a,{name:"search"})]),_:1},8,["modelValue"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",pe,[e.createElementVNode("div",me,[L.value?(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("div",he,[t[6]||(t[6]=e.createElementVNode("span",null,"搜索结果",-1)),e.createVNode(_,{size:"small",variant:"text",onClick:Y},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("返回",-1)])]),_:1})]),P.value?(e.openBlock(),e.createElementBlock("div",ue,[e.createVNode(N),t[7]||(t[7]=e.createElementVNode("span",null,"搜索中...",-1))])):D.value.length===0?(e.openBlock(),e.createElementBlock("div",ke,[e.createVNode(a,{name:"search",size:"48px",style:{color:"#ddd"}}),t[8]||(t[8]=e.createElementVNode("p",null,"未找到匹配的人员",-1))])):(e.openBlock(),e.createElementBlock("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:e.normalizeClass(["cd-ps-result-item",{"cd-ps-selected":r.value.includes(l.id)}]),onClick:J=>ot(l)},[e.createVNode(E,{checked:r.value.includes(l.id),onClick:t[2]||(t[2]=e.withModifiers(()=>{},["stop"]))},null,8,["checked"]),e.createElementVNode("div",ge,[e.createVNode(a,{name:"user"})]),e.createElementVNode("div",ye,[e.createElementVNode("div",Ce,e.toDisplayString(l.displayName||l.name),1),e.createElementVNode("div",Be,[l.position?(e.openBlock(),e.createElementBlock("span",Ne,e.toDisplayString(l.position),1)):e.createCommentVNode("",!0),l.department?(e.openBlock(),e.createElementBlock("span",Ee,e.toDisplayString(l.department),1)):e.createCommentVNode("",!0),l.phone?(e.openBlock(),e.createElementBlock("span",Se,e.toDisplayString(l.phone),1)):e.createCommentVNode("",!0)])])],10,Ve))),128))]))])):(e.openBlock(),e.createBlock(R,{key:1,modelValue:B.value,"onUpdate:modelValue":t[3]||(t[3]=l=>B.value=l),onChange:m},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,l=>(e.openBlock(),e.createBlock(O,{key:l.key,value:l.key,label:l.name},{default:e.withCtx(()=>{var J;return[e.createElementVNode("div",be,[((J=U.value[l.key])==null?void 0:J.length)>0?(e.openBlock(),e.createBlock(W,{key:0,ref_for:!0,ref:V=>n(l.key,V),data:U.value[l.key],keys:{value:"id",label:"name",children:"children"},hover:"",checkable:"","expand-all":!1,value:r.value,onChange:at},{label:e.withCtx(({node:V})=>{var ne;return[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-node",{"cd-ps-node-user":V.data.isUser}])},[e.createVNode(a,{name:V.data.isUser?"user":l.icon||"folder"},null,8,["name"]),e.createElementVNode("span",xe,[e.createTextVNode(e.toDisplayString(V.label)+" ",1),V.data.isUser&&V.data.position?(e.openBlock(),e.createElementBlock("span",we,e.toDisplayString(V.data.position),1)):e.createCommentVNode("",!0)]),V.data.userCount&&!V.data.isUser?(e.openBlock(),e.createElementBlock("span",Ue,"("+e.toDisplayString(V.data.userCount)+")",1)):e.createCommentVNode("",!0),!V.data.isUser&&!((ne=V.data.children)!=null&&ne.length)&&!V.data.loaded?(e.openBlock(),e.createBlock(_,{key:1,size:"small",variant:"text",class:"cd-ps-load-btn",onClick:e.withModifiers(it=>nt(V,l.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(a,{name:l.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",De,[e.createElementVNode("div",ze,[t[12]||(t[12]=e.createElementVNode("span",{class:"cd-ps-title"},"已选择",-1)),e.createElementVNode("span",Te,e.toDisplayString(d.value.length)+" 项",1),d.value.length>0?(e.openBlock(),e.createBlock(_,{key:0,size:"small",variant:"text",onClick:oe},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("清空",-1)])]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",Pe,[d.value.length===0?(e.openBlock(),e.createElementBlock("div",Oe,[e.createVNode(a,{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(d.value,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:e.normalizeClass(["cd-ps-selected-item",{"cd-ps-dept-item":!l.isUser}])},[e.createElementVNode("div",Le,[e.createElementVNode("div",{class:e.normalizeClass(["cd-ps-avatar",{"cd-ps-avatar-dept":!l.isUser}])},[e.createVNode(a,{name:l.isUser?"user":"folder"},null,8,["name"])],2),e.createElementVNode("div",Re,[e.createElementVNode("div",Me,e.toDisplayString(l.displayName||l.name),1),e.createElementVNode("div",Ae,[l.isUser&&l.position?(e.openBlock(),e.createElementBlock("span",Fe,e.toDisplayString(l.position),1)):e.createCommentVNode("",!0),l.isUser&&l.department?(e.openBlock(),e.createElementBlock("span",je,e.toDisplayString(l.department),1)):e.createCommentVNode("",!0),l.isUser?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",We,e.toDisplayString(l.typeName||"部门"),1)),!l.isUser&&l.userCount?(e.openBlock(),e.createElementBlock("span",Je,e.toDisplayString(l.userCount)+"人",1)):e.createCommentVNode("",!0)])])]),e.createVNode(_,{size:"small",variant:"text",shape:"circle",onClick:J=>st(l.id)},{icon:e.withCtx(()=>[e.createVNode(a,{name:"close"})]),_:1},8,["onClick"])],2))),128))]))])])])])]),_:1},8,["visible","width"])}}}),v=(h,$)=>{const u=h.__vccOpts||h;for(const[c,g]of $)u[c]=g;return u},q=v(qe,[["__scopeId","data-v-1e0585c3"]]),Ge={class:"cd-input-select"},He={class:"cd-input-select__option-content"},Qe={key:0,class:"cd-input-select__option-avatar"},Xe=["src","alt"],Ye={class:"cd-input-select__option-info"},Ze={class:"cd-input-select__option-name"},Ke={key:0,class:"cd-input-select__option-desc"},ve={key:2,class:"ri-building-line cd-input-select__option-icon"},ee=v(e.defineComponent({name:"CdInputPersonSelector",__name:"InputSelect",props:{modelValue:{},multiple:{type:Boolean,default:!0},placeholder:{default:"搜索用户、部门、职位"},tabs:{},organizations:{}},emits:["update:modelValue","search","load-users"],setup(h,{emit:$}){const u=h,c=$,g=e.ref(!1),y=e.ref([]),B=e.ref(void 0),C=e.ref(!1),b=e.ref([]),r=e.ref([]),f=e.ref(!1),T=e.computed(()=>{const n=new Set(r.value.map(d=>d.id));return[...r.value,...y.value.filter(d=>!n.has(d.id))]}),L=n=>n?n.substring(0,2).toUpperCase():"",P=n=>{const i=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#13c2c2","#eb2f96","#fa8c16"];let d=0;for(let k=0;k<n.length;k++)d=n.charCodeAt(k)+((d<<5)-d);return i[Math.abs(d)%i.length]},D=n=>{n&&n.trim()?(f.value=!0,g.value=!0,c("search",{keyword:n,callback:i=>{y.value=i,g.value=!1}})):(y.value=[],g.value=!1,f.value=!1)},G=n=>{n&&y.value.length===0&&(f.value=!1)},M=n=>{const i=Array.isArray(n)?n:n?[n]:[],d=u.modelValue.map(m=>m.id),k=i.filter(m=>!d.includes(m)),S=d.filter(m=>!i.includes(m));if(k.length>0){const m=k.map(s=>T.value.find(X=>X.id===s)).filter(Boolean);if(!u.multiple)c("update:modelValue",m),r.value=m,y.value=[],f.value=!1;else{const s=[...u.modelValue,...m];c("update:modelValue",s),r.value=s}}if(S.length>0){const m=u.modelValue.filter(s=>!S.includes(s.id));c("update:modelValue",m),r.value=m}},A=n=>{const i=u.modelValue.filter(d=>d.id!==n);c("update:modelValue",i),r.value=i},F=n=>{n&&typeof n.stopPropagation=="function"&&n.stopPropagation(),n&&typeof n.preventDefault=="function"&&n.preventDefault(),f.value=!1,H()},H=()=>{C.value=!0},Q=n=>{const i=n.map(d=>{const k=d.displayName||d.name||d.title||String(d.id);return{id:d.id,name:k,avatar:d.avatar||"",department:d.department||"",position:d.position||"",phone:d.phone||"",isUser:d.isUser!==!1}});if(!u.multiple)c("update:modelValue",i.slice(0,1)),r.value=i.slice(0,1);else{const d=new Set(u.modelValue.map(m=>m.id)),k=i.filter(m=>!d.has(m.id)),S=[...u.modelValue,...k];c("update:modelValue",S),r.value=S}C.value=!1},U=n=>{c("load-users",n)},j=n=>{c("search",{keyword:n.keyword,callback:n.callback})};return e.watch(()=>u.modelValue,n=>{u.multiple?B.value=n.map(i=>i.id):B.value=n.length>0?n[0].id:void 0,b.value=n.map(i=>i.id),r.value=n},{immediate:!0,deep:!0}),(n,i)=>{const d=e.resolveComponent("t-icon"),k=e.resolveComponent("t-tag"),S=e.resolveComponent("t-option"),m=e.resolveComponent("t-select");return e.openBlock(),e.createElementBlock("div",Ge,[e.createVNode(m,{ref:"selectRef",modelValue:B.value,"onUpdate:modelValue":i[0]||(i[0]=s=>B.value=s),multiple:h.multiple,placeholder:h.placeholder,filterable:!0,filter:()=>!0,loading:g.value,"reserve-keyword":!1,"allow-input":!0,"popup-visible":f.value,"onUpdate:popupVisible":i[1]||(i[1]=s=>f.value=s),size:"medium",class:"cd-input-select__select",onSearch:D,onChange:M,onPopupVisibleChange:G},{suffix:e.withCtx(()=>[e.createVNode(d,{name:"add-circle",onClick:F})]),valueDisplay:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,s=>(e.openBlock(),e.createBlock(k,{key:s.id,closable:"",size:"medium",variant:s.isUser===!1?"outline":"light",theme:s.isUser===!1?"primary":"default",onClose:()=>A(s.id),class:"cd-input-select__tag"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.name),1)]),_:2},1032,["variant","theme","onClose"]))),128))]),suffixIcon:e.withCtx(()=>[e.createElementVNode("i",{class:"ri-add-circle-line cd-input-select__add-icon",onClick:F})]),default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,s=>(e.openBlock(),e.createBlock(S,{key:s.id,value:s.id,label:s.name,class:"cd-input-select__option"},{default:e.withCtx(()=>[e.createElementVNode("div",He,[s.avatar?(e.openBlock(),e.createElementBlock("div",Qe,[e.createElementVNode("img",{src:s.avatar,alt:s.name},null,8,Xe)])):(e.openBlock(),e.createElementBlock("div",{key:1,class:"cd-input-select__option-avatar cd-input-select__option-avatar--placeholder",style:e.normalizeStyle({backgroundColor:s.isUser===!1?"#e6f4ff":P(s.name),color:s.isUser===!1?"#0052d9":"#fff"})},e.toDisplayString(L(s.name)),5)),e.createElementVNode("div",Ye,[e.createElementVNode("div",Ze,e.toDisplayString(s.name),1),s.department||s.position?(e.openBlock(),e.createElementBlock("div",Ke,e.toDisplayString(s.department)+e.toDisplayString(s.department&&s.position?" · ":"")+e.toDisplayString(s.position),1)):e.createCommentVNode("",!0)]),s.isUser===!1?(e.openBlock(),e.createElementBlock("i",ve)):e.createCommentVNode("",!0)])]),_:2},1032,["value","label"]))),128))]),_:1},8,["modelValue","multiple","placeholder","loading","popup-visible"]),h.tabs&&h.tabs.length>0&&C.value?(e.openBlock(),e.createBlock(q,{key:0,visible:C.value,"onUpdate:visible":i[2]||(i[2]=s=>C.value=s),modelValue:b.value,"onUpdate:modelValue":i[3]||(i[3]=s=>b.value=s),tabs:h.tabs,organizations:h.organizations||[],"show-org":!1,"show-search":!0,multiple:h.multiple,tips:"选择要添加的人员",onConfirm:Q,onLoadUsers:U,onSearch:j},null,8,["visible","modelValue","tabs","organizations","multiple"])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-30a96740"]]),et={install(h){h.component("PersonSelector",q),h.component("CdInputPersonSelector",ee)}};w.InputSelect=ee,w.PersonSelector=q,w.default=et,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as ge, ref as h, computed as L, watch as X, resolveComponent as I, createBlock as O, openBlock as n, withCtx as b, createElementVNode as c, createElementBlock as u, createCommentVNode as y, createVNode as g, toDisplayString as m, Fragment as F, renderList as q, createTextVNode as Y, normalizeClass as
|
|
1
|
+
import { defineComponent as ge, ref as h, computed as L, watch as X, resolveComponent as I, createBlock as O, openBlock as n, withCtx as b, createElementVNode as c, createElementBlock as u, createCommentVNode as y, createVNode as g, toDisplayString as m, Fragment as F, renderList as q, createTextVNode as Y, normalizeClass as se, withModifiers as _e, nextTick as Ne, normalizeStyle as ze } from "vue";
|
|
2
2
|
const we = { class: "cd-ps-container" }, Te = {
|
|
3
3
|
key: 0,
|
|
4
4
|
class: "cd-ps-tips"
|
|
@@ -29,7 +29,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
29
29
|
}, et = {
|
|
30
30
|
key: 1,
|
|
31
31
|
class: "cd-ps-empty"
|
|
32
|
-
}, tt = { class: "cd-ps-right" }, lt = { class: "cd-ps-right-header" },
|
|
32
|
+
}, tt = { class: "cd-ps-right" }, lt = { class: "cd-ps-right-header" }, at = { class: "cd-ps-num" }, st = { class: "cd-ps-right-list" }, nt = {
|
|
33
33
|
key: 0,
|
|
34
34
|
class: "cd-ps-empty"
|
|
35
35
|
}, ot = {
|
|
@@ -55,9 +55,9 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
55
55
|
X(() => i.tabs, (t) => {
|
|
56
56
|
if (t && t.length > 0) {
|
|
57
57
|
const e = {};
|
|
58
|
-
t.forEach((
|
|
59
|
-
e[
|
|
60
|
-
}), R.value = e, (!w.value || !t.find((
|
|
58
|
+
t.forEach((a) => {
|
|
59
|
+
e[a.key] = JSON.parse(JSON.stringify(a.tree));
|
|
60
|
+
}), R.value = e, (!w.value || !t.find((a) => a.key === w.value)) && (w.value = t[0].key);
|
|
61
61
|
}
|
|
62
62
|
}, { immediate: !0, deep: !0 });
|
|
63
63
|
function te() {
|
|
@@ -76,14 +76,14 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
76
76
|
}), X(N, (t) => {
|
|
77
77
|
x("update:visible", t);
|
|
78
78
|
});
|
|
79
|
-
function
|
|
79
|
+
function s(t, e) {
|
|
80
80
|
e && (W.value[t] = e);
|
|
81
81
|
}
|
|
82
82
|
function r(t, e) {
|
|
83
|
-
for (const
|
|
84
|
-
if (
|
|
85
|
-
if (
|
|
86
|
-
const v = r(
|
|
83
|
+
for (const a of t) {
|
|
84
|
+
if (a.id === e) return a;
|
|
85
|
+
if (a.children) {
|
|
86
|
+
const v = r(a.children, e);
|
|
87
87
|
if (v) return v;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -100,8 +100,8 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
100
100
|
B.value = "";
|
|
101
101
|
}, o = (t) => {
|
|
102
102
|
const e = {};
|
|
103
|
-
i.tabs.forEach((
|
|
104
|
-
e[
|
|
103
|
+
i.tabs.forEach((a) => {
|
|
104
|
+
e[a.key] = [];
|
|
105
105
|
}), R.value = e, x("org-change", t);
|
|
106
106
|
};
|
|
107
107
|
let E = null;
|
|
@@ -114,7 +114,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
114
114
|
}, be = () => {
|
|
115
115
|
M.value = [];
|
|
116
116
|
const t = (e) => {
|
|
117
|
-
M.value = e.map((
|
|
117
|
+
M.value = e.map((a) => ({ ...a, isUser: !0 })), J.value = !1;
|
|
118
118
|
};
|
|
119
119
|
x("search", { keyword: B.value, orgId: z.value || void 0, callback: t });
|
|
120
120
|
}, ce = () => {
|
|
@@ -123,22 +123,22 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
123
123
|
p.value.indexOf(t.id) > -1 ? $(t.id) : (i.multiple || (p.value = [], _.value.clear()), C(t.id, { ...t, isUser: !0, typeName: "搜索结果", orgId: z.value }), i.multiple || ue());
|
|
124
124
|
};
|
|
125
125
|
function Ce(t) {
|
|
126
|
-
const e = [],
|
|
126
|
+
const e = [], a = (v) => {
|
|
127
127
|
for (const D of v)
|
|
128
|
-
e.push(D.id), D.children &&
|
|
128
|
+
e.push(D.id), D.children && a(D.children);
|
|
129
129
|
};
|
|
130
|
-
return
|
|
130
|
+
return a(t), e;
|
|
131
131
|
}
|
|
132
132
|
const Ue = (t, e) => {
|
|
133
133
|
var U, T;
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const P =
|
|
134
|
+
const a = e == null ? void 0 : e.node;
|
|
135
|
+
if (a) {
|
|
136
|
+
const P = a.value ?? ((U = a.data) == null ? void 0 : U.id);
|
|
137
137
|
if (P !== void 0) {
|
|
138
|
-
if (
|
|
138
|
+
if (a.checked) {
|
|
139
139
|
i.multiple || (p.value = [], _.value.clear());
|
|
140
140
|
const j = i.tabs.find((re) => re.key === w.value), Q = j ? j.name.replace(/^按/, "") : "";
|
|
141
|
-
C(P, { ...
|
|
141
|
+
C(P, { ...a.data, typeName: Q, orgId: z.value }), !i.multiple && ((T = a.data) != null && T.isUser) && ue();
|
|
142
142
|
} else
|
|
143
143
|
$(P);
|
|
144
144
|
return;
|
|
@@ -147,27 +147,27 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
147
147
|
const v = R.value[w.value] || [], D = Ce(v), A = p.value.filter((P) => !D.includes(P));
|
|
148
148
|
p.value = [...A, ...t];
|
|
149
149
|
};
|
|
150
|
-
function pe(t, e,
|
|
150
|
+
function pe(t, e, a) {
|
|
151
151
|
for (const v of t) {
|
|
152
152
|
if (v.id === e)
|
|
153
|
-
return v.children = v.children || [], v.children.push(...
|
|
154
|
-
if (v.children && pe(v.children, e,
|
|
153
|
+
return v.children = v.children || [], v.children.push(...a), v.loaded = !0, !0;
|
|
154
|
+
if (v.children && pe(v.children, e, a))
|
|
155
155
|
return !0;
|
|
156
156
|
}
|
|
157
157
|
return !1;
|
|
158
158
|
}
|
|
159
159
|
async function Se(t, e) {
|
|
160
|
-
const
|
|
161
|
-
x("load-users", { tabKey: e, nodeId:
|
|
160
|
+
const a = t.value, v = W.value[e];
|
|
161
|
+
x("load-users", { tabKey: e, nodeId: a, node: t, callback: async (A) => {
|
|
162
162
|
if (A.length > 0) {
|
|
163
163
|
const U = A.map((P) => {
|
|
164
164
|
const { id: le, name: j, ...Q } = P;
|
|
165
165
|
return { ...Q, id: le, name: P.displayName || j, isUser: !0 };
|
|
166
166
|
}), T = R.value[e];
|
|
167
|
-
if (T && pe(T,
|
|
168
|
-
v.appendTo(
|
|
167
|
+
if (T && pe(T, a, U), v) {
|
|
168
|
+
v.appendTo(a, U), t.data.loaded = !0, await Ne();
|
|
169
169
|
try {
|
|
170
|
-
v.setItem(
|
|
170
|
+
v.setItem(a, { expanded: !0 });
|
|
171
171
|
} catch {
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -175,7 +175,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
175
175
|
t.data.loaded = !0;
|
|
176
176
|
const U = R.value[e];
|
|
177
177
|
if (U) {
|
|
178
|
-
const T = r(U,
|
|
178
|
+
const T = r(U, a);
|
|
179
179
|
T && (T.loaded = !0);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -192,10 +192,10 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
192
192
|
};
|
|
193
193
|
return G({
|
|
194
194
|
clearSelection: ve,
|
|
195
|
-
appendUsers: (t, e,
|
|
195
|
+
appendUsers: (t, e, a) => {
|
|
196
196
|
const v = W.value[t];
|
|
197
|
-
if (v &&
|
|
198
|
-
const D =
|
|
197
|
+
if (v && a.length > 0) {
|
|
198
|
+
const D = a.map((A) => {
|
|
199
199
|
const { id: U, name: T, ...P } = A;
|
|
200
200
|
return { ...P, id: U, name: A.displayName || T, isUser: !0 };
|
|
201
201
|
});
|
|
@@ -203,7 +203,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}), (t, e) => {
|
|
206
|
-
const
|
|
206
|
+
const a = I("t-icon"), v = I("t-option"), D = I("t-select"), A = I("t-input"), U = I("t-button"), T = I("t-loading"), P = I("t-checkbox"), le = I("t-tree"), j = I("t-tab-panel"), Q = I("t-tabs"), re = I("t-dialog");
|
|
207
207
|
return n(), O(re, {
|
|
208
208
|
visible: N.value,
|
|
209
209
|
"onUpdate:visible": e[4] || (e[4] = (l) => N.value = l),
|
|
@@ -218,7 +218,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
218
218
|
default: b(() => [
|
|
219
219
|
c("div", we, [
|
|
220
220
|
K.value ? (n(), u("div", Te, [
|
|
221
|
-
g(
|
|
221
|
+
g(a, { name: "info-circle" }),
|
|
222
222
|
c("span", null, m(K.value), 1)
|
|
223
223
|
])) : y("", !0),
|
|
224
224
|
ee.value ? (n(), u("div", Pe, [
|
|
@@ -250,7 +250,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
250
250
|
onClear: ce
|
|
251
251
|
}, {
|
|
252
252
|
"prefix-icon": b(() => [
|
|
253
|
-
g(
|
|
253
|
+
g(a, { name: "search" })
|
|
254
254
|
]),
|
|
255
255
|
_: 1
|
|
256
256
|
}, 8, ["modelValue"])
|
|
@@ -276,7 +276,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
276
276
|
g(T),
|
|
277
277
|
e[7] || (e[7] = c("span", null, "搜索中...", -1))
|
|
278
278
|
])) : M.value.length === 0 ? (n(), u("div", Me, [
|
|
279
|
-
g(
|
|
279
|
+
g(a, {
|
|
280
280
|
name: "search",
|
|
281
281
|
size: "48px",
|
|
282
282
|
style: { color: "#ddd" }
|
|
@@ -285,8 +285,8 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
285
285
|
])) : (n(), u("div", Ee, [
|
|
286
286
|
(n(!0), u(F, null, q(M.value, (l) => (n(), u("div", {
|
|
287
287
|
key: l.id,
|
|
288
|
-
class:
|
|
289
|
-
onClick: (
|
|
288
|
+
class: se(["cd-ps-result-item", { "cd-ps-selected": p.value.includes(l.id) }]),
|
|
289
|
+
onClick: (ae) => Ve(l)
|
|
290
290
|
}, [
|
|
291
291
|
g(P, {
|
|
292
292
|
checked: p.value.includes(l.id),
|
|
@@ -294,7 +294,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
294
294
|
}, ["stop"]))
|
|
295
295
|
}, null, 8, ["checked"]),
|
|
296
296
|
c("div", Je, [
|
|
297
|
-
g(
|
|
297
|
+
g(a, { name: "user" })
|
|
298
298
|
]),
|
|
299
299
|
c("div", je, [
|
|
300
300
|
c("div", Fe, m(l.displayName || l.name), 1),
|
|
@@ -319,13 +319,13 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
319
319
|
label: l.name
|
|
320
320
|
}, {
|
|
321
321
|
default: b(() => {
|
|
322
|
-
var
|
|
322
|
+
var ae;
|
|
323
323
|
return [
|
|
324
324
|
c("div", Xe, [
|
|
325
|
-
((
|
|
325
|
+
((ae = R.value[l.key]) == null ? void 0 : ae.length) > 0 ? (n(), O(le, {
|
|
326
326
|
key: 0,
|
|
327
327
|
ref_for: !0,
|
|
328
|
-
ref: (S) =>
|
|
328
|
+
ref: (S) => s(l.key, S),
|
|
329
329
|
data: R.value[l.key],
|
|
330
330
|
keys: { value: "id", label: "name", children: "children" },
|
|
331
331
|
hover: "",
|
|
@@ -338,9 +338,9 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
338
338
|
var he;
|
|
339
339
|
return [
|
|
340
340
|
c("div", {
|
|
341
|
-
class:
|
|
341
|
+
class: se(["cd-ps-node", { "cd-ps-node-user": S.data.isUser }])
|
|
342
342
|
}, [
|
|
343
|
-
g(
|
|
343
|
+
g(a, {
|
|
344
344
|
name: S.data.isUser ? "user" : l.icon || "folder"
|
|
345
345
|
}, null, 8, ["name"]),
|
|
346
346
|
c("span", Ye, [
|
|
@@ -365,7 +365,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
365
365
|
}),
|
|
366
366
|
_: 2
|
|
367
367
|
}, 1032, ["data", "value"])) : (n(), u("div", et, [
|
|
368
|
-
g(
|
|
368
|
+
g(a, {
|
|
369
369
|
name: l.icon || "folder-open",
|
|
370
370
|
size: "48px",
|
|
371
371
|
style: { color: "#ddd" }
|
|
@@ -384,7 +384,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
384
384
|
c("div", tt, [
|
|
385
385
|
c("div", lt, [
|
|
386
386
|
e[12] || (e[12] = c("span", { class: "cd-ps-title" }, "已选择", -1)),
|
|
387
|
-
c("span",
|
|
387
|
+
c("span", at, m(d.value.length) + " 项", 1),
|
|
388
388
|
d.value.length > 0 ? (n(), O(U, {
|
|
389
389
|
key: 0,
|
|
390
390
|
size: "small",
|
|
@@ -397,9 +397,9 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
397
397
|
_: 1
|
|
398
398
|
})) : y("", !0)
|
|
399
399
|
]),
|
|
400
|
-
c("div",
|
|
400
|
+
c("div", st, [
|
|
401
401
|
d.value.length === 0 ? (n(), u("div", nt, [
|
|
402
|
-
g(
|
|
402
|
+
g(a, {
|
|
403
403
|
name: "user-checked",
|
|
404
404
|
size: "64px",
|
|
405
405
|
style: { color: "#ddd" }
|
|
@@ -408,13 +408,13 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
408
408
|
])) : (n(), u("div", ot, [
|
|
409
409
|
(n(!0), u(F, null, q(d.value, (l) => (n(), u("div", {
|
|
410
410
|
key: l.id,
|
|
411
|
-
class:
|
|
411
|
+
class: se(["cd-ps-selected-item", { "cd-ps-dept-item": !l.isUser }])
|
|
412
412
|
}, [
|
|
413
413
|
c("div", it, [
|
|
414
414
|
c("div", {
|
|
415
|
-
class:
|
|
415
|
+
class: se(["cd-ps-avatar", { "cd-ps-avatar-dept": !l.isUser }])
|
|
416
416
|
}, [
|
|
417
|
-
g(
|
|
417
|
+
g(a, {
|
|
418
418
|
name: l.isUser ? "user" : "folder"
|
|
419
419
|
}, null, 8, ["name"])
|
|
420
420
|
], 2),
|
|
@@ -432,10 +432,10 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
432
432
|
size: "small",
|
|
433
433
|
variant: "text",
|
|
434
434
|
shape: "circle",
|
|
435
|
-
onClick: (
|
|
435
|
+
onClick: (ae) => Ie(l.id)
|
|
436
436
|
}, {
|
|
437
437
|
icon: b(() => [
|
|
438
|
-
g(
|
|
438
|
+
g(a, { name: "close" })
|
|
439
439
|
]),
|
|
440
440
|
_: 1
|
|
441
441
|
}, 8, ["onClick"])
|
|
@@ -477,12 +477,12 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
477
477
|
emits: ["update:modelValue", "search", "load-users"],
|
|
478
478
|
setup(k, { emit: G }) {
|
|
479
479
|
const V = k, i = G, x = h(!1), N = h([]), w = h(void 0), z = h(!1), B = h([]), p = h([]), _ = h(!1), W = L(() => {
|
|
480
|
-
const
|
|
480
|
+
const s = new Set(p.value.map((d) => d.id));
|
|
481
481
|
return [
|
|
482
482
|
...p.value,
|
|
483
|
-
...N.value.filter((d) => !
|
|
483
|
+
...N.value.filter((d) => !s.has(d.id))
|
|
484
484
|
];
|
|
485
|
-
}), H = (
|
|
485
|
+
}), H = (s) => s ? s.substring(0, 2).toUpperCase() : "", J = (s) => {
|
|
486
486
|
const r = [
|
|
487
487
|
"#1890ff",
|
|
488
488
|
"#52c41a",
|
|
@@ -494,20 +494,20 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
494
494
|
"#fa8c16"
|
|
495
495
|
];
|
|
496
496
|
let d = 0;
|
|
497
|
-
for (let C = 0; C <
|
|
498
|
-
d =
|
|
497
|
+
for (let C = 0; C < s.length; C++)
|
|
498
|
+
d = s.charCodeAt(C) + ((d << 5) - d);
|
|
499
499
|
return r[Math.abs(d) % r.length];
|
|
500
|
-
}, M = (
|
|
501
|
-
|
|
502
|
-
keyword:
|
|
500
|
+
}, M = (s) => {
|
|
501
|
+
s && s.trim() ? (_.value = !0, x.value = !0, i("search", {
|
|
502
|
+
keyword: s,
|
|
503
503
|
callback: (r) => {
|
|
504
504
|
N.value = r, x.value = !1;
|
|
505
505
|
}
|
|
506
506
|
})) : (N.value = [], x.value = !1, _.value = !1);
|
|
507
|
-
}, ne = (
|
|
508
|
-
|
|
509
|
-
}, Z = (
|
|
510
|
-
const r = Array.isArray(
|
|
507
|
+
}, ne = (s) => {
|
|
508
|
+
s && N.value.length === 0 && (_.value = !1);
|
|
509
|
+
}, Z = (s) => {
|
|
510
|
+
const r = Array.isArray(s) ? s : s ? [s] : [], d = V.modelValue.map((f) => f.id), C = r.filter((f) => !d.includes(f)), $ = d.filter((f) => !r.includes(f));
|
|
511
511
|
if (C.length > 0) {
|
|
512
512
|
const f = C.map((o) => W.value.find((de) => de.id === o)).filter(Boolean);
|
|
513
513
|
if (!V.multiple)
|
|
@@ -521,15 +521,15 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
521
521
|
const f = V.modelValue.filter((o) => !$.includes(o.id));
|
|
522
522
|
i("update:modelValue", f), p.value = f;
|
|
523
523
|
}
|
|
524
|
-
}, K = (
|
|
525
|
-
const r = V.modelValue.filter((d) => d.id !==
|
|
524
|
+
}, K = (s) => {
|
|
525
|
+
const r = V.modelValue.filter((d) => d.id !== s);
|
|
526
526
|
i("update:modelValue", r), p.value = r;
|
|
527
|
-
}, ee = (
|
|
528
|
-
|
|
527
|
+
}, ee = (s) => {
|
|
528
|
+
s && typeof s.stopPropagation == "function" && s.stopPropagation(), s && typeof s.preventDefault == "function" && s.preventDefault(), _.value = !1, oe();
|
|
529
529
|
}, oe = () => {
|
|
530
530
|
z.value = !0;
|
|
531
|
-
}, ie = (
|
|
532
|
-
const r =
|
|
531
|
+
}, ie = (s) => {
|
|
532
|
+
const r = s.map((d) => {
|
|
533
533
|
const C = d.displayName || d.name || d.title || String(d.id);
|
|
534
534
|
return {
|
|
535
535
|
id: d.id,
|
|
@@ -548,17 +548,17 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
548
548
|
i("update:modelValue", $), p.value = $;
|
|
549
549
|
}
|
|
550
550
|
z.value = !1;
|
|
551
|
-
}, R = (
|
|
552
|
-
i("load-users",
|
|
553
|
-
}, te = (
|
|
551
|
+
}, R = (s) => {
|
|
552
|
+
i("load-users", s);
|
|
553
|
+
}, te = (s) => {
|
|
554
554
|
i("search", {
|
|
555
|
-
keyword:
|
|
556
|
-
callback:
|
|
555
|
+
keyword: s.keyword,
|
|
556
|
+
callback: s.callback
|
|
557
557
|
});
|
|
558
558
|
};
|
|
559
|
-
return X(() => V.modelValue, (
|
|
560
|
-
V.multiple ? w.value =
|
|
561
|
-
}, { immediate: !0, deep: !0 }), (
|
|
559
|
+
return X(() => V.modelValue, (s) => {
|
|
560
|
+
V.multiple ? w.value = s.map((r) => r.id) : w.value = s.length > 0 ? s[0].id : void 0, B.value = s.map((r) => r.id), p.value = s;
|
|
561
|
+
}, { immediate: !0, deep: !0 }), (s, r) => {
|
|
562
562
|
const d = I("t-icon"), C = I("t-tag"), $ = I("t-option"), f = I("t-select");
|
|
563
563
|
return n(), u("div", ht, [
|
|
564
564
|
g(f, {
|
|
@@ -582,7 +582,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
582
582
|
}, {
|
|
583
583
|
suffix: b(() => [
|
|
584
584
|
g(d, {
|
|
585
|
-
name: "
|
|
585
|
+
name: "add-circle",
|
|
586
586
|
onClick: ee
|
|
587
587
|
})
|
|
588
588
|
]),
|
|
@@ -661,7 +661,7 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
661
661
|
]);
|
|
662
662
|
};
|
|
663
663
|
}
|
|
664
|
-
}), St = /* @__PURE__ */ ye(Ut, [["__scopeId", "data-v-
|
|
664
|
+
}), St = /* @__PURE__ */ ye(Ut, [["__scopeId", "data-v-30a96740"]]), Nt = {
|
|
665
665
|
install(k) {
|
|
666
666
|
k.component("PersonSelector", ke), k.component("CdInputPersonSelector", St);
|
|
667
667
|
}
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.cd-ps-container[data-v-1e0585c3]{display:flex;flex-direction:column;gap:16px;min-height:500px}.cd-ps-tips[data-v-1e0585c3]{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-1e0585c3]{display:flex;gap:12px;align-items:center}.cd-ps-org-select[data-v-1e0585c3]{flex-shrink:0}.cd-ps-search-input[data-v-1e0585c3]{flex:1}.cd-ps-content[data-v-1e0585c3]{display:flex;gap:0;height:450px;border:1px solid #dfe1e6;border-radius:4px;overflow:hidden}.cd-ps-left[data-v-1e0585c3]{width:480px;flex-shrink:0;border-right:1px solid #dfe1e6;display:flex;flex-direction:column;background-color:#fafafa}.cd-ps-left[data-v-1e0585c3] .t-tabs__nav-container{padding:0 8px;background-color:#fff}.cd-ps-left[data-v-1e0585c3] .t-tabs__content{flex:1;overflow:hidden}.cd-ps-tree[data-v-1e0585c3]{height:100%;overflow-y:auto;padding:8px}.cd-ps-tree[data-v-1e0585c3]::-webkit-scrollbar{width:6px}.cd-ps-tree[data-v-1e0585c3]::-webkit-scrollbar-track{background:#f1f1f1}.cd-ps-tree[data-v-1e0585c3]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.cd-ps-node[data-v-1e0585c3]{display:flex;align-items:center;gap:6px;font-size:14px;width:100%}.cd-ps-node-name[data-v-1e0585c3]{flex:1;min-width:0;display:flex;align-items:center;gap:6px}.cd-ps-position[data-v-1e0585c3]{color:#0052d9;font-size:12px;padding:2px 8px;background:#e8f4ff;border-radius:4px;white-space:nowrap;flex-shrink:0}[data-v-1e0585c3] .t-tree__label{flex:1}[data-v-1e0585c3] .t-checkbox__label{width:100%}.cd-ps-node-user[data-v-1e0585c3]{font-size:13px;color:#666}.cd-ps-count[data-v-1e0585c3]{color:#999;font-size:12px}.cd-ps-load-btn[data-v-1e0585c3]{margin-left:auto;color:#0052d9;font-size:12px;flex-shrink:0}.cd-ps-empty[data-v-1e0585c3]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;color:#999}.cd-ps-empty p[data-v-1e0585c3]{margin-top:16px;font-size:14px}.cd-ps-search-results[data-v-1e0585c3]{display:flex;flex-direction:column;height:100%}.cd-ps-search-header[data-v-1e0585c3]{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-1e0585c3]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;gap:12px;color:#999}.cd-ps-result-list[data-v-1e0585c3]{flex:1;overflow-y:auto;padding:8px}.cd-ps-result-item[data-v-1e0585c3]{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-1e0585c3]:hover{border-color:#0052d9;background:#f0f5ff}.cd-ps-result-item.cd-ps-selected[data-v-1e0585c3]{border-color:#0052d9;background:#e8f4ff}.cd-ps-avatar[data-v-1e0585c3]{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-1e0585c3]{width:36px;height:36px}.cd-ps-avatar-dept[data-v-1e0585c3]{background:linear-gradient(135deg,#f5af19,#f12711)}.cd-ps-info[data-v-1e0585c3]{flex:1;min-width:0}.cd-ps-name[data-v-1e0585c3]{font-size:13px;font-weight:500;color:#333;margin-bottom:4px}.cd-ps-result-item .cd-ps-name[data-v-1e0585c3]{font-size:14px}.cd-ps-meta[data-v-1e0585c3]{display:flex;flex-wrap:wrap;gap:6px;font-size:11px;color:#999}.cd-ps-result-item .cd-ps-meta[data-v-1e0585c3]{font-size:12px}.cd-ps-meta span[data-v-1e0585c3]:before{content:"•";margin-right:4px}.cd-ps-meta span[data-v-1e0585c3]:first-child:before{display:none}.cd-ps-right[data-v-1e0585c3]{flex:1;display:flex;flex-direction:column;overflow:hidden;background-color:#fafafa}.cd-ps-right-header[data-v-1e0585c3]{display:flex;align-items:center;padding:12px 16px;border-bottom:1px solid #dfe1e6;background-color:#fff}.cd-ps-title[data-v-1e0585c3]{font-weight:500;font-size:14px;color:#333}.cd-ps-num[data-v-1e0585c3]{font-size:13px;color:#0052d9;font-weight:600;margin-left:8px;flex:1}.cd-ps-right-list[data-v-1e0585c3]{flex:1;overflow-y:auto;padding:8px}.cd-ps-right-list[data-v-1e0585c3]::-webkit-scrollbar{width:6px}.cd-ps-right-list[data-v-1e0585c3]::-webkit-scrollbar-track{background:#f1f1f1}.cd-ps-right-list[data-v-1e0585c3]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.cd-ps-selected-list[data-v-1e0585c3]{display:flex;flex-direction:column;gap:8px}.cd-ps-selected-item[data-v-1e0585c3]{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-1e0585c3]:hover{border-color:#0052d9;box-shadow:0 2px 4px #0052d91a}.cd-ps-dept-item[data-v-1e0585c3]{border-color:#f5af19}.cd-ps-item-info[data-v-1e0585c3]{flex:1;min-width:0;display:flex;align-items:center;gap:10px}.cd-input-select[data-v-
|
|
1
|
+
.cd-ps-container[data-v-1e0585c3]{display:flex;flex-direction:column;gap:16px;min-height:500px}.cd-ps-tips[data-v-1e0585c3]{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-1e0585c3]{display:flex;gap:12px;align-items:center}.cd-ps-org-select[data-v-1e0585c3]{flex-shrink:0}.cd-ps-search-input[data-v-1e0585c3]{flex:1}.cd-ps-content[data-v-1e0585c3]{display:flex;gap:0;height:450px;border:1px solid #dfe1e6;border-radius:4px;overflow:hidden}.cd-ps-left[data-v-1e0585c3]{width:480px;flex-shrink:0;border-right:1px solid #dfe1e6;display:flex;flex-direction:column;background-color:#fafafa}.cd-ps-left[data-v-1e0585c3] .t-tabs__nav-container{padding:0 8px;background-color:#fff}.cd-ps-left[data-v-1e0585c3] .t-tabs__content{flex:1;overflow:hidden}.cd-ps-tree[data-v-1e0585c3]{height:100%;overflow-y:auto;padding:8px}.cd-ps-tree[data-v-1e0585c3]::-webkit-scrollbar{width:6px}.cd-ps-tree[data-v-1e0585c3]::-webkit-scrollbar-track{background:#f1f1f1}.cd-ps-tree[data-v-1e0585c3]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.cd-ps-node[data-v-1e0585c3]{display:flex;align-items:center;gap:6px;font-size:14px;width:100%}.cd-ps-node-name[data-v-1e0585c3]{flex:1;min-width:0;display:flex;align-items:center;gap:6px}.cd-ps-position[data-v-1e0585c3]{color:#0052d9;font-size:12px;padding:2px 8px;background:#e8f4ff;border-radius:4px;white-space:nowrap;flex-shrink:0}[data-v-1e0585c3] .t-tree__label{flex:1}[data-v-1e0585c3] .t-checkbox__label{width:100%}.cd-ps-node-user[data-v-1e0585c3]{font-size:13px;color:#666}.cd-ps-count[data-v-1e0585c3]{color:#999;font-size:12px}.cd-ps-load-btn[data-v-1e0585c3]{margin-left:auto;color:#0052d9;font-size:12px;flex-shrink:0}.cd-ps-empty[data-v-1e0585c3]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;color:#999}.cd-ps-empty p[data-v-1e0585c3]{margin-top:16px;font-size:14px}.cd-ps-search-results[data-v-1e0585c3]{display:flex;flex-direction:column;height:100%}.cd-ps-search-header[data-v-1e0585c3]{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-1e0585c3]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;gap:12px;color:#999}.cd-ps-result-list[data-v-1e0585c3]{flex:1;overflow-y:auto;padding:8px}.cd-ps-result-item[data-v-1e0585c3]{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-1e0585c3]:hover{border-color:#0052d9;background:#f0f5ff}.cd-ps-result-item.cd-ps-selected[data-v-1e0585c3]{border-color:#0052d9;background:#e8f4ff}.cd-ps-avatar[data-v-1e0585c3]{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-1e0585c3]{width:36px;height:36px}.cd-ps-avatar-dept[data-v-1e0585c3]{background:linear-gradient(135deg,#f5af19,#f12711)}.cd-ps-info[data-v-1e0585c3]{flex:1;min-width:0}.cd-ps-name[data-v-1e0585c3]{font-size:13px;font-weight:500;color:#333;margin-bottom:4px}.cd-ps-result-item .cd-ps-name[data-v-1e0585c3]{font-size:14px}.cd-ps-meta[data-v-1e0585c3]{display:flex;flex-wrap:wrap;gap:6px;font-size:11px;color:#999}.cd-ps-result-item .cd-ps-meta[data-v-1e0585c3]{font-size:12px}.cd-ps-meta span[data-v-1e0585c3]:before{content:"•";margin-right:4px}.cd-ps-meta span[data-v-1e0585c3]:first-child:before{display:none}.cd-ps-right[data-v-1e0585c3]{flex:1;display:flex;flex-direction:column;overflow:hidden;background-color:#fafafa}.cd-ps-right-header[data-v-1e0585c3]{display:flex;align-items:center;padding:12px 16px;border-bottom:1px solid #dfe1e6;background-color:#fff}.cd-ps-title[data-v-1e0585c3]{font-weight:500;font-size:14px;color:#333}.cd-ps-num[data-v-1e0585c3]{font-size:13px;color:#0052d9;font-weight:600;margin-left:8px;flex:1}.cd-ps-right-list[data-v-1e0585c3]{flex:1;overflow-y:auto;padding:8px}.cd-ps-right-list[data-v-1e0585c3]::-webkit-scrollbar{width:6px}.cd-ps-right-list[data-v-1e0585c3]::-webkit-scrollbar-track{background:#f1f1f1}.cd-ps-right-list[data-v-1e0585c3]::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.cd-ps-selected-list[data-v-1e0585c3]{display:flex;flex-direction:column;gap:8px}.cd-ps-selected-item[data-v-1e0585c3]{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-1e0585c3]:hover{border-color:#0052d9;box-shadow:0 2px 4px #0052d91a}.cd-ps-dept-item[data-v-1e0585c3]{border-color:#f5af19}.cd-ps-item-info[data-v-1e0585c3]{flex:1;min-width:0;display:flex;align-items:center;gap:10px}.cd-input-select[data-v-30a96740]{position:relative;width:100%}.cd-input-select__select[data-v-30a96740]{width:100%}.cd-input-select__add-icon[data-v-30a96740]{font-size:20px;color:var(--td-brand-color, #0052d9);cursor:pointer;transition:all .2s;flex-shrink:0}.cd-input-select__add-icon[data-v-30a96740]:hover{color:var(--td-brand-color-hover, #004BBD);transform:scale(1.1)}.cd-input-select__select[data-v-30a96740] .t-input{min-height:32px;height:auto;padding:0!important;display:flex;align-items:flex-start}.cd-input-select__select[data-v-30a96740] .t-input__wrap{min-height:32px;padding:2px 8px;display:flex;align-items:flex-start;flex-wrap:nowrap!important}.cd-input-select__select[data-v-30a96740] .t-input__prefix{margin-left:5px}.cd-input-select__select[data-v-30a96740] .t-input__suffix{display:flex;align-items:center;flex-shrink:0;padding-top:8px}.cd-input-select__select[data-v-30a96740] .t-input__inner{min-height:28px;line-height:28px}.cd-input-select__select[data-v-30a96740] .t-select__suffix{display:flex;align-items:center;flex-shrink:0}.cd-input-select__select[data-v-30a96740] .t-select__suffix-icon{display:flex;align-items:center;flex-shrink:0;margin-left:4px}.cd-input-select__select[data-v-30a96740] .t-select__dropdown{width:100%!important}.cd-input-select__select[data-v-30a96740] .t-tag-input{min-height:32px;padding:2px 8px;display:flex;flex-wrap:nowrap!important;align-items:flex-start}.cd-input-select__select[data-v-30a96740] .t-tag-input__suffix{display:flex;flex-shrink:0;margin-left:8px;padding-top:6px}.cd-input-select[data-v-30a96740] .t-select__dropdown .t-select-option .t-checkbox{width:100%!important;height:auto!important;padding:0!important;margin:0!important;display:flex!important;align-items:stretch!important}.cd-input-select[data-v-30a96740] .t-select__dropdown .t-select-option .t-checkbox__label{width:100%!important;height:auto!important;padding:0!important;display:flex!important;align-items:center!important}.cd-input-select[data-v-30a96740] .t-select__dropdown .t-select-option .t-checkbox__input{align-self:center!important;margin-right:8px!important}.t-select-option[data-v-30a96740]{height:auto!important;min-height:auto!important;padding:0!important;align-items:stretch!important}.cd-input-select__option{height:auto!important;min-height:auto!important}.cd-input-select__option-content{display:flex;align-items:center;gap:12px;padding:10px 12px;width:100%;min-height:56px;box-sizing:border-box}.cd-input-select__option-avatar{width:36px;height:36px;border-radius:50%;overflow:hidden;flex-shrink:0}.cd-input-select__option-avatar img{width:100%;height:100%;object-fit:cover}.cd-input-select__option-avatar--placeholder{display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600}.cd-input-select__option-info{flex:1;min-width:0}.cd-input-select__option-name{font-size:14px;font-weight:500;color:var(--td-text-color-primary, #262626);margin-bottom:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cd-input-select__option-desc{font-size:12px;color:var(--td-text-color-secondary, #8c8c8c);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cd-input-select__option-icon{font-size:18px;color:var(--td-brand-color, #0052d9);flex-shrink:0}
|
package/package.json
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cd-personselector",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "人员选择器组件 - 支持多Tab、树形结构、搜索、懒加载、输入框选择模式",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./dist/index.mjs",
|
|
12
|
-
"require": "./dist/index.js",
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
14
|
-
},
|
|
15
|
-
"./style.css": "./dist/style.css",
|
|
16
|
-
"./dist/style.css": "./dist/style.css"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
"src"
|
|
21
|
-
],
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"vue-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cd-personselector",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"description": "人员选择器组件 - 支持多Tab、树形结构、搜索、懒加载、输入框选择模式",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css",
|
|
16
|
+
"./dist/style.css": "./dist/style.css"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "vite",
|
|
24
|
+
"build": "vite build",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"vue",
|
|
29
|
+
"vue3",
|
|
30
|
+
"person-selector",
|
|
31
|
+
"tdesign",
|
|
32
|
+
"组织架构",
|
|
33
|
+
"人员选择"
|
|
34
|
+
],
|
|
35
|
+
"author": "",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"vue": "^3.0.0",
|
|
39
|
+
"tdesign-vue-next": "^1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
43
|
+
"sass": "^1.70.0",
|
|
44
|
+
"sass-embedded": "^1.97.1",
|
|
45
|
+
"tdesign-vue-next": "^1.9.0",
|
|
46
|
+
"typescript": "^5.0.0",
|
|
47
|
+
"vite": "^5.0.0",
|
|
48
|
+
"vite-plugin-dts": "^3.0.0",
|
|
49
|
+
"vue": "^3.4.0",
|
|
50
|
+
"vue-tsc": "^2.0.0"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/InputSelect.vue
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
:allow-input="true" v-model:popup-visible="popupVisible" size="medium" class="cd-input-select__select"
|
|
6
6
|
@search="handleSearchInput" @change="handleSelectChange" @popup-visible-change="handleVisibleChange">
|
|
7
7
|
<template #suffix>
|
|
8
|
-
<t-icon name="
|
|
8
|
+
<t-icon name="add-circle" @click="handleIconClick" />
|
|
9
9
|
</template>
|
|
10
10
|
<template #valueDisplay>
|
|
11
11
|
<t-tag v-for="user in selectedOptions" :key="user.id" closable size="medium"
|
|
@@ -256,7 +256,6 @@ watch(() => props.modelValue, (newUsers) => {
|
|
|
256
256
|
display: flex;
|
|
257
257
|
align-items: center;
|
|
258
258
|
flex-shrink: 0;
|
|
259
|
-
margin:0 10px;
|
|
260
259
|
padding-top: 8px;
|
|
261
260
|
}
|
|
262
261
|
:deep(.t-input__inner) {
|