You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/public/assets/select-region.266d5e86.js

2 lines
198 KiB

11 months ago
import{_ as e}from"./u-loading.01f91c7b.js";import{x as i,o as l,c as d,w as n,a,l as m,n as p,f as v,t as o,b as r,F as t,d as g,i as s,a0 as u,a1 as c,$ as h,a2 as f}from"./index-ae8bbb19.js";import{r as y}from"./uni-app.es.ee1d5b08.js";import{_}from"./u-popup.d74d5514.js";import{_ as b}from"./_plugin-vue_export-helper.1b428a4d.js";import{E as V}from"./u-form.711cedfd.js";const S=b({emits:["update:modelValue","input","confirm"],props:{value:{type:Boolean,default:!1},modelValue:{type:Boolean,default:!1},list:{type:Array,default:()=>[]},border:{type:Boolean,default:!0},cancelColor:{type:String,default:"#606266"},confirmColor:{type:String,default:"#2979ff"},zIndex:{type:[String,Number],default:0},safeAreaInsetBottom:{type:Boolean,default:!1},maskCloseAble:{type:Boolean,default:!0},defaultValue:{type:Array,default:()=>[0]},mode:{type:String,default:"single-column"},valueName:{type:String,default:"value"},labelName:{type:String,default:"label"},childName:{type:String,default:"children"},title:{type:String,default:""},cancelText:{type:String,default:"取消"},confirmText:{type:String,default:"确认"},blur:{type:[Number,String],default:0}},data:()=>({popupValue:!1,defaultSelector:[0],columnData:[],selectValue:[],lastSelectIndex:[],columnNum:0,moving:!1}),watch:{value:{immediate:!0,handler(e){e&&setTimeout((()=>this.init()),10),this.popupValue=e}},modelValue:{immediate:!0,handler(e){e&&setTimeout((()=>this.init()),10),this.popupValue=e}}},computed:{uZIndex(){return this.zIndex?this.zIndex:this.$u.zIndex.popup}},methods:{pickstart(){},pickend(){},init(){this.setColumnNum(),this.setDefaultSelector(),this.setColumnData(),this.setSelectValue()},setDefaultSelector(){this.defaultSelector=this.defaultValue.length==this.columnNum?this.defaultValue:Array(this.columnNum).fill(0),this.lastSelectIndex=this.$u.deepClone(this.defaultSelector)},setColumnNum(){if("single-column"==this.mode)this.columnNum=1;else if("mutil-column"==this.mode)this.columnNum=this.list.length;else if("mutil-column-auto"==this.mode){let e=1,i=this.list;for(;i[0][this.childName];)i=i[0]?i[0][this.childName]:{},e++;this.columnNum=e}},setColumnData(){let e=[];if(this.selectValue=[],"mutil-column-auto"==this.mode){let i=this.list[this.defaultSelector.length?this.defaultSelector[0]:0];for(let l=0;l<this.columnNum;l++)0==l?(e[l]=this.list,i=i[this.childName]):(e[l]=i,i=i[this.defaultSelector[l]][this.childName])}else"single-column"==this.mode?e[0]=this.list:e=this.list;this.columnData=e},setSelectValue(){let e=null;for(let i=0;i<this.columnNum;i++){e=this.columnData[i][this.defaultSelector[i]];let l={value:e?e[this.valueName]:null,label:e?e[this.labelName]:null};e&&e.extra&&(l.extra=e.extra),this.selectValue.push(l)}},columnChange(e){let i=null,l=e.detail.value;if(this.selectValue=[],"mutil-column-auto"==this.mode){this.lastSelectIndex.map(((e,d)=>{e!=l[d]&&(i=d)})),this.defaultSelector=l;for(let e=i+1;e<this.columnNum;e++)this.columnData[e]=this.columnData[e-1][e-1==i?l[i]:0][this.childName],this.defaultSelector[e]=0;l.map(((e,i)=>{let d=this.columnData[i][l[i]],n={value:d?d[this.valueName]:null,label:d?d[this.labelName]:null};d&&void 0!==d.extra&&(n.extra=d.extra),this.selectValue.push(n)})),this.lastSelectIndex=l}else if("single-column"==this.mode){let e=this.columnData[0][l[0]],i={value:e?e[this.valueName]:null,label:e?e[this.labelName]:null};e&&void 0!==e.extra&&(i.extra=e.extra),this.selectValue.push(i)}else"mutil-column"==this.mode&&l.map(((e,i)=>{let d=this.columnData[i][l[i]],n={value:d?d[this.valueName]:null,label:d?d[this.labelName]:null};d&&void 0!==d.extra&&(n.extra=d.extra),this.selectValue.push(n)}))},close(){this.$emit("input",!1),this.$emit("update:modelValue",!1)},getResult(e=null){e&&this.$emit(e,this.selectValue),this.close()},selectHandler(){this.$emit("click")}}},[["render",function(e,h,f,b,V,S){const x=s,N=u,C=c,D=y(i("u-popup"),_);return l(),d(x,{class:"u-select"},{default:n((()=>[a(D,{blur:f.blur,maskCloseAble:f.maskCloseAble,mode:"bottom",popup:!1,modelValue:V.popupValue,"onUpdate:modelValue":h[4]||(h[4]=e=>V.popupValue=e),length:"auto",safeAr