import{b as D,k as y,o as u,h as v,A as w,c as b,r as P,F as _,l as V,t as B,p as d,e as h,f as c,Z as T,E as C}from"./index.4d3e3847.js";function O(n){const t={};for(const o of n)switch(o.type){case"checkbox":case"array":case"img_upload_list":t[o.field]=[];break;case"number":t[o.field]=0;break;default:t[o.field]="";break}return t}function S(n,t,o){const a={};for(let r=0;r<n.length;r++){const{field:e,type:l}=n[r];switch(l){case"checkbox":case"array":case"img_upload_list":a[e]=t[o[e]]||t[e]||[];break;case"number":a[e]=Number(t[o[e]])||Number(t[e])||0;break;default:a[e]=t[o[e]]||t[e]||"";break}}return a}const j={modalConfig:{type:Object,required:!0},prviewDescription:{type:Boolean,default:!1},defaultInfo:{type:Object,required:!0}},q={config:{type:Object,required:!0},defaultInfo:{type:Object,required:!0}},E=D({__name:"description",props:q,setup(n){return(t,o)=>{const a=y("el-descriptions-item"),r=y("el-descriptions");return u(),v(r,{column:1,border:""},{default:w(()=>[(u(!0),b(_,null,P(t.config.formItems,(e,l)=>(u(),v(a,{key:l,label:e.label,span:e.showSpan?e.showSpan:24,width:e.labelWidth?e.labelWidth:"180px"},{default:w(()=>[e.render?(u(),b(_,{key:0},[V(B(e.render(t.defaultInfo[e.field],t.defaultInfo)),1)],64)):(u(),b(_,{key:1},[V(B(t.defaultInfo[e.field]),1)],64))]),_:2},1032,["label","span","width"]))),128))]),_:1})}}}),F={update:"\u7F16\u8F91",create:"\u65B0\u589E",preview:"\u8BE6\u60C5"};function L(n){return F[n]}const A=D({__name:"page-modal",props:j,setup(n,{expose:t}){const o=n,a=d("preview"),r=d(!1),e=d(!1),l=h(()=>a.value==="preview"),g=h(()=>{const i=L(a.value);return a.value==="preview"?o.modalConfig.title+i:i+o.modalConfig.title}),f=h(()=>o.modalConfig.width);return t({dialogVisible:r,confirmLoading:e,type:a}),(i,p)=>{const s=y("el-dialog");return u(),v(s,{title:c(g),modelValue:r.value,"onUpdate:modelValue":p[0]||(p[0]=m=>r.value=m),center:"",top:"8vh","destroy-on-close":"",width:c(f)?c(f):"1024px"},{default:w(()=>[c(l)?C("",!0):T(i.$slots,"default",{key:0}),c(l)?(u(),v(E,{key:1,config:i.modalConfig,"default-info":i.defaultInfo},null,8,["config","default-info"])):C("",!0)]),_:3},8,["title","modelValue","width"])}}});function x({createCallback:n,updateCallback:t,confirmCallback:o,previewCallback:a,pageContentRef:r}){const e=d(null),l=d({});function g(){l.value={},e.value.type="create",n&&n(),e.value.dialogVisible=!0}function f(s){l.value={...s},e.value.type="update",t&&t(),e.value.dialogVisible=!0}function i(s){l.value={...s},e.value.type="preview",a&&a(),e.value.dialogVisible=!0}function p(s,m){const k=o?o(m):{};e.value.confirmLoading=!0;const I={...s==="update"?{id:l.value.id}:{},...k||{},...m};r.value.onBeforeAction(s,I,()=>{e.value.confirmLoading=!1,e.value.dialogVisible=!1})}return{handleCreateData:g,handleUpdateData:f,handlePreviewData:i,handleConfrim:p,defaultInfo:l,pageModalRef:e}}export{A as _,O as c,S as t,x as u};
