"use strict";const e=require("../../../../common/vendor.js"),t={name:"up-cascader",props:{show:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},modelValue:{type:Array,default:()=>[]},valueKey:{type:String,default:"value"},labelKey:{type:String,default:"label"},childrenKey:{type:String,default:"children"},maskCloseAble:{type:Boolean,default:!0},zIndex:{type:[String,Number],default:0},autoClose:{type:Boolean,default:!1},headerDirection:{type:String,default:"row"},optionsCols:{type:[Number],default:2},closeable:{type:Boolean,default:!0}},data:()=>({levelList:[],selectedValueIndexs:[],tabsIndex:0,popupShow:!1,confirmValues:[]}),watch:{data:{handler(){this.initLevelList(),this.setDefaultValue()},immediate:!0},show(){this.popupShow=this.show},modelValue:{handler(){this.setDefaultValue()},immediate:!0}},computed:{isChange(){return this.tabsIndex>1},genTabsList(){let e=[{name:"请选择"}];for(let t=0;t<this.selectedValueIndexs.length;t++)if(void 0!==this.selectedValueIndexs[t]&&this.levelList[t]){const s=this.levelList[t][this.selectedValueIndexs[t]];s&&(e[t]={name:s[this.labelKey]},t===this.selectedValueIndexs.length-1&&s[this.childrenKey]&&s[this.childrenKey].length>0&&e.push({name:"请选择"}))}return e},uZIndex(){return this.zIndex?this.zIndex:this.$u.zIndex.popup}},emits:["update:modelValue","update:show","change","confirm","cancel"],methods:{t:e.t$1,initLevelList(){this.data&&this.data.length>0&&(this.levelList=[this.data],this.selectedValueIndexs=[])},setDefaultValue(){if(!this.data||0==this.data.length)return;if(!this.modelValue||0==this.modelValue.length)return;this.selectedValueIndexs=[],this.levelList=[];let e=this.data;for(let t=0;t<this.modelValue.length;t++){const s=this.modelValue[t],l=e.findIndex(e=>e[this.valueKey]===s);if(this.levelList[t]=e,-1===l)break;if(this.selectedValueIndexs.push(l),!e[l][this.childrenKey])break;e=e[l][this.childrenKey]}},close(){this.$emit("cancel"),this.$emit("update:show",!1)},tabsChange(e){},levelChange(e,t){this.$set(this.selectedValueIndexs,e,t),this.selectedValueIndexs.splice(e+1),this.tabsIndex=Math.min(this.tabsIndex,e),this.levelList.splice(e+1);const s=this.levelList[e][t];s&&s[this.childrenKey]&&s[this.childrenKey].length>0?(this.levelList.length<=e+1?this.levelList.push(s[this.childrenKey]):this.$set(this.levelList,e+1,s[this.childrenKey]),this.tabsIndex=e+1):this.autoClose?(this.emitChange(),this.handleConfirm()):this.emitChange(!1)},emitChange(e=!0){const t=[];for(let s=0;s<this.selectedValueIndexs.length;s++)void 0!==this.selectedValueIndexs[s]&&this.levelList[s]&&t.push(this.levelList[s][this.selectedValueIndexs[s]][this.valueKey]);this.confirmValues=[...t],this.$emit("change",this.confirmValues),e&&this.close()},handleCancel(){this.close()},handleConfirm(){this.$emit("update:modelValue",this.confirmValues),this.$emit("confirm",this.confirmValues),this.close()}}};if(!Array){(e.resolveComponent("up-steps-item")+e.resolveComponent("up-steps")+e.resolveComponent("up-tabs")+e.resolveComponent("up-icon")+e.resolveComponent("up-cell")+e.resolveComponent("up-cell-group")+e.resolveComponent("up-button")+e.resolveComponent("up-popup"))()}Math||((()=>"../u-steps-item/u-steps-item.js")+(()=>"../u-steps/u-steps.js")+(()=>"../u-tabs/u-tabs.js")+(()=>"../u-icon/u-icon.js")+(()=>"../u-cell/u-cell.js")+(()=>"../u-cell-group/u-cell-group.js")+(()=>"../u-button/u-button.js")+(()=>"../u-popup/u-popup.js"))();const s=e._export_sfc(t,[["render",function(t,s,l,i,a,n){return e.e({a:"column"==l.headerDirection},"column"==l.headerDirection?e.e({b:a.popupShow},a.popupShow?{c:e.f(n.genTabsList,(t,s,l)=>({a:e.o(e=>a.tabsIndex=s),b:"2b4d73a7-2-"+l+",2b4d73a7-1",c:e.p({title:t.name})})),d:e.o(e=>a.tabsIndex=e),e:e.p({dot:!0,direction:"column",current:a.tabsIndex})}:{}):e.e({f:a.popupShow},a.popupShow?{g:e.sr("tabs","2b4d73a7-3,2b4d73a7-0"),h:e.o(n.tabsChange),i:e.o(e=>a.tabsIndex=e),j:e.p({list:n.genTabsList,scrollable:!0,current:a.tabsIndex})}:{}),{k:e.f(a.levelList,(t,s,i)=>e.e({a:2==l.optionsCols||s==a.tabsIndex},2==l.optionsCols||s==a.tabsIndex?e.e({b:0===s||void 0!==a.selectedValueIndexs[s-1]},0===s||void 0!==a.selectedValueIndexs[s-1]?{c:e.f(t,(t,o,h)=>e.e({a:a.selectedValueIndexs[s]===o},a.selectedValueIndexs[s]===o?{b:"2b4d73a7-6-"+i+"-"+h+",2b4d73a7-5-"+i+"-"+h,c:e.p({size:"17",name:"checkbox-mark"})}:{},{d:o,e:e.o(e=>n.levelChange(s,o),o),f:"2b4d73a7-5-"+i+"-"+h+",2b4d73a7-4-"+i,g:e.p({title:t[l.labelKey],arrow:!1,index:o})})),d:"2b4d73a7-4-"+i+",2b4d73a7-0"}:{},{e:2==l.optionsCols?"33.33333%":"750rpx"}):{},{f:s})),l:n.isChange?1:"",m:2==l.optionsCols&&n.isChange?"translateX(-33.3333333%)":"",n:e.t(n.t("up.common.cancel")),o:e.o(n.handleCancel),p:e.p({type:"default"}),q:e.t(n.t("up.common.confirm")),r:e.o(n.handleConfirm),s:e.p({type:"primary"}),t:e.o(n.close),v:e.p({show:a.popupShow,mode:"bottom",popup:!1,mask:!0,closeable:l.closeable,"safe-area-inset-bottom":!0,"close-icon-color":"#ffffff","z-index":n.uZIndex,maskCloseAble:l.maskCloseAble})})}]]);wx.createComponent(s);
