pages-my-subordinate-index.DXoy1ic5.js 26 KB

1
  1. import{_ as e}from"./ly-tree.D703-q15.js";import{$ as t,Y as s,X as d,x as i,y as o,p as n,m as r,w as h,q as a,E as l,a1 as c,N as u,z as f,B as y,F as p,t as k,v as N,C,G as g,D as x,o as b,Z as m,c8 as I,k as v}from"./index-C9TJPork.js";import{r as K}from"./uni-app.es.CUt9gedF.js";import{_ as w}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./resources.DEPsJg7u.js";const E="$treeNodeId",_=function(e,t){t&&!t[E]&&Object.defineProperty(t,E,{value:e.id,enumerable:!1,configurable:!1,writable:!1})},L=function(e,t){return t?e?t[e]:t[E]:null},A=function(e){for(let t=1,s=arguments.length;t<s;t++){let s=arguments[t]||{};for(let t in s)if(s.hasOwnProperty(t)){let d=s[t];void 0!==d&&(e[t]=d)}}return e},D=function(e){let t=!0,s=!0,d=!0;for(let i=0,o=e.length;i<o;i++){const o=e[i];(!0!==o.checked||o.indeterminate)&&(t=!1,o.disabled||(d=!1)),(!1!==o.checked||o.indeterminate)&&(s=!1)}return{all:t,none:s,allWithoutDisable:d,half:!t&&!s}},O=function(e){if(!e||0===e.childNodesId.length)return;let t=e.getChildNodes(e.childNodesId);const{all:s,none:d,half:i}=D(t);s?(e.checked=!0,e.indeterminate=!1):i?(e.checked=!1,e.indeterminate=!0):d&&(e.checked=!1,e.indeterminate=!1);let o=e.getParent(e.parentId);o&&0!==o.level&&(e.store().checkStrictly||O(o))},P=function(e,t){const s=e.store().props,d=e.data||{},i=s[t];if("function"==typeof i)return i(d,e);if("string"==typeof i)return d[i];if(void 0===i){const e=d[t];return void 0===e?"":e}},S=function(e){let t=e;return function(){return t}};let B=0;class R{constructor(e){this.time=(new Date).getTime(),this.id=B++,this.text=null,this.checked=!1,this.indeterminate=!1,this.data=null,this.expanded=!1,this.parentId=null,this.visible=!0,this.isCurrent=!1;for(let t in e)e.hasOwnProperty(t)&&("store"===t?this.store=S(e[t]):this[t]=e[t]);if(!this.store())throw new Error("[Node]store is required!");this.level=0,this.loaded=!1,this.childNodesId=[],this.loading=!1,this.label=P(this,"label"),this.key=this._getKey(),this.disabled=P(this,"disabled"),this.nextSibling=null,this.previousSibling=null,this.icon="",this._handleParentAndLevel(),this._handleProps(),this._handleExpand(),this._handleCurrent(),this.store().lazy&&this.store()._initDefaultCheckedNode(this),this.updateLeafState()}_getKey(){if(!this.data||Array.isArray(this.data))return null;if("object"==typeof this.data){const e=this.store().key,t=this.data[e];if(void 0===t)throw new Error(`您配置的node-key为"${e}",但数据中并未找到对应"${e}"属性的值,请检查node-key的配置是否合理`);return t}throw new Error("不合法的data数据")}_handleParentAndLevel(){if(null!==this.parentId){let e=this.getParent(this.parentId);if(this.store().isInjectParentInNode&&(this.parent=e),e){const t=e.getChildNodes(e.childNodesId),s=e.childNodesId.indexOf(this.key);this.nextSibling=s>-1?t[s+1]:null,this.previousSibling=s>0?t[s-1]:null}else e={level:0};this.level=e.level+1}}_handleProps(){const e=this.store().props;if(this.store().showNodeIcon&&(e&&void 0!==e.icon?this.icon=P(this,"icon"):console.warn('请配置props属性中的"icon"字段')),this.store().registerNode(this),e&&void 0!==e.isLeaf){const e=P(this,"isLeaf");"boolean"==typeof e&&(this.isLeafByUser=e)}}_handleExpand(){if(!0!==this.store().lazy&&this.data?(this.setData(this.data),this.store().defaultExpandAll&&(this.expanded=!0)):this.level>0&&this.store().lazy&&this.store().defaultExpandAll&&this.expand(),Array.isArray(this.data)||_(this,this.data),!this.data)return;const e=this.store().defaultExpandedKeys;this.store().key&&e&&-1!==e.indexOf(this.key)&&this.expand(null,this.store().autoExpandparent)}_handleCurrent(){this.store().key&&void 0!==this.store().currentNodeKey&&this.key===this.store().currentNodeKey&&(this.store().currentNode=this,this.store().currentNode.isCurrent=!0)}destroyStore(){}setData(e){let t;Array.isArray(e)||_(this,e),this.data=e,this.childNodesId=[],t=0===this.level&&Array.isArray(this.data)?this.data:P(this,"children")||[];for(let s=0,d=t.length;s<d;s++)this.insertChild({data:t[s]})}contains(e,t=!0){const s=function(d){const i=d.getChildNodes(d.childNodesId)||[];let o=!1;for(let n=0,r=i.length;n<r;n++){const d=i[n];if(d===e||t&&s(d)){o=!0;break}}return o};return s(this)}remove(){if(null!==this.parentId){this.getParent(this.parentId).removeChild(this)}}insertChild(e,t,s){if(!e)throw new Error("insertChild error: child is required.");if(!(e instanceof R)){if(!s){const s=this.getChildren(!0);-1===s.indexOf(e.data)&&(void 0===t||t<0?s.push(e.data):s.splice(t,0,e.data))}A(e,{parentId:(d=this.key,null==d||""===d?"":this.key),store:this.store()}),e=new R(e)}var d;e.level=this.level+1,void 0===t||t<0?this.childNodesId.push(e.key):this.childNodesId.splice(t,0,e.key),this.updateLeafState()}insertBefore(e,t){let s;t&&(s=this.childNodesId.indexOf(t.id)),this.insertChild(e,s)}insertAfter(e,t){let s;t&&(s=this.childNodesId.indexOf(t.id),-1!==s&&(s+=1)),this.insertChild(e,s)}removeChild(e){const t=this.getChildren()||[],s=t.indexOf(e.data);s>-1&&t.splice(s,1);const d=this.childNodesId.indexOf(e.key);d>-1&&(this.store()&&this.store().deregisterNode(e),e.parentId=null,this.childNodesId.splice(d,1)),this.updateLeafState()}removeChildByData(e){let t=null;for(let s=0;s<this.childNodesId.length;s++){let d=this.getChildNodes(this.childNodesId);if(d[s].data===e){t=d[s];break}}t&&this.removeChild(t)}getParent(e){try{return e.toString()?this.store().nodesMap[e]:null}catch(t){return null}}getChildNodes(e){let t=[];return 0===e.length||e.forEach((e=>{t.push(this.store().nodesMap[e])})),t}expand(e,t){const s=()=>{if(t){let e=this.getParent(this.parentId);for(;e&&e.level>0;)e.expanded=!0,e=this.getParent(e.parentId)}this.expanded=!0,e&&e()};this.shouldLoadData()?this.loadData((function(e){Array.isArray(e)&&(this.checked?this.setChecked(!0,!0):this.store().checkStrictly||O(this),s())})):s()}doCreateChildren(e,t={}){e.forEach((e=>{this.insertChild(A({data:e},t),void 0,!0)}))}collapse(){this.expanded=!1}shouldLoadData(){return!0===this.store().lazy&&this.store().load&&!this.loaded}updateLeafState(){if(!0===this.store().lazy&&!0!==this.loaded&&void 0!==this.isLeafByUser)return void(this.isLeaf=this.isLeafByUser);const e=this.childNodesId;!this.store().lazy||!0===this.store().lazy&&!0===this.loaded?this.isLeaf=!e||0===e.length:this.isLeaf=!1}setChecked(e,t,s,d){if(this.indeterminate="half"===e,this.checked=!0===e,this.checked&&this.store().expandOnCheckNode&&this.expand(null,!0),this.store().checkStrictly)return;if(this.store().showRadio)return;if(!this.shouldLoadData()||this.store().checkDescendants){let s=this.getChildNodes(this.childNodesId),{all:i,allWithoutDisable:o}=D(s);this.isLeaf||i||!o||(this.checked=!1,e=!1);const n=()=>{if(t){let s=this.getChildNodes(this.childNodesId);for(let n=0,r=s.length;n<r;n++){const i=s[n];d=d||!1!==e;const o=i.disabled?i.checked:d;i.setChecked(o,t,!0,d)}const{half:i,all:o}=D(s);o||(this.checked=o,this.indeterminate=i)}};if(this.shouldLoadData())return void this.loadData((()=>{n(),O(this)}),{checked:!1!==e});n()}if(!this.parentId)return;let i=this.getParent(this.parentId);i&&0===i.level||s||O(i)}setRadioChecked(e){this.store()._getAllNodes().sort(((e,t)=>t.level-e.level)).forEach((e=>e.setChecked(!1,!1))),this.checked=!0===e}getChildren(e=!1){if(0===this.level)return this.data;const t=this.data;if(!t)return null;const s=this.store().props;let d="children";return s&&(d=s.children||"children"),void 0===t[d]&&(t[d]=null),e&&!t[d]&&(t[d]=[]),t[d]}updateChildren(){let e=this.getChildNodes(this.childNodesId);const t=this.getChildren()||[],s=e.map((e=>e.data)),d={},i=[];t.forEach(((e,t)=>{const o=e[E];!!o&&function(e,t){for(let s=0;s!==e.length;++s)if(t(e[s]))return s;return-1}(s,(e=>e[E]===o))>=0?d[o]={index:t,data:e}:i.push({index:t,data:e})})),this.store().lazy||s.forEach((e=>{d[e[E]]||this.removeChildByData(e)})),i.forEach((({index:e,data:t})=>{this.insertChild({data:t},e)})),this.updateLeafState()}loadData(e,t={}){if(!0!==this.store().lazy||!this.store().load||this.loaded||this.loading&&!Object.keys(t).length)e&&e.call(this);else{this.loading=!0;const s=s=>{this.loaded=!0,this.loading=!1,this.childNodesId=[],this.doCreateChildren(s,t),this.updateLeafState(),e&&e.call(this,s)};this.store().load(this,s)}}}class T{constructor(e){if(this.ready=!1,this.currentNode=null,this.currentNodeKey=null,Object.assign(this,e),!this.key)throw new Error("[Tree] nodeKey is required");if(this.nodesMap={},this.root=new R({data:this.data,store:this}),this.lazy&&this.load){(0,this.load)(this.root,(e=>{this.root.doCreateChildren(e),this._initDefaultCheckedNodes(),this.ready=!0,t("updateKey")}))}else this._initDefaultCheckedNodes(),this.ready=!0}getReady(){return this.ready}filter(e,t){const s=this.filterNodeMethod,d=this.lazy,i=this,o=function(n){const r=n.root?n.root.getChildNodes(n.root.childNodesId):n.getChildNodes(n.childNodesId);if(r.forEach((d=>{if(t&&"object"==typeof t){if(!i.getNodePath(d.data).some((e=>e[i.key]===t[i.key])))return d.visible=!1,void o(d)}if(i.childVisibleForFilterNode){let t=d.getParent(d.parentId);d.visible=s.call(d,e,d.data,d)||t&&t.visible}else d.visible=s.call(d,e,d.data,d);o(d)})),!n.visible&&r.length){let e=!0;e=!r.some((e=>e.visible)),n.root?n.root.visible=!1===e:n.visible=!1===e}e&&(!n.visible||n.isLeaf||d||n.expand())};o(this)}setData(e){e!==this.root.data?(this.root.setData(e),this._initDefaultCheckedNodes()):this.root.updateChildren()}getNode(e){if(e instanceof R)return e;const t="object"!=typeof e?e:L(this.key,e);return t&&this.nodesMap[t]||null}insertBefore(e,t){const s=this.getNode(t);s.getParent(s.parentId).insertBefore({data:e},s)}insertAfter(e,t){const s=this.getNode(t);s.getParent(s.parentId).insertAfter({data:e},s)}remove(e){const t=this.getNode(e);if(t&&null!==t.parentId){let e=t.getParent(t.parentId);t===this.currentNode&&(this.currentNode=null),e.removeChild(t)}}append(e,t){const s=t?this.getNode(t):this.root;s&&s.insertChild({data:e})}_initDefaultCheckedNodes(){const e=this.defaultCheckedKeys||[],t=this.nodesMap;let s=[],d=[];for(let i in t){(P(t[i],"checked")||!1)&&s.push(i)}d=Array.from(new Set([...e,...s])),d.forEach((e=>{const s=t[e];s&&s.setChecked(!0,!this.checkStrictly)}))}_initDefaultCheckedNode(e){-1!==(this.defaultCheckedKeys||[]).indexOf(e.key)&&e.setChecked(!0,!this.checkStrictly)}toggleExpendAll(e){this._getAllNodes().forEach((t=>{const s=this.getNode(t.key);s&&(e?s.expand():s.collapse())}))}setCheckAll(e){this._getAllNodes().forEach((t=>{t.setChecked(e,!1)}))}setDefaultCheckedKey(e){e!==this.defaultCheckedKeys&&(this.defaultCheckedKeys=e,this._initDefaultCheckedNodes())}registerNode(e){if(!this.key||!e||!e.data)return;void 0!==e.key&&(this.nodesMap[e.key]=e)}deregisterNode(e){if(!this.key||!e||!e.data)return;e.getChildNodes(e.childNodesId).forEach((e=>{this.deregisterNode(e)})),delete this.nodesMap[e.key]}getNodePath(e){if(!this.key)throw new Error("[Tree] nodeKey is required in getNodePath");const t=this.getNode(e);if(!t)return[];const s=[t.data];let d=t.getParent(t.parentId);for(;d&&d!==this.root;)s.push(d.data),d=d.getParent(d.parentId);return s.reverse()}getCheckedNodes(e=!1,t=!1){const s=[],d=function(i){(i.root?i.root.getChildNodes(i.root.childNodesId):i.getChildNodes(i.childNodesId)).forEach((i=>{(i.checked||t&&i.indeterminate)&&(!e||e&&i.isLeaf)&&s.push(i.data),d(i)}))};return d(this),s}getCheckedKeys(e=!1,t=!1){return this.getCheckedNodes(e,t).map((e=>(e||{})[this.key]))}getHalfCheckedNodes(){const e=[],t=function(s){(s.root?s.root.getChildNodes(s.root.childNodesId):s.getChildNodes(s.childNodesId)).forEach((s=>{s.indeterminate&&e.push(s.data),t(s)}))};return t(this),e}getHalfCheckedKeys(){return this.getHalfCheckedNodes().map((e=>(e||{})[this.key]))}_getAllNodes(){const e=[],t=this.nodesMap;for(let s in t)t.hasOwnProperty(s)&&e.push(t[s]);return e}updateChildren(e,t){const s=this.nodesMap[e];if(!s)return;const d=s.getChildNodes(s.childNodesId);for(let i=d.length-1;i>=0;i--){const e=d[i];this.remove(e.data)}for(let i=0,o=t.length;i<o;i++){const e=t[i];this.append(e,s.data)}}_setCheckedKeys(e,t=!1,s){const d=this._getAllNodes().sort(((e,t)=>t.level-e.level)),i=Object.create(null),o=Object.keys(s);d.forEach((e=>e.setChecked(!1,!1)));for(let n=0,r=d.length;n<r;n++){const s=d[n];let r=s.data[e];if(void 0===r)continue;if(r=r.toString(),!(o.indexOf(r)>-1)){s.checked&&!i[r]&&s.setChecked(!1,!1);continue}let h=s.getParent(s.parentId);for(;h&&h.level>0;)i[h.data[e]]=!0,h=h.getParent(h.parentId);if(s.isLeaf||this.checkStrictly)s.setChecked(!0,!1);else if(s.setChecked(!0,!0),t){s.setChecked(!1,!1);const e=function(t){t.getChildNodes(t.childNodesId).forEach((t=>{t.isLeaf||t.setChecked(!1,!1),e(t)}))};e(s)}}}setCheckedNodes(e,t=!1){const s=this.key,d={};e.forEach((e=>{d[(e||{})[s]]=!0})),this._setCheckedKeys(s,t,d)}setCheckedKeys(e,t=!1){this.defaultCheckedKeys=e;const s=this.key,d={};e.forEach((e=>{d[e]=!0})),this._setCheckedKeys(s,t,d)}setDefaultExpandedKeys(e){e=e||[],this.defaultExpandedKeys=e,e.forEach((e=>{const t=this.getNode(e);t&&t.expand(null,this.autoExpandParent)}))}setChecked(e,t,s){const d=this.getNode(e);d&&d.setChecked(!!t,s)}getCurrentNode(){return this.currentNode}setCurrentNode(e){const t=this.currentNode;t&&(t.isCurrent=!1),this.currentNode=e,this.currentNode.isCurrent=!0,this.expandCurrentNodeParent&&this.currentNode.expand(null,!0)}setUserCurrentNode(e){const t=e[this.key],s=this.nodesMap[t];this.setCurrentNode(s)}setCurrentNodeKey(e){if(null==e)return this.currentNode&&(this.currentNode.isCurrent=!1),void(this.currentNode=null);const t=this.getNode(e);t&&this.setCurrentNode(t)}}let $;const j=w({components:{LyTree:w({name:"LyTree",componentName:"LyTree",components:{LyTreeNode:w({name:"LyTreeNode",componentName:"LyTreeNode",props:{nodeId:[Number,String],renderAfterExpand:{type:Boolean,default:!0},checkOnlyLeaf:{type:Boolean,default:!1},showCheckbox:{type:Boolean,default:!1},showRadio:{type:Boolean,default:!1},indent:Number,iconClass:String},data:()=>({node:{indeterminate:!1,checked:!1,expanded:!1},expanded:!1,childNodeRendered:!1,oldChecked:null,oldIndeterminate:null,highlightCurrent:!1}),inject:["tree"],computed:{checkboxVisible(){return this.checkOnlyLeaf?this.showCheckbox&&this.node.isLeaf:this.showCheckbox},radioVisible(){return this.checkOnlyLeaf?this.showRadio&&this.node.isLeaf:this.showRadio}},watch:{"node.indeterminate"(e){this.handleSelectChange(this.node.checked,e)},"node.checked"(e){this.handleSelectChange(e,this.node.indeterminate)},"node.expanded"(e){this.$nextTick((()=>this.expanded=e)),e&&(this.childNodeRendered=!0)}},methods:{getNodeKey(e){let t=this.tree.store.root.getChildNodes([e])[0];return L(this.tree.nodeKey,t.data)},handleSelectChange(e,t){if(this.oldChecked!==e&&this.oldIndeterminate!==t){if(this.checkOnlyLeaf&&!this.node.isLeaf)return;if(this.checkboxVisible){const s=this.tree.store._getAllNodes();this.tree.$emit("check-change",{checked:e,indeterminate:t,node:this.node,data:this.node.data,checkedall:s.every((e=>e.checked))})}else this.tree.$emit("radio-change",{checked:e,node:this.node,data:this.node.data,checkedall:!1})}!this.expanded&&this.tree.expandOnCheckNode&&e&&this.handleExpandIconClick(),this.oldChecked=e,this.indeterminate=t},handleClick(){this.tree.store.setCurrentNode(this.node),this.tree.$emit("current-change",{node:this.node,data:this.tree.store.currentNode?this.tree.store.currentNode.data:null,currentNode:this.tree.store.currentNode}),this.tree.currentNode=this.node,this.tree.expandOnClickNode&&this.handleExpandIconClick(),this.tree.checkOnClickNode&&!this.node.disabled&&(this.checkboxVisible||this.radioVisible)&&this.handleCheckChange(!this.node.checked),this.tree.$emit("node-click",this.node)},handleExpandIconClick(){this.node.isLeaf||(this.expanded?(this.tree.$emit("node-collapse",this.node),this.node.collapse()):(this.node.expand(),this.tree.$emit("node-expand",this.node),this.tree.accordion&&t(`${this.tree.elId}-tree-node-expand`,this.node)))},handleCheckChange(e){this.node.disabled||(this.checkboxVisible?this.node.setChecked(e,!(this.tree.checkStrictly||this.checkOnlyLeaf)):this.node.setRadioChecked(e),this.$nextTick((()=>{this.tree.$emit("check",{node:this.node,data:this.node.data,checkedNodes:this.tree.store.getCheckedNodes(),checkedKeys:this.tree.store.getCheckedKeys(),halfCheckedNodes:this.tree.store.getHalfCheckedNodes(),halfCheckedKeys:this.tree.store.getHalfCheckedKeys()})})),t("updateKey"))},handleImageError(){this.node.icon=this.tree.defaultNodeIcon}},created(){if(!this.tree)throw new Error("Can not find node's tree.");this.node=this.tree.store.nodesMap[this.nodeId],this.highlightCurrent=this.tree.highlightCurrent,this.node.expanded&&(this.expanded=!0,this.childNodeRendered=!0);const e=(this.tree.props||{}).children||"children";this.$watch(`node.data.${e}`,(()=>{this.node.updateChildren()})),this.tree.accordion&&s(`${this.tree.elId}-tree-node-expand`,(e=>{this.node.id!==e.id&&this.node.level===e.level&&this.node.collapse()}))},beforeDestroy(){this.$parent=null}},[["render",function(e,t,s,m,I,v){const K=g,w=d("ly-checkbox"),E=x,_=b,L=d("ly-tree-node",!0);return i((n(),r(_,{ref:"node",name:"LyTreeNode",class:l(["ly-tree-node",{"is-expanded":I.expanded,"is-hidden":!I.node.visible,"is-checked":!I.node.disabled&&I.node.checked}]),role:"treeitem",onClick:u(v.handleClick,["stop"])},{default:h((()=>[a(_,{class:l(["ly-tree-node__content",{"is-current":I.node.isCurrent&&I.highlightCurrent}]),style:c({"padding-left":(I.node.level-1)*s.indent+"px"})},{default:h((()=>[a(K,{onClick:u(v.handleExpandIconClick,["stop"]),class:l([{"is-leaf":I.node.isLeaf,expanded:!I.node.isLeaf&&I.node.expanded},"ly-tree-node__expand-icon",s.iconClass?s.iconClass:"ly-iconfont ly-icon-caret-right"])},null,8,["onClick","class"]),v.checkboxVisible||v.radioVisible?(n(),r(w,{key:0,type:v.checkboxVisible?"checkbox":"radio",checked:I.node.checked,indeterminate:I.node.indeterminate,disabled:!!I.node.disabled,onCheck:t[0]||(t[0]=e=>v.handleCheckChange(!I.node.checked))},null,8,["type","checked","indeterminate","disabled"])):f("",!0),I.node.loading?(n(),r(K,{key:1,class:"ly-tree-node__loading-icon ly-iconfont ly-icon-loading"})):f("",!0),I.node.icon&&I.node.icon.length>0?(n(),y(p,{key:2},[-1!==I.node.icon.indexOf("/")?(n(),r(E,{key:0,class:"ly-tree-node__icon",mode:"widthFix",src:I.node.icon,onError:v.handleImageError},null,8,["src","onError"])):(n(),r(K,{key:1,class:l(["ly-tree-node__icon",I.node.icon])},null,8,["class"]))],64)):f("",!0),a(_,{class:"ly-tree-node__label_box"},{default:h((()=>[a(K,{class:"ly-tree-node__label u-line-1"},{default:h((()=>[k(N(I.node.data.userName),1)])),_:1}),a(K,{style:{color:"#c6c6c6"},class:"ly-tree-node__label u-line-1"},{default:h((()=>[k(N(I.node.data.position?I.node.data.department+"/"+I.node.data.position:I.node.data.department),1)])),_:1})])),_:1})])),_:1},8,["class","style"]),!s.renderAfterExpand||I.childNodeRendered?i((n(),r(_,{key:0,class:"ly-tree-node__children",role:"group"},{default:h((()=>[(n(!0),y(p,null,C(I.node.childNodesId,(e=>(n(),r(L,{nodeId:e,"render-after-expand":s.renderAfterExpand,"show-checkbox":s.showCheckbox,"show-radio":s.showRadio,"check-only-leaf":s.checkOnlyLeaf,key:v.getNodeKey(e),indent:s.indent,"icon-class":s.iconClass},null,8,["nodeId","render-after-expand","show-checkbox","show-radio","check-only-leaf","indent","icon-class"])))),128))])),_:1},512)),[[o,I.expanded]]):f("",!0)])),_:1},8,["class","onClick"])),[[o,I.node.visible]])}],["__scopeId","data-v-da7133da"]])},data:()=>({updateKey:(new Date).getTime(),elId:`ly_${Math.ceil(1e6*Math.random()).toString(36)}`,visible:!0,store:{ready:!1},currentNode:null,childNodesId:[],mathKey:1}),provide(){return{tree:this}},props:{treeData:Array,ready:{type:Boolean,default:!0},emptyText:{type:String,default:"暂无数据"},renderAfterExpand:{type:Boolean,default:!0},nodeKey:String,checkStrictly:Boolean,defaultExpandAll:{type:Boolean,default:!0},toggleExpendAll:Boolean,expandOnClickNode:{type:Boolean,default:!0},expandOnCheckNode:{type:Boolean,default:!0},checkOnClickNode:Boolean,checkDescendants:{type:Boolean,default:!1},autoExpandParent:{type:Boolean,default:!0},defaultCheckedKeys:Array,defaultExpandedKeys:Array,expandCurrentNodeParent:Boolean,currentNodeKey:[String,Number],checkOnlyLeaf:{type:Boolean,default:!1},showCheckbox:{type:Boolean,default:!1},showRadio:{type:Boolean,default:!1},props:{type:[Object,Function],default:()=>({children:"children",label:"label",disabled:"disabled"})},lazy:{type:Boolean,default:!1},highlightCurrent:Boolean,load:Function,filterNodeMethod:Function,childVisibleForFilterNode:{type:Boolean,default:!1},accordion:Boolean,indent:{type:Number,default:18},iconClass:String,showNodeIcon:{type:Boolean,default:!1},defaultNodeIcon:{type:String,default:""},isInjectParentInNode:{type:Boolean,default:!1}},computed:{isEmpty(){if(this.store.root){const e=this.store.root.getChildNodes(this.childNodesId);return!e||0===e.length||e.every((({visible:e})=>!e))}return!0},showLoading(){return this.mathKey,!(this.store.getReady()&&this.ready)}},watch:{toggleExpendAll(e){this.store.toggleExpendAll(e)},defaultCheckedKeys(e){this.store.setDefaultCheckedKey(e)},defaultExpandedKeys(e){this.store.defaultExpandedKeys=e,this.store.setDefaultExpandedKeys(e)},checkStrictly(e){this.store.checkStrictly=e||this.checkOnlyLeaf},"store.root.childNodesId"(e){this.childNodesId=e},"store.root.visible"(e){this.visible=e},childNodesId(){this.$nextTick((()=>{this.$emit("ly-tree-render-completed")}))},treeData:{handler(e){this.updateKey=(new Date).getTime(),this.store.setData(e)},deep:!0}},methods:{filter(e,t){if(!this.filterNodeMethod)throw new Error("[Tree] filterNodeMethod is required when filter");this.store.filter(e,t),this.handleUpdateKey()},handleUpdateKey(){this.updateKey=(new Date).getTime()},getNodeKey(e){let t=this.store.root.getChildNodes([e])[0];return L(this.nodeKey,t.data)},getNodePath(e){return this.store.getNodePath(e)},getCheckedNodes(e,t){return this.store.getCheckedNodes(e,t)},getCheckedKeys(e,t){return this.store.getCheckedKeys(e,t)},getCurrentNode(){const e=this.store.getCurrentNode();return e?e.data:null},getCurrentKey(){const e=this.getCurrentNode();return e?e[this.nodeKey]:null},setCheckAll(e=!0){if(this.showRadio)throw new Error('You set the "show-radio" property, so you cannot select all nodes');this.showCheckbox||console.warn('You have not set the property "show-checkbox". Please check your settings'),this.store.setCheckAll(e)},setCheckedNodes(e,t){this.store.setCheckedNodes(e,t)},setCheckedKeys(e,t){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedKeys");this.store.setCheckedKeys(e,t),this.handleUpdateKey()},setChecked(e,t,s){this.store.setChecked(e,t,s)},getHalfCheckedNodes(){return this.store.getHalfCheckedNodes()},getHalfCheckedKeys(){return this.store.getHalfCheckedKeys()},setCurrentNode(e){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentNode");this.store.setUserCurrentNode(e)},setCurrentKey(e){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentKey");this.store.setCurrentNodeKey(e)},getNode(e){return this.store.getNode(e)},remove(e){this.store.remove(e)},append(e,t){this.store.append(e,t)},insertBefore(e,t){this.store.insertBefore(e,t)},insertAfter(e,t){this.store.insertAfter(e,t)},updateKeyChildren(e,t){if(!this.nodeKey)throw new Error("[Tree] nodeKey is required in updateKeyChild");this.store.updateChildren(e,t)}},created(){this.isTree=!0;let e=this.props;if("function"==typeof this.props&&(e=this.props()),"object"!=typeof e)throw new Error("props must be of object type.");this.store=new T({key:this.nodeKey,data:this.treeData,lazy:this.lazy,props:e,load:this.load,showCheckbox:this.showCheckbox,showRadio:this.showRadio,currentNodeKey:this.currentNodeKey,checkStrictly:this.checkStrictly||this.checkOnlyLeaf,checkDescendants:this.checkDescendants,expandOnCheckNode:this.expandOnCheckNode,defaultCheckedKeys:this.defaultCheckedKeys,defaultExpandedKeys:this.defaultExpandedKeys,expandCurrentNodeParent:this.expandCurrentNodeParent,autoExpandParent:this.autoExpandParent,defaultExpandAll:this.defaultExpandAll,filterNodeMethod:this.filterNodeMethod,childVisibleForFilterNode:this.childVisibleForFilterNode,showNodeIcon:this.showNodeIcon,isInjectParentInNode:this.isInjectParentInNode}),this.childNodesId=this.store.root.childNodesId,s("updateKey",(()=>{this.handleUpdateKey(),this.mathKey++}))},beforeDestroy(){this.accordion&&m(`${this.elId}-tree-node-expand`),m("updateKey")}},[["render",function(e,t,s,i,o,c){const u=b,g=d("ly-tree-node");return n(),r(u,null,{default:h((()=>[c.showLoading?(n(),r(u,{key:0,class:"ly-loader ly-flex-center"},{default:h((()=>[a(u,{class:"ly-loader-inner"},{default:h((()=>[k("加载中...")])),_:1})])),_:1})):(n(),y(p,{key:1},[c.isEmpty||!o.visible?(n(),r(u,{key:0,class:"ly-empty"},{default:h((()=>[k(N(s.emptyText),1)])),_:1})):f("",!0),(n(),r(u,{key:o.updateKey,class:l(["ly-tree",{"is-empty":c.isEmpty||!o.visible}]),role:"tree",name:"LyTreeExpand"},{default:h((()=>[(n(!0),y(p,null,C(o.childNodesId,(e=>(n(),r(g,{nodeId:e,"render-after-expand":s.renderAfterExpand,"show-checkbox":s.showCheckbox,"show-radio":s.showRadio,"check-only-leaf":s.checkOnlyLeaf,key:c.getNodeKey(e),indent:s.indent,"icon-class":s.iconClass,updateKey:"hanldeUpdateKey"},null,8,["nodeId","render-after-expand","show-checkbox","show-radio","check-only-leaf","indent","icon-class"])))),128))])),_:1},8,["class"]))],64))])),_:1})}],["__scopeId","data-v-a318dbc6"]])},data:()=>({isReady:!1,props:{label:"userName",isLeaf:"isLeaf",value:"id",icon:"avatar"},treeData:[]}),onLoad(){$=this,this.isReady=!0},computed:{baseURL(){return this.define.baseURL}},methods:{loadNode(e,t){0===e.level?I(e.level).then((e=>{let s=JSON.parse(JSON.stringify(e.data));s.map((e=>(e.avatar=$.baseURL+e.avatar,s))),t(s)})):I(e.key).then((e=>{let s=JSON.parse(JSON.stringify(e.data));s.map((e=>(e.avatar=$.baseURL+e.avatar,s))),t(s)}))}}},[["render",function(t,s,d,i,o,a){const l=K(v("ly-tree"),e),c=b;return n(),r(c,{class:"tree-main"},{default:h((()=>[o.isReady?(n(),r(l,{key:0,props:o.props,"node-key":o.props.value,load:a.loadNode,lazy:"","tree-data":o.treeData,"show-node-icon":"",defaultExpandAll:!1},null,8,["props","node-key","load","tree-data"])):f("",!0)])),_:1})}]]);export{j as default};