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