import{b as F,k as B,o as c,h as b,A as v,c as P,r as T,l as w,t as q,F as L,p as f,e as I,x as N,f as r,aM as O,E as j,a as V,Z as x,j as E}from"./index.4d3e3847.js";import{B as A}from"./basic-form.114da3ff.js";const M={modalConfig:{type:Object,required:!0},prviewDescription:{type:Boolean,default:!1},defaultInfo:{type:Object,required:!0}},R={config:{type:Object,required:!0},defaultInfo:{type:Object,required:!0}},U=F({__name:"description",props:R,setup(s){return(d,g)=>{const n=B("el-descriptions-item"),l=B("el-descriptions");return c(),b(l,{column:1,border:""},{default:v(()=>[(c(!0),P(L,null,T(d.config.formItems,(e,i)=>(c(),b(n,{key:i,label:e.label,align:"center"},{default:v(()=>[w(q(d.defaultInfo[e.field]),1)]),_:2},1032,["label"]))),128))]),_:1})}}}),$={update:"\u7F16\u8F91",create:"\u65B0\u589E",preview:"\u8BE6\u60C5"};function S(s){return $[s]}const G={key:2,class:"flex justify-end"},H=F({__name:"page-modal",props:M,emits:["confirmBtnClick"],setup(s,{expose:d,emit:g}){const n=s,l=f({}),e=f("preview"),i=f(null),m=f(!1),y=f(!1),p=I(()=>e.value==="preview"),h=I(()=>{const a=S(e.value);return e.value==="preview"?n.modalConfig.title+a:a+n.modalConfig.title}),u=I(()=>n.modalConfig.width);function _(a,t){for(const o of a)switch(o.type){case"checkbox":l.value[o.field]=t[o.field]?t[o.field].split(","):[];break;case"img_upload_list":l.value[o.field]=t[o.field]?t[o.field]:[];break;case"number":l.value[o.field]=t[o.field]?t[o.field]:0;break;default:l.value[o.field]=t[o.field]?t[o.field]:"";break}}N(()=>n.defaultInfo,a=>{const{formGroup:t,formItems:o}=n.modalConfig;if(!t)return _(o,a);t.forEach(D=>_(D.formItems,a))});function C(){i.value.validate(a=>{a&&g("confirmBtnClick",r(e),r(l))})}return d({dialogVisible:m,confirmLoading:y,type:e}),(a,t)=>{const o=B("el-button"),D=B("el-dialog");return c(),b(D,{title:r(h),modelValue:m.value,"onUpdate:modelValue":t[2]||(t[2]=k=>m.value=k),center:"","destroy-on-close":"",width:r(u)?r(u):"1024px"},{default:v(()=>[r(p)?j("",!0):(c(),b(r(A),O({key:0,ref_key:"formRef",ref:i},a.modalConfig,{"form-data":l.value,"onUpdate:form-data":t[0]||(t[0]=k=>l.value=k),disabled:r(p)}),null,16,["form-data","disabled"])),r(p)?(c(),b(U,{key:1,config:a.modalConfig,"default-info":a.defaultInfo},{default:v(()=>[V("template",null,[x(a.$slots,"default")])]),_:3},8,["config","default-info"])):j("",!0),r(p)?j("",!0):(c(),P("div",G,[E(o,{type:"primary",loading:y.value,onClick:C},{default:v(()=>[w("\u4FDD\u5B58")]),_:1},8,["loading"]),E(o,{onClick:t[1]||(t[1]=k=>m.value=!1)},{default:v(()=>[w("\u5173\u95ED")]),_:1})]))]),_:3},8,["title","modelValue","width"])}}});function J({createCallback:s,updateCallback:d,confirmCallback:g,previewCallback:n,pageContentRef:l}){const e=f(null),i=f({});function m(){i.value={},e.value.type="create",s&&s(),e.value.dialogVisible=!0}function y(u){i.value={...u},e.value.type="update",d&&d(),e.value.dialogVisible=!0}function p(u){i.value={...u},e.value.type="preview",n&&n(),e.value.dialogVisible=!0}function h(u,_){const C=g?g(_):{};e.value.confirmLoading=!0;const a={...u==="update"?{id:i.value.id}:{},...C||{},..._};l.value.onBeforeAction(u,a,()=>{e.value.confirmLoading=!1,e.value.dialogVisible=!1})}return{handleCreateData:m,handleUpdateData:y,handlePreviewData:p,handleConfrim:h,defaultInfo:i,pageModalRef:e}}export{H as _,J as u};
