u-picker.js 7.1 KB
"use strict";const r=require("../../../../common/vendor.js"),d=require("./props.js"),m=require("../../libs/mixin/mpMixin.js"),c=require("../../libs/mixin/mixin.js");require("../../libs/config/props.js");require("../../libs/config/config.js");require("../../libs/config/props/actionSheet.js");require("../../libs/config/props/album.js");require("../../libs/config/props/alert.js");require("../../libs/config/props/avatar.js");require("../../libs/config/props/avatarGroup.js");require("../../libs/config/props/backtop.js");require("../../libs/config/props/badge.js");require("../../libs/config/props/button.js");require("../../libs/config/props/calendar.js");require("../../libs/config/props/carKeyboard.js");require("../../libs/config/props/cell.js");require("../../libs/config/props/cellGroup.js");require("../../libs/config/props/checkbox.js");require("../../libs/config/props/checkboxGroup.js");require("../../libs/config/props/circleProgress.js");require("../../libs/config/props/code.js");require("../../libs/config/props/codeInput.js");require("../../libs/config/props/col.js");require("../../libs/config/props/collapse.js");require("../../libs/config/props/collapseItem.js");require("../../libs/config/props/columnNotice.js");require("../../libs/config/props/countDown.js");require("../../libs/config/props/countTo.js");require("../../libs/config/props/datetimePicker.js");require("../../libs/config/props/divider.js");require("../../libs/config/props/empty.js");require("../../libs/config/props/form.js");require("../../libs/config/props/formItem.js");require("../../libs/config/props/gap.js");require("../../libs/config/props/grid.js");require("../../libs/config/props/gridItem.js");require("../../libs/config/props/icon.js");require("../../libs/config/props/image.js");require("../../libs/config/props/indexAnchor.js");require("../../libs/config/props/indexList.js");require("../../libs/config/props/input.js");require("../../libs/config/props/keyboard.js");require("../../libs/config/props/line.js");require("../../libs/config/props/lineProgress.js");require("../../libs/config/props/link.js");require("../../libs/config/props/list.js");require("../../libs/config/props/listItem.js");require("../../libs/config/props/loadingIcon.js");require("../../libs/config/props/loadingPage.js");require("../../libs/config/props/loadmore.js");require("../../libs/config/props/modal.js");require("../../libs/config/props/navbar.js");require("../../libs/config/color.js");require("../../libs/config/props/noNetwork.js");require("../../libs/config/props/noticeBar.js");require("../../libs/config/props/notify.js");require("../../libs/config/props/numberBox.js");require("../../libs/config/props/numberKeyboard.js");require("../../libs/config/props/overlay.js");require("../../libs/config/props/parse.js");require("../../libs/config/props/picker.js");require("../../libs/config/props/popup.js");require("../../libs/config/props/radio.js");require("../../libs/config/props/radioGroup.js");require("../../libs/config/props/rate.js");require("../../libs/config/props/readMore.js");require("../../libs/config/props/row.js");require("../../libs/config/props/rowNotice.js");require("../../libs/config/props/scrollList.js");require("../../libs/config/props/search.js");require("../../libs/config/props/section.js");require("../../libs/config/props/skeleton.js");require("../../libs/config/props/slider.js");require("../../libs/config/props/statusBar.js");require("../../libs/config/props/steps.js");require("../../libs/config/props/stepsItem.js");require("../../libs/config/props/sticky.js");require("../../libs/config/props/subsection.js");require("../../libs/config/props/swipeAction.js");require("../../libs/config/props/swipeActionItem.js");require("../../libs/config/props/swiper.js");require("../../libs/config/props/swipterIndicator.js");require("../../libs/config/props/switch.js");require("../../libs/config/props/tabbar.js");require("../../libs/config/props/tabbarItem.js");require("../../libs/config/props/tabs.js");require("../../libs/config/props/tag.js");require("../../libs/config/props/text.js");require("../../libs/config/props/textarea.js");require("../../libs/config/props/toast.js");require("../../libs/config/props/toolbar.js");require("../../libs/config/props/tooltip.js");require("../../libs/config/props/transition.js");require("../../libs/config/props/upload.js");require("../../libs/config/props/drawer.js");const h={name:"u-picker",mixins:[m.mpMixin,c.mixin,d.props],data(){return{lastIndex:[],innerIndex:[],innerColumns:[],columnIndex:0}},watch:{defaultIndex:{immediate:!0,handler(e){this.setIndexs(e,!0)}},columns:{immediate:!0,deep:!0,handler(e){this.setColumns(e)}}},emits:["close","cancel","confirm","change"],methods:{getItemText(e){return r.index.$u.test.object(e)?e[this.keyName]:e},closeHandler(){this.closeOnClickOverlay&&this.$emit("close")},cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm",{indexs:this.innerIndex,value:this.innerColumns.map((e,i)=>e[this.innerIndex[i]]),values:this.innerColumns})},changeHandler(e){const{value:i}=e.detail;let o=0,s=0;for(let n=0;n<i.length;n++){let u=i[n];if(u!==(this.lastIndex[n]||0)){s=n,o=u;break}}this.columnIndex=s;const t=this.innerColumns;this.setLastIndex(i),this.setIndexs(i),this.$emit("change",{value:this.innerColumns.map((n,u)=>n[i[u]]),index:o,indexs:i,values:t,columnIndex:s})},setIndexs(e,i){this.innerIndex=r.index.$u.deepClone(e),i&&this.setLastIndex(e)},setLastIndex(e){this.lastIndex=r.index.$u.deepClone(e)},setColumnValues(e,i){this.innerColumns.splice(e,1,i);let o=r.index.$u.deepClone(this.innerIndex);for(let s=0;s<this.innerColumns.length;s++)s>this.columnIndex&&(o[s]=0);this.setIndexs(o)},getColumnValues(e){return(async()=>await r.index.$u.sleep())(),this.innerColumns[e]},setColumns(e){console.log(e),this.innerColumns=r.index.$u.deepClone(e),this.innerIndex.length===0&&(this.innerIndex=new Array(e.length).fill(0))},getIndexs(){return this.innerIndex},getValues(){return(async()=>await r.index.$u.sleep())(),this.innerColumns.map((e,i)=>e[this.innerIndex[i]])}}};if(!Array){const e=r.resolveComponent("u-toolbar"),i=r.resolveComponent("u-loading-icon"),o=r.resolveComponent("u-popup");(e+i+o)()}const p=()=>"../u-toolbar/u-toolbar.js",I=()=>"../u-loading-icon/u-loading-icon.js",C=()=>"../u-popup/u-popup.js";Math||(p+I+C)();function g(e,i,o,s,t,n){return r.e({a:e.showToolbar},e.showToolbar?{b:r.o(n.cancel),c:r.o(n.confirm),d:r.p({cancelColor:e.cancelColor,confirmColor:e.confirmColor,cancelText:e.cancelText,confirmText:e.confirmText,title:e.title})}:{},{e:r.f(t.innerColumns,(u,l,f)=>r.e({a:e.$u.test.array(u)},e.$u.test.array(u)?{b:r.f(u,(a,q,_)=>({a:r.t(n.getItemText(a)),b:q,c:q===t.innerIndex[l]?"bold":"normal"})),c:e.$u.addUnit(e.itemHeight),d:e.$u.addUnit(e.itemHeight)}:{},{e:l})),f:`height: ${e.$u.addUnit(e.itemHeight)}`,g:t.innerIndex,h:e.immediateChange,i:`${e.$u.addUnit(e.visibleItemCount*e.itemHeight)}`,j:r.o((...u)=>n.changeHandler&&n.changeHandler(...u)),k:e.loading},e.loading?{l:r.p({mode:"circle"})}:{},{m:r.o(n.closeHandler),n:r.p({show:e.show})})}const x=r._export_sfc(h,[["render",g],["__scopeId","data-v-91b05052"],["__file","D:/vue/大健康商城/healthMall/uni_modules/uview-plus/components/u-picker/u-picker.vue"]]);wx.createComponent(x);