import{_ as e,r as l,d as n,e as a,F as d,l as i,h as o,f as t,k as s,n as r,am as c,j as h,an as u,bz as m,a2 as g,a7 as p,w as f,g as v,E as _,bf as C,q as k}from"./index.286e9b79.js";import{v as V}from"./loading.c49775a6.js";import{E as b}from"./dialog.ec9503d2.js";import"./overlay.2c1583ac.js";import{g as y,p as j}from"./http.f588794f.js";/* empty css                       */import{E as x,a as I}from"./checkbox.f06171a4.js";const E={class:"region-item"},U=e({__name:"area",props:{modelValue:Boolean,region:{type:Array,default:[]}},emits:["update:modelValue","select"],setup(e,{emit:g}){const p=e,f=g;let v=l([]);const _=()=>{let e=p.region,l=[];for(let n=0;n<e.length;n++){let a=e[n];if(!a.isChecked)continue;if(l.push(a.id),a.children.length<=0)continue;let d=a.children;for(let e=0;e<d.length;e++){if(!d[e].isChecked)continue;if(l.push(d[e].id),d[e].children<=0)continue;let n=d[e].children;for(let e=0;e<n.length;e++)n[e].isChecked&&l.push(n[e].id)}}f("select",l)},C=(e,l)=>{e.isChecked=l,e.isChildren=l,e.chosen=l?e._chosen:[],e.children&&e.children.length>0&&V(e.children,l),k(p.region,e.pid),_()},k=(e,l)=>{e&&e.forEach((e=>{let n=0,a=0;e.id==l?(e.chosen=[],e.children.forEach((l=>{l.isIndeterminate?a++:l.isChecked&&(n++,e.chosen.push(l.id))})),e.isChecked=n===e._chosen.length,e.isIndeterminate=(a>0||n>0)&&n<e._chosen.length,0!=e.isChecked&&k(p.region,e.pid)):k(e.children,l)}))},V=(e,l)=>{e.forEach((e=>{e.isChecked=l,e.isChildren=l,e.chosen=l?e._chosen:[],e.children&&e.children.length>0&&V(e.children,l)}))};return(e,l)=>{const g=x,f=I;return n(),a("div",null,[(n(!0),a(d,null,i(p.region,((e,l)=>(n(),a("div",{key:l},[o("div",E,[t(g,{label:e.id,modelValue:e.isChecked,"onUpdate:modelValue":l=>e.isChecked=l,indeterminate:e.isIndeterminate,onChange:l=>((e,l)=>{e.isChecked=l,e.isIndeterminate=!1,e.chosen=l?e._chosen:[],l?m(e.id,v.value)||v.value.push(e.id):m(e.id,v.value)&&(v.value=v.value.filter((l=>l!=e.id))),e.children&&e.children.length>0&&V(e.children,l),_()})(e,l)},{default:s((()=>[r(c(e.name),1)])),_:2},1032,["label","modelValue","onUpdate:modelValue","indeterminate","onChange"])]),e.isChildren?(n(),h(f,{key:0,modelValue:e.chosen,"onUpdate:modelValue":l=>e.chosen=l},{default:s((()=>[(n(!0),a(d,null,i(e.children,((e,l)=>(n(),a(d,{key:l},[t(g,{class:"region-children-wrap",onChange:l=>C(e,l),label:e.id},{default:s((()=>[r(c(e.name),1)])),_:2},1032,["onChange","label"]),e.isChildren?(n(),h(f,{key:0,modelValue:e.chosen,"onUpdate:modelValue":l=>e.chosen=l,class:"region-children-box"},{default:s((()=>[(n(!0),a(d,null,i(e.children,((e,l)=>(n(),h(g,{class:"region-children",key:l,onChange:l=>C(e,l),label:e.id},{default:s((()=>[r(c(e.name),1)])),_:2},1032,["onChange","label"])))),128))])),_:2},1032,["modelValue","onUpdate:modelValue"])):u("",!0)],64)))),128))])),_:2},1032,["modelValue","onUpdate:modelValue"])):u("",!0)])))),128))])}}},[["__scopeId","data-v-6463400f"]]),w={class:"album-header"},z=["id"],B={class:"region-content"},q={class:"tree-left"},A={class:"region-btn"},F=e({__name:"region",props:{modelValue:Boolean},emits:["update:modelValue","select"],setup(e,{emit:d}){const i=e;let c=l(!1),u=l(!1);const m=d;let x=l([]);g((()=>i.modelValue),(e=>{e&&x.value.length<=0&&(c.value=!0,y("common/get_region").then((e=>{e.code&&(x.value=I(e.data,0)),c.value=!1})))}));const I=(e,l)=>e.length<=0?[]:(e.map((e=>{e.isChildren=l<=0,e.isChecked=!1,e.isIndeterminate=!1,e.chosen=[],e._chosen=[],e.level=l,e.children&&e.children.length>0&&(e.children.map((l=>{e._chosen.push(l.id)})),I(e.children,l+1))})),e);let E=l([]);const F=e=>{E.value=e},S=()=>{E.value.length<=0?_.error("请选择地区"):j("common/get_region_children",{id:E.value}).then((e=>{e.code?(m("select",e.data),m("update:modelValue",!1)):_.error(e.msg)}))},D=()=>{m("update:modelValue",!1)};return(e,l)=>{const d=C,m=k,g=b,_=V;return n(),a("div",null,[t(g,{"model-value":i.modelValue,width:"1000",style:{"border-radius":"10px"},"align-center":!0,onClose:D,title:"选择区域"},{header:s((({titleId:e,titleClass:l})=>[o("div",w,[o("h4",{id:e,class:p(l),style:{"font-size":"15px","font-weight":"normal"}},"选择区域",10,z)])])),default:s((()=>[o("div",B,[o("div",q,[f((n(),h(d,{height:"400px"},{default:s((()=>[t(U,{"model-value":v(u),region:v(x),onSelect:F},null,8,["model-value","region"])])),_:1})),[[_,v(c)]])])]),o("div",A,[t(m,{onClick:D},{default:s((()=>[r("取消")])),_:1}),t(m,{onClick:S,type:"primary"},{default:s((()=>[r("确认")])),_:1})])])),_:1},8,["model-value"])])}}},[["__scopeId","data-v-91f3e2ef"]]);export{F as _};
