2 lines
8.4 KiB
Java
2 lines
8.4 KiB
Java
var rr=Object.defineProperty;var I=Object.getOwnPropertySymbols;var or=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable;var M=Math.pow,V=(r,t,u)=>t in r?rr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:u}):r[t]=u,C=(r,t)=>{for(var u in t||(t={}))or.call(t,u)&&V(r,u,t[u]);if(I)for(var u of I(t))tr.call(t,u)&&V(r,u,t[u]);return r};function ar(){return{fieldMap:{},tableSources:["mainTable","detailList"],params:[],detailTables:[]}}function ir(r){return{id:r.id,component:r.type,bindField:r.bindField||"",region:r.region||"",bandId:r.bandId||"",rect:{x:r.x,y:r.y,w:r.w,h:r.h,zIndex:r.zIndex},style:C({},r.style||{}),payload:r.type==="image"?{src:r.src,fit:r.fit}:r.type==="table"||r.type==="detailTable"?{source:r.source,mergeColumnKeys:r.mergeColumnKeys||[],strictGrouping:r.strictGrouping!==!1,enableMultiHeader:r.enableMultiHeader===!0,tableHeightMode:r.tableHeightMode,fixedRows:r.fixedRows,showHeader:r.showHeader,rowHeight:r.rowHeight,headerHeight:r.headerHeight,headerFontSize:r.headerFontSize,bodyFontSize:r.bodyFontSize,headerBgColor:r.headerBgColor,headerTextColor:r.headerTextColor,footerLabelColumnKey:r.footerLabelColumnKey,footerLabelText:r.footerLabelText,footerLabelCenter:r.footerLabelCenter,footerShowTotal:r.footerShowTotal!==!1,footerTotalMode:r.footerTotalMode||"overall",headerConfig:r.headerConfig,columns:r.columns}:r.type==="freeTable"?{printRepeated:r.printRepeated===!0,rowCount:Number(r.rowCount||1),colCount:Number(r.colCount||1),borderColor:r.borderColor||"#d9d9d9",borderWidth:Number(r.borderWidth||1),outerBorderLineStyle:r.outerBorderLineStyle||"solid",innerBorderHorizontalLineStyle:r.innerBorderHorizontalLineStyle||"solid",innerBorderVerticalLineStyle:r.innerBorderVerticalLineStyle||"solid",colWidths:Array.isArray(r.colWidths)?[...r.colWidths]:void 0,rowHeights:Array.isArray(r.rowHeights)?[...r.rowHeights]:void 0,outerBorder:r.outerBorder,innerBorder:r.innerBorder,cells:Array.isArray(r.cells)?r.cells.map(t=>({row:t.row,col:t.col,rowspan:Math.max(1,Number((t==null?void 0:t.rowspan)||1)),colspan:Math.max(1,Number((t==null?void 0:t.colspan)||1)),text:t.text,bindField:t.bindField,contentType:t.contentType||"text",fillCell:t.fillCell,contentScale:t.contentScale,imageFit:t.imageFit,qrLevel:t.qrLevel,qrRenderType:t.qrRenderType,barcodeFormat:t.barcodeFormat,decimalPlaces:t.decimalPlaces,roundHalfUp:t.roundHalfUp,amountType:t.amountType,autoWrap:t.autoWrap,autoFitFont:t.autoFitFont,align:t.align,verticalAlign:t.verticalAlign,fontSize:t.fontSize,color:t.color,backgroundColor:t.backgroundColor,hideBorderTop:t.hideBorderTop,hideBorderRight:t.hideBorderRight,hideBorderBottom:t.hideBorderBottom,hideBorderLeft:t.hideBorderLeft})):[]}:r.type==="reportHeader"||r.type==="reportFooter"?{text:r.text,bookmarkText:r.bookmarkText,keepTogether:r.keepTogether,centerWithDetail:r.centerWithDetail,refreshPage:r.refreshPage,visible:r.visible,stretch:r.stretch,shrink:r.shrink,printRepeated:r.printRepeated,printAtPageBottom:r.printAtPageBottom,removeBlankWhenNoData:r.removeBlankWhenNoData}:r.type==="qrcode"||r.type==="barcode"?{value:r.value}:{text:r.text,format:r.format}}}function nr(r){return{engine:"native-template-style",version:"1.0.0",page:C({},r.page),elements:r.elements.map(t=>ir(t)),dataBinding:r.dataBinding||ar()}}function dr(r,t=2){return JSON.stringify(nr(r),null,t)}function er(r,t){const u=(o,n)=>Math.floor(Math.random()*(n-o+1))+o,v=o=>o[u(0,Math.max(0,o.length-1))],z=["标准件","不锈钢","铝板","铜件","塑胶件","辅料","组件"],P=["用于产线组装的关键部件,需按工艺要求进行批次追溯与检验记录。","该物料用于连续生产流程,建议结合库存周转与批次有效期进行动态补料。","本条数据为模拟长文本,主要用于验证列宽变化后自动换行与字号自适应效果。"],G=(o,n)=>`${o}_${v(z)}_${n+1}`,J=(o,n)=>`${o}_${n+1}_${v(P)}`,q=(o,n,d)=>d&&Math.random()<.45?J(o,n):G(o,n),D=o=>String(o||"").replace(/[^a-zA-Z0-9]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"CODE",w=o=>`QR_${D(o)}_${u(1e5,999999)}`,N=o=>`BAR${u(1e11,999999999999)}${D(o).slice(0,6).toUpperCase()}`,E=(o,n,d)=>d?`${o}_合并组${n+1}_${v(P)}`:`${o}_合并组${n+1}_${v(z)}`,Q=o=>{var p;let n={};try{n=JSON.parse(t||"{}")}catch(s){n={}}if(!Array.isArray(n==null?void 0:n.elements))return Array.isArray(o==null?void 0:o.columns)?o.columns:[];const d=n.elements.find(s=>{const a=String((s==null?void 0:s.component)||"");return(s==null?void 0:s.id)===(o==null?void 0:o.id)&&(a==="table"||a==="detailTable")});return Array.isArray((p=d==null?void 0:d.payload)==null?void 0:p.columns)?d.payload.columns:Array.isArray(o==null?void 0:o.columns)?o.columns:[]},Z=o=>{var y;const n=Array.isArray(o==null?void 0:o.cells)?o.cells:[];let d={};try{d=JSON.parse(t||"{}")}catch(i){d={}}if(!Array.isArray(d==null?void 0:d.elements))return n;const p=d.elements.find(i=>(i==null?void 0:i.id)===(o==null?void 0:o.id)&&String((i==null?void 0:i.component)||"")==="freeTable"),s=(y=p==null?void 0:p.payload)==null?void 0:y.cells;if(!Array.isArray(s)||!s.length)return n;const a=new Map;return n.forEach(i=>{var b,B;const x=`${Number((b=i==null?void 0:i.row)!=null?b:0)}_${Number((B=i==null?void 0:i.col)!=null?B:0)}`;a.set(x,C({},i))}),s.forEach(i=>{var B,A;const x=`${Number((B=i==null?void 0:i.row)!=null?B:0)}_${Number((A=i==null?void 0:i.col)!=null?A:0)}`,b=a.get(x)||{};a.set(x,C(C({},b),i))}),Array.from(a.values())},e={},X=/{{\s*([\w.]+)\s*}}/g,$=(o,n,d)=>{const p=String(n||"").split(".").filter(Boolean);if(!p.length)return;let s=o;for(let a=0;a<p.length-1;a+=1){const y=p[a];(!s[y]||typeof s[y]!="object")&&(s[y]={}),s=s[y]}s[p[p.length-1]]=d},_=(o,n)=>{if(o)return String(n||"").split(".").filter(Boolean).reduce((d,p)=>d==null?void 0:d[p],o)};let k=1,H=1;return r.forEach(o=>{if(o.type==="table"||o.type==="detailTable"){const s=o.source||"mainTable",a=Q(o),y=Array.isArray(o.mergeColumnKeys)?o.mergeColumnKeys:[],i=o.strictGrouping!==!1,x=y.map(g=>a.find(c=>String((c==null?void 0:c.key)||"")===String(g||""))).filter(Boolean).map(g=>String((g==null?void 0:g.bindField)||(g==null?void 0:g.field)||"")).filter(Boolean),b=u(6,10),B=[],A=Array.from({length:b}).map((g,c)=>{const T={},R=c>0?B[c-1]||{}:null;return a.forEach((f,Y)=>{var K;const h=String((f==null?void 0:f.bindField)||(f==null?void 0:f.field)||`field${Y+1}`),L=(f==null?void 0:f.autoWrap)!==!1,F=String((f==null?void 0:f.contentType)||"text"),m=q(h,c,L),W=x.findIndex(S=>S===h),O=W>=0,l=!i||W<=0||x.slice(0,W).every(S=>_(R,S)===_(T,S));if(O&&c>0&&R&&l&&Math.random()<.5){const S=_(R,h);$(T,h,S!=null?S:E(h,u(0,3),L))}else if(O)$(T,h,E(h,u(0,3),L));else if(F==="image")$(T,h,`https://picsum.photos/seed/${encodeURIComponent(`${h}_${c+1}`)}/260/120`);else if(F==="qrcode")$(T,h,w(h));else if(F==="barcode")$(T,h,N(h));else if(F==="number"||F==="amount"){const S=Math.max(0,Math.min(6,Number((K=f==null?void 0:f.decimalPlaces)!=null?K:2))),U=u(100,5e4)+Math.random(),j=(f==null?void 0:f.roundHalfUp)===!1?Math.trunc(U*M(10,S))/M(10,S):Number(U.toFixed(S));$(T,h,j)}else $(T,h,m)}),B.push(T),T});e[s]=A;return}if(o.type==="freeTable"){Z(o).forEach((a,y)=>{var A;const i=String((a==null?void 0:a.bindField)||"").trim();if(!i||i in e)return;const x=String((a==null?void 0:a.text)||"").trim(),b=String((a==null?void 0:a.contentType)||"text"),B=(a==null?void 0:a.autoWrap)!==!1;if(b==="image")e[i]=`https://picsum.photos/seed/${encodeURIComponent(`${i}_ft`)}/260/120`;else if(b==="qrcode")e[i]=w(i||`ft${y}`);else if(b==="barcode")e[i]=N(i||`ft${y}`);else if(b==="number"||b==="amount"){const g=Math.max(0,Math.min(6,Number((A=a==null?void 0:a.decimalPlaces)!=null?A:2))),c=u(100,5e4)+Math.random(),T=(a==null?void 0:a.roundHalfUp)===!1?Math.trunc(c*M(10,g))/M(10,g):Number(c.toFixed(g));e[i]=T}else e[i]=x||q(i,0,B)});return}if(o.type==="qrcode"){const s=String(o.bindField||"").trim(),a=s||`qrcodeValue${k}`;e[a]=w(s||`qrcode${k}`),k+=1;return}if(o.type==="barcode"){const s=String(o.bindField||"").trim(),a=s||`barcodeValue${H}`;e[a]=N(s||`barcode${H}`),H+=1;return}const n=String(o.bindField||"").trim();n&&!(n in e)&&(o.type==="image"?e[n]="https://via.placeholder.com/180x80.png?text=Image":o.type==="date"?e[n]="2026-01-01":e[n]=`${n}_示例值`);const d=String(o.text||"");Array.from(d.matchAll(X)).forEach(s=>{const a=String((s==null?void 0:s[1])||"").split(".")[0];a&&(a in e||(e[a]=`${a}_示例值`))})}),Object.keys(e).length||(e.docNo="DOC-001",e.orderNo="ORDER-001",e.mainTable=[{field1:"值1",field2:"值2",field3:"值3"}]),e}export{nr as b,er as g,dr as s};
|