var Y=Object.defineProperty,Z=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var U=(s,n,o)=>n in s?Y(s,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[n]=o,x=(s,n)=>{for(var o in n||(n={}))ee.call(n,o)&&U(s,o,n[o]);if(M)for(var o of M(n))ae.call(n,o)&&U(s,o,n[o]);return s},F=(s,n)=>Z(s,$(n));var y=(s,n,o)=>new Promise((b,d)=>{var w=u=>{try{_(o.next(u))}catch(k){d(k)}},g=u=>{try{_(o.throw(u))}catch(k){d(k)}},_=u=>u.done?b(u.value):Promise.resolve(u.value).then(w,g);_((o=o.apply(s,n)).next())});import{a as te}from"./useEnum-4e87ed86.js";import{u as oe,h as ne,f as q,g as V,s as le}from"./index-2a45336b.js";import{u as re}from"./useForm-269e95cd.js";import{a as h,b as i,o as E,c as A,w as l,e as t,u as r,k as se,F as ue,D as ce,E as ie,G as me,d as de}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 qe={__name:"EditDialog",emits:["ok"],setup(s,{expose:n,emit:o}){const{t:b}=oe(),{modal:d,showModal:w,hideModal:g,showLoading:_,hideLoading:u}=ne(),{formRecord:k,formData:a,formRef:C,formRules:I,resetForm:B}=re(),D=h(b("button.cancel")),L=h(b("button.confirm"));h([]),h([]);const R=h("");I.value={name:{required:!0,message:"请输入名称"},status:[{required:!0,message:"请选择状态",trigger:"change"}],areaId:[{required:!0,message:"请选择所属区域",trigger:"change"}],sequence:[{required:!0,message:"请选择顺序",trigger:"change"}],img:[{required:!0,message:"请上传图片",trigger:"change"}],areaId:[{required:!0,message:"请选择区域",trigger:"change"}]};function N(){w({type:"create",title:"添加"}),a.value.status="enabled"}function T(){return y(this,arguments,function*(p={}){w({type:"edit",title:"编辑"});const{data:e,success:m}=yield q.imgmgt.getMenu(p.id).catch();if(console.log("====data",e),!m){g();return}a.value=x({},e),a.value.pushAt=de(e.pushAt),a.value.img=e.img?[V("http.apiBasic")+e.img]:[]})}function j(){C.value.validateFields().then(p=>y(this,null,function*(){console.log(p);try{_();const e=F(x({},p),{img:a.value.img?le(a.value.img[0]):""});let m=null;switch(console.log(d.value.type),d.value.type){case"create":m=yield q.imgmgt.createMenu(e).catch(()=>{throw new Error});break;case"edit":m=yield q.imgmgt.updateMenu(a.value.id,e).catch(()=>{throw new Error});break}u(),V("http.code.success")===(m==null?void 0:m.success)&&(g(),o("ok"))}catch(e){console.log(e),u()}})).catch(p=>{console.log(p),u()})}function O(){R.value="",g()}function G(){B(),u()}return n({handleCreate:N,handleEdit:T}),(p,e)=>{const m=i("a-input"),f=i("a-form-item"),v=i("a-col"),S=i("a-select-option"),z=i("a-select"),H=i("a-input-number"),J=i("a-radio-group"),K=i("gx-upload"),P=i("a-row"),Q=i("a-card"),W=i("a-form"),X=i("a-modal");return E(),A(X,{open:r(d).open,title:r(d).title,width:640,"confirm-loading":r(d).confirmLoading,"after-close":G,"cancel-text":D.value,"ok-text":L.value,onOk:j,onCancel:O},{default:l(()=>[t(W,{ref_key:"formRef",ref:C,model:r(a),rules:r(I)},{default:l(()=>[t(Q,{class:"mb-8-2"},{default:l(()=>[t(P,{gutter:12},{default:l(()=>[t(v,{span:24},{default:l(()=>[t(f,{label:"名称",name:"name"},{default:l(()=>[t(m,{placeholder:"请输入名称",value:r(a).name,"onUpdate:value":e[0]||(e[0]=c=>r(a).name=c)},null,8,["value"])]),_:1})]),_:1}),t(v,{span:24},{default:l(()=>[t(f,{label:"所属区域",name:"areaId"},{default:l(()=>[t(z,{ref:"select",value:r(a).areaId,"onUpdate:value":e[1]||(e[1]=c=>r(a).areaId=c),placeholder:"请输入所属区域"},{default:l(()=>[(E(!0),se(ue,null,ce(r(te).getAll(),c=>(E(),A(S,{value:c.value},{default:l(()=>[ie(me(c.name),1)]),_:2},1032,["value"]))),256))]),_:1},8,["value"])]),_:1})]),_:1}),t(v,{span:24},{default:l(()=>[t(f,{label:"顺序",name:"sequence"},{default:l(()=>[t(H,{placeholder:"请输入顺序",value:r(a).sequence,"onUpdate:value":e[2]||(e[2]=c=>r(a).sequence=c)},null,8,["value"])]),_:1})]),_:1}),t(v,{span:24},{default:l(()=>[t(f,{label:"状态",name:"status"},{default:l(()=>[t(J,{value:r(a).status,"onUpdate:value":e[3]||(e[3]=c=>r(a).status=c),options:[{label:"启用",value:"enabled"},{label:"停用",value:"disabled"}]},null,8,["value"])]),_:1})]),_:1}),t(v,{span:24},{default:l(()=>[t(f,{label:"图片",name:"img"},{default:l(()=>[t(K,{modelValue:r(a).img,"onUpdate:modelValue":e[4]||(e[4]=c=>r(a).img=c),"accept-types":".jpg,.png,.webp",fileNumber:1},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["open","title","confirm-loading","cancel-text","ok-text"])}}};export{qe as default};
