index-e7199279.js 2.1 KB

1
  1. import{c as O,ab as b,b as C,aa as _,d as E,r as y,e as V,w as P,X as N,a as S,ad as k,h as A,k as T}from"./index-4498bb4b.js";import{p as x,P as I}from"./index-71f03d2a.js";const p="000000",M=["title","cancel","confirm","toolbar","columns-top","columns-bottom"],j=["title","loading","readonly","optionHeight","swipeDuration","visibleOptionNum","cancelButtonText","confirmButtonText"],l=(a="",s=p,e=void 0)=>({text:a,value:s,children:e});function R({areaList:a,columnsNum:s,columnsPlaceholder:e}){const{city_list:n={},county_list:r={},province_list:f={}}=a,m=+s>1,u=+s>2,v=()=>{if(m)return e.length?[l(e[0],p,u?[]:void 0)]:[]},t=new Map;Object.keys(f).forEach(o=>{t.set(o.slice(0,2),l(f[o],o,v()))});const i=new Map;if(m){const o=()=>{if(u)return e.length?[l(e[1])]:[]};Object.keys(n).forEach(c=>{const d=l(n[c],c,o());i.set(c.slice(0,4),d);const g=t.get(c.slice(0,2));g&&g.children.push(d)})}u&&Object.keys(r).forEach(o=>{const c=i.get(o.slice(0,4));c&&c.children.push(l(r[o],o))});const h=Array.from(t.values());if(e.length){const o=u?[l(e[2])]:void 0,c=m?[l(e[1],p,o)]:void 0;h.unshift(l(e[0],p,c))}return h}const[D,H]=O("area"),w=b({},x,{modelValue:String,columnsNum:C(3),columnsPlaceholder:_(),areaList:{type:Object,default:()=>({})}});var B=E({name:D,props:w,emits:["change","confirm","cancel","update:modelValue"],setup(a,{emit:s,slots:e}){const n=y([]),r=y(),f=V(()=>R(a)),m=(...t)=>s("change",...t),u=(...t)=>s("cancel",...t),v=(...t)=>s("confirm",...t);return P(n,t=>{const i=t.length?t[t.length-1]:"";i&&i!==a.modelValue&&s("update:modelValue",i)},{deep:!0}),P(()=>a.modelValue,t=>{if(t){const i=n.value.length?n.value[n.value.length-1]:"";t!==i&&(n.value=[`${t.slice(0,2)}0000`,`${t.slice(0,4)}00`,t].slice(0,+a.columnsNum))}else n.value=[]},{immediate:!0}),N({confirm:()=>{var t;return(t=r.value)==null?void 0:t.confirm()},getSelectedOptions:()=>{var t;return((t=r.value)==null?void 0:t.getSelectedOptions())||[]}}),()=>S(I,A({ref:r,modelValue:n.value,"onUpdate:modelValue":t=>n.value=t,class:H(),columns:f.value,onChange:m,onCancel:u,onConfirm:v},k(a,j)),k(e,M))}});const F=T(B);export{F as A};