1 |
- import{c as C,ad as _,af as h,b,ac as E,d as V,r as P,e as N,w as k,Z as S,a as A,h as T,k as x}from"./index-869d77fb.js";import{P as I,p as M}from"./index-6f985828.js";const p="000000",j=["title","cancel","confirm","toolbar","columns-top","columns-bottom"],O=["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 g=l(n[c],c,o());i.set(c.slice(0,4),g);const y=t.get(c.slice(0,2));y&&y.children.push(g)})}u&&Object.keys(r).forEach(o=>{const c=i.get(o.slice(0,4));c&&c.children.push(l(r[o],o))});const d=Array.from(t.values());if(e.length){const o=u?[l(e[2])]:void 0,c=m?[l(e[1],p,o)]:void 0;d.unshift(l(e[0],p,c))}return d}const[D,H]=C("area"),w=_({},h(M,O),{modelValue:String,columnsNum:b(3),columnsPlaceholder:E(),areaList:{type:Object,default:()=>({})}});var B=V({name:D,props:w,emits:["change","confirm","cancel","update:modelValue"],setup(a,{emit:s,slots:e}){const n=P([]),r=P(),f=N(()=>R(a)),m=(...t)=>s("change",...t),u=(...t)=>s("cancel",...t),v=(...t)=>s("confirm",...t);return k(n,t=>{const i=t.length?t[t.length-1]:"";i&&i!==a.modelValue&&s("update:modelValue",i)},{deep:!0}),k(()=>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}),S({confirm:()=>{var t;return(t=r.value)==null?void 0:t.confirm()},getSelectedOptions:()=>{var t;return((t=r.value)==null?void 0:t.getSelectedOptions())||[]}}),()=>A(I,T({ref:r,modelValue:n.value,"onUpdate:modelValue":t=>n.value=t,class:H(),columns:f.value,onChange:m,onCancel:u,onConfirm:v},h(a,O)),h(e,j))}});const F=x(B);export{F as A};
|