var T=Object.defineProperty;var g=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var y=(n,a,e)=>a in n?T(n,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[a]=e,b=(n,a)=>{for(var e in a||(a={}))V.call(a,e)&&y(n,e,a[e]);if(g)for(var e of g(a))j.call(a,e)&&y(n,e,a[e]);return n};var x=(n,a,e)=>new Promise((m,u)=>{var v=r=>{try{s(e.next(r))}catch(o){u(o)}},h=r=>{try{s(e.throw(r))}catch(o){u(o)}},s=r=>r.done?m(r.value):Promise.resolve(r.value).then(v,h);s((e=e.apply(n,a)).next())});import{h as q,f as C,g as z}from"./index-2a45336b.js";import{u as G}from"./useForm-269e95cd.js";import{c as H}from"./lodash-es-7cb071db.js";import{a as I,b as f,o as J,c as K,w as _,e as i,u as t}from"./ant-design-vue-710243d9.js";import"./tinymce-3184e0f1.js";import"./echarts-ca5d9323.js";import"./cropper-47c8e461.js";import"./qrcode-bec2257a.js";import"./jschardet-bd496279.js";const oe={__name:"EditDialog",emits:["ok"],setup(n,{expose:a,emit:e}){const{modal:m,showModal:u,hideModal:v,showLoading:h,hideLoading:s}=q(),{formRecord:r,formData:o,formRef:k,formRules:E,resetForm:R}=G(),D=I("取消");function F(){u({type:"create",title:"新建项"})}function L(d={}){u({type:"edit",title:"编辑项"}),r.value=d,o.value=H(d)}function M(){k.value.validateFields().then(d=>x(this,null,function*(){try{h();const l=b({},d);let c=null;switch(m.value.type){case"create":c=yield C.common.create(l).catch(()=>{throw new Error});break;case"edit":c=yield C.common.update(l).catch(()=>{throw new Error});break}s(),z("http.code.success")===(c==null?void 0:c.code)&&(v(),e("ok"))}catch(l){s()}})).catch(()=>{s()})}function U(){v()}function B(){R(),s()}return a({handleCreate:F,handleEdit:L}),(d,l)=>{const c=f("a-input"),w=f("a-form-item"),O=f("a-radio-group"),A=f("a-form"),N=f("a-modal");return J(),K(N,{open:t(m).open,title:t(m).title,width:480,"confirm-loading":t(m).confirmLoading,"after-close":B,"cancel-text":D.value,onOk:M,onCancel:U},{default:_(()=>[i(A,{ref_key:"formRef",ref:k,model:t(o),rules:t(E),"label-col":{style:{width:"90px"}}},{default:_(()=>[i(w,{label:"名称",name:"name"},{default:_(()=>[i(c,{value:t(o).name,"onUpdate:value":l[0]||(l[0]=p=>t(o).name=p)},null,8,["value"])]),_:1}),i(w,{label:"唯一值",name:"key"},{default:_(()=>[i(c,{value:t(o).key,"onUpdate:value":l[1]||(l[1]=p=>t(o).key=p)},null,8,["value"])]),_:1}),i(w,{label:"状态",name:"status"},{default:_(()=>[i(O,{value:t(o).status,"onUpdate:value":l[2]||(l[2]=p=>t(o).status=p),options:[{label:"启用",value:1},{label:"禁用",value:0}]},null,8,["value"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["open","title","confirm-loading","cancel-text"])}}};export{oe as default};
