import{dd as M,Z as c,d as S,j as u,df as O,r as d,ay as U,a4 as F,aj as _,N as w,ai as V,am as R,dY as $,aw as q,aq as B,c as z,o as A,w as p,W as E,i as g,H,cf as W,l as x,k as X,B as Y,p as j,e3 as Z,X as G}from"./index-9PRMimni.js";import{c as J}from"./componentMap-CElCaWis.js";const K={...M,addTemplate:{type:Object,required:!0},dataSource:{type:[Object],default:()=>[]},columns:{type:[Array],default:()=>[],required:!0},isPopconfirm:{type:Boolean,default:!0},popconfirmProps:{type:Object,default:()=>{}}},L=({component:a="NInput"},{attrs:r})=>{const m=J.get(a);return c(m,r)},Q=S({name:"DeleteIncon",emits:[],setup(a,{slots:r}){return()=>u(O,null,r)}}),ee=S({name:"FormTable",props:K,emits:["on-add","on-remove"],setup(a,{emit:r,slots:m,expose:f}){const n=d([]),v=d([]);U(()=>a.columns,()=>{s()},{immediate:!0,deep:!0});const b=F(()=>v.value.filter(e=>e.hidden!==!0));function y(){n.value.push(_(a.addTemplate)),r("on-add",n.value)}function l(e){n.value.splice(e,1),r("on-remove",n.value)}function s(){const e=_(a.columns);e.forEach(t=>{(t.component||t.slots)&&(t.render=t.slots?k(t):h(t))}),e.unshift({key:"custom",width:30,title(){return c(w,{component:R,size:20,class:"cursor-pointer",onClick:y})},render(t,o){return a.isPopconfirm?c(Q,{onPositiveClick:l.bind(null,o),...a.popconfirmProps},{trigger:()=>c(w,{component:V,size:20,class:"cursor-pointer"}),default:()=>"您确定要删除吗？"}):c(w,{component:V,size:20,class:"cursor-pointer",onClick:l.bind(null,o)})}}),v.value=e}const C=(e,t)=>o=>{n.value[t][e.key]=o};function k(e){return(t,o)=>{const i=n.value[o];return $(m,e.slots,{rowData:i,columnData:e,index:o})}}function h(e){return(t,o)=>{const i=_(e);i.value=n.value[o][e.key]||null,i.onUpdateValue=C(i,o);const I=Object.assign(i,{component:i.component},e.componentProps);return c(L,I)}}function D(){const e=_(a.addTemplate);n.value.push(e)}function T(){return n.value}function N(e){n.value=e}function P(){n.value=[_(a.addTemplate)]}return f({getTableData:T,setTableData:N,resetTableData:P}),q(()=>{s(),D()}),()=>u(B,{columns:b.value,data:n.value},null)}}),te={class:"pl-2 mb-6"},ne={class:"mt-6"},oe={class:"mt-6"},se=S({__name:"formTable",setup(a){const r=d([]),m=d(!0),f=d([{title:"姓名",key:"name",component:"NInput"},{title:"手机号码",key:"mobile",component:"NInput",slots:"mobile"},{title:"性别",key:"gender",width:150,component:"NSelect",componentProps:{placeholder:"请选择类型",options:[{label:"男",value:1},{label:"女",value:2}]}},{title:"年龄",key:"age",component:"NInputNumber",hidden:m},{key:"makeDate",title:"预约时间",component:"NDatePicker"},{key:"firstMake",title:"首次预约",component:"NSwitch"}]),n=d([{title:"姓名",key:"name"},{title:"手机号码",key:"mobile"},{title:"性别",key:"gender",width:150,render(l){return c("span",{},{default:()=>l.gender===1?"男":l.gender===2?"女":""})}},{title:"年龄",key:"age"},{key:"makeDate",title:"预约时间"},{key:"firstMake",title:"首次预约",render(l){return c("span",{},{default:()=>l.firstMake?"是":"否"})}}]),v={name:"",mobile:"",type:"",age:"",makeDate:"",firstMake:!1},b=d();function y(){const l=b.value.getTableData();console.log("🚀 ~ file: formTableRef.VUE ~ line 117 ~ handelSave ~ formValues",l),r.value=l}return(l,s)=>{const C=W,k=H,h=X,D=Y,T=Z,N=B,P=E,e=G;return A(),z(e,{title:"表单表格",content:"主要用在承载批量提交表单集合",showFooter:""},{default:p(()=>[u(P,{bordered:!1,class:"mt-3 proCard",title:"基础使用","content-style":"padding-top: 0;"},{default:p(()=>[g("div",te,[u(k,null,{default:p(()=>[s[1]||(s[1]=g("span",null,"隐藏年龄",-1)),u(C,{value:m.value,"onUpdate:value":s[0]||(s[0]=t=>m.value=t)},null,8,["value"])]),_:1})]),u(x(ee),{ref_key:"formTableRef",ref:b,columns:f.value,addTemplate:v},{mobile:p(({rowData:t})=>[u(h,{value:t.mobile,"onUpdate:value":o=>t.mobile=o},null,8,["value","onUpdate:value"])]),_:1},8,["columns"]),g("div",ne,[u(k,null,{default:p(()=>[u(D,{type:"primary",onClick:y},{default:p(()=>s[2]||(s[2]=[j("保存")])),_:1})]),_:1})]),g("div",oe,[u(T,null,{default:p(()=>s[3]||(s[3]=[j("表单数据")])),_:1}),u(N,{columns:n.value,data:r.value,pagination:!1,bordered:!1},null,8,["columns","data"])])]),_:1})]),_:1})}}});export{se as default};
