import{F as b,M as m,I as M,r as T,W as q}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{s as B,u as O}from"./region.1703796278973.js";import{d as g,k as t,m as U,u as l,o as w,c as D,a as u,b as r,B as P}from"./vue.1703796278973.js";const R=g({name:"modifyModal"}),Q=g({...R,props:{formData:{type:Object,default:()=>{}},title:{type:String,defult:"新增区域"},isAdd:{type:Number,default:0},isChild:{type:Number,default:0}},emits:["refresh"],setup(x,{expose:I,emit:p}){const o=x,v=t(),y=b.useForm;t([]),t([]),t([]);const h=t({});t({});const c=t({}),e=t({name:"",sortIndex:null,describe:"",city:"",region:""}),_=t({province:[{required:!0,message:"请选择省份",trigger:"change"}],city:[{required:!0,message:"请选择城市",trigger:"change"}],region:[{required:!0,message:"请选择区域",trigger:"change"}]}),n=t(!1),{resetFields:C,validate:V,validateInfos:J}=y(e.value,_.value),k=async()=>{v.value.validate().then(async()=>{if(c.value={},o.isAdd===0)c.value={...e.value,sortIndex:Number(e.value.sortIndex)},(await B(c.value)).status===200?(m.success("操作成功！"),n.value=!1,p("refresh")):m.error("操作失败！");else if(o.isAdd===2){const a=e.value.id||"",s={...e.value,sortIndex:Number(e.value.sortIndex)};delete s.parentId,(await O(a,s)).status===200?(m.success("操作成功！"),n.value=!1,p("refresh")):m.error("操作失败！")}})},j=async a=>{o.isAdd===0?(e.value={parentId:a.id||"",name:"",sortIndex:null,describe:""},n.value=!0):o.isAdd===2&&(h.value=a,e.value={parentId:a.parentId,id:a.id,name:a.name,sortIndex:a.sortIndex,describe:a.describe},n.value=!0)},A=()=>{n.value=!1,C()};return U([()=>o.isAdd],()=>{},{immediate:!1,deep:!0}),I({show:j}),(a,s)=>{const i=M,f=T,N=b,F=q;return l(n)?(w(),D(F,{key:0,title:o.title,maskClosable:!1,"destroy-on-close":"",visible:"",onOk:k,onCancel:A,okText:"确定",cancelText:"取消"},{default:u(()=>[r(N,{layout:"vertical",ref_key:"formRef",ref:v,rules:l(_),model:l(e)},{default:u(()=>[r(f,{label:"名称",name:"name"},{default:u(()=>[r(i,{value:l(e).name,"onUpdate:value":s[0]||(s[0]=d=>l(e).name=d),maxlength:64,placeholder:"请输入名称",allowClear:""},null,8,["value"])]),_:1}),r(f,{label:"序号",name:"sortIndex"},{default:u(()=>[r(i,{value:l(e).sortIndex,"onUpdate:value":s[1]||(s[1]=d=>l(e).sortIndex=d),maxlength:64,placeholder:"请输入序号",allowClear:""},null,8,["value"])]),_:1}),r(f,{label:"备注"},{default:u(()=>[r(i,{value:l(e).describe,"onUpdate:value":s[2]||(s[2]=d=>l(e).describe=d),maxlength:64,placeholder:"请输入备注",allowClear:""},null,8,["value"])]),_:1})]),_:1},8,["rules","model"])]),_:1},8,["title"])):P("",!0)}}});export{Q as _};
