import{F as I,M as d,a9 as O,a5 as T,r as P,I as V,W as L}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 R,u as U}from"./store.1703796278973.js";import{a as E}from"./institution.1703796278973.js";import{d as b,k as n,p as J,m as W,u as s,o as c,c as h,a as i,b as u,x as z,F as G,h as H,t as K,A as Q,B as X}from"./vue.1703796278973.js";const Y=b({name:"modifyModal"}),me=b({...Y,props:{formData:{type:Object,default:()=>{}},title:{type:String,defult:"新增区域"},isAdd:{type:Number,default:0},isChild:{type:Number,default:0}},emits:["refresh"],setup(k,{expose:x,emit:f}){const r=k,p=n(),j=I.useForm,_=n([]),A=n({}),m=n({}),e=n({name:"",institutionId:""}),v=n({name:[{required:!0,message:"请填写库房名称",trigger:"change"}],institutionId:[{required:!0,message:"请选择单位",trigger:"change"}]}),l=n(!1),{resetFields:C,validate:Z,validateInfos:$}=j(e.value,v.value);J(()=>{F()});const F=async()=>{const a=await E({paging:!1,sorts:[{name:"sortIndex",order:"asc"},{name:"createTime",order:"desc"}],where:"",terms:[]});a.status===200&&(_.value=a.result)},w=async()=>{p.value.validate().then(async()=>{if(m.value={},r.isAdd===0)m.value={...e.value},(await R(m.value)).status===200?(d.success("操作成功！"),l.value=!1,f("refresh")):d.error("操作失败！");else if(r.isAdd===2){const t=e.value.id||"",a={...e.value};(await U(t,a)).status===200?(d.success("操作成功！"),l.value=!1,f("refresh")):d.error("操作失败！")}})},M=async t=>{r.isAdd===0?(e.value={name:"",institutionId:""},l.value=!0):r.isAdd===2&&(A.value=t,e.value={id:t.id,name:t.name,institutionId:t.institutionId},l.value=!0)},N=()=>{l.value=!1,C()};return W([()=>r.isAdd],()=>{},{immediate:!1,deep:!0}),x({show:M}),(t,a)=>{const g=O,S=T,y=P,q=V,B=I,D=L;return s(l)?(c(),h(D,{key:0,title:r.title,maskClosable:!1,"destroy-on-close":"",visible:"",onOk:w,onCancel:N,okText:"确定",cancelText:"取消"},{default:i(()=>[u(B,{layout:"vertical",ref_key:"formRef",ref:p,rules:s(v),model:s(e)},{default:i(()=>[u(y,{label:"所属单位",name:"institutionId"},{default:i(()=>[u(S,{style:{width:"100%"},value:s(e).institutionId,"onUpdate:value":a[0]||(a[0]=o=>s(e).institutionId=o),placeholder:"请选择单位"},{default:i(()=>[(c(!0),z(G,null,H(s(_),o=>(c(),h(g,{key:o.id,value:o.id},{default:i(()=>[K(Q(o.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1}),u(y,{label:"名称",name:"name"},{default:i(()=>[u(q,{value:s(e).name,"onUpdate:value":a[1]||(a[1]=o=>s(e).name=o),maxlength:64,placeholder:"请输入名称",allowClear:""},null,8,["value"])]),_:1})]),_:1},8,["rules","model"])]),_:1},8,["title"])):X("",!0)}}});export{me as _};
