var Q=Object.defineProperty;var U=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var F=(u,o,e)=>o in u?Q(u,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[o]=e,k=(u,o)=>{for(var e in o||(o={}))W.call(o,e)&&F(u,e,o[e]);if(U)for(var e of U(o))X.call(o,e)&&F(u,e,o[e]);return u};var x=(u,o,e)=>new Promise((v,m)=>{var h=r=>{try{_(e.next(r))}catch(w){m(w)}},f=r=>{try{_(e.throw(r))}catch(w){m(w)}},_=r=>r.done?v(r.value):Promise.resolve(r.value).then(h,f);_((e=e.apply(u,o)).next())});import{u as Y,h as Z,f as y,g as $}from"./index-2a45336b.js";import{u as ee}from"./useForm-269e95cd.js";import{u as ae}from"./useSpining-af3901ce.js";import{a as I,b as i,o as te,c as oe,w as l,e as t,u as n,aa as L}from"./ant-design-vue-710243d9.js";import"./tinymce-3184e0f1.js";import"./echarts-ca5d9323.js";import"./cropper-47c8e461.js";import"./lodash-es-7cb071db.js";import"./qrcode-bec2257a.js";import"./jschardet-bd496279.js";const _e={__name:"EditDialog",emits:["ok"],setup(u,{expose:o,emit:e}){const{t:v}=Y(),{modal:m,showModal:h,hideModal:f,showLoading:_,hideLoading:r}=Z(),{formRecord:w,formData:s,formRef:C,formRules:q,resetForm:M}=ee(),{spining:S,showSpining:B,hideSpining:E}=ae(),D=I(v("button.cancel")),O=I(v("button.confirm"));q.value={name:{required:!0,message:"请输入区域名称"},lon:{required:!0,message:"请输入经度"},lat:{required:!0,message:"请输入纬度"},status:[{required:!0,message:"请选择状态",trigger:"change"}]};function T(){h({type:"create",title:"新增区域"}),s.value.status="enabled"}function j(){return x(this,arguments,function*(g={}){h({type:"edit",title:"编辑区域"});try{B();const{data:a,success:c}=yield y.area.getItem(g.id).catch();if(!c){f();return}E(),s.value=k({},a)}catch(a){L.error({content:a.message}),E()}})}function A(){C.value.validateFields().then(g=>x(this,null,function*(){try{_();const a=k({},g);let c=null;switch(m.value.type){case"create":c=yield y.area.createProject(a).catch(p=>{throw new Error(p)});break;case"edit":c=yield y.area.updateItem(s.value.id,a).catch(()=>{throw new Error(error)});break}r(),$("http.code.success")===(c==null?void 0:c.success)&&(f(),e("ok"))}catch(a){L.error({content:a.message}),r()}})).catch(g=>{r()})}function N(){f()}function P(){M(),r()}return o({handleCreate:T,handleEdit:j}),(g,a)=>{const c=i("a-input"),p=i("a-form-item"),b=i("a-col"),R=i("a-input-number"),V=i("a-radio-group"),z=i("a-row"),G=i("a-card"),H=i("a-form"),J=i("a-spin"),K=i("a-modal");return te(),oe(K,{open:n(m).open,title:n(m).title,width:640,"confirm-loading":n(m).confirmLoading,"after-close":P,"cancel-text":D.value,"ok-text":O.value,onOk:A,onCancel:N},{default:l(()=>[t(J,{spinning:n(S)},{default:l(()=>[t(H,{ref_key:"formRef",ref:C,model:n(s),rules:n(q)},{default:l(()=>[t(G,{class:"mb-8-2"},{default:l(()=>[t(z,{gutter:12},{default:l(()=>[t(b,{span:24},{default:l(()=>[t(p,{label:"区域",name:"name"},{default:l(()=>[t(c,{placeholder:"请输入区域",value:n(s).name,"onUpdate:value":a[0]||(a[0]=d=>n(s).name=d)},null,8,["value"])]),_:1})]),_:1}),t(b,{span:24},{default:l(()=>[t(p,{label:"经度",name:"lon"},{default:l(()=>[t(R,{placeholder:"请输入经度",style:{width:"100%"},precision:2,value:n(s).lon,"onUpdate:value":a[1]||(a[1]=d=>n(s).lon=d)},null,8,["value"])]),_:1})]),_:1}),t(b,{span:24},{default:l(()=>[t(p,{label:"纬度",name:"lat"},{default:l(()=>[t(R,{placeholder:"请输入纬度",style:{width:"100%"},precision:2,value:n(s).lat,"onUpdate:value":a[2]||(a[2]=d=>n(s).lat=d)},null,8,["value"])]),_:1})]),_:1}),t(b,{span:24},{default:l(()=>[t(p,{label:"状态",name:"status"},{default:l(()=>[t(V,{value:n(s).status,"onUpdate:value":a[3]||(a[3]=d=>n(s).status=d),options:[{label:"启用",value:"enabled"},{label:"停用",value:"disabled"}]},null,8,["value"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["spinning"])]),_:1},8,["open","title","confirm-loading","cancel-text","ok-text"])}}};export{_e as default};
