cd-personselector 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +282 -272
- package/dist/src/InputSelect.vue.d.ts +4 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/InputSelect.vue +4 -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-0480b186"]]),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(f,{expose:$,emit:u}){var le,ae;const c=f,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([]),h=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),h.value.clear(),c.modelValue.forEach(t=>{h.value.set(t.id,t)})):r.value=[...c.modelValue]}else r.value=[],h.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=>h.value.get(o)).filter(Boolean));function k(o,t){r.value.includes(o)||r.value.push(o),h.value.set(o,t)}function S(o){r.value=r.value.filter(t=>t!==o),h.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=[],h.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=[],h.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=[],h.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=(f,$)=>{const u=f.__vccOpts||f;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:{},showSelector:{type:Boolean,default:!0}},emits:["update:modelValue","search","load-users"],setup(f,{emit:$}){const u=f,c=$,g=e.ref(!1),y=e.ref([]),B=e.ref(void 0),C=e.ref(!1),b=e.ref([]),r=e.ref([]),h=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()?(h.value=!0,g.value=!0,c("search",{keyword:n,callback:i=>{y.value=i,g.value=!1}})):(y.value=[],g.value=!1,h.value=!1)},G=n=>{n&&y.value.length===0&&(h.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=[],h.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(),h.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:f.multiple,placeholder:f.placeholder,filterable:!0,filter:()=>!0,loading:g.value,"reserve-keyword":!1,"allow-input":!0,"popup-visible":h.value,"onUpdate:popupVisible":i[1]||(i[1]=s=>h.value=s),size:"medium",class:"cd-input-select__select",onSearch:D,onChange:M,onPopupVisibleChange:G},e.createSlots({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))]),_:2},[f.showSelector?{name:"suffix",fn:e.withCtx(()=>[e.createVNode(d,{name:"search",onClick:F})]),key:"0"}:void 0,f.showSelector?{name:"suffixIcon",fn:e.withCtx(()=>[e.createElementVNode("i",{class:"ri-add-circle-line cd-input-select__add-icon",onClick:F})]),key:"1"}:void 0]),1032,["modelValue","multiple","placeholder","loading","popup-visible"]),f.tabs&&f.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:f.tabs,organizations:f.organizations||[],"show-org":!1,"show-search":!0,multiple:f.multiple,tips:"选择要添加的人员",onConfirm:Q,onLoadUsers:U,onSearch:j},null,8,["visible","modelValue","tabs","organizations","multiple"])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-3180b8c7"]]),et={install(f){f.component("PersonSelector",q),f.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,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as ge, ref as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as ge, ref as _, computed as L, watch as X, resolveComponent as I, createBlock as O, openBlock as o, withCtx as b, createElementVNode as c, createElementBlock as u, createCommentVNode as k, createVNode as y, toDisplayString as m, Fragment as F, renderList as q, createTextVNode as Y, normalizeClass as se, withModifiers as _e, nextTick as Ne, createSlots as we, normalizeStyle as ze } from "vue";
|
|
2
|
+
const Te = { class: "cd-ps-container" }, Be = {
|
|
3
3
|
key: 0,
|
|
4
4
|
class: "cd-ps-tips"
|
|
5
5
|
}, Pe = {
|
|
@@ -8,34 +8,34 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
8
8
|
}, $e = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "cd-ps-org-select"
|
|
11
|
-
},
|
|
11
|
+
}, De = { class: "cd-ps-search-input" }, Oe = { class: "cd-ps-content" }, Re = { class: "cd-ps-left" }, Ae = {
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "cd-ps-search-results"
|
|
14
|
-
},
|
|
14
|
+
}, Le = { class: "cd-ps-search-header" }, Me = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "cd-ps-loading"
|
|
17
|
-
},
|
|
17
|
+
}, Ee = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "cd-ps-empty"
|
|
20
|
-
},
|
|
20
|
+
}, We = {
|
|
21
21
|
key: 2,
|
|
22
22
|
class: "cd-ps-result-list"
|
|
23
|
-
},
|
|
23
|
+
}, Je = ["onClick"], je = { class: "cd-ps-avatar" }, Fe = { class: "cd-ps-info" }, qe = { class: "cd-ps-name" }, Ge = { class: "cd-ps-meta" }, He = { key: 0 }, Qe = { key: 1 }, Xe = { key: 2 }, Ye = { class: "cd-ps-tree" }, Ze = { class: "cd-ps-node-name" }, Ke = {
|
|
24
24
|
key: 0,
|
|
25
25
|
class: "cd-ps-position"
|
|
26
|
-
},
|
|
26
|
+
}, et = {
|
|
27
27
|
key: 0,
|
|
28
28
|
class: "cd-ps-count"
|
|
29
|
-
},
|
|
29
|
+
}, tt = {
|
|
30
30
|
key: 1,
|
|
31
31
|
class: "cd-ps-empty"
|
|
32
|
-
},
|
|
32
|
+
}, lt = { class: "cd-ps-right" }, at = { class: "cd-ps-right-header" }, st = { class: "cd-ps-num" }, ot = { class: "cd-ps-right-list" }, nt = {
|
|
33
33
|
key: 0,
|
|
34
34
|
class: "cd-ps-empty"
|
|
35
|
-
},
|
|
35
|
+
}, it = {
|
|
36
36
|
key: 1,
|
|
37
37
|
class: "cd-ps-selected-list"
|
|
38
|
-
},
|
|
38
|
+
}, dt = { class: "cd-ps-item-info" }, ct = { class: "cd-ps-info" }, ut = { class: "cd-ps-name" }, rt = { class: "cd-ps-meta" }, pt = { key: 0 }, vt = { key: 1 }, ft = { key: 2 }, mt = { key: 3 }, ht = /* @__PURE__ */ ge({
|
|
39
39
|
__name: "PersonSelector",
|
|
40
40
|
props: {
|
|
41
41
|
visible: { type: Boolean, default: !1 },
|
|
@@ -49,64 +49,64 @@ 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(
|
|
52
|
+
setup(h, { expose: G, emit: V }) {
|
|
53
53
|
var fe, me;
|
|
54
|
-
const i =
|
|
54
|
+
const i = h, x = V, N = _(i.visible), z = _(((me = (fe = i.tabs) == null ? void 0 : fe[0]) == null ? void 0 : me.key) || ""), w = _(null), $ = _(""), p = _([]), g = _(/* @__PURE__ */ new Map()), W = _({}), H = _(!1), J = _(!1), M = _([]), oe = L(() => i.tabs || []), Z = L(() => i.organizations || []), K = L(() => i.tips || ""), ee = L(() => i.showSearch), ne = L(() => i.showOrg), ie = L(() => i.dialogWidth), R = _({});
|
|
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, (!
|
|
58
|
+
t.forEach((a) => {
|
|
59
|
+
e[a.key] = JSON.parse(JSON.stringify(a.tree));
|
|
60
|
+
}), R.value = e, (!z.value || !t.find((a) => a.key === z.value)) && (z.value = t[0].key);
|
|
61
61
|
}
|
|
62
62
|
}, { immediate: !0, deep: !0 });
|
|
63
63
|
function te() {
|
|
64
64
|
if (i.modelValue && i.modelValue.length > 0) {
|
|
65
65
|
const t = i.modelValue[0];
|
|
66
|
-
typeof t == "object" && t !== null && "id" in t ? (p.value = i.modelValue.map((e) => e.id),
|
|
67
|
-
|
|
66
|
+
typeof t == "object" && t !== null && "id" in t ? (p.value = i.modelValue.map((e) => e.id), g.value.clear(), i.modelValue.forEach((e) => {
|
|
67
|
+
g.value.set(e.id, e);
|
|
68
68
|
})) : p.value = [...i.modelValue];
|
|
69
69
|
} else
|
|
70
|
-
p.value = [],
|
|
70
|
+
p.value = [], g.value.clear();
|
|
71
71
|
}
|
|
72
72
|
X(() => i.modelValue, (t) => {
|
|
73
73
|
N.value && t && te();
|
|
74
74
|
}, { deep: !0 }), X(() => i.visible, (t) => {
|
|
75
|
-
N.value = t, t && (te(), i.organizations.length > 0 && !
|
|
75
|
+
N.value = t, t && (te(), i.organizations.length > 0 && !w.value && (w.value = i.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 d = L(() => p.value.map((t) =>
|
|
92
|
+
const d = L(() => p.value.map((t) => g.value.get(t)).filter(Boolean));
|
|
93
93
|
function C(t, e) {
|
|
94
|
-
p.value.includes(t) || p.value.push(t),
|
|
94
|
+
p.value.includes(t) || p.value.push(t), g.value.set(t, e);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
p.value = p.value.filter((e) => e !== t),
|
|
96
|
+
function P(t) {
|
|
97
|
+
p.value = p.value.filter((e) => e !== t), g.value.delete(t);
|
|
98
98
|
}
|
|
99
99
|
const f = () => {
|
|
100
|
-
|
|
101
|
-
},
|
|
100
|
+
$.value = "";
|
|
101
|
+
}, n = (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;
|
|
108
108
|
const de = () => {
|
|
109
|
-
if (E && clearTimeout(E),
|
|
109
|
+
if (E && clearTimeout(E), !$.value.trim()) {
|
|
110
110
|
ce();
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
@@ -114,77 +114,77 @@ 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
|
-
x("search", { keyword:
|
|
119
|
+
x("search", { keyword: $.value, orgId: w.value || void 0, callback: t });
|
|
120
120
|
}, ce = () => {
|
|
121
|
-
E && (clearTimeout(E), E = null), H.value = !1,
|
|
121
|
+
E && (clearTimeout(E), E = null), H.value = !1, $.value = "", M.value = [], J.value = !1;
|
|
122
122
|
}, Ve = (t) => {
|
|
123
|
-
p.value.indexOf(t.id) > -1 ?
|
|
123
|
+
p.value.indexOf(t.id) > -1 ? P(t.id) : (i.multiple || (p.value = [], g.value.clear()), C(t.id, { ...t, isUser: !0, typeName: "搜索结果", orgId: w.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
|
-
const
|
|
133
|
-
var
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
if (
|
|
139
|
-
i.multiple || (p.value = [],
|
|
140
|
-
const j = i.tabs.find((re) => re.key ===
|
|
141
|
-
C(
|
|
132
|
+
const Se = (t, e) => {
|
|
133
|
+
var S, T;
|
|
134
|
+
const a = e == null ? void 0 : e.node;
|
|
135
|
+
if (a) {
|
|
136
|
+
const B = a.value ?? ((S = a.data) == null ? void 0 : S.id);
|
|
137
|
+
if (B !== void 0) {
|
|
138
|
+
if (a.checked) {
|
|
139
|
+
i.multiple || (p.value = [], g.value.clear());
|
|
140
|
+
const j = i.tabs.find((re) => re.key === z.value), Q = j ? j.name.replace(/^按/, "") : "";
|
|
141
|
+
C(B, { ...a.data, typeName: Q, orgId: w.value }), !i.multiple && ((T = a.data) != null && T.isUser) && ue();
|
|
142
142
|
} else
|
|
143
|
-
|
|
143
|
+
P(B);
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
const v = R.value[
|
|
147
|
+
const v = R.value[z.value] || [], D = Ce(v), A = p.value.filter((B) => !D.includes(B));
|
|
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
|
-
async function
|
|
160
|
-
const
|
|
161
|
-
x("load-users", { tabKey: e, nodeId:
|
|
159
|
+
async function Ue(t, e) {
|
|
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: le, name: j, ...Q } =
|
|
165
|
-
return { ...Q, id: le, name:
|
|
163
|
+
const S = A.map((B) => {
|
|
164
|
+
const { id: le, name: j, ...Q } = B;
|
|
165
|
+
return { ...Q, id: le, name: B.displayName || j, isUser: !0 };
|
|
166
166
|
}), T = R.value[e];
|
|
167
|
-
if (T && pe(T,
|
|
168
|
-
v.appendTo(
|
|
167
|
+
if (T && pe(T, a, S), v) {
|
|
168
|
+
v.appendTo(a, S), 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 S = R.value[e];
|
|
177
|
+
if (S) {
|
|
178
|
+
const T = r(S, a);
|
|
179
179
|
T && (T.loaded = !0);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
} });
|
|
183
183
|
}
|
|
184
184
|
const Ie = (t) => {
|
|
185
|
-
|
|
185
|
+
P(t);
|
|
186
186
|
}, ve = () => {
|
|
187
|
-
p.value = [],
|
|
187
|
+
p.value = [], g.value.clear();
|
|
188
188
|
}, ue = () => {
|
|
189
189
|
x("update:modelValue", p.value), x("confirm", d.value), N.value = !1;
|
|
190
190
|
}, xe = () => {
|
|
@@ -192,19 +192,19 @@ 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 =
|
|
199
|
-
const { id:
|
|
200
|
-
return { ...
|
|
197
|
+
if (v && a.length > 0) {
|
|
198
|
+
const D = a.map((A) => {
|
|
199
|
+
const { id: S, name: T, ...B } = A;
|
|
200
|
+
return { ...B, id: S, 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 = I("t-icon"), v = I("t-option"), D = I("t-select"), A = I("t-input"), S = I("t-button"), T = I("t-loading"), B = I("t-checkbox"), le = I("t-tree"), j = I("t-tab-panel"), Q = I("t-tabs"), re = I("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: "选择人员",
|
|
@@ -216,22 +216,22 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
216
216
|
onClose: xe
|
|
217
217
|
}, {
|
|
218
218
|
default: b(() => [
|
|
219
|
-
c("div",
|
|
220
|
-
K.value ? (
|
|
221
|
-
|
|
219
|
+
c("div", Te, [
|
|
220
|
+
K.value ? (o(), u("div", Be, [
|
|
221
|
+
y(a, { name: "info-circle" }),
|
|
222
222
|
c("span", null, m(K.value), 1)
|
|
223
|
-
])) :
|
|
224
|
-
ee.value ? (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
modelValue:
|
|
228
|
-
"onUpdate:modelValue": e[0] || (e[0] = (l) =>
|
|
223
|
+
])) : k("", !0),
|
|
224
|
+
ee.value ? (o(), u("div", Pe, [
|
|
225
|
+
ne.value && Z.value.length > 0 ? (o(), u("div", $e, [
|
|
226
|
+
y(D, {
|
|
227
|
+
modelValue: w.value,
|
|
228
|
+
"onUpdate:modelValue": e[0] || (e[0] = (l) => w.value = l),
|
|
229
229
|
placeholder: "选择组织",
|
|
230
230
|
style: { width: "200px" },
|
|
231
|
-
onChange:
|
|
231
|
+
onChange: n
|
|
232
232
|
}, {
|
|
233
233
|
default: b(() => [
|
|
234
|
-
(
|
|
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
|
|
@@ -239,29 +239,29 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
239
239
|
]),
|
|
240
240
|
_: 1
|
|
241
241
|
}, 8, ["modelValue"])
|
|
242
|
-
])) :
|
|
243
|
-
c("div",
|
|
244
|
-
|
|
245
|
-
modelValue:
|
|
246
|
-
"onUpdate:modelValue": e[1] || (e[1] = (l) =>
|
|
242
|
+
])) : k("", !0),
|
|
243
|
+
c("div", De, [
|
|
244
|
+
y(A, {
|
|
245
|
+
modelValue: $.value,
|
|
246
|
+
"onUpdate:modelValue": e[1] || (e[1] = (l) => $.value = l),
|
|
247
247
|
placeholder: "输入手机号/工号/姓名/部门/职位搜索",
|
|
248
248
|
clearable: "",
|
|
249
249
|
onInput: de,
|
|
250
250
|
onClear: ce
|
|
251
251
|
}, {
|
|
252
252
|
"prefix-icon": b(() => [
|
|
253
|
-
|
|
253
|
+
y(a, { name: "search" })
|
|
254
254
|
]),
|
|
255
255
|
_: 1
|
|
256
256
|
}, 8, ["modelValue"])
|
|
257
257
|
])
|
|
258
|
-
])) :
|
|
259
|
-
c("div",
|
|
260
|
-
c("div",
|
|
261
|
-
H.value ? (
|
|
262
|
-
c("div",
|
|
258
|
+
])) : k("", !0),
|
|
259
|
+
c("div", Oe, [
|
|
260
|
+
c("div", Re, [
|
|
261
|
+
H.value ? (o(), u("div", Ae, [
|
|
262
|
+
c("div", Le, [
|
|
263
263
|
e[6] || (e[6] = c("span", null, "搜索结果", -1)),
|
|
264
|
-
|
|
264
|
+
y(S, {
|
|
265
265
|
size: "small",
|
|
266
266
|
variant: "text",
|
|
267
267
|
onClick: ce
|
|
@@ -272,100 +272,100 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
272
272
|
_: 1
|
|
273
273
|
})
|
|
274
274
|
]),
|
|
275
|
-
J.value ? (
|
|
276
|
-
|
|
275
|
+
J.value ? (o(), u("div", Me, [
|
|
276
|
+
y(T),
|
|
277
277
|
e[7] || (e[7] = c("span", null, "搜索中...", -1))
|
|
278
|
-
])) : M.value.length === 0 ? (
|
|
279
|
-
|
|
278
|
+
])) : M.value.length === 0 ? (o(), u("div", Ee, [
|
|
279
|
+
y(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", We, [
|
|
286
|
+
(o(!0), u(F, null, q(M.value, (l) => (o(), 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
|
+
y(B, {
|
|
292
292
|
checked: p.value.includes(l.id),
|
|
293
293
|
onClick: e[2] || (e[2] = _e(() => {
|
|
294
294
|
}, ["stop"]))
|
|
295
295
|
}, null, 8, ["checked"]),
|
|
296
|
-
c("div", Je, [
|
|
297
|
-
g(s, { name: "user" })
|
|
298
|
-
]),
|
|
299
296
|
c("div", je, [
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
297
|
+
y(a, { name: "user" })
|
|
298
|
+
]),
|
|
299
|
+
c("div", Fe, [
|
|
300
|
+
c("div", qe, m(l.displayName || l.name), 1),
|
|
301
|
+
c("div", Ge, [
|
|
302
|
+
l.position ? (o(), u("span", He, m(l.position), 1)) : k("", !0),
|
|
303
|
+
l.department ? (o(), u("span", Qe, m(l.department), 1)) : k("", !0),
|
|
304
|
+
l.phone ? (o(), u("span", Xe, m(l.phone), 1)) : k("", !0)
|
|
305
305
|
])
|
|
306
306
|
])
|
|
307
|
-
], 10,
|
|
307
|
+
], 10, Je))), 128))
|
|
308
308
|
]))
|
|
309
|
-
])) : (
|
|
309
|
+
])) : (o(), O(Q, {
|
|
310
310
|
key: 1,
|
|
311
|
-
modelValue:
|
|
312
|
-
"onUpdate:modelValue": e[3] || (e[3] = (l) =>
|
|
311
|
+
modelValue: z.value,
|
|
312
|
+
"onUpdate:modelValue": e[3] || (e[3] = (l) => z.value = l),
|
|
313
313
|
onChange: f
|
|
314
314
|
}, {
|
|
315
315
|
default: b(() => [
|
|
316
|
-
(
|
|
316
|
+
(o(!0), u(F, null, q(oe.value, (l) => (o(), O(j, {
|
|
317
317
|
key: l.key,
|
|
318
318
|
value: l.key,
|
|
319
319
|
label: l.name
|
|
320
320
|
}, {
|
|
321
321
|
default: b(() => {
|
|
322
|
-
var
|
|
322
|
+
var ae;
|
|
323
323
|
return [
|
|
324
|
-
c("div",
|
|
325
|
-
((
|
|
324
|
+
c("div", Ye, [
|
|
325
|
+
((ae = R.value[l.key]) == null ? void 0 : ae.length) > 0 ? (o(), O(le, {
|
|
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: "",
|
|
332
332
|
checkable: "",
|
|
333
333
|
"expand-all": !1,
|
|
334
334
|
value: p.value,
|
|
335
|
-
onChange:
|
|
335
|
+
onChange: Se
|
|
336
336
|
}, {
|
|
337
|
-
label: b(({ node:
|
|
337
|
+
label: b(({ node: U }) => {
|
|
338
338
|
var he;
|
|
339
339
|
return [
|
|
340
340
|
c("div", {
|
|
341
|
-
class:
|
|
341
|
+
class: se(["cd-ps-node", { "cd-ps-node-user": U.data.isUser }])
|
|
342
342
|
}, [
|
|
343
|
-
|
|
344
|
-
name:
|
|
343
|
+
y(a, {
|
|
344
|
+
name: U.data.isUser ? "user" : l.icon || "folder"
|
|
345
345
|
}, null, 8, ["name"]),
|
|
346
|
-
c("span",
|
|
347
|
-
Y(m(
|
|
348
|
-
|
|
346
|
+
c("span", Ze, [
|
|
347
|
+
Y(m(U.label) + " ", 1),
|
|
348
|
+
U.data.isUser && U.data.position ? (o(), u("span", Ke, m(U.data.position), 1)) : k("", !0)
|
|
349
349
|
]),
|
|
350
|
-
|
|
351
|
-
!
|
|
350
|
+
U.data.userCount && !U.data.isUser ? (o(), u("span", et, "(" + m(U.data.userCount) + ")", 1)) : k("", !0),
|
|
351
|
+
!U.data.isUser && !((he = U.data.children) != null && he.length) && !U.data.loaded ? (o(), O(S, {
|
|
352
352
|
key: 1,
|
|
353
353
|
size: "small",
|
|
354
354
|
variant: "text",
|
|
355
355
|
class: "cd-ps-load-btn",
|
|
356
|
-
onClick: _e((
|
|
356
|
+
onClick: _e((xt) => Ue(U, l.key), ["stop"])
|
|
357
357
|
}, {
|
|
358
358
|
default: b(() => [...e[9] || (e[9] = [
|
|
359
359
|
Y("显示人员", -1)
|
|
360
360
|
])]),
|
|
361
361
|
_: 1
|
|
362
|
-
}, 8, ["onClick"])) :
|
|
362
|
+
}, 8, ["onClick"])) : k("", !0)
|
|
363
363
|
], 2)
|
|
364
364
|
];
|
|
365
365
|
}),
|
|
366
366
|
_: 2
|
|
367
|
-
}, 1032, ["data", "value"])) : (
|
|
368
|
-
|
|
367
|
+
}, 1032, ["data", "value"])) : (o(), u("div", tt, [
|
|
368
|
+
y(a, {
|
|
369
369
|
name: l.icon || "folder-open",
|
|
370
370
|
size: "48px",
|
|
371
371
|
style: { color: "#ddd" }
|
|
@@ -381,11 +381,11 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
381
381
|
_: 1
|
|
382
382
|
}, 8, ["modelValue"]))
|
|
383
383
|
]),
|
|
384
|
-
c("div",
|
|
385
|
-
c("div",
|
|
384
|
+
c("div", lt, [
|
|
385
|
+
c("div", at, [
|
|
386
386
|
e[12] || (e[12] = c("span", { class: "cd-ps-title" }, "已选择", -1)),
|
|
387
387
|
c("span", st, m(d.value.length) + " 项", 1),
|
|
388
|
-
d.value.length > 0 ? (
|
|
388
|
+
d.value.length > 0 ? (o(), O(S, {
|
|
389
389
|
key: 0,
|
|
390
390
|
size: "small",
|
|
391
391
|
variant: "text",
|
|
@@ -395,47 +395,47 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
395
395
|
Y("清空", -1)
|
|
396
396
|
])]),
|
|
397
397
|
_: 1
|
|
398
|
-
})) :
|
|
398
|
+
})) : k("", !0)
|
|
399
399
|
]),
|
|
400
|
-
c("div",
|
|
401
|
-
d.value.length === 0 ? (
|
|
402
|
-
|
|
400
|
+
c("div", ot, [
|
|
401
|
+
d.value.length === 0 ? (o(), u("div", nt, [
|
|
402
|
+
y(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", it, [
|
|
409
|
+
(o(!0), u(F, null, q(d.value, (l) => (o(), 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
|
-
c("div",
|
|
413
|
+
c("div", dt, [
|
|
414
414
|
c("div", {
|
|
415
|
-
class:
|
|
415
|
+
class: se(["cd-ps-avatar", { "cd-ps-avatar-dept": !l.isUser }])
|
|
416
416
|
}, [
|
|
417
|
-
|
|
417
|
+
y(a, {
|
|
418
418
|
name: l.isUser ? "user" : "folder"
|
|
419
419
|
}, null, 8, ["name"])
|
|
420
420
|
], 2),
|
|
421
|
-
c("div",
|
|
422
|
-
c("div",
|
|
423
|
-
c("div",
|
|
424
|
-
l.isUser && l.position ? (
|
|
425
|
-
l.isUser && l.department ? (
|
|
426
|
-
l.isUser ?
|
|
427
|
-
!l.isUser && l.userCount ? (
|
|
421
|
+
c("div", ct, [
|
|
422
|
+
c("div", ut, m(l.displayName || l.name), 1),
|
|
423
|
+
c("div", rt, [
|
|
424
|
+
l.isUser && l.position ? (o(), u("span", pt, m(l.position), 1)) : k("", !0),
|
|
425
|
+
l.isUser && l.department ? (o(), u("span", vt, m(l.department), 1)) : k("", !0),
|
|
426
|
+
l.isUser ? k("", !0) : (o(), u("span", ft, m(l.typeName || "部门"), 1)),
|
|
427
|
+
!l.isUser && l.userCount ? (o(), u("span", mt, m(l.userCount) + "人", 1)) : k("", !0)
|
|
428
428
|
])
|
|
429
429
|
])
|
|
430
430
|
]),
|
|
431
|
-
|
|
431
|
+
y(S, {
|
|
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
|
-
|
|
438
|
+
y(a, { name: "close" })
|
|
439
439
|
]),
|
|
440
440
|
_: 1
|
|
441
441
|
}, 8, ["onClick"])
|
|
@@ -450,18 +450,18 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
450
450
|
}, 8, ["visible", "width"]);
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
|
-
}), ye = (
|
|
454
|
-
const V =
|
|
453
|
+
}), ye = (h, G) => {
|
|
454
|
+
const V = h.__vccOpts || h;
|
|
455
455
|
for (const [i, x] of G)
|
|
456
456
|
V[i] = x;
|
|
457
457
|
return V;
|
|
458
|
-
}, ke = /* @__PURE__ */ ye(
|
|
458
|
+
}, ke = /* @__PURE__ */ ye(ht, [["__scopeId", "data-v-1e0585c3"]]), _t = { class: "cd-input-select" }, gt = { class: "cd-input-select__option-content" }, yt = {
|
|
459
459
|
key: 0,
|
|
460
460
|
class: "cd-input-select__option-avatar"
|
|
461
|
-
},
|
|
461
|
+
}, kt = ["src", "alt"], bt = { class: "cd-input-select__option-info" }, Vt = { class: "cd-input-select__option-name" }, Ct = {
|
|
462
462
|
key: 0,
|
|
463
463
|
class: "cd-input-select__option-desc"
|
|
464
|
-
},
|
|
464
|
+
}, St = {
|
|
465
465
|
key: 2,
|
|
466
466
|
class: "ri-building-line cd-input-select__option-icon"
|
|
467
467
|
}, Ut = /* @__PURE__ */ ge({
|
|
@@ -472,17 +472,18 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
472
472
|
multiple: { type: Boolean, default: !0 },
|
|
473
473
|
placeholder: { default: "搜索用户、部门、职位" },
|
|
474
474
|
tabs: {},
|
|
475
|
-
organizations: {}
|
|
475
|
+
organizations: {},
|
|
476
|
+
showSelector: { type: Boolean, default: !0 }
|
|
476
477
|
},
|
|
477
478
|
emits: ["update:modelValue", "search", "load-users"],
|
|
478
|
-
setup(
|
|
479
|
-
const V =
|
|
480
|
-
const
|
|
479
|
+
setup(h, { emit: G }) {
|
|
480
|
+
const V = h, i = G, x = _(!1), N = _([]), z = _(void 0), w = _(!1), $ = _([]), p = _([]), g = _(!1), W = L(() => {
|
|
481
|
+
const s = new Set(p.value.map((d) => d.id));
|
|
481
482
|
return [
|
|
482
483
|
...p.value,
|
|
483
|
-
...N.value.filter((d) => !
|
|
484
|
+
...N.value.filter((d) => !s.has(d.id))
|
|
484
485
|
];
|
|
485
|
-
}), H = (
|
|
486
|
+
}), H = (s) => s ? s.substring(0, 2).toUpperCase() : "", J = (s) => {
|
|
486
487
|
const r = [
|
|
487
488
|
"#1890ff",
|
|
488
489
|
"#52c41a",
|
|
@@ -494,42 +495,42 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
494
495
|
"#fa8c16"
|
|
495
496
|
];
|
|
496
497
|
let d = 0;
|
|
497
|
-
for (let C = 0; C <
|
|
498
|
-
d =
|
|
498
|
+
for (let C = 0; C < s.length; C++)
|
|
499
|
+
d = s.charCodeAt(C) + ((d << 5) - d);
|
|
499
500
|
return r[Math.abs(d) % r.length];
|
|
500
|
-
}, M = (
|
|
501
|
-
|
|
502
|
-
keyword:
|
|
501
|
+
}, M = (s) => {
|
|
502
|
+
s && s.trim() ? (g.value = !0, x.value = !0, i("search", {
|
|
503
|
+
keyword: s,
|
|
503
504
|
callback: (r) => {
|
|
504
505
|
N.value = r, x.value = !1;
|
|
505
506
|
}
|
|
506
|
-
})) : (N.value = [], x.value = !1,
|
|
507
|
-
},
|
|
508
|
-
|
|
509
|
-
}, Z = (
|
|
510
|
-
const r = Array.isArray(
|
|
507
|
+
})) : (N.value = [], x.value = !1, g.value = !1);
|
|
508
|
+
}, oe = (s) => {
|
|
509
|
+
s && N.value.length === 0 && (g.value = !1);
|
|
510
|
+
}, Z = (s) => {
|
|
511
|
+
const r = Array.isArray(s) ? s : s ? [s] : [], d = V.modelValue.map((f) => f.id), C = r.filter((f) => !d.includes(f)), P = d.filter((f) => !r.includes(f));
|
|
511
512
|
if (C.length > 0) {
|
|
512
|
-
const f = C.map((
|
|
513
|
+
const f = C.map((n) => W.value.find((de) => de.id === n)).filter(Boolean);
|
|
513
514
|
if (!V.multiple)
|
|
514
|
-
i("update:modelValue", f), p.value = f, N.value = [],
|
|
515
|
+
i("update:modelValue", f), p.value = f, N.value = [], g.value = !1;
|
|
515
516
|
else {
|
|
516
|
-
const
|
|
517
|
-
i("update:modelValue",
|
|
517
|
+
const n = [...V.modelValue, ...f];
|
|
518
|
+
i("update:modelValue", n), p.value = n;
|
|
518
519
|
}
|
|
519
520
|
}
|
|
520
|
-
if (
|
|
521
|
-
const f = V.modelValue.filter((
|
|
521
|
+
if (P.length > 0) {
|
|
522
|
+
const f = V.modelValue.filter((n) => !P.includes(n.id));
|
|
522
523
|
i("update:modelValue", f), p.value = f;
|
|
523
524
|
}
|
|
524
|
-
}, K = (
|
|
525
|
-
const r = V.modelValue.filter((d) => d.id !==
|
|
525
|
+
}, K = (s) => {
|
|
526
|
+
const r = V.modelValue.filter((d) => d.id !== s);
|
|
526
527
|
i("update:modelValue", r), p.value = r;
|
|
527
|
-
}, ee = (
|
|
528
|
-
|
|
529
|
-
},
|
|
530
|
-
|
|
531
|
-
}, ie = (
|
|
532
|
-
const r =
|
|
528
|
+
}, ee = (s) => {
|
|
529
|
+
s && typeof s.stopPropagation == "function" && s.stopPropagation(), s && typeof s.preventDefault == "function" && s.preventDefault(), g.value = !1, ne();
|
|
530
|
+
}, ne = () => {
|
|
531
|
+
w.value = !0;
|
|
532
|
+
}, ie = (s) => {
|
|
533
|
+
const r = s.map((d) => {
|
|
533
534
|
const C = d.displayName || d.name || d.title || String(d.id);
|
|
534
535
|
return {
|
|
535
536
|
id: d.id,
|
|
@@ -544,130 +545,139 @@ const we = { class: "cd-ps-container" }, Te = {
|
|
|
544
545
|
if (!V.multiple)
|
|
545
546
|
i("update:modelValue", r.slice(0, 1)), p.value = r.slice(0, 1);
|
|
546
547
|
else {
|
|
547
|
-
const d = new Set(V.modelValue.map((f) => f.id)), C = r.filter((f) => !d.has(f.id)),
|
|
548
|
-
i("update:modelValue",
|
|
548
|
+
const d = new Set(V.modelValue.map((f) => f.id)), C = r.filter((f) => !d.has(f.id)), P = [...V.modelValue, ...C];
|
|
549
|
+
i("update:modelValue", P), p.value = P;
|
|
549
550
|
}
|
|
550
|
-
|
|
551
|
-
}, R = (
|
|
552
|
-
i("load-users",
|
|
553
|
-
}, te = (
|
|
551
|
+
w.value = !1;
|
|
552
|
+
}, R = (s) => {
|
|
553
|
+
i("load-users", s);
|
|
554
|
+
}, te = (s) => {
|
|
554
555
|
i("search", {
|
|
555
|
-
keyword:
|
|
556
|
-
callback:
|
|
556
|
+
keyword: s.keyword,
|
|
557
|
+
callback: s.callback
|
|
557
558
|
});
|
|
558
559
|
};
|
|
559
|
-
return X(() => V.modelValue, (
|
|
560
|
-
V.multiple ?
|
|
561
|
-
}, { immediate: !0, deep: !0 }), (
|
|
562
|
-
const d = I("t-icon"), C = I("t-tag"),
|
|
563
|
-
return
|
|
564
|
-
|
|
560
|
+
return X(() => V.modelValue, (s) => {
|
|
561
|
+
V.multiple ? z.value = s.map((r) => r.id) : z.value = s.length > 0 ? s[0].id : void 0, $.value = s.map((r) => r.id), p.value = s;
|
|
562
|
+
}, { immediate: !0, deep: !0 }), (s, r) => {
|
|
563
|
+
const d = I("t-icon"), C = I("t-tag"), P = I("t-option"), f = I("t-select");
|
|
564
|
+
return o(), u("div", _t, [
|
|
565
|
+
y(f, {
|
|
565
566
|
ref: "selectRef",
|
|
566
|
-
modelValue:
|
|
567
|
-
"onUpdate:modelValue": r[0] || (r[0] = (
|
|
568
|
-
multiple:
|
|
569
|
-
placeholder:
|
|
567
|
+
modelValue: z.value,
|
|
568
|
+
"onUpdate:modelValue": r[0] || (r[0] = (n) => z.value = n),
|
|
569
|
+
multiple: h.multiple,
|
|
570
|
+
placeholder: h.placeholder,
|
|
570
571
|
filterable: !0,
|
|
571
572
|
filter: () => !0,
|
|
572
573
|
loading: x.value,
|
|
573
574
|
"reserve-keyword": !1,
|
|
574
575
|
"allow-input": !0,
|
|
575
|
-
"popup-visible":
|
|
576
|
-
"onUpdate:popupVisible": r[1] || (r[1] = (
|
|
576
|
+
"popup-visible": g.value,
|
|
577
|
+
"onUpdate:popupVisible": r[1] || (r[1] = (n) => g.value = n),
|
|
577
578
|
size: "medium",
|
|
578
579
|
class: "cd-input-select__select",
|
|
579
580
|
onSearch: M,
|
|
580
581
|
onChange: Z,
|
|
581
|
-
onPopupVisibleChange:
|
|
582
|
-
}, {
|
|
583
|
-
suffix: b(() => [
|
|
584
|
-
g(d, {
|
|
585
|
-
name: "search",
|
|
586
|
-
onClick: ee
|
|
587
|
-
})
|
|
588
|
-
]),
|
|
582
|
+
onPopupVisibleChange: oe
|
|
583
|
+
}, we({
|
|
589
584
|
valueDisplay: b(() => [
|
|
590
|
-
(
|
|
591
|
-
key:
|
|
585
|
+
(o(!0), u(F, null, q(p.value, (n) => (o(), O(C, {
|
|
586
|
+
key: n.id,
|
|
592
587
|
closable: "",
|
|
593
588
|
size: "medium",
|
|
594
|
-
variant:
|
|
595
|
-
theme:
|
|
596
|
-
onClose: () => K(
|
|
589
|
+
variant: n.isUser === !1 ? "outline" : "light",
|
|
590
|
+
theme: n.isUser === !1 ? "primary" : "default",
|
|
591
|
+
onClose: () => K(n.id),
|
|
597
592
|
class: "cd-input-select__tag"
|
|
598
593
|
}, {
|
|
599
594
|
default: b(() => [
|
|
600
|
-
Y(m(
|
|
595
|
+
Y(m(n.name), 1)
|
|
601
596
|
]),
|
|
602
597
|
_: 2
|
|
603
598
|
}, 1032, ["variant", "theme", "onClose"]))), 128))
|
|
604
599
|
]),
|
|
605
|
-
suffixIcon: b(() => [
|
|
606
|
-
c("i", {
|
|
607
|
-
class: "ri-add-circle-line cd-input-select__add-icon",
|
|
608
|
-
onClick: ee
|
|
609
|
-
})
|
|
610
|
-
]),
|
|
611
600
|
default: b(() => [
|
|
612
|
-
(
|
|
613
|
-
key:
|
|
614
|
-
value:
|
|
615
|
-
label:
|
|
601
|
+
(o(!0), u(F, null, q(W.value, (n) => (o(), O(P, {
|
|
602
|
+
key: n.id,
|
|
603
|
+
value: n.id,
|
|
604
|
+
label: n.name,
|
|
616
605
|
class: "cd-input-select__option"
|
|
617
606
|
}, {
|
|
618
607
|
default: b(() => [
|
|
619
|
-
c("div",
|
|
620
|
-
|
|
608
|
+
c("div", gt, [
|
|
609
|
+
n.avatar ? (o(), u("div", yt, [
|
|
621
610
|
c("img", {
|
|
622
|
-
src:
|
|
623
|
-
alt:
|
|
624
|
-
}, null, 8,
|
|
625
|
-
])) : (
|
|
611
|
+
src: n.avatar,
|
|
612
|
+
alt: n.name
|
|
613
|
+
}, null, 8, kt)
|
|
614
|
+
])) : (o(), u("div", {
|
|
626
615
|
key: 1,
|
|
627
616
|
class: "cd-input-select__option-avatar cd-input-select__option-avatar--placeholder",
|
|
628
617
|
style: ze({
|
|
629
|
-
backgroundColor:
|
|
630
|
-
color:
|
|
618
|
+
backgroundColor: n.isUser === !1 ? "#e6f4ff" : J(n.name),
|
|
619
|
+
color: n.isUser === !1 ? "#0052d9" : "#fff"
|
|
631
620
|
})
|
|
632
|
-
}, m(H(
|
|
633
|
-
c("div",
|
|
634
|
-
c("div",
|
|
635
|
-
|
|
621
|
+
}, m(H(n.name)), 5)),
|
|
622
|
+
c("div", bt, [
|
|
623
|
+
c("div", Vt, m(n.name), 1),
|
|
624
|
+
n.department || n.position ? (o(), u("div", Ct, m(n.department) + m(n.department && n.position ? " · " : "") + m(n.position), 1)) : k("", !0)
|
|
636
625
|
]),
|
|
637
|
-
|
|
626
|
+
n.isUser === !1 ? (o(), u("i", St)) : k("", !0)
|
|
638
627
|
])
|
|
639
628
|
]),
|
|
640
629
|
_: 2
|
|
641
630
|
}, 1032, ["value", "label"]))), 128))
|
|
642
631
|
]),
|
|
643
|
-
_:
|
|
644
|
-
},
|
|
645
|
-
|
|
632
|
+
_: 2
|
|
633
|
+
}, [
|
|
634
|
+
h.showSelector ? {
|
|
635
|
+
name: "suffix",
|
|
636
|
+
fn: b(() => [
|
|
637
|
+
y(d, {
|
|
638
|
+
name: "search",
|
|
639
|
+
onClick: ee
|
|
640
|
+
})
|
|
641
|
+
]),
|
|
642
|
+
key: "0"
|
|
643
|
+
} : void 0,
|
|
644
|
+
h.showSelector ? {
|
|
645
|
+
name: "suffixIcon",
|
|
646
|
+
fn: b(() => [
|
|
647
|
+
c("i", {
|
|
648
|
+
class: "ri-add-circle-line cd-input-select__add-icon",
|
|
649
|
+
onClick: ee
|
|
650
|
+
})
|
|
651
|
+
]),
|
|
652
|
+
key: "1"
|
|
653
|
+
} : void 0
|
|
654
|
+
]), 1032, ["modelValue", "multiple", "placeholder", "loading", "popup-visible"]),
|
|
655
|
+
h.tabs && h.tabs.length > 0 && w.value ? (o(), O(ke, {
|
|
646
656
|
key: 0,
|
|
647
|
-
visible:
|
|
648
|
-
"onUpdate:visible": r[2] || (r[2] = (
|
|
649
|
-
modelValue:
|
|
650
|
-
"onUpdate:modelValue": r[3] || (r[3] = (
|
|
651
|
-
tabs:
|
|
652
|
-
organizations:
|
|
657
|
+
visible: w.value,
|
|
658
|
+
"onUpdate:visible": r[2] || (r[2] = (n) => w.value = n),
|
|
659
|
+
modelValue: $.value,
|
|
660
|
+
"onUpdate:modelValue": r[3] || (r[3] = (n) => $.value = n),
|
|
661
|
+
tabs: h.tabs,
|
|
662
|
+
organizations: h.organizations || [],
|
|
653
663
|
"show-org": !1,
|
|
654
664
|
"show-search": !0,
|
|
655
|
-
multiple:
|
|
665
|
+
multiple: h.multiple,
|
|
656
666
|
tips: "选择要添加的人员",
|
|
657
667
|
onConfirm: ie,
|
|
658
668
|
onLoadUsers: R,
|
|
659
669
|
onSearch: te
|
|
660
|
-
}, null, 8, ["visible", "modelValue", "tabs", "organizations", "multiple"])) :
|
|
670
|
+
}, null, 8, ["visible", "modelValue", "tabs", "organizations", "multiple"])) : k("", !0)
|
|
661
671
|
]);
|
|
662
672
|
};
|
|
663
673
|
}
|
|
664
|
-
}),
|
|
665
|
-
install(
|
|
666
|
-
|
|
674
|
+
}), It = /* @__PURE__ */ ye(Ut, [["__scopeId", "data-v-3180b8c7"]]), wt = {
|
|
675
|
+
install(h) {
|
|
676
|
+
h.component("PersonSelector", ke), h.component("CdInputPersonSelector", It);
|
|
667
677
|
}
|
|
668
678
|
};
|
|
669
679
|
export {
|
|
670
|
-
|
|
680
|
+
It as InputSelect,
|
|
671
681
|
ke as PersonSelector,
|
|
672
|
-
|
|
682
|
+
wt as default
|
|
673
683
|
};
|
|
@@ -6,10 +6,12 @@ interface Props {
|
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
tabs?: any[];
|
|
8
8
|
organizations?: any[];
|
|
9
|
+
showSelector?: boolean;
|
|
9
10
|
}
|
|
10
11
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
11
12
|
multiple: boolean;
|
|
12
13
|
placeholder: string;
|
|
14
|
+
showSelector: boolean;
|
|
13
15
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
16
|
"update:modelValue": (users: import('./types').User[]) => void;
|
|
15
17
|
search: (payload: {
|
|
@@ -24,6 +26,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
24
26
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
25
27
|
multiple: boolean;
|
|
26
28
|
placeholder: string;
|
|
29
|
+
showSelector: boolean;
|
|
27
30
|
}>>> & Readonly<{
|
|
28
31
|
"onUpdate:modelValue"?: ((users: import('./types').User[]) => any) | undefined;
|
|
29
32
|
"onLoad-users"?: ((payload: {
|
|
@@ -38,6 +41,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
38
41
|
}>, {
|
|
39
42
|
multiple: boolean;
|
|
40
43
|
placeholder: string;
|
|
44
|
+
showSelector: boolean;
|
|
41
45
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
42
46
|
export default _default;
|
|
43
47
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
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-3180b8c7]{position:relative;width:100%}.cd-input-select__select[data-v-3180b8c7]{width:100%}.cd-input-select__add-icon[data-v-3180b8c7]{font-size:20px;color:var(--td-brand-color, #0052d9);cursor:pointer;transition:all .2s;flex-shrink:0}.cd-input-select__add-icon[data-v-3180b8c7]:hover{color:var(--td-brand-color-hover, #004BBD);transform:scale(1.1)}.cd-input-select__select[data-v-3180b8c7] .t-input{min-height:32px;height:auto;padding:0!important;display:flex;align-items:flex-start}.cd-input-select__select[data-v-3180b8c7] .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-3180b8c7] .t-input__prefix{margin-left:5px}.cd-input-select__select[data-v-3180b8c7] .t-input__suffix{display:flex;align-items:center;flex-shrink:0;margin:0 10px;padding-top:8px}.cd-input-select__select[data-v-3180b8c7] .t-input__inner{min-height:28px;line-height:28px}.cd-input-select__select[data-v-3180b8c7] .t-select__suffix{display:flex;align-items:center;flex-shrink:0}.cd-input-select__select[data-v-3180b8c7] .t-select__suffix-icon{display:flex;align-items:center;flex-shrink:0;margin-left:4px}.cd-input-select__select[data-v-3180b8c7] .t-select__dropdown{width:100%!important}.cd-input-select__select[data-v-3180b8c7] .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-3180b8c7] .t-tag-input__suffix{display:flex;flex-shrink:0;margin-left:8px;padding-top:6px}.cd-input-select[data-v-3180b8c7] .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-3180b8c7] .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-3180b8c7] .t-select__dropdown .t-select-option .t-checkbox__input{align-self:center!important;margin-right:8px!important}.t-select-option[data-v-3180b8c7]{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
package/src/InputSelect.vue
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:filterable="true" :filter="() => true" :loading="searchLoading" :reserve-keyword="false"
|
|
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
|
-
<template #suffix>
|
|
7
|
+
<template #suffix v-if="showSelector">
|
|
8
8
|
<t-icon name="search" @click="handleIconClick" />
|
|
9
9
|
</template>
|
|
10
10
|
<template #valueDisplay>
|
|
@@ -38,7 +38,7 @@
|
|
|
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>
|
|
41
|
+
<template #suffixIcon v-if="showSelector">
|
|
42
42
|
<i class="ri-add-circle-line cd-input-select__add-icon" @click="handleIconClick"></i>
|
|
43
43
|
</template>
|
|
44
44
|
</t-select>
|
|
@@ -59,10 +59,12 @@ interface Props {
|
|
|
59
59
|
placeholder?: string;
|
|
60
60
|
tabs?: any[];
|
|
61
61
|
organizations?: any[];
|
|
62
|
+
showSelector?: boolean; // 是否显示人员选择器按钮
|
|
62
63
|
}
|
|
63
64
|
const props = withDefaults(defineProps<Props>(), {
|
|
64
65
|
multiple: true,
|
|
65
66
|
placeholder: '搜索用户、部门、职位',
|
|
67
|
+
showSelector: true, // 默认显示
|
|
66
68
|
});
|
|
67
69
|
const emit = defineEmits<{
|
|
68
70
|
(e: 'update:modelValue', users: UserItem[]): void;
|