var W=Object.defineProperty;var E=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var R=(i,o,e)=>o in i?W(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e,V=(i,o)=>{for(var e in o||(o={}))X.call(o,e)&&R(i,e,o[e]);if(E)for(var e of E(o))Y.call(o,e)&&R(i,e,o[e]);return i};var x=(i,o,e)=>new Promise((h,p)=>{var b=s=>{try{_(e.next(s))}catch(w){p(w)}},f=s=>{try{_(e.throw(s))}catch(w){p(w)}},_=s=>s.done?h(s.value):Promise.resolve(s.value).then(b,f);_((e=e.apply(i,o)).next())});import{u as Z,h as ee,i as ae,f as y,g as B,s as te}from"./index-2a45336b.js";import{u as oe}from"./useForm-269e95cd.js";import{u as ne}from"./useSpining-af3901ce.js";import{a as c,b as m,o as se,c as le,w as r,e as n,u as l,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 he={__name:"EditDialog",emits:["ok"],setup(i,{expose:o,emit:e}){c();const{t:h}=Z(),{modal:p,showModal:b,hideModal:f,showLoading:_,hideLoading:s}=ee(),{formRecord:w,formData:t,formRef:C,formRules:j,resetForm:F}=oe(),{spining:I,showSpining:M,hideSpining:S}=ne(),q=c(h("button.cancel")),D=c(h("button.confirm"));c([]),c([]),c("1222"),c([]),c(!1);const U=c([]);c({name:"",status:"enabled"}),j.value={name:{required:!0,message:"请输入案场名称"},status:[{required:!0,message:"请选择状态",trigger:"change"}]};function N(){b({type:"create",title:"新增案场"}),t.value.status="enabled"}function O(){return x(this,arguments,function*(d={}){b({type:"edit",title:"编辑案场"});try{M();const{data:a,success:u}=yield y.project.getItem(d.id).catch();if(!u){f();return}S(),t.value=V({},a),a.img&&(t.value.fileList=[B("http.apiBasic")+a.img])}catch(a){L.error({content:a.message}),S()}})}const T=d=>{U.value.push(d)};function A(){if(U.value.length===0)return L.error("请上传图片");C.value.validateFields().then(d=>x(this,null,function*(){try{_();const a={name:t.value.name,status:t.value.status,img:t.value.fileList?te(t.value.fileList[0]):[""]};let u=null;switch(p.value.type){case"create":u=yield y.project.createProject(a).catch(g=>{throw new Error(g)});break;case"edit":u=yield y.project.updateItem(t.value.id,a).catch(()=>{throw new Error(error)});break}s(),B("http.code.success")===(u==null?void 0:u.success)&&(f(),e("ok"))}catch(a){L.error({content:a.message}),s()}})).catch(d=>{s()})}function P(){f()}function $(){F(),s()}return o({handleCreate:N,handleEdit:O}),(d,a)=>{const u=m("a-input"),g=m("a-form-item"),k=m("a-col"),z=m("a-radio-group"),G=m("a-row"),H=m("a-card"),J=m("a-form"),K=m("a-spin"),Q=m("a-modal");return se(),le(Q,{open:l(p).open,title:l(p).title,width:640,"confirm-loading":l(p).confirmLoading,"after-close":$,"cancel-text":q.value,"ok-text":D.value,onOk:A,onCancel:P},{default:r(()=>[n(K,{spinning:l(I)},{default:r(()=>[n(J,{ref_key:"formRef",ref:C,model:l(t),rules:l(j)},{default:r(()=>[n(H,{class:"mb-8-2"},{default:r(()=>[n(G,{gutter:12},{default:r(()=>[n(k,{span:24},{default:r(()=>[n(g,{label:"案场名称",name:"name"},{default:r(()=>[n(u,{placeholder:"请输入案场名称",value:l(t).name,"onUpdate:value":a[0]||(a[0]=v=>l(t).name=v)},null,8,["value"])]),_:1})]),_:1}),n(k,{span:24},{default:r(()=>[n(g,{label:"状态",name:"status"},{default:r(()=>[n(z,{value:l(t).status,"onUpdate:value":a[1]||(a[1]=v=>l(t).status=v),options:[{label:"启用",value:"enabled"},{label:"停用",value:"disabled"}]},null,8,["value"])]),_:1})]),_:1}),n(k,{span:24},{default:r(()=>[n(g,{label:"图片"},{default:r(()=>[n(ae,{modelValue:l(t).fileList,"onUpdate:modelValue":a[2]||(a[2]=v=>l(t).fileList=v),"accept-types":".jpg,.png,.webp",fileNumber:1,onUploadSuccess:T},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["spinning"])]),_:1},8,["open","title","confirm-loading","cancel-text","ok-text"])}}};export{he as default};
