2 lines
7.6 KiB
JavaScript
2 lines
7.6 KiB
JavaScript
|
import{_ as e}from"./u-input.46b72faa.js";import{d as a,r as l,a as t,b6 as i,aa as r,b7 as s,p as d,q as o,h as c,i as u,w as n,j as p,J as m,H as v,K as f,l as _,k as b,E as y,F as h,G as x,v as g,t as k,ao as j,o as V,b8 as C,c as P,m as $,b9 as w,ba as q,$ as A,Y as U}from"./index-849cf30e.js";import{_ as E,a as I}from"./u-form.4f9a45b5.js";import{_ as R}from"./u-switch.2489393e.js";import{_ as T}from"./u-button.9fa3f2a0.js";import{_ as Y}from"./u-popup.e01742d2.js";import"./u-icon.e3aa4770.js";import"./_plugin-vue_export-helper.1b428a4d.js";import"./u-line.19eb5c40.js";import"./u-loading-icon.d012ecbf.js";import"./u-transition.75065529.js";import"./u-safe-bottom.2f6af56c.js";const z=a({__name:"area-select",props:{areaId:{type:Number,default:0}},emits:["complete"],setup(e,{expose:a,emit:V}){const C=e,P=l(!1),$=t({province:[],city:[],district:[]}),w=l("province"),q=t({province:null,city:null,district:null});i(0).then((({data:e})=>{$.province=e})).catch(),r((()=>C.areaId),((e,a)=>{e&&!a&&s(e).then((({data:e})=>{e.province&&(q.province=e.province),e.city&&(q.city=e.city),e.district&&(q.district=e.district)})).catch()})),r((()=>q.province),(()=>{i(q.province.id).then((({data:e})=>{if($.city=e,w.value="city",q.city){let a=!1;for(let l=0;l<e.length;l++)if(q.city.id==e[l].id){a=!0;break}a||(q.city=null)}})).catch()}),{deep:!0}),r((()=>q.city),(e=>{e?i(q.city.id).then((({data:e})=>{if($.district=e,w.value="district",q.district){let a=!1;for(let l=0;l<e.length;l++)if(q.district.id==e[l].id){a=!0;break}a||(q.district=null)}})).catch():($.district=[],q.district=null)}),{deep:!0}),r((()=>q.district),(e=>{e&&(w.value="district",V("complete",q),P.value=!1)}),{deep:!0});return a({open:()=>{P.value=!0}}),(e,a)=>{const l=k,t=j,i=d(o("u-popup"),Y);return c(),u(i,{show:P.value,onClose:a[3]||(a[3]=e=>P.value=!1),mode:"bottom",round:10,closeable:!0},{default:n((()=>[p(l,{class:"text-center p-[30rpx]"},{default:n((()=>[m("请选择地区")])),_:1}),p(l,{class:"flex p-[30rpx] text-sm font-semibold"},{default:n((()=>[$.province.length?(c(),u(l,{key:0,class:v(["pr-[50rpx]",{"text-[red]":"province"==w.value}]),onClick:a[0]||(a[0]=e=>w.value="province")},{default:n((()=>[q.province?(c(),u(l,{key:0},{default:n((()=>[m(f(q.province.name),1)])),_:1})):(c(),u(l,{key:1},{default:n((()=>[m("请选择")])),_:1}))])),_:1},8,["class"])):_("v-if",!0),$.city.length?(c(),u(l,{key:1,class:v(["pr-[50rpx]",{"text-[red]":"city"==w.value}]),onClick:a[1]||(a[1]=e=>w.value="city")},{default:n((()=>[q.city?(c(),u(l,{key:0},{default:n((()=>[m(f(q.city.name),1)])),_:1})):(c(),u(l,{key:1},{default:n((()=>[m("请选择")])),_:1}))])),_:1},8,["class"])):_("v-if",!0),$.district.length?(c(),u(l,{key:2,class:v(["pr-[50rpx]",{"text-[red]":"district"==w.value}]),onClick:a[2]||(a[2]=e=>w.value="district")},{default:n((()=>[q.district?(c(),u(l,{key:0},{default:n((()=>[m(f(q.district.name),1)])),_:1})):(c(),u(l,{key:1},{default:n((()=>[m("请选择")])),_:1}))])),_:1},8,["class"])):_("v-if",!0)])),_:1}),p(t,{"scroll-y":"true",class:"h-[50vh]"},{default:n((()=>[p(l,{class:"flex p-[30rpx] pt-0 text-sm"},{default:n((()=>[$.province.length?b((c(),u(l,{key:0},{default:n((()=>[(c(!0),y(h,null,x($.province,(e=>(c(),u(l,{class:v(["leading-loose",{"text-[red]":q.province&&q.province.id==e.id}]),onClick:a=>q.province=e},{default:n((()=>[m(f(e.name),1)])),_:2},1032,["class","onClick"])))),256))])),_:1},512)),[[g,"province"==w.value]]):_("v-if",!0),$.city.length?b((c(),u(l,{key:1},{default:n((()=>[(c(!0),y(h,null,x($.city,(e=>(c(),u(l,{class:v(["leading-loose",{"text-[red]":q.city&&q.city.id==e.id}]),onClick:a=>q.city=e},{default:n((()=>[m(f(e.name),1)])),_:2},1032,["class","onClick"])))),256))])),_:1},512)),[[g,"city"==w.value]]):_("v-if",!0),$.district.length?b((c(),u(l,{key:2},{default:n((()=>[(c(!0),y(h,null,x($.district,(e=>(c(),u(l,{class:v(["leading-loose",{"text-[red]":q.district&&q.district.id==e.id}]),onClick:a=>q.district=e},{default:n((()=>[m(f(e.name),1)])),_:2},1032,["class","onClick"])))),256))])),_:1},512)),[[g,"district"==w.value]]):_("v-if",!0)])),_:1})])),_:1})])),_:1
|