import{F as w,M as p,a9 as H,a5 as J,r as W,I as G,W as K}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import{s as Q,u as X}from"./institution.1703796278973.js";import{q as Y}from"./region.1703796278973.js";import{d as A,k as n,p as Z,m as $,u as o,o as u,c as v,a as s,b as i,x as b,F as h,h as k,t as x,A as C,B as ee}from"./vue.1703796278973.js";const ae=A({name:"modifyModal"}),fe=A({...ae,props:{formData:{type:Object,default:()=>{}},title:{type:String,defult:""},isAdd:{type:Number,default:0},isChild:{type:Number,default:0}},emits:["refresh"],setup(F,{expose:O,emit:S}){const c=F,I=n(),M=w.useForm;n([]),n([]),n([]);const N=n({});n({});const f=n({}),_=n([]),g=n([]),j=n([]);Z(()=>{T()});const T=async()=>{let l=await Y({pageIndex:0,pageSize:12,paging:!1,sorts:[{name:"sortIndex",order:"asc"},{name:"createTime",order:"desc"}],terms:[]});_.value=l.result},B=(t,l)=>{console.log("onSelectProvince:",t,l),_.value.map(r=>{r.id==t&&(g.value=r.children)})},D=(t,l)=>{console.log("onSelectCity:",t,l),g.value.map(r=>{r.id==t&&(j.value=r.children)})},e=n({name:"",city:"",region:"",province:""}),q=n({name:[{required:!0,message:"请输入单位名称",trigger:"blur"},{max:64,message:"最多可输入64个字符"}],province:[{required:!0,message:"请选择省份",trigger:"change"}],city:[{required:!0,message:"请选择城市",trigger:"change"}],region:[{required:!0,message:"请选择区域",trigger:"change"}]}),d=n(!1),{resetFields:P,validate:te,validateInfos:le}=M(e.value,q.value),R=async()=>{I.value.validate().then(async()=>{if(f.value={},console.log("submitData:",e.value),c.isAdd===0)f.value={provinceId:e.value.province,cityId:e.value.city,regionId:e.value.region,name:e.value.name},(await Q(f.value)).status===200?(p.success("操作成功！"),d.value=!1,S("refresh")):p.error("操作失败！");else if(c.isAdd===2){const t=e.value.id||"",l={...e.value};(await X(t,l)).status===200?(p.success("操作成功！"),d.value=!1,S("refresh")):p.error("操作失败！")}})},U=async t=>{c.isAdd===0?(e.value={province:"",city:"",region:"",name:""},d.value=!0):c.isAdd===2&&(N.value=t,e.value={id:t.id,province:t.province.name,city:t.city.name,region:t.region.name,name:t.name},d.value=!0)},V=()=>{d.value=!1,P()};return $([()=>c.isAdd],()=>{},{immediate:!1,deep:!0}),O({show:U}),(t,l)=>{const r=H,y=J,m=W,L=G,z=w,E=K;return o(d)?(u(),v(E,{key:0,title:c.title,maskClosable:!1,"destroy-on-close":"",visible:"",onOk:R,onCancel:V,okText:"确定",cancelText:"取消"},{default:s(()=>[i(z,{layout:"vertical",ref_key:"formRef",ref:I,rules:o(q),model:o(e)},{default:s(()=>[i(m,{label:"省份",name:"province"},{default:s(()=>[i(y,{style:{width:"100%"},value:o(e).province,"onUpdate:value":l[0]||(l[0]=a=>o(e).province=a),placeholder:"请选省份",allowClear:"",onSelect:B},{default:s(()=>[(u(!0),b(h,null,k(o(_),a=>(u(),v(r,{key:a.id,value:a.id},{default:s(()=>[x(C(a.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1}),i(m,{label:"城市",name:"city"},{default:s(()=>[i(y,{style:{width:"100%"},value:o(e).city,"onUpdate:value":l[1]||(l[1]=a=>o(e).city=a),placeholder:"请选择城市",allowClear:"",onSelect:D},{default:s(()=>[(u(!0),b(h,null,k(o(g),a=>(u(),v(r,{key:a.id,value:a.id},{default:s(()=>[x(C(a.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1}),i(m,{label:"区域",name:"region"},{default:s(()=>[i(y,{style:{width:"100%"},value:o(e).region,"onUpdate:value":l[2]||(l[2]=a=>o(e).region=a),placeholder:"请选择区域",allowClear:""},{default:s(()=>[(u(!0),b(h,null,k(o(j),a=>(u(),v(r,{key:a.id,value:a.id},{default:s(()=>[x(C(a.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1}),i(m,{label:"单位名称",name:"name"},{default:s(()=>[i(L,{value:o(e).name,"onUpdate:value":l[3]||(l[3]=a=>o(e).name=a),maxlength:64,placeholder:"请输入单位名称"},null,8,["value"])]),_:1})]),_:1},8,["rules","model"])]),_:1},8,["title"])):ee("",!0)}}});export{fe as _};
