cd-personselector 1.2.4 → 1.2.6
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 +223 -229
- package/dist/style.css +1 -1
- package/package.json +52 -51
- package/src/InputSelect.vue +1 -5
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(U,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(U=typeof globalThis<"u"?globalThis:U||self,e(U.CdPersonSelector={},U.Vue))})(this,function(U,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"},Ue={key:0,class:"cd-ps-position"},we={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([]),q=e.computed(()=>c.tabs||[]),M=e.computed(()=>c.organizations||[]),A=e.computed(()=>c.tips||""),G=e.computed(()=>c.showSearch),H=e.computed(()=>c.showOrg),Q=e.computed(()=>c.dialogWidth),w=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))}),w.value=t,(!B.value||!o.find(a=>a.key===B.value))&&(B.value=o[0].key)}},{immediate:!0,deep:!0});function F(){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&&F()},{deep:!0}),e.watch(()=>c.visible,o=>{y.value=o,o&&(F(),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]=[]}),w.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=w.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:j,name:O,...R}=E;return{...R,id:j,name:E.displayName||O,isUser:!0}}),N=w.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 _=w.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"),j=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),G.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:W=>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(q.value,l=>(e.openBlock(),e.createBlock(O,{key:l.key,value:l.key,label:l.name},{default:e.withCtx(()=>{var W;return[e.createElementVNode("div",be,[((W=w.value[l.key])==null?void 0:W.length)>0?(e.openBlock(),e.createBlock(j,{key:0,ref_for:!0,ref:V=>n(l.key,V),data:w.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",Ue,e.toDisplayString(V.data.position),1)):e.createCommentVNode("",!0)]),V.data.userCount&&!V.data.isUser?(e.openBlock(),e.createElementBlock("span",we,"("+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:W=>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},J=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)},q=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},G=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},w=n=>{c("load-users",n)},F=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:q},{suffix:e.withCtx(()=>[e.createVNode(d,{name:"add-circle",onClick:G})]),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))]),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(J,{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:w,onSearch:F},null,8,["visible","modelValue","tabs","organizations","multiple"])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-54561d77"]]),et={install(h){h.component("PersonSelector",J),h.component("CdInputPersonSelector",ee)}};U.InputSelect=ee,U.PersonSelector=J,U.default=et,Object.defineProperties(U,{__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
|
|
1
|
+
import { defineComponent as ge, ref as h, computed as L, watch as X, resolveComponent as S, createBlock as O, openBlock as o, withCtx as I, 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 ae, 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,13 +29,13 @@ 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" }, ot = {
|
|
33
33
|
key: 0,
|
|
34
34
|
class: "cd-ps-empty"
|
|
35
|
-
},
|
|
35
|
+
}, nt = {
|
|
36
36
|
key: 1,
|
|
37
37
|
class: "cd-ps-selected-list"
|
|
38
|
-
},
|
|
38
|
+
}, dt = { class: "cd-ps-item-info" }, it = { class: "cd-ps-info" }, ct = { class: "cd-ps-name" }, ut = { class: "cd-ps-meta" }, rt = { key: 0 }, pt = { key: 1 }, vt = { key: 2 }, ft = { key: 3 }, mt = /* @__PURE__ */ ge({
|
|
39
39
|
__name: "PersonSelector",
|
|
40
40
|
props: {
|
|
41
41
|
visible: { type: Boolean, default: !1 },
|
|
@@ -49,48 +49,48 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
49
49
|
multiple: { type: Boolean, default: !0 }
|
|
50
50
|
},
|
|
51
51
|
emits: ["update:visible", "update:modelValue", "confirm", "load-users", "search", "org-change"],
|
|
52
|
-
setup(k, { expose: G, emit:
|
|
52
|
+
setup(k, { expose: G, emit: b }) {
|
|
53
53
|
var fe, me;
|
|
54
|
-
const
|
|
55
|
-
X(() =>
|
|
54
|
+
const d = k, x = b, N = h(d.visible), w = h(((me = (fe = d.tabs) == null ? void 0 : fe[0]) == null ? void 0 : me.key) || ""), z = h(null), B = h(""), p = h([]), _ = h(/* @__PURE__ */ new Map()), W = h({}), H = h(!1), J = h(!1), M = h([]), se = L(() => d.tabs || []), Z = L(() => d.organizations || []), K = L(() => d.tips || ""), oe = L(() => d.showSearch), ne = L(() => d.showOrg), de = L(() => d.dialogWidth), R = h({});
|
|
55
|
+
X(() => d.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
|
-
function
|
|
64
|
-
if (
|
|
65
|
-
const t =
|
|
66
|
-
typeof t == "object" && t !== null && "id" in t ? (p.value =
|
|
63
|
+
function ee() {
|
|
64
|
+
if (d.modelValue && d.modelValue.length > 0) {
|
|
65
|
+
const t = d.modelValue[0];
|
|
66
|
+
typeof t == "object" && t !== null && "id" in t ? (p.value = d.modelValue.map((e) => e.id), _.value.clear(), d.modelValue.forEach((e) => {
|
|
67
67
|
_.value.set(e.id, e);
|
|
68
|
-
})) : p.value = [...
|
|
68
|
+
})) : p.value = [...d.modelValue];
|
|
69
69
|
} else
|
|
70
70
|
p.value = [], _.value.clear();
|
|
71
71
|
}
|
|
72
|
-
X(() =>
|
|
73
|
-
N.value && t &&
|
|
74
|
-
}, { deep: !0 }), X(() =>
|
|
75
|
-
N.value = t, t && (
|
|
72
|
+
X(() => d.modelValue, (t) => {
|
|
73
|
+
N.value && t && ee();
|
|
74
|
+
}, { deep: !0 }), X(() => d.visible, (t) => {
|
|
75
|
+
N.value = t, t && (ee(), d.organizations.length > 0 && !z.value && (z.value = d.organizations[0].id));
|
|
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
|
}
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
|
-
const
|
|
93
|
-
function
|
|
92
|
+
const i = L(() => p.value.map((t) => _.value.get(t)).filter(Boolean));
|
|
93
|
+
function V(t, e) {
|
|
94
94
|
p.value.includes(t) || p.value.push(t), _.value.set(t, e);
|
|
95
95
|
}
|
|
96
96
|
function $(t) {
|
|
@@ -98,14 +98,14 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
98
98
|
}
|
|
99
99
|
const f = () => {
|
|
100
100
|
B.value = "";
|
|
101
|
-
},
|
|
101
|
+
}, n = (t) => {
|
|
102
102
|
const e = {};
|
|
103
|
-
|
|
104
|
-
e[
|
|
103
|
+
d.tabs.forEach((a) => {
|
|
104
|
+
e[a.key] = [];
|
|
105
105
|
}), R.value = e, x("org-change", t);
|
|
106
106
|
};
|
|
107
107
|
let E = null;
|
|
108
|
-
const
|
|
108
|
+
const ie = () => {
|
|
109
109
|
if (E && clearTimeout(E), !B.value.trim()) {
|
|
110
110
|
ce();
|
|
111
111
|
return;
|
|
@@ -114,31 +114,31 @@ 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 = () => {
|
|
121
121
|
E && (clearTimeout(E), E = null), H.value = !1, B.value = "", M.value = [], J.value = !1;
|
|
122
122
|
}, Ve = (t) => {
|
|
123
|
-
p.value.indexOf(t.id) > -1 ? $(t.id) : (
|
|
123
|
+
p.value.indexOf(t.id) > -1 ? $(t.id) : (d.multiple || (p.value = [], _.value.clear()), V(t.id, { ...t, isUser: !0, typeName: "搜索结果", orgId: z.value }), d.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
|
-
var
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const P =
|
|
133
|
+
var C, T;
|
|
134
|
+
const a = e == null ? void 0 : e.node;
|
|
135
|
+
if (a) {
|
|
136
|
+
const P = a.value ?? ((C = a.data) == null ? void 0 : C.id);
|
|
137
137
|
if (P !== void 0) {
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
const j =
|
|
141
|
-
|
|
138
|
+
if (a.checked) {
|
|
139
|
+
d.multiple || (p.value = [], _.value.clear());
|
|
140
|
+
const j = d.tabs.find((re) => re.key === w.value), Q = j ? j.name.replace(/^按/, "") : "";
|
|
141
|
+
V(P, { ...a.data, typeName: Q, orgId: z.value }), !d.multiple && ((T = a.data) != null && T.isUser) && ue();
|
|
142
142
|
} else
|
|
143
143
|
$(P);
|
|
144
144
|
return;
|
|
@@ -147,35 +147,35 @@ 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
|
-
const
|
|
164
|
-
const { id:
|
|
165
|
-
return { ...Q, id:
|
|
163
|
+
const C = A.map((P) => {
|
|
164
|
+
const { id: te, name: j, ...Q } = P;
|
|
165
|
+
return { ...Q, id: te, 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, C), v) {
|
|
168
|
+
v.appendTo(a, C), 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
|
}
|
|
174
174
|
} else {
|
|
175
175
|
t.data.loaded = !0;
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
const T = r(
|
|
176
|
+
const C = R.value[e];
|
|
177
|
+
if (C) {
|
|
178
|
+
const T = r(C, a);
|
|
179
179
|
T && (T.loaded = !0);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -186,52 +186,52 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
186
186
|
}, ve = () => {
|
|
187
187
|
p.value = [], _.value.clear();
|
|
188
188
|
}, ue = () => {
|
|
189
|
-
x("update:modelValue", p.value), x("confirm",
|
|
189
|
+
x("update:modelValue", p.value), x("confirm", i.value), N.value = !1;
|
|
190
190
|
}, xe = () => {
|
|
191
191
|
N.value = !1;
|
|
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 =
|
|
199
|
-
const { id:
|
|
200
|
-
return { ...P, id:
|
|
197
|
+
if (v && a.length > 0) {
|
|
198
|
+
const D = a.map((A) => {
|
|
199
|
+
const { id: C, name: T, ...P } = A;
|
|
200
|
+
return { ...P, id: C, name: A.displayName || T, isUser: !0 };
|
|
201
201
|
});
|
|
202
202
|
v.appendTo(e, D);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}), (t, e) => {
|
|
206
|
-
const
|
|
207
|
-
return
|
|
206
|
+
const a = S("t-icon"), v = S("t-option"), D = S("t-select"), A = S("t-input"), C = S("t-button"), T = S("t-loading"), P = S("t-checkbox"), te = S("t-tree"), j = S("t-tab-panel"), Q = S("t-tabs"), re = S("t-dialog");
|
|
207
|
+
return o(), O(re, {
|
|
208
208
|
visible: N.value,
|
|
209
209
|
"onUpdate:visible": e[4] || (e[4] = (l) => N.value = l),
|
|
210
210
|
header: "选择人员",
|
|
211
|
-
width:
|
|
211
|
+
width: de.value,
|
|
212
212
|
footer: !0,
|
|
213
213
|
placement: "center",
|
|
214
214
|
"destroy-on-close": "",
|
|
215
215
|
onConfirm: ue,
|
|
216
216
|
onClose: xe
|
|
217
217
|
}, {
|
|
218
|
-
default:
|
|
218
|
+
default: I(() => [
|
|
219
219
|
c("div", we, [
|
|
220
|
-
K.value ? (
|
|
221
|
-
g(
|
|
220
|
+
K.value ? (o(), u("div", Te, [
|
|
221
|
+
g(a, { name: "info-circle" }),
|
|
222
222
|
c("span", null, m(K.value), 1)
|
|
223
223
|
])) : y("", !0),
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
oe.value ? (o(), u("div", Pe, [
|
|
225
|
+
ne.value && Z.value.length > 0 ? (o(), u("div", $e, [
|
|
226
226
|
g(D, {
|
|
227
227
|
modelValue: z.value,
|
|
228
228
|
"onUpdate:modelValue": e[0] || (e[0] = (l) => z.value = l),
|
|
229
229
|
placeholder: "选择组织",
|
|
230
230
|
style: { width: "200px" },
|
|
231
|
-
onChange:
|
|
231
|
+
onChange: n
|
|
232
232
|
}, {
|
|
233
|
-
default:
|
|
234
|
-
(
|
|
233
|
+
default: I(() => [
|
|
234
|
+
(o(!0), u(F, null, q(Z.value, (l) => (o(), O(v, {
|
|
235
235
|
key: l.id,
|
|
236
236
|
value: l.id,
|
|
237
237
|
label: l.displayName || l.name
|
|
@@ -246,11 +246,11 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
246
246
|
"onUpdate:modelValue": e[1] || (e[1] = (l) => B.value = l),
|
|
247
247
|
placeholder: "输入手机号/工号/姓名/部门/职位搜索",
|
|
248
248
|
clearable: "",
|
|
249
|
-
onInput:
|
|
249
|
+
onInput: ie,
|
|
250
250
|
onClear: ce
|
|
251
251
|
}, {
|
|
252
|
-
"prefix-icon":
|
|
253
|
-
g(
|
|
252
|
+
"prefix-icon": I(() => [
|
|
253
|
+
g(a, { name: "search" })
|
|
254
254
|
]),
|
|
255
255
|
_: 1
|
|
256
256
|
}, 8, ["modelValue"])
|
|
@@ -258,35 +258,35 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
258
258
|
])) : y("", !0),
|
|
259
259
|
c("div", De, [
|
|
260
260
|
c("div", Oe, [
|
|
261
|
-
H.value ? (
|
|
261
|
+
H.value ? (o(), u("div", Re, [
|
|
262
262
|
c("div", Ae, [
|
|
263
263
|
e[6] || (e[6] = c("span", null, "搜索结果", -1)),
|
|
264
|
-
g(
|
|
264
|
+
g(C, {
|
|
265
265
|
size: "small",
|
|
266
266
|
variant: "text",
|
|
267
267
|
onClick: ce
|
|
268
268
|
}, {
|
|
269
|
-
default:
|
|
269
|
+
default: I(() => [...e[5] || (e[5] = [
|
|
270
270
|
Y("返回", -1)
|
|
271
271
|
])]),
|
|
272
272
|
_: 1
|
|
273
273
|
})
|
|
274
274
|
]),
|
|
275
|
-
J.value ? (
|
|
275
|
+
J.value ? (o(), u("div", Le, [
|
|
276
276
|
g(T),
|
|
277
277
|
e[7] || (e[7] = c("span", null, "搜索中...", -1))
|
|
278
|
-
])) : M.value.length === 0 ? (
|
|
279
|
-
g(
|
|
278
|
+
])) : M.value.length === 0 ? (o(), u("div", Me, [
|
|
279
|
+
g(a, {
|
|
280
280
|
name: "search",
|
|
281
281
|
size: "48px",
|
|
282
282
|
style: { color: "#ddd" }
|
|
283
283
|
}),
|
|
284
284
|
e[8] || (e[8] = c("p", null, "未找到匹配的人员", -1))
|
|
285
|
-
])) : (
|
|
286
|
-
(
|
|
285
|
+
])) : (o(), u("div", Ee, [
|
|
286
|
+
(o(!0), u(F, null, q(M.value, (l) => (o(), u("div", {
|
|
287
287
|
key: l.id,
|
|
288
288
|
class: ae(["cd-ps-result-item", { "cd-ps-selected": p.value.includes(l.id) }]),
|
|
289
|
-
onClick: (
|
|
289
|
+
onClick: (le) => Ve(l)
|
|
290
290
|
}, [
|
|
291
291
|
g(P, {
|
|
292
292
|
checked: p.value.includes(l.id),
|
|
@@ -294,38 +294,38 @@ 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),
|
|
301
301
|
c("div", qe, [
|
|
302
|
-
l.position ? (
|
|
303
|
-
l.department ? (
|
|
304
|
-
l.phone ? (
|
|
302
|
+
l.position ? (o(), u("span", Ge, m(l.position), 1)) : y("", !0),
|
|
303
|
+
l.department ? (o(), u("span", He, m(l.department), 1)) : y("", !0),
|
|
304
|
+
l.phone ? (o(), u("span", Qe, m(l.phone), 1)) : y("", !0)
|
|
305
305
|
])
|
|
306
306
|
])
|
|
307
307
|
], 10, We))), 128))
|
|
308
308
|
]))
|
|
309
|
-
])) : (
|
|
309
|
+
])) : (o(), O(Q, {
|
|
310
310
|
key: 1,
|
|
311
311
|
modelValue: w.value,
|
|
312
312
|
"onUpdate:modelValue": e[3] || (e[3] = (l) => w.value = l),
|
|
313
313
|
onChange: f
|
|
314
314
|
}, {
|
|
315
|
-
default:
|
|
316
|
-
(
|
|
315
|
+
default: I(() => [
|
|
316
|
+
(o(!0), u(F, null, q(se.value, (l) => (o(), O(j, {
|
|
317
317
|
key: l.key,
|
|
318
318
|
value: l.key,
|
|
319
319
|
label: l.name
|
|
320
320
|
}, {
|
|
321
|
-
default:
|
|
322
|
-
var
|
|
321
|
+
default: I(() => {
|
|
322
|
+
var le;
|
|
323
323
|
return [
|
|
324
324
|
c("div", Xe, [
|
|
325
|
-
((
|
|
325
|
+
((le = R.value[l.key]) == null ? void 0 : le.length) > 0 ? (o(), O(te, {
|
|
326
326
|
key: 0,
|
|
327
327
|
ref_for: !0,
|
|
328
|
-
ref: (
|
|
328
|
+
ref: (U) => s(l.key, U),
|
|
329
329
|
data: R.value[l.key],
|
|
330
330
|
keys: { value: "id", label: "name", children: "children" },
|
|
331
331
|
hover: "",
|
|
@@ -334,28 +334,28 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
334
334
|
value: p.value,
|
|
335
335
|
onChange: Ue
|
|
336
336
|
}, {
|
|
337
|
-
label:
|
|
337
|
+
label: I(({ node: U }) => {
|
|
338
338
|
var he;
|
|
339
339
|
return [
|
|
340
340
|
c("div", {
|
|
341
|
-
class: ae(["cd-ps-node", { "cd-ps-node-user":
|
|
341
|
+
class: ae(["cd-ps-node", { "cd-ps-node-user": U.data.isUser }])
|
|
342
342
|
}, [
|
|
343
|
-
g(
|
|
344
|
-
name:
|
|
343
|
+
g(a, {
|
|
344
|
+
name: U.data.isUser ? "user" : l.icon || "folder"
|
|
345
345
|
}, null, 8, ["name"]),
|
|
346
346
|
c("span", Ye, [
|
|
347
|
-
Y(m(
|
|
348
|
-
|
|
347
|
+
Y(m(U.label) + " ", 1),
|
|
348
|
+
U.data.isUser && U.data.position ? (o(), u("span", Ze, m(U.data.position), 1)) : y("", !0)
|
|
349
349
|
]),
|
|
350
|
-
|
|
351
|
-
!
|
|
350
|
+
U.data.userCount && !U.data.isUser ? (o(), u("span", Ke, "(" + m(U.data.userCount) + ")", 1)) : y("", !0),
|
|
351
|
+
!U.data.isUser && !((he = U.data.children) != null && he.length) && !U.data.loaded ? (o(), O(C, {
|
|
352
352
|
key: 1,
|
|
353
353
|
size: "small",
|
|
354
354
|
variant: "text",
|
|
355
355
|
class: "cd-ps-load-btn",
|
|
356
|
-
onClick: _e((It) => Se(
|
|
356
|
+
onClick: _e((It) => Se(U, l.key), ["stop"])
|
|
357
357
|
}, {
|
|
358
|
-
default:
|
|
358
|
+
default: I(() => [...e[9] || (e[9] = [
|
|
359
359
|
Y("显示人员", -1)
|
|
360
360
|
])]),
|
|
361
361
|
_: 1
|
|
@@ -364,8 +364,8 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
364
364
|
];
|
|
365
365
|
}),
|
|
366
366
|
_: 2
|
|
367
|
-
}, 1032, ["data", "value"])) : (
|
|
368
|
-
g(
|
|
367
|
+
}, 1032, ["data", "value"])) : (o(), u("div", et, [
|
|
368
|
+
g(a, {
|
|
369
369
|
name: l.icon || "folder-open",
|
|
370
370
|
size: "48px",
|
|
371
371
|
style: { color: "#ddd" }
|
|
@@ -384,58 +384,58 @@ 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",
|
|
388
|
-
|
|
387
|
+
c("span", at, m(i.value.length) + " 项", 1),
|
|
388
|
+
i.value.length > 0 ? (o(), O(C, {
|
|
389
389
|
key: 0,
|
|
390
390
|
size: "small",
|
|
391
391
|
variant: "text",
|
|
392
392
|
onClick: ve
|
|
393
393
|
}, {
|
|
394
|
-
default:
|
|
394
|
+
default: I(() => [...e[11] || (e[11] = [
|
|
395
395
|
Y("清空", -1)
|
|
396
396
|
])]),
|
|
397
397
|
_: 1
|
|
398
398
|
})) : y("", !0)
|
|
399
399
|
]),
|
|
400
|
-
c("div",
|
|
401
|
-
|
|
402
|
-
g(
|
|
400
|
+
c("div", st, [
|
|
401
|
+
i.value.length === 0 ? (o(), u("div", ot, [
|
|
402
|
+
g(a, {
|
|
403
403
|
name: "user-checked",
|
|
404
404
|
size: "64px",
|
|
405
405
|
style: { color: "#ddd" }
|
|
406
406
|
}),
|
|
407
407
|
e[13] || (e[13] = c("p", null, "暂无选择", -1))
|
|
408
|
-
])) : (
|
|
409
|
-
(
|
|
408
|
+
])) : (o(), u("div", nt, [
|
|
409
|
+
(o(!0), u(F, null, q(i.value, (l) => (o(), u("div", {
|
|
410
410
|
key: l.id,
|
|
411
411
|
class: ae(["cd-ps-selected-item", { "cd-ps-dept-item": !l.isUser }])
|
|
412
412
|
}, [
|
|
413
|
-
c("div",
|
|
413
|
+
c("div", dt, [
|
|
414
414
|
c("div", {
|
|
415
415
|
class: ae(["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),
|
|
421
|
-
c("div",
|
|
421
|
+
c("div", it, [
|
|
422
422
|
c("div", ct, m(l.displayName || l.name), 1),
|
|
423
423
|
c("div", ut, [
|
|
424
|
-
l.isUser && l.position ? (
|
|
425
|
-
l.isUser && l.department ? (
|
|
426
|
-
l.isUser ? y("", !0) : (
|
|
427
|
-
!l.isUser && l.userCount ? (
|
|
424
|
+
l.isUser && l.position ? (o(), u("span", rt, m(l.position), 1)) : y("", !0),
|
|
425
|
+
l.isUser && l.department ? (o(), u("span", pt, m(l.department), 1)) : y("", !0),
|
|
426
|
+
l.isUser ? y("", !0) : (o(), u("span", vt, m(l.typeName || "部门"), 1)),
|
|
427
|
+
!l.isUser && l.userCount ? (o(), u("span", ft, m(l.userCount) + "人", 1)) : y("", !0)
|
|
428
428
|
])
|
|
429
429
|
])
|
|
430
430
|
]),
|
|
431
|
-
g(
|
|
431
|
+
g(C, {
|
|
432
432
|
size: "small",
|
|
433
433
|
variant: "text",
|
|
434
434
|
shape: "circle",
|
|
435
|
-
onClick: (
|
|
435
|
+
onClick: (le) => Ie(l.id)
|
|
436
436
|
}, {
|
|
437
|
-
icon:
|
|
438
|
-
g(
|
|
437
|
+
icon: I(() => [
|
|
438
|
+
g(a, { name: "close" })
|
|
439
439
|
]),
|
|
440
440
|
_: 1
|
|
441
441
|
}, 8, ["onClick"])
|
|
@@ -451,10 +451,10 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
453
|
}), ye = (k, G) => {
|
|
454
|
-
const
|
|
455
|
-
for (const [
|
|
456
|
-
|
|
457
|
-
return
|
|
454
|
+
const b = k.__vccOpts || k;
|
|
455
|
+
for (const [d, x] of G)
|
|
456
|
+
b[d] = x;
|
|
457
|
+
return b;
|
|
458
458
|
}, ke = /* @__PURE__ */ ye(mt, [["__scopeId", "data-v-1e0585c3"]]), ht = { class: "cd-input-select" }, _t = { class: "cd-input-select__option-content" }, gt = {
|
|
459
459
|
key: 0,
|
|
460
460
|
class: "cd-input-select__option-avatar"
|
|
@@ -476,13 +476,13 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
476
476
|
},
|
|
477
477
|
emits: ["update:modelValue", "search", "load-users"],
|
|
478
478
|
setup(k, { emit: G }) {
|
|
479
|
-
const
|
|
480
|
-
const
|
|
479
|
+
const b = k, d = G, x = h(!1), N = h([]), w = h(void 0), z = h(!1), B = h([]), p = h([]), _ = h(!1), W = L(() => {
|
|
480
|
+
const s = new Set(p.value.map((i) => i.id));
|
|
481
481
|
return [
|
|
482
482
|
...p.value,
|
|
483
|
-
...N.value.filter((
|
|
483
|
+
...N.value.filter((i) => !s.has(i.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",
|
|
@@ -493,78 +493,78 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
493
493
|
"#eb2f96",
|
|
494
494
|
"#fa8c16"
|
|
495
495
|
];
|
|
496
|
-
let
|
|
497
|
-
for (let
|
|
498
|
-
|
|
499
|
-
return r[Math.abs(
|
|
500
|
-
}, M = (
|
|
501
|
-
|
|
502
|
-
keyword:
|
|
496
|
+
let i = 0;
|
|
497
|
+
for (let V = 0; V < s.length; V++)
|
|
498
|
+
i = s.charCodeAt(V) + ((i << 5) - i);
|
|
499
|
+
return r[Math.abs(i) % r.length];
|
|
500
|
+
}, M = (s) => {
|
|
501
|
+
s && s.trim() ? (_.value = !0, x.value = !0, d("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
|
-
},
|
|
508
|
-
|
|
509
|
-
}, Z = (
|
|
510
|
-
const r = Array.isArray(
|
|
511
|
-
if (
|
|
512
|
-
const f =
|
|
513
|
-
if (!
|
|
514
|
-
|
|
507
|
+
}, se = (s) => {
|
|
508
|
+
s && N.value.length === 0 && (_.value = !1);
|
|
509
|
+
}, Z = (s) => {
|
|
510
|
+
const r = Array.isArray(s) ? s : s ? [s] : [], i = b.modelValue.map((f) => f.id), V = r.filter((f) => !i.includes(f)), $ = i.filter((f) => !r.includes(f));
|
|
511
|
+
if (V.length > 0) {
|
|
512
|
+
const f = V.map((n) => W.value.find((ie) => ie.id === n)).filter(Boolean);
|
|
513
|
+
if (!b.multiple)
|
|
514
|
+
d("update:modelValue", f), p.value = f, N.value = [], _.value = !1;
|
|
515
515
|
else {
|
|
516
|
-
const
|
|
517
|
-
|
|
516
|
+
const n = [...b.modelValue, ...f];
|
|
517
|
+
d("update:modelValue", n), p.value = n;
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
if ($.length > 0) {
|
|
521
|
-
const f =
|
|
522
|
-
|
|
521
|
+
const f = b.modelValue.filter((n) => !$.includes(n.id));
|
|
522
|
+
d("update:modelValue", f), p.value = f;
|
|
523
523
|
}
|
|
524
|
-
}, K = (
|
|
525
|
-
const r =
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
|
|
529
|
-
},
|
|
524
|
+
}, K = (s) => {
|
|
525
|
+
const r = b.modelValue.filter((i) => i.id !== s);
|
|
526
|
+
d("update:modelValue", r), p.value = r;
|
|
527
|
+
}, oe = (s) => {
|
|
528
|
+
s && typeof s.stopPropagation == "function" && s.stopPropagation(), s && typeof s.preventDefault == "function" && s.preventDefault(), _.value = !1, ne();
|
|
529
|
+
}, ne = () => {
|
|
530
530
|
z.value = !0;
|
|
531
|
-
},
|
|
532
|
-
const r =
|
|
533
|
-
const
|
|
531
|
+
}, de = (s) => {
|
|
532
|
+
const r = s.map((i) => {
|
|
533
|
+
const V = i.displayName || i.name || i.title || String(i.id);
|
|
534
534
|
return {
|
|
535
|
-
id:
|
|
536
|
-
name:
|
|
537
|
-
avatar:
|
|
538
|
-
department:
|
|
539
|
-
position:
|
|
540
|
-
phone:
|
|
541
|
-
isUser:
|
|
535
|
+
id: i.id,
|
|
536
|
+
name: V,
|
|
537
|
+
avatar: i.avatar || "",
|
|
538
|
+
department: i.department || "",
|
|
539
|
+
position: i.position || "",
|
|
540
|
+
phone: i.phone || "",
|
|
541
|
+
isUser: i.isUser !== !1
|
|
542
542
|
};
|
|
543
543
|
});
|
|
544
|
-
if (!
|
|
545
|
-
|
|
544
|
+
if (!b.multiple)
|
|
545
|
+
d("update:modelValue", r.slice(0, 1)), p.value = r.slice(0, 1);
|
|
546
546
|
else {
|
|
547
|
-
const
|
|
548
|
-
|
|
547
|
+
const i = new Set(b.modelValue.map((f) => f.id)), V = r.filter((f) => !i.has(f.id)), $ = [...b.modelValue, ...V];
|
|
548
|
+
d("update:modelValue", $), p.value = $;
|
|
549
549
|
}
|
|
550
550
|
z.value = !1;
|
|
551
|
-
}, R = (
|
|
552
|
-
|
|
553
|
-
},
|
|
554
|
-
|
|
555
|
-
keyword:
|
|
556
|
-
callback:
|
|
551
|
+
}, R = (s) => {
|
|
552
|
+
d("load-users", s);
|
|
553
|
+
}, ee = (s) => {
|
|
554
|
+
d("search", {
|
|
555
|
+
keyword: s.keyword,
|
|
556
|
+
callback: s.callback
|
|
557
557
|
});
|
|
558
558
|
};
|
|
559
|
-
return X(() =>
|
|
560
|
-
|
|
561
|
-
}, { immediate: !0, deep: !0 }), (
|
|
562
|
-
const
|
|
563
|
-
return
|
|
559
|
+
return X(() => b.modelValue, (s) => {
|
|
560
|
+
b.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
|
+
const i = S("t-icon"), V = S("t-tag"), $ = S("t-option"), f = S("t-select");
|
|
563
|
+
return o(), u("div", ht, [
|
|
564
564
|
g(f, {
|
|
565
565
|
ref: "selectRef",
|
|
566
566
|
modelValue: w.value,
|
|
567
|
-
"onUpdate:modelValue": r[0] || (r[0] = (
|
|
567
|
+
"onUpdate:modelValue": r[0] || (r[0] = (n) => w.value = n),
|
|
568
568
|
multiple: k.multiple,
|
|
569
569
|
placeholder: k.placeholder,
|
|
570
570
|
filterable: !0,
|
|
@@ -573,68 +573,62 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
573
573
|
"reserve-keyword": !1,
|
|
574
574
|
"allow-input": !0,
|
|
575
575
|
"popup-visible": _.value,
|
|
576
|
-
"onUpdate:popupVisible": r[1] || (r[1] = (
|
|
576
|
+
"onUpdate:popupVisible": r[1] || (r[1] = (n) => _.value = n),
|
|
577
577
|
size: "medium",
|
|
578
578
|
class: "cd-input-select__select",
|
|
579
579
|
onSearch: M,
|
|
580
580
|
onChange: Z,
|
|
581
|
-
onPopupVisibleChange:
|
|
581
|
+
onPopupVisibleChange: se
|
|
582
582
|
}, {
|
|
583
|
-
suffix:
|
|
584
|
-
g(
|
|
585
|
-
name: "
|
|
586
|
-
onClick:
|
|
583
|
+
suffix: I(() => [
|
|
584
|
+
g(i, {
|
|
585
|
+
name: "add-circle",
|
|
586
|
+
onClick: oe
|
|
587
587
|
})
|
|
588
588
|
]),
|
|
589
|
-
valueDisplay:
|
|
590
|
-
(
|
|
591
|
-
key:
|
|
589
|
+
valueDisplay: I(() => [
|
|
590
|
+
(o(!0), u(F, null, q(p.value, (n) => (o(), O(V, {
|
|
591
|
+
key: n.id,
|
|
592
592
|
closable: "",
|
|
593
593
|
size: "medium",
|
|
594
|
-
variant:
|
|
595
|
-
theme:
|
|
596
|
-
onClose: () => K(
|
|
594
|
+
variant: n.isUser === !1 ? "outline" : "light",
|
|
595
|
+
theme: n.isUser === !1 ? "primary" : "default",
|
|
596
|
+
onClose: () => K(n.id),
|
|
597
597
|
class: "cd-input-select__tag"
|
|
598
598
|
}, {
|
|
599
|
-
default:
|
|
600
|
-
Y(m(
|
|
599
|
+
default: I(() => [
|
|
600
|
+
Y(m(n.name), 1)
|
|
601
601
|
]),
|
|
602
602
|
_: 2
|
|
603
603
|
}, 1032, ["variant", "theme", "onClose"]))), 128))
|
|
604
604
|
]),
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
]),
|
|
611
|
-
default: b(() => [
|
|
612
|
-
(n(!0), u(F, null, q(W.value, (o) => (n(), O($, {
|
|
613
|
-
key: o.id,
|
|
614
|
-
value: o.id,
|
|
615
|
-
label: o.name,
|
|
605
|
+
default: I(() => [
|
|
606
|
+
(o(!0), u(F, null, q(W.value, (n) => (o(), O($, {
|
|
607
|
+
key: n.id,
|
|
608
|
+
value: n.id,
|
|
609
|
+
label: n.name,
|
|
616
610
|
class: "cd-input-select__option"
|
|
617
611
|
}, {
|
|
618
|
-
default:
|
|
612
|
+
default: I(() => [
|
|
619
613
|
c("div", _t, [
|
|
620
|
-
|
|
614
|
+
n.avatar ? (o(), u("div", gt, [
|
|
621
615
|
c("img", {
|
|
622
|
-
src:
|
|
623
|
-
alt:
|
|
616
|
+
src: n.avatar,
|
|
617
|
+
alt: n.name
|
|
624
618
|
}, null, 8, yt)
|
|
625
|
-
])) : (
|
|
619
|
+
])) : (o(), u("div", {
|
|
626
620
|
key: 1,
|
|
627
621
|
class: "cd-input-select__option-avatar cd-input-select__option-avatar--placeholder",
|
|
628
622
|
style: ze({
|
|
629
|
-
backgroundColor:
|
|
630
|
-
color:
|
|
623
|
+
backgroundColor: n.isUser === !1 ? "#e6f4ff" : J(n.name),
|
|
624
|
+
color: n.isUser === !1 ? "#0052d9" : "#fff"
|
|
631
625
|
})
|
|
632
|
-
}, m(H(
|
|
626
|
+
}, m(H(n.name)), 5)),
|
|
633
627
|
c("div", kt, [
|
|
634
|
-
c("div", bt, m(
|
|
635
|
-
|
|
628
|
+
c("div", bt, m(n.name), 1),
|
|
629
|
+
n.department || n.position ? (o(), u("div", Vt, m(n.department) + m(n.department && n.position ? " · " : "") + m(n.position), 1)) : y("", !0)
|
|
636
630
|
]),
|
|
637
|
-
|
|
631
|
+
n.isUser === !1 ? (o(), u("i", Ct)) : y("", !0)
|
|
638
632
|
])
|
|
639
633
|
]),
|
|
640
634
|
_: 2
|
|
@@ -642,26 +636,26 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
642
636
|
]),
|
|
643
637
|
_: 1
|
|
644
638
|
}, 8, ["modelValue", "multiple", "placeholder", "loading", "popup-visible"]),
|
|
645
|
-
k.tabs && k.tabs.length > 0 && z.value ? (
|
|
639
|
+
k.tabs && k.tabs.length > 0 && z.value ? (o(), O(ke, {
|
|
646
640
|
key: 0,
|
|
647
641
|
visible: z.value,
|
|
648
|
-
"onUpdate:visible": r[2] || (r[2] = (
|
|
642
|
+
"onUpdate:visible": r[2] || (r[2] = (n) => z.value = n),
|
|
649
643
|
modelValue: B.value,
|
|
650
|
-
"onUpdate:modelValue": r[3] || (r[3] = (
|
|
644
|
+
"onUpdate:modelValue": r[3] || (r[3] = (n) => B.value = n),
|
|
651
645
|
tabs: k.tabs,
|
|
652
646
|
organizations: k.organizations || [],
|
|
653
647
|
"show-org": !1,
|
|
654
648
|
"show-search": !0,
|
|
655
649
|
multiple: k.multiple,
|
|
656
650
|
tips: "选择要添加的人员",
|
|
657
|
-
onConfirm:
|
|
651
|
+
onConfirm: de,
|
|
658
652
|
onLoadUsers: R,
|
|
659
|
-
onSearch:
|
|
653
|
+
onSearch: ee
|
|
660
654
|
}, null, 8, ["visible", "modelValue", "tabs", "organizations", "multiple"])) : y("", !0)
|
|
661
655
|
]);
|
|
662
656
|
};
|
|
663
657
|
}
|
|
664
|
-
}), St = /* @__PURE__ */ ye(Ut, [["__scopeId", "data-v-
|
|
658
|
+
}), St = /* @__PURE__ */ ye(Ut, [["__scopeId", "data-v-54561d77"]]), Nt = {
|
|
665
659
|
install(k) {
|
|
666
660
|
k.component("PersonSelector", ke), k.component("CdInputPersonSelector", St);
|
|
667
661
|
}
|
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-54561d77]{position:relative;width:100%}.cd-input-select__select[data-v-54561d77]{width:100%}.cd-input-select__add-icon[data-v-54561d77]{font-size:20px;color:var(--td-brand-color, #0052d9);cursor:pointer;transition:all .2s;flex-shrink:0}.cd-input-select__add-icon[data-v-54561d77]:hover{color:var(--td-brand-color-hover, #004BBD);transform:scale(1.1)}.cd-input-select__select[data-v-54561d77] .t-input{min-height:32px;height:auto;padding:0!important;display:flex;align-items:flex-start}.cd-input-select__select[data-v-54561d77] .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-54561d77] .t-input__prefix{margin-left:5px}.cd-input-select__select[data-v-54561d77] .t-input__suffix{display:flex;align-items:center;flex-shrink:0;padding-top:8px}.cd-input-select__select[data-v-54561d77] .t-input__inner{min-height:28px;line-height:28px}.cd-input-select__select[data-v-54561d77] .t-select__suffix{display:flex;align-items:center;flex-shrink:0}.cd-input-select__select[data-v-54561d77] .t-select__suffix-icon{display:flex;align-items:center;flex-shrink:0;margin-left:4px}.cd-input-select__select[data-v-54561d77] .t-select__dropdown{width:100%!important}.cd-input-select__select[data-v-54561d77] .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-54561d77] .t-tag-input__suffix{display:flex;flex-shrink:0;margin-left:8px;padding-top:6px}.cd-input-select[data-v-54561d77] .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-54561d77] .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-54561d77] .t-select__dropdown .t-select-option .t-checkbox__input{align-self:center!important;margin-right:8px!important}.t-select-option[data-v-54561d77]{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.6",
|
|
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"
|
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
<i v-if="result.isUser === false" class="ri-building-line cd-input-select__option-icon"></i>
|
|
39
39
|
</div>
|
|
40
40
|
</t-option>
|
|
41
|
-
<template #suffixIcon >
|
|
42
|
-
<i class="ri-add-circle-line cd-input-select__add-icon" @click="handleIconClick"></i>
|
|
43
|
-
</template>
|
|
44
41
|
</t-select>
|
|
45
42
|
<PersonSelector v-if="tabs && tabs.length > 0 && showPersonSelector" v-model:visible="showPersonSelector"
|
|
46
43
|
v-model="selectedIds" :tabs="tabs" :organizations="organizations || []" :show-org="false"
|
|
@@ -256,7 +253,6 @@ watch(() => props.modelValue, (newUsers) => {
|
|
|
256
253
|
display: flex;
|
|
257
254
|
align-items: center;
|
|
258
255
|
flex-shrink: 0;
|
|
259
|
-
margin:0 10px;
|
|
260
256
|
padding-top: 8px;
|
|
261
257
|
}
|
|
262
258
|
:deep(.t-input__inner) {
|