@worm-vue3-print/canvas 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -17
- package/dist/canvas.css +1 -1
- package/dist/components/CanvasArea.vue.d.ts +16 -4
- package/dist/components/CanvasPaper.vue.d.ts +0 -3
- package/dist/components/DesignerToolbar.vue.d.ts +11 -1
- package/dist/components/HelpButton.vue.d.ts +7 -0
- package/dist/components/HelpModal.vue.d.ts +15 -0
- package/dist/components/PrintDesigner.vue.d.ts +2 -0
- package/dist/components/Ruler.vue.d.ts +11 -2
- package/dist/composables/useDesignerState.d.ts +1 -0
- package/dist/help-content/changelog.d.ts +6 -0
- package/dist/help-content/faq.d.ts +6 -0
- package/dist/help-content/features.d.ts +6 -0
- package/dist/help-content/getting-started.d.ts +6 -0
- package/dist/help-content/index.d.ts +7 -0
- package/dist/help-content/shortcuts.d.ts +6 -0
- package/dist/index.cjs +427 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4226 -3496
- package/dist/index.js.map +1 -1
- package/dist/utils/ruler.d.ts +24 -2
- package/dist/utils/scale.d.ts +14 -1
- package/dist/utils/units.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,428 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),ce=require("@worm-vue3-print/core"),tt=require("jsbarcode"),nt=require("qrcode"),Qt=require("dompurify");function _t(){let t=0;return function(){return t+=1,`cell-${Date.now().toString(36)}-${t}`}}function en(){let t=0;return function(){return t+=1,`row-${Date.now().toString(36)}-${t}`}}const tn=_t(),nn=en(),ze={width:.75,style:"solid",color:"#333333"};function ot(t){return JSON.parse(JSON.stringify(t))}function lt(t){return{id:tn(),borders:{top:{...ze},right:{...ze},bottom:{...ze},left:{...ze}},...t}}function on(){const t=[50,50,50],l=(o,a)=>({id:nn(),type:o,height:8,...a!==void 0?{repeatOnPage:a}:{},cells:t.map(()=>lt())}),n=l("header",!0);return n.cells.forEach((o,a)=>{o.formatter=`列${a+1}`,o.align="center",o.fontWeight="bold"}),{rows:[n,l("data"),l("subtotal"),l("summary")],colWidths:t}}function at(t,l,n){if(!t[l].cells[n].merged)return{r:l,c:n};for(let o=l;o>=0;o--)for(let a=n;a>=0;a--){const i=t[o].cells[a];if(i.merged)continue;const r=i.rowspan??1,s=i.colspan??1;if(o+r-1>=l&&a+s-1>=n)return{r:o,c:a}}return{r:l,c:n}}function ke(t,l,n){const o=at(t,l,n),a=t[o.r].cells[o.c];return{r1:o.r,c1:o.c,r2:o.r+(a.rowspan??1)-1,c2:o.c+(a.colspan??1)-1}}function Ct(t,l,n){let o={r1:Math.min(l.r,n.r),c1:Math.min(l.c,n.c),r2:Math.max(l.r,n.r),c2:Math.max(l.c,n.c)};for(;;){let a=!1;for(let i=o.r1;i<=o.r2;i++)for(let r=o.c1;r<=o.c2;r++){const s=ke(t,i,r),d={r1:Math.min(o.r1,s.r1),c1:Math.min(o.c1,s.c1),r2:Math.max(o.r2,s.r2),c2:Math.max(o.c2,s.c2)};(d.r1!==o.r1||d.c1!==o.c1||d.r2!==o.r2||d.c2!==o.c2)&&(o=d,a=!0)}if(!a)return o}}function St(t,l){if((l.r2-l.r1+1)*(l.c2-l.c1+1)<2)return"至少选择 2 个单元格";const o=new Set;for(let i=l.r1;i<=l.r2;i++)o.add(t[i].type);if(o.size>1)return"合并区域不能跨越不同类型的行";const a=Ct(t,{r:l.r1,c:l.c1},{r:l.r2,c:l.c2});return a.r1!==l.r1||a.c1!==l.c1||a.r2!==l.r2||a.c2!==l.c2?"选区与已有合并区域部分重叠":null}function $t(t,l){const n=t[l.r1].cells[l.c1],o=[];for(let a=l.r1;a<=l.r2;a++)for(let i=l.c1;i<=l.c2;i++){const r=t[a].cells[i];r.formatter&&o.push(r.formatter),!(a===l.r1&&i===l.c1)&&(r.merged=!0,r.rowspan=1,r.colspan=1,r.formatter="")}n.rowspan=l.r2-l.r1+1,n.colspan=l.c2-l.c1+1,n.formatter=o.join(" ")}function Mt(t,l){for(let n=l.r1;n<=l.r2;n++)for(let o=l.c1;o<=l.c2;o++){const a=t[n].cells[o];if(!a.merged&&((a.rowspan??1)>1||(a.colspan??1)>1)){const i=ke(t,n,o),r=a;for(let s=i.r1;s<=i.r2;s++)for(let d=i.c1;d<=i.c2;d++){const u=t[s].cells[d];u.merged=!1,u.rowspan=1,u.colspan=1,ln(r,u)}a.rowspan=1,a.colspan=1}}}function ln(t,l){t!==l&&(l.align=t.align,l.valign=t.valign,l.fontSize=t.fontSize,l.fontWeight=t.fontWeight,l.color=t.color,l.backgroundColor=t.backgroundColor,l.borders=t.borders?ot(t.borders):void 0,l.padding=t.padding,l.wordWrap=t.wordWrap)}function mt(t,l,n){const o=n==="above"?l:l+1,a=t[l],i=a.cells.length,r=a.type==="data"?"header":a.type,s={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:r,height:a.height,cells:Array.from({length:i},()=>lt())};for(let d=0;d<i;d++)if(o>0&&o<t.length){const u=ke(t,o-1,d);if(u.r1<o&&u.r2>=o){const f=t[u.r1].cells[u.c1];f.rowspan=(f.rowspan??1)+1,s.cells[d].merged=!0}}t.splice(o,0,s)}function an(t,l){if(t.length<=1)return"不能删除最后一行";const n=t[l],o=n.cells.length;for(let a=0;a<o;a++){const i=n.cells[a];if(!i.merged&&(i.rowspan??1)>1){const r=t[l+1].cells[a];Object.assign(r,ot(i),{id:r.id}),r.rowspan=(i.rowspan??1)-1,r.merged=!1}else if(i.merged){const r=ke(t,l,a);if(r.r1<l&&r.c1===a){const s=t[r.r1].cells[r.c1];s.rowspan=(s.rowspan??1)-1}}}return t.splice(l,1),null}function pt(t,l,n,o){const a=o==="left"?n:n+1;l.splice(a,0,l[n]);for(const i of t){const r=lt();if(a>0&&a<i.cells.length){const s=t.indexOf(i),d=ke(t,s,a-1);if(d.c1<a&&d.c2>=a){const u=t[d.r1].cells[d.c1];s===d.r1&&(u.colspan=(u.colspan??1)+1),r.merged=!0}}i.cells.splice(a,0,r)}}function rn(t,l,n){if(l.length<=1)return"不能删除最后一列";for(let o=0;o<t.length;o++){const a=t[o].cells[n];if(!a.merged&&(a.colspan??1)>1){const i=t[o].cells[n+1];Object.assign(i,ot(a),{id:i.id}),i.colspan=(a.colspan??1)-1,i.merged=!1}else if(a.merged){const i=ke(t,o,n);if(i.c1<n&&i.r1===o){const r=t[i.r1].cells[i.c1];r.colspan=(r.colspan??1)-1}}}for(const o of t)o.cells.splice(n,1);return l.splice(n,1),null}function Ze(t,l,n){if(n==="data"){const o=t.findIndex((a,i)=>a.type==="data"&&i!==l);if(o>=0)return`数据行已存在(第 ${o+1} 行),全表最多一行`}if(n==="header"){for(let o=0;o<l;o++)if(t[o].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const o=t.findIndex(a=>a.type==="data");if(o<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(l<o)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&t.slice(0,l).some(o=>o.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&t.slice(l+1).some(o=>o.type==="subtotal"))return"汇总行必须位于小计行之后";if(t[l].type==="header"&&n!=="header"){for(let o=l+1;o<t.length;o++)if(t[o].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}return t[l].type=n,n!=="header"&&delete t[l].repeatOnPage,null}function sn(t,l,n,o){for(let a=l.r1;a<=l.r2;a++)for(let i=l.c1;i<=l.c2;i++){const r=t[a].cells[i];if(r.merged)continue;if(n==="none"){delete r.borders;continue}const s=ke(t,a,i),d=s.r1===l.r1,u=s.r2===l.r2,f=s.c1===l.c1,m=s.c2===l.c2,y={...r.borders??{}};n==="all"?(y.top={...o},y.bottom={...o},y.left={...o},y.right={...o}):n==="outer"?(d&&(y.top={...o}),u&&(y.bottom={...o}),f&&(y.left={...o}),m&&(y.right={...o})):n==="inner"&&(d||(y.top={...o}),u||(y.bottom={...o}),f||(y.left={...o}),m||(y.right={...o})),r.borders=y}}const dn="1px dashed rgba(0,0,0,0.18)";function Le(t,l={}){return t&&t.style!=="none"?`${t.width}pt ${t.style} ${t.color}`:l.designMode&&l.showGhostBorder!==!1?dn:"none"}function Re(t){const l=(t.tableColWidths??[]).reduce((o,a)=>o+a,0),n=(t.tableRows??[]).reduce((o,a)=>o+a.height,0);t.width=Math.round(l*100)/100,t.height=Math.round(n*100)/100}const ft=5;function cn(t,l,n,o){const a=t.reduce((s,d,u)=>u===l?s:s+d,0),i=o===1/0?1/0:Math.max(ft,o-a),r=Math.round(n*10)/10;return Math.min(Math.max(r,ft),i)}function Ne(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function un(t){const l={left:7,top:17.6,width:42.3,height:7.1};switch(t){case"text":return{...l,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...l,width:28.2,height:28.2,fit:"contain"};case"longText":return{...l,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:n,colWidths:o}=on(),a=o.reduce((r,s)=>r+s,0),i=n.reduce((r,s)=>r+s.height,0);return{...l,width:a,height:i,tableMode:"dynamic",tableRows:n,tableColWidths:o,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"hline":return{...l,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...l,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...l,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...l,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...l,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...l,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...l,width:28.2,height:28.2};default:return l}}function Bt(t,l){const n={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:Ne(),options:{...un(t),...l},printElementType:{type:t,title:n[t]?.title||t}}}const it=new ce.TemplateEngine;function xt(){return fe}const fe={supplier:{name:"鑫达五金有限公司",phone:"0571-88776655",address:"杭州市萧山区经济开发区88号"},receiver:{name:"李四",phone:"13912345678",address:"杭州市余杭区文一西路998号"},order:{no:"PO20260801001",date:"2026-08-01",total:69543.75},goods:[{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:100,price:.5,amount:50,remark:"A级"},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:117,price:.75,amount:87.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:134,price:1,amount:134,remark:""},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:151,price:1.25,amount:188.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:168,price:1.5,amount:252,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:185,price:1.75,amount:323.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:202,price:2,amount:404,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:219,price:2.25,amount:492.75,remark:"A级"},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:236,price:2.5,amount:590,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:253,price:2.75,amount:695.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×20",unit:"个",qty:270,price:3,amount:810,remark:""},{name:"不锈钢螺母 M10",spec:"M16×21",unit:"套",qty:287,price:3.25,amount:932.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×22",unit:"盒",qty:304,price:3.5,amount:1064,remark:""},{name:"六角螺栓 M14",spec:"M5×23",unit:"支",qty:321,price:3.75,amount:1203.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×24",unit:"袋",qty:338,price:4,amount:1352,remark:"A级"},{name:"平垫圈 M6",spec:"M4×25",unit:"件",qty:355,price:4.25,amount:1508.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×26",unit:"根",qty:372,price:4.5,amount:1674,remark:""},{name:"双头螺柱 M20",spec:"M8×27",unit:"包",qty:389,price:4.75,amount:1847.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×28",unit:"只",qty:406,price:5,amount:2030,remark:""},{name:"十字盘头钉 M3",spec:"M12×29",unit:"组",qty:423,price:5.25,amount:2220.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×30",unit:"个",qty:440,price:.5,amount:220,remark:""},{name:"不锈钢螺母 M10",spec:"M16×31",unit:"套",qty:457,price:.75,amount:342.75,remark:"A级"},{name:"弹簧垫圈 M12",spec:"M6×32",unit:"盒",qty:474,price:1,amount:474,remark:""},{name:"六角螺栓 M14",spec:"M5×33",unit:"支",qty:491,price:1.25,amount:613.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×34",unit:"袋",qty:508,price:1.5,amount:762,remark:""},{name:"平垫圈 M6",spec:"M4×35",unit:"件",qty:525,price:1.75,amount:918.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×36",unit:"根",qty:542,price:2,amount:1084,remark:""},{name:"双头螺柱 M20",spec:"M8×37",unit:"包",qty:559,price:2.25,amount:1257.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×38",unit:"只",qty:576,price:2.5,amount:1440,remark:"A级"},{name:"十字盘头钉 M3",spec:"M12×39",unit:"组",qty:593,price:2.75,amount:1630.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×40",unit:"个",qty:610,price:3,amount:1830,remark:""},{name:"不锈钢螺母 M10",spec:"M16×41",unit:"套",qty:627,price:3.25,amount:2037.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×42",unit:"盒",qty:644,price:3.5,amount:2254,remark:""},{name:"六角螺栓 M14",spec:"M5×43",unit:"支",qty:661,price:3.75,amount:2478.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×44",unit:"袋",qty:678,price:4,amount:2712,remark:""},{name:"平垫圈 M6",spec:"M4×45",unit:"件",qty:695,price:4.25,amount:2953.75,remark:"A级"},{name:"自攻螺钉 M5",spec:"M3×46",unit:"根",qty:712,price:4.5,amount:3204,remark:""},{name:"双头螺柱 M20",spec:"M8×47",unit:"包",qty:729,price:4.75,amount:3462.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×48",unit:"只",qty:746,price:5,amount:3730,remark:""},{name:"十字盘头钉 M3",spec:"M12×49",unit:"组",qty:763,price:5.25,amount:4005.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:780,price:.5,amount:390,remark:""},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:797,price:.75,amount:597.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:814,price:1,amount:814,remark:"A级"},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:831,price:1.25,amount:1038.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:848,price:1.5,amount:1272,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:865,price:1.75,amount:1513.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:882,price:2,amount:1764,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:899,price:2.25,amount:2022.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:916,price:2.5,amount:2290,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:933,price:2.75,amount:2565.75,remark:"A级"}]},mn={MONEY:ce.formatMoney,CONCAT:(...t)=>t.filter(l=>l!=null).join(""),IF:ce.ifFn,FORMAT:t=>typeof t!="number"?String(t):t.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(t,l,n)=>String(t).slice(l,n?l+n:void 0),LEN:t=>String(t).length,ROUND:(t,l)=>Number(Number(t).toFixed(l)),NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(t,l)=>t!=null&&t!==""?String(t):l,PAD:(t,l,n)=>String(t).padStart(l,n),REPLACE:(t,l,n)=>String(t).replace(new RegExp(l,"g"),n),JSON:t=>JSON.stringify(t,null,2),DATE:ce.formatDate,UPPER:ce.toUpperCaseAmount};for(const[t,l]of Object.entries(mn))it.registerFunction(t,l);function pn(t,l,n){switch(t.toUpperCase()){case"SUM":return ce.sum(n,l);case"AVG":return ce.avg(n,l);case"COUNT":return ce.count(n,l);case"MIN":return ce.min(n,l);case"MAX":return ce.max(n,l);default:return 0}}function Ce(t,l){if(!t)return"";if(!t.includes("{"))return t;const n=Array.isArray(l.rows)?l.rows:[];let o=t.replace(/\{([^}]+)\}/g,(a,i)=>{let r=i.trim();return r=r.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(s,d,u)=>{const f=u.trim().replace(/^['"]|['"]$/g,"");return String(pn(d,f,n))}),`{${r}}`});try{return it.render(o,l)}catch{return t}}function fn(t){return Bt("text",{formatter:`{${t.fieldKey}}`,title:t.fieldLabel})}function Ue(t,l){if(t.formatter){if(!l||l.length===0)return"";const n=l[0];try{return it.render(t.formatter,n??{})}catch{return t.formatter}}return""}function vt(t){let l=fe;for(const n of t.split(".")){if(l==null)return;l=Array.isArray(l)?l[0]?.[n]:l[n]}return l}function vn(t,l){const n=l?.[0];return(t??"").replace(/\{([^{}]+)\}/g,(a,i)=>{const r=i.trim(),s=r.includes(".")?vt(r):n?.[r]??vt(r);return s==null?"":String(s)}).trim()||"1234567890128"}function gn(t){return t/2.83464566929}function Pe(t){return t*(25.4/96)}const hn=["left","top","width","height"];function bn(t){const l={...t.options};for(const n of hn){const o=l[n];typeof o=="number"&&Number.isFinite(o)&&(l[n]=yn(gn(o)))}return{...t,options:l}}function yn(t){return Math.round(t*100)/100}function kn(t){if(t.unit==="mm")return t;const l=n=>n?.map(bn)??[];return{...t,unit:"mm",elements:l(t.elements),header:t.header?{...t.header,elements:l(t.header.elements)}:t.header,footer:t.footer?{...t.footer,elements:l(t.footer.elements)}:t.footer,firstPageOverlay:t.firstPageOverlay?{...t.firstPageOverlay,elements:l(t.firstPageOverlay.elements)}:t.firstPageOverlay}}const Qe={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:216,height:279},Legal:{width:216,height:356}};function Se(t){let l;return t.paperSize==="CUSTOM"?l={width:t.customWidth??210,height:t.customHeight??297}:l=Qe[t.paperSize]||Qe.A4,t.orientation==="landscape"?{width:l.height,height:l.width}:l}function En(t,l,n,o,a=.9){if(n<=0||o<=0)return 100;const i=Math.min(t/n,l/o)*a,r=Math.round(i*100);return Math.min(200,Math.max(50,r))}const Dt=["text","image","hline","vline","rect","oval","barcode","qrcode"];function wn(t){return Se(t)}function Fe(t){const l=wn(t),n=t.margins,o=t.header.height,a=t.footer.height,i=l.width-n.left-n.right,r=l.height-n.top-n.bottom-o-a,s=(d,u,f,m)=>({left:d,top:u,width:f,height:m});return{header:s(n.left,n.top,i,o),content:s(n.left,n.top+o,i,r),footer:s(n.left,l.height-n.bottom-a,i,a)}}function Tt(t,l,n){const o=Fe(t);return o.footer.height>0&&n>=o.footer.top?"footer":o.header.height>0&&n<o.header.top+o.header.height?"header":"content"}function _e(t,l){const n=t.options;n.width=Math.min(n.width,l.width),n.height=Math.min(n.height,l.height),n.left=Math.min(Math.max(0,n.left),l.width-n.width),n.top=Math.min(Math.max(0,n.top),l.height-n.height)}function Vn(t,l){const n=Fe(l),o=t.zone||"content",a=n[o],i=a.left+t.options.left+t.options.width/2,r=a.top+t.options.top+t.options.height/2;let s=Tt(l,i,r),d=!1;if(s!=="content"&&!Dt.includes(t.printElementType.type)&&(s="content",d=!0),s!==o){const u=n[s];t.options.left=a.left+t.options.left-u.left,t.options.top=a.top+t.options.top-u.top,t.zone=s}return s!=="content"?_e(t,n[s]):d&&_e(t,n.content),{rejected:d}}const zt=Symbol("selected-ids"),Lt=Symbol("preview-ids");function Nn(t){const l=e.ref(new Set),n=e.ref(new Set),o=e.computed(()=>t.value.filter(y=>l.value.has(y.id))),a=e.computed(()=>l.value.size>0);function i(y,B=!1){if(B){const z=new Set(l.value);z.has(y)?z.delete(y):z.add(y),l.value=z}else l.value=new Set([y])}function r(){l.value=new Set}function s(y){l.value=new Set(y)}function d(y){n.value=new Set(y)}function u(){n.value=new Set}function f(){l.value=new Set(n.value),n.value=new Set}function m(){const y=o.value;if(y.length===0)return null;let B=1/0,z=1/0,E=-1/0,V=-1/0;return y.forEach(A=>{B=Math.min(B,A.options.left),z=Math.min(z,A.options.top),E=Math.max(E,A.options.left+A.options.width),V=Math.max(V,A.options.top+A.options.height)}),{left:B,top:z,width:E-B,height:V-z}}return{selectedIds:l,selectedElements:o,hasSelection:a,select:i,clearSelection:r,selectAll:s,getSelectionBounds:m,previewIds:n,setPreview:d,clearPreview:u,commitPreview:f}}function Cn(){const t=e.ref(null);function l(a){t.value=a.map(i=>({options:{...i.options},printElementType:{...i.printElementType}}))}function n(a=10){return t.value?t.value.map(i=>({id:Ne(),options:{...i.options,left:i.options.left+a,top:i.options.top+a},printElementType:{...i.printElementType}})):null}function o(){return t.value!==null&&t.value.length>0}return{clipboard:t,copy:l,paste:n,hasData:o}}function Sn(){function t(l,n){if(l.length<2)return;const o={minLeft:Math.min(...l.map(a=>a.options.left)),maxRight:Math.max(...l.map(a=>a.options.left+a.options.width)),minTop:Math.min(...l.map(a=>a.options.top)),maxBottom:Math.max(...l.map(a=>a.options.top+a.options.height))};switch(n){case"left":l.forEach(a=>{a.options.left=o.minLeft});break;case"right":l.forEach(a=>{a.options.left=o.maxRight-a.options.width});break;case"top":l.forEach(a=>{a.options.top=o.minTop});break;case"bottom":l.forEach(a=>{a.options.top=o.maxBottom-a.options.height});break;case"vertical":{const a=o.minLeft+(o.maxRight-o.minLeft)/2;l.forEach(i=>{i.options.left=a-i.options.width/2});break}case"horizontal":{const a=o.minTop+(o.maxBottom-o.minTop)/2;l.forEach(i=>{i.options.top=a-i.options.height/2});break}case"distributeHor":{const a=[...l].sort((d,u)=>d.options.left-u.options.left),i=a.reduce((d,u)=>d+u.options.width,0),r=(o.maxRight-o.minLeft-i)/(a.length-1);let s=o.minLeft;a.forEach(d=>{d.options.left=s,s+=d.options.width+r});break}case"distributeVer":{const a=[...l].sort((d,u)=>d.options.top-u.options.top),i=a.reduce((d,u)=>d+u.options.height,0),r=(o.maxBottom-o.minTop-i)/(a.length-1);let s=o.minTop;a.forEach(d=>{d.options.top=s,s+=d.options.height+r});break}}}return{align:t}}function $n(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function Mn(){function t(o,a){if(o.filter(s=>a.has(s.id)).length<2)return o;const r=$n();return o.map(s=>a.has(s.id)?{...s,options:{...s.options,groupId:r}}:s)}function l(o,a){const i=o.filter(s=>a.has(s.id)),r=new Set(i.map(s=>s.options.groupId).filter(Boolean));return o.map(s=>s.options.groupId&&r.has(s.options.groupId)?{...s,options:{...s.options,groupId:void 0}}:s)}function n(o,a){const i=o.find(s=>s.id===a);if(!i?.options.groupId)return new Set([a]);const r=new Set;for(const s of o)s.options.groupId===i.options.groupId&&r.add(s.id);return r}return{group:t,ungroup:l,getGroupedIds:n}}function Bn(t){const n=e.ref([]),o=e.ref([]),a=e.ref(!1),i=e.ref(!1);function r(){a.value=n.value.length>0,i.value=o.value.length>0}function s(B){return{elements:JSON.parse(JSON.stringify(B?.elements??[])),templateData:JSON.parse(JSON.stringify(B?.templateData??{}))}}function d(B){return s(B)}function u(B){n.value.push(d(B)),o.value=[],n.value.length>50&&n.value.shift(),r()}function f(B){if(n.value.length===0)return null;const z=n.value.pop();return o.value.push(B?d(B):s(z)),r(),n.value.length>0?s(n.value[n.value.length-1]):null}function m(B){if(o.value.length===0)return null;const z=o.value.pop();return n.value.push(B?d(B):s(z)),r(),s(z)}function y(){n.value=[],o.value=[],r()}return{push:u,undo:f,redo:m,canUndo:a,canRedo:i,clear:y}}const xn=1,Dn=10,Tn=.5;function zn(t){function l(a){const i=a.target.tagName;if(i==="INPUT"||i==="TEXTAREA"||i==="SELECT")return;const r=a.ctrlKey||a.metaKey;if(a.key.startsWith("Arrow")){a.preventDefault();const s=a.shiftKey?Dn:a.ctrlKey?Tn:xn,d=a.key==="ArrowLeft"?-s:a.key==="ArrowRight"?s:0,u=a.key==="ArrowUp"?-s:a.key==="ArrowDown"?s:0;t.onMove?.(d,u);return}if(a.key==="Delete"||a.key==="Backspace"){a.preventDefault(),t.onDelete?.();return}if(r){const s=a.key.toLowerCase();s==="c"?(a.preventDefault(),t.onCopy?.()):s==="v"?(a.preventDefault(),t.onPaste?.()):s==="a"?(a.preventDefault(),t.onSelectAll?.()):s==="d"?(a.preventDefault(),t.onDuplicate?.()):s==="z"?(a.preventDefault(),a.shiftKey?t.onRedo?.():t.onUndo?.()):s==="y"?(a.preventDefault(),t.onRedo?.()):s==="1"?(a.preventDefault(),t.onResetZoom?.()):s==="l"?(a.preventDefault(),t.onAlignLeft?.()):s==="r"?(a.preventDefault(),t.onAlignRight?.()):s==="e"?(a.preventDefault(),t.onAlignCenterH?.()):s==="t"?(a.preventDefault(),t.onAlignTop?.()):s==="b"?(a.preventDefault(),t.onAlignBottom?.()):s==="g"&&(a.preventDefault(),a.shiftKey?t.onUngroup?.():t.onGroup?.())}}function n(){document.addEventListener("keydown",l)}function o(){document.removeEventListener("keydown",l)}return{setup:n,cleanup:o}}function Pt(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},firstPageOverlay:{height:0,elements:[]},elements:[],watermark:{}}}function et(t){const l=(n,o)=>(n??[]).map(a=>{const i={...a.options};return(a.printElementType?.type??a.type)==="table"&&Re(i),{id:a.id||Ne(),zone:o,options:i,printElementType:{...a.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},firstPageOverlay:{height:t.firstPageOverlay?.height??0,elements:[...t.firstPageOverlay?.elements??[]]},guides:[...t.guides??[]],elements:[...l(t.elements??[],"content"),...l(t.header?.elements??[],"header"),...l(t.footer?.elements??[],"footer")]}}function Ln(t={}){const l=e.ref(100),n=e.ref(!0),o=e.ref(!1),a=e.ref(!0),i=e.ref(et(t.initialTemplate||Pt())),r=e.computed({get:()=>i.value.elements,set:F=>{i.value.elements=F}}),s=e.ref(t.initialFields||[]),{selectedIds:d,selectedElements:u,select:f,clearSelection:m,selectAll:y,previewIds:B,setPreview:z,clearPreview:E,commitPreview:V}=Nn(r),{group:A,ungroup:H}=Mn(),{copy:W,paste:L,hasData:G}=Cn(),{align:Y}=Sn(),{push:J,undo:P,redo:v,canUndo:g,canRedo:M}=Bn(),x=e.computed(()=>{if(d.value.size===0)return null;const F=d.value.values().next().value;return r.value.find(Q=>Q.id===F)||null}),c=e.ref(null);function h(F){c.value=F}function T(){return{elements:r.value.map(F=>({id:F.id,zone:F.zone,options:JSON.parse(JSON.stringify(F.options)),printElementType:{...F.printElementType}})),templateData:{paperSize:i.value.paperSize,orientation:i.value.orientation,margins:{...i.value.margins},header:{height:i.value.header.height,elements:[]},footer:{height:i.value.footer.height,elements:[]},firstPageOverlay:{height:i.value.firstPageOverlay.height,elements:[]},elements:[],customWidth:i.value.customWidth,customHeight:i.value.customHeight,watermark:i.value.watermark?{...i.value.watermark}:void 0,guides:[...i.value.guides??[]]}}}function O(){J(T())}function X(){const F=P(T());F?.templateData&&(i.value={...F.templateData,elements:F.elements})}function oe(){const F=v(T());F?.templateData&&(i.value={...F.templateData,elements:F.elements})}function ie(){W(u.value)}function re(){W(u.value),k()}function se(){const F=L();F&&F.length>0&&(r.value.push(...F),O())}function ae(){W(u.value);const F=L();F&&F.length>0&&(F.forEach(Q=>{Q.options.left+=5,Q.options.top+=5}),r.value.push(...F),f(F[0].id,!1),O())}function p(){l.value=100}const b=e.computed(()=>G());let N=!1,S=null;const U=300;function K(F,Q){const j=u.value.filter(ee=>!ee.options.locked);j.length!==0&&(j.forEach(ee=>{ee.options.left+=F,ee.options.top+=Q}),N||(N=!0,O()),S&&clearTimeout(S),S=setTimeout(()=>{N=!1,S=null},U))}function C(){y(r.value.map(F=>F.id))}function $(F){Y(u.value,F),O()}function D(){r.value=A(r.value,d.value),O()}function w(){r.value=H(r.value,d.value),O()}function k(){d.value.size!==0&&(r.value=r.value.filter(F=>!d.value.has(F.id)),m(),O())}const{setup:q,cleanup:Z}=zn({onMove:K,onDelete:k,onCopy:ie,onPaste:se,onSelectAll:C,onUndo:X,onRedo:oe,onDuplicate:ae,onResetZoom:p,onAlignLeft:()=>$("left"),onAlignRight:()=>$("right"),onAlignCenterH:()=>$("vertical"),onAlignTop:()=>$("top"),onAlignBottom:()=>$("bottom"),onGroup:D,onUngroup:w});let de=null;function pe(){de=T()}function be(){if(!de)return;const F=new Map(de.elements.map(le=>[le.id,le]));let Q=!1;for(const le of r.value){const ue=F.get(le.id);if(!ue)continue;(ue.options.left!==le.options.left||ue.options.top!==le.options.top||ue.options.width!==le.options.width||ue.options.height!==le.options.height)&&Vn(le,i.value).rejected&&(Q=!0)}Q&&alert("该元素类型不能放入页眉/页脚");const j=le=>`${le.id}:${le.zone||"content"}:${le.options.left},${le.options.top},${le.options.width},${le.options.height}`,ee=de.elements.map(j).join("|"),ve=T().elements.map(j).join("|");de=null,ee!==ve&&O()}function $e(F,Q){const j=Tt(i.value,Q.x,Q.y);if(j!=="content"&&!Dt.includes(F.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const ee=Fe(i.value)[j];return F.zone=j,F.options.left=Q.x-ee.left,F.options.top=Q.y-ee.top,j!=="content"&&_e(F,ee),!0}function ye(F,Q){const j=Bt(F);Q&&!$e(j,Q)||(r.value.push(j),f(j.id,!1),O())}function Ee(F,Q){const j=fn(F);Q&&!$e(j,Q)||(r.value.push(j),f(j.id,!1),O())}function He(F){if(d.value.size===0)return;const Q=d.value.values().next().value,j=r.value.find(we=>we.id===Q);if(!j)return;const ee=j.options.zIndex??0,ve=r.value.map(we=>we.options.zIndex??0),le=Math.max(...ve,0),ue=Math.min(...ve,0);switch(F){case"top":j.options.zIndex=le+1;break;case"bottom":j.options.zIndex=ue-1;break;case"up":j.options.zIndex=ee+1;break;case"down":j.options.zIndex=ee-1;break}O()}function Oe(F,Q){const{width:j,height:ee}=Se(i.value),ve=96/25.4;l.value=En(F,Q,j*ve,ee*ve)}function De(F){i.value={...F},O()}function Ge(){const F=r.value,Q=j=>F.filter(ee=>(ee.zone||"content")===j).map(ee=>({id:ee.id,type:ee.printElementType.type,options:{...ee.options},printElementType:{...ee.printElementType}}));return{unit:"mm",...i.value,header:{...i.value.header,elements:Q("header")},footer:{...i.value.footer,elements:Q("footer")},firstPageOverlay:{...i.value.firstPageOverlay,elements:i.value.firstPageOverlay.elements.map(j=>({id:j.id||Ne(),type:j.printElementType?.type||"text",options:{...j.options},printElementType:{...j.printElementType}}))},elements:Q("content"),guides:[...i.value.guides??[]]}}function qe(F,Q){const j=kn(F);i.value=et(j),Q&&(i.value={...i.value,elements:Q.map(ee=>({...ee,id:ee.id||Ne(),zone:ee.zone||"content",options:{...ee.options},printElementType:{...ee.printElementType}}))}),J(T())}return J(T()),e.onMounted(()=>q()),e.onUnmounted(()=>{Z(),S&&(clearTimeout(S),S=null)}),{scale:l,showGrid:n,snapToGrid:o,showTableGhostBorder:a,templateData:i,elements:r,fields:s,selectedIds:d,selectedElements:u,selectedElement:x,select:f,clearSelection:m,selectAll:C,previewIds:B,setPreview:z,clearPreview:E,commitPreview:V,hasClipboard:b,copy:ie,paste:se,cutSelected:re,tableSelection:c,setTableSelection:h,canUndo:g,canRedo:M,undo:X,redo:oe,recordHistory:O,alignSelected:$,groupSelected:D,ungroupSelected:w,deleteSelected:k,duplicateSelected:ae,resetZoom:p,dragStart:pe,dragStop:be,addElement:ye,addFieldElement:Ee,moveLayer:He,fitToWindow:Oe,updateTemplateData:De,getTemplateJson:Ge,loadTemplate:qe}}let gt=0;function Pn(){return gt+=1,`guide-${gt}`}function In(t,l){const n=e.computed(()=>t.value.guides??[]);function o(d){t.value={...t.value,guides:d([...t.value.guides??[]])},l()}function a(d,u){o(f=>(f.push({type:d,position:u,id:Pn()}),f))}function i(d,u){o(f=>f.map(m=>m.id===d?{...m,position:u}:m))}function r(d){o(u=>u.filter(f=>f.id!==d))}function s(){const d=[],u=[];for(const f of n.value)f.type==="vertical"?d.push(f.position):u.push(f.position);return{vertical:d,horizontal:u}}return{guides:n,addGuide:a,moveGuide:i,removeGuide:r,getGuidePositions:s}}const xe=Symbol("table-edit"),rt=Symbol("print-upload-image"),An={class:"designer-toolbar"},Rn={class:"tb-group"},Un={class:"tb-title"},Fn={class:"tb-title-name"},Hn={class:"tb-group"},On=["disabled"],Gn=["disabled"],qn={key:0,class:"tb-group"},Wn={key:1,class:"tb-group"},Kn={key:2,class:"tb-group"},Yn={key:3,class:"tb-group"},Xn={class:"tb-group"},jn={class:"tb-zoom"},Jn={class:"tb-group"},Zn={class:"tb-group"},Qn=e.defineComponent({__name:"DesignerToolbar",props:e.mergeModels({isEdit:{type:Boolean},canUndo:{type:Boolean},canRedo:{type:Boolean},hasMultiSelection:{type:Boolean},hasSelection:{type:Boolean},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},selectedElementHasGroup:{type:Boolean},overlayVisible:{type:Boolean},showLoadDefault:{type:Boolean}},{scale:{default:100},scaleModifiers:{}}),emits:e.mergeModels(["preview","save","load-default","undo","redo","align","move-layer","toggle-grid","toggle-snap","toggle-table-ghost-border","toggle-overlay","group","ungroup","add-overlay-element","fit-window","zoom"],["update:scale"]),setup(t){const l=e.useModel(t,"scale");return(n,o)=>(e.openBlock(),e.createElementBlock("div",An,[e.createElementVNode("div",Rn,[o[28]||(o[28]=e.createStaticVNode('<span class="tb-mark" aria-hidden="true" data-v-76b4f0cc><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-76b4f0cc><rect x="5" y="3" width="14" height="18" rx="2.5" data-v-76b4f0cc></rect><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" data-v-76b4f0cc></line><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" data-v-76b4f0cc></line><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" data-v-76b4f0cc></line></svg></span>',1)),e.createElementVNode("div",Un,[e.createElementVNode("span",Fn,e.toDisplayString(t.isEdit?"编辑模板":"新建模板"),1),o[27]||(o[27]=e.createElementVNode("span",{class:"tb-title-sub"},"打印模板设计器",-1))])]),e.createElementVNode("div",Hn,[e.createElementVNode("button",{class:"tb-btn tb-icon",disabled:!t.canUndo,onClick:o[0]||(o[0]=a=>n.$emit("undo")),title:"撤销"},"↶",8,On),e.createElementVNode("button",{class:"tb-btn tb-icon",disabled:!t.canRedo,onClick:o[1]||(o[1]=a=>n.$emit("redo")),title:"重做"},"↷",8,Gn)]),t.hasMultiSelection?(e.openBlock(),e.createElementBlock("div",qn,[e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[2]||(o[2]=a=>n.$emit("align","left")),title:"左对齐"},"⇤"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[3]||(o[3]=a=>n.$emit("align","right")),title:"右对齐"},"⇥"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[4]||(o[4]=a=>n.$emit("align","top")),title:"顶对齐"},"⇡"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[5]||(o[5]=a=>n.$emit("align","bottom")),title:"底对齐"},"⇣"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[6]||(o[6]=a=>n.$emit("align","vertical")),title:"水平居中"},"↔"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[7]||(o[7]=a=>n.$emit("align","horizontal")),title:"垂直居中"},"↕"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[8]||(o[8]=a=>n.$emit("align","distributeHor")),title:"水平分布"},"⇔"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[9]||(o[9]=a=>n.$emit("align","distributeVer")),title:"垂直分布"},"⇕")])):e.createCommentVNode("",!0),t.hasMultiSelection?(e.openBlock(),e.createElementBlock("div",Wn,[e.createElementVNode("button",{class:"tb-btn",onClick:o[10]||(o[10]=a=>n.$emit("group")),title:"组合"},"组合")])):e.createCommentVNode("",!0),!t.hasMultiSelection&&t.selectedElementHasGroup?(e.openBlock(),e.createElementBlock("div",Kn,[e.createElementVNode("button",{class:"tb-btn",onClick:o[11]||(o[11]=a=>n.$emit("ungroup")),title:"取消组合"},"取消组合")])):e.createCommentVNode("",!0),t.hasSelection?(e.openBlock(),e.createElementBlock("div",Yn,[e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[12]||(o[12]=a=>n.$emit("move-layer","top")),"data-tip":"置顶"},"⤒"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[13]||(o[13]=a=>n.$emit("move-layer","up")),"data-tip":"上移一层"},"↑"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[14]||(o[14]=a=>n.$emit("move-layer","down")),"data-tip":"下移一层"},"↓"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[15]||(o[15]=a=>n.$emit("move-layer","bottom")),"data-tip":"置底"},"⤓")])):e.createCommentVNode("",!0),e.createElementVNode("div",Xn,[e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showGrid}]),onClick:o[16]||(o[16]=a=>n.$emit("toggle-grid"))},[...o[29]||(o[29]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 网格 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showTableGhostBorder}]),title:"显示/隐藏无边框表格的虚拟虚线",onClick:o[17]||(o[17]=a=>n.$emit("toggle-table-ghost-border"))},[...o[30]||(o[30]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 虚框 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.snapToGrid}]),onClick:o[18]||(o[18]=a=>n.$emit("toggle-snap"))},[...o[31]||(o[31]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 吸附 ",-1)])],2),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[19]||(o[19]=a=>n.$emit("fit-window")),title:"适应窗口"},"⤢"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[20]||(o[20]=a=>n.$emit("zoom",-10)),title:"缩小"},"−"),e.createElementVNode("span",jn,e.toDisplayString(l.value)+"%",1),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:o[21]||(o[21]=a=>n.$emit("zoom",10)),title:"放大"},"+")]),o[32]||(o[32]=e.createElementVNode("div",{class:"tb-spacer"},null,-1)),e.createElementVNode("div",Jn,[e.createElementVNode("button",{class:"tb-btn",onClick:o[22]||(o[22]=a=>n.$emit("add-overlay-element"))},"首页专属"),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{warn:t.overlayVisible}]),onClick:o[23]||(o[23]=a=>n.$emit("toggle-overlay"))},"叠层对比",2)]),e.createElementVNode("div",Zn,[t.showLoadDefault?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn-secondary",onClick:o[24]||(o[24]=a=>n.$emit("load-default"))},"加载默认布局")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"btn-secondary",onClick:o[25]||(o[25]=a=>n.$emit("preview"))},"预览"),e.createElementVNode("button",{class:"btn-primary",onClick:o[26]||(o[26]=a=>n.$emit("save"))},"保存")])]))}}),_=(t,l)=>{const n=t.__vccOpts||t;for(const[o,a]of l)n[o]=a;return n},_n=_(Qn,[["__scopeId","data-v-76b4f0cc"]]),eo={class:"layer-panel"},to=["onClick"],no={class:"layer-icon"},oo={class:"layer-name"},lo={key:0,class:"layer-zone"},ao={class:"layer-zindex"},io={key:0,class:"layer-actions"},ro=e.defineComponent({__name:"LayerPanel",props:{elements:{},selectedIds:{}},emits:["select","move-layer"],setup(t){const l=t,n=e.computed(()=>[...l.elements].sort((s,d)=>(d.options.zIndex??0)-(s.options.zIndex??0))),o={text:"T",longText:"¶",table:"⊞",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function a(s){return o[s.printElementType.type]||"?"}function i(s){return s.options.title||s.printElementType.title||s.printElementType.type}function r(s){return s.zone==="header"?"页眉":s.zone==="footer"?"页脚":""}return(s,d)=>(e.openBlock(),e.createElementBlock("div",eo,[d[4]||(d[4]=e.createElementVNode("div",{class:"panel-title"},"图层",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,u=>(e.openBlock(),e.createElementBlock("div",{key:u.id,class:e.normalizeClass(["layer-item",{active:t.selectedIds.has(u.id)}]),onClick:f=>s.$emit("select",u.id,!1)},[e.createElementVNode("span",no,e.toDisplayString(a(u)),1),e.createElementVNode("span",oo,e.toDisplayString(i(u)),1),r(u)?(e.openBlock(),e.createElementBlock("span",lo,e.toDisplayString(r(u)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",ao,"z:"+e.toDisplayString(u.options.zIndex??0),1)],10,to))),128)),n.value.length>0?(e.openBlock(),e.createElementBlock("div",io,[e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[0]||(d[0]=u=>s.$emit("move-layer","top")),title:"置顶"}," ⤒ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[1]||(d[1]=u=>s.$emit("move-layer","up")),title:"上移"}," ↑ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[2]||(d[2]=u=>s.$emit("move-layer","down")),title:"下移"}," ↓ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[3]||(d[3]=u=>s.$emit("move-layer","bottom")),title:"置底"}," ⤓ ")])):e.createCommentVNode("",!0)]))}}),so=_(ro,[["__scopeId","data-v-d091c3fa"]]);function It(t){const l=[...t].sort((r,s)=>(r.sortOrder??0)-(s.sortOrder??0)),n=new Map,o=[];for(const r of l){const s=r.fieldKey.indexOf(".");if(s===-1)continue;const d=r.fieldKey.slice(0,s);let u=n.get(d);u||(u={key:d,label:d,isList:!1,fields:[]},n.set(d,u),o.push(d)),u.fields.push(r)}const a=[],i=[];for(const r of l){if(r.fieldKey.includes("."))continue;const s=n.get(r.fieldKey);s?(s.label=r.fieldLabel,s.isList=r.fieldType==="list"):i.push(r)}i.length&&a.push({key:"",label:"",isList:!1,fields:i});for(const r of o)a.push(n.get(r));return a}function At(t,l){const n=l.trim().toLowerCase();return n?t.map(o=>({...o,fields:o.fields.filter(a=>a.fieldLabel.toLowerCase().includes(n)||a.fieldKey.toLowerCase().includes(n))})).filter(o=>o.fields.length>0):t}const co={class:"field-tree-panel"},uo={class:"tree-container"},mo=["onClick"],po={class:"expand-icon"},fo={class:"node-icon"},vo={class:"group-label"},go=["onDragstart"],ho={class:"node-label"},bo={class:"node-key"},yo={key:0,class:"pd-empty"},ko=e.defineComponent({__name:"FieldTreePanel",props:{fields:{}},emits:["field-drag"],setup(t,{emit:l}){const n=t,o=l,a=e.ref(""),i=e.ref(new Set),r=e.computed(()=>!!a.value.trim()),s=e.computed(()=>At(It(n.fields),a.value));function d(f){const m=new Set(i.value);m.has(f)?m.delete(f):m.add(f),i.value=m}function u(f,m){f.dataTransfer?.setData("fieldData",JSON.stringify({fieldKey:m.fieldKey,fieldLabel:m.fieldLabel})),f.dataTransfer&&(f.dataTransfer.effectAllowed="copy"),o("field-drag",m)}return(f,m)=>(e.openBlock(),e.createElementBlock("div",co,[m[2]||(m[2]=e.createElementVNode("div",{class:"panel-title"},"业务字段",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":m[0]||(m[0]=y=>a.value=y),class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段"},null,512),[[e.vModelText,a.value]]),e.createElementVNode("div",uo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,y=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:y.key||"_top"},[y.key?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["field-group-header",{"is-list":y.isList}]),onClick:B=>d(y.key)},[e.createElementVNode("span",po,e.toDisplayString(i.value.has(y.key)&&!r.value?"▶":"▼"),1),e.createElementVNode("span",fo,e.toDisplayString(y.isList?"📋":"📁"),1),e.createElementVNode("span",vo,e.toDisplayString(y.label),1)],10,mo)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.fields,B=>(e.openBlock(),e.createElementBlock("div",{key:B.fieldKey,class:"field-row",draggable:"true",style:e.normalizeStyle({paddingLeft:(y.key?22:8)+"px"}),onDragstart:z=>u(z,B)},[m[1]||(m[1]=e.createElementVNode("span",{class:"node-icon"},"📄",-1)),e.createElementVNode("span",ho,e.toDisplayString(B.fieldLabel),1),e.createElementVNode("span",bo,"("+e.toDisplayString(B.fieldKey)+")",1)],44,go))),128))],512),[[e.vShow,!y.key||r.value||!i.value.has(y.key)]])],64))),128))]),s.value.length===0?(e.openBlock(),e.createElementBlock("p",yo,"暂无字段")):e.createCommentVNode("",!0)]))}}),Eo=_(ko,[["__scopeId","data-v-cc814de0"]]),wo={key:0,class:"left-collapsed"},Vo={class:"left-head"},No={class:"pd-tabs left-tabs"},Co={class:"pd-tab-bar",role:"tablist"},So={class:"pd-tab-pane",role:"tabpanel"},$o=["onDragstart"],Mo={class:"material-icon"},Bo={class:"material-label"},xo={class:"pd-tab-pane",role:"tabpanel"},Do={class:"pd-tab-pane",role:"tabpanel"},To=e.defineComponent({__name:"LeftPanel",props:{fields:{},elements:{},selectedIds:{},collapsed:{type:Boolean}},emits:["select","move-layer","toggle-visible","toggle-locked","field-drag","toggle-collapse"],setup(t,{emit:l}){const n=l,o=e.ref("elements"),a=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}];function i(d,u){d.dataTransfer?.setData("elementType",u)}function r(d){n("field-drag",d)}function s(d){o.value=d,n("toggle-collapse")}return(d,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["left-panel",{collapsed:t.collapsed}])},[t.collapsed?(e.openBlock(),e.createElementBlock("div",wo,[e.createElementVNode("button",{class:"lc-btn",title:"展开素材台",onClick:u[0]||(u[0]=f=>s(o.value))},"»"),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:o.value==="elements"}]),title:"元素",onClick:u[1]||(u[1]=f=>s("elements"))},"▦",2),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:o.value==="fields"}]),title:"字段",onClick:u[2]||(u[2]=f=>s("fields"))},"⊛",2),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:o.value==="layers"}]),title:"图层",onClick:u[3]||(u[3]=f=>s("layers"))},"≡",2)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Vo,[u[12]||(u[12]=e.createElementVNode("span",{class:"left-title"},"素材台",-1)),e.createElementVNode("button",{class:"collapse-btn",title:"收起素材台",onClick:u[4]||(u[4]=f=>d.$emit("toggle-collapse"))},"«")]),e.createElementVNode("div",No,[e.createElementVNode("div",Co,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:o.value==="elements"}]),onClick:u[5]||(u[5]=f=>o.value="elements")},"元素",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:o.value==="fields"}]),onClick:u[6]||(u[6]=f=>o.value="fields")},"字段",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:o.value==="layers"}]),onClick:u[7]||(u[7]=f=>o.value="layers")},"图层",2)]),e.withDirectives(e.createElementVNode("div",So,[u[13]||(u[13]=e.createElementVNode("div",{class:"panel-title"},"拖拽元素到画布",-1)),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,f=>e.createElementVNode("div",{key:f.type,class:"material-card",draggable:"true",onDragstart:m=>i(m,f.type)},[e.createElementVNode("span",Mo,e.toDisplayString(f.icon),1),e.createElementVNode("span",Bo,e.toDisplayString(f.label),1)],40,$o)),64))],512),[[e.vShow,o.value==="elements"]]),e.withDirectives(e.createElementVNode("div",xo,[e.createVNode(Eo,{fields:t.fields,onFieldDrag:r},null,8,["fields"])],512),[[e.vShow,o.value==="fields"]]),e.withDirectives(e.createElementVNode("div",Do,[e.createVNode(so,{elements:t.elements,"selected-ids":t.selectedIds,onSelect:u[8]||(u[8]=(f,m)=>d.$emit("select",f,m)),onMoveLayer:u[9]||(u[9]=f=>d.$emit("move-layer",f)),onToggleVisible:u[10]||(u[10]=f=>d.$emit("toggle-visible",f)),onToggleLocked:u[11]||(u[11]=f=>d.$emit("toggle-locked",f))},null,8,["elements","selected-ids"])],512),[[e.vShow,o.value==="layers"]])])],64))],2))}}),zo=_(To,[["__scopeId","data-v-eb646f19"]]);function Lo(t,l){const n=e.ref(!1),o=e.ref(null);let a=0,i=0,r=0,s=0,d=!1;function u(E){if(l.disabled)return;const V=E.target;if(!(V instanceof HTMLElement)||V.classList.contains("resize-handle"))return;n.value=!0,d=E.altKey,a=E.clientX,i=E.clientY;const A=t.value;A&&(r=parseFloat(A.style.left)||0,s=parseFloat(A.style.top)||0,o.value={left:r,top:s,width:parseFloat(A.style.width)||0,height:parseFloat(A.style.height)||0},l.onStart?.({altKey:d}),document.addEventListener("mousemove",m),document.addEventListener("mouseup",y),E.preventDefault())}function f(E){const V=l.getScale?.()??1;let A=r+(E.clientX-a)/V,H=s+(E.clientY-i)/V;if(l.axis==="x"&&(H=s),l.axis==="y"&&(A=r),l.onAdsorb){const W=t.value;if(W){const L=parseFloat(W.style.width)||0,G=parseFloat(W.style.height)||0,Y=l.onAdsorb({left:A,top:H,width:L,height:G});A=Y.left,H=Y.top}}return{left:A,top:H}}function m(E){const V=f(E);o.value&&(o.value.left=V.left,o.value.top=V.top),l.onDrag(V)}function y(E){n.value=!1;const V=f(E);l.onDragEnd?.(V,{altKey:d}),l.onStop?.(),o.value=null,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",y)}function B(){const E=t.value;E&&E.removeEventListener("mousedown",u),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",y)}function z(){B();const E=t.value;E&&E.addEventListener("mousedown",u)}return{isDragging:n,dragPreview:o,setup:z,cleanup:B}}const Po=["nw","n","ne","e","se","s","sw","w"];function Io(t,l,n,o,a,i){let{left:r,top:s,width:d,height:u}=l;switch(t){case"e":d=Math.max(a,l.width+n);break;case"w":d=Math.max(a,l.width-n),r=l.left+l.width-d;break;case"s":u=Math.max(i,l.height+o);break;case"n":u=Math.max(i,l.height-o),s=l.top+l.height-u;break;case"se":d=Math.max(a,l.width+n),u=Math.max(i,l.height+o);break;case"sw":d=Math.max(a,l.width-n),r=l.left+l.width-d,u=Math.max(i,l.height+o);break;case"ne":d=Math.max(a,l.width+n),u=Math.max(i,l.height-o),s=l.top+l.height-u;break;case"nw":d=Math.max(a,l.width-n),r=l.left+l.width-d,u=Math.max(i,l.height-o),s=l.top+l.height-u;break}return{left:r,top:s,width:d,height:u}}function Ao(t){let l=0,n=0,o={left:0,top:0,width:0,height:0},a=null;function i(u,f){a=u,l=f.clientX,n=f.clientY,o={...t.getRect()},t.onStart?.(),document.addEventListener("mousemove",r),document.addEventListener("mouseup",s),f.preventDefault()}function r(u){if(!a)return;const f=t.getScale?.()||1,m=(u.clientX-l)/f,y=(u.clientY-n)/f,B=t.minWidth||20,z=t.minHeight||20;t.onResize(Io(a,o,m,y,B,z))}function s(){a=null,t.onStop?.(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s)}function d(){document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s)}return{startResize:i,cleanup:d}}function Ro(t,l){return l.split(".").reduce((n,o)=>n?.[o],t)}function Uo(){function t(l){const n=l.options.formatter,o=l.options.title;if(!n)return{status:"unbound",badge:o||"文本",badgeColor:"#909399",demoPreview:o||"文本"};const a=xt(),i=n.match(/\{([^}]+)\}/);if(i){const r=i[1],s=Ro(a,r);return{status:"bound",badge:`fx ${n}`,badgeColor:"#409EFF",demoPreview:s!=null?String(s):n}}return{status:"bound",badge:`fx ${n}`,badgeColor:"#409EFF",demoPreview:n}}return{getBindingDisplayState:t}}const Fo=e.defineComponent({__name:"TextElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n={top:"flex-start",middle:"center",bottom:"flex-end"},o={left:"flex-start",center:"center",right:"flex-end"},a=e.computed(()=>{const r=l.element.options;return{fontSize:(r.fontSize||12)+"pt",fontWeight:r.fontWeight||"normal",fontFamily:r.fontFamily||"inherit",color:r.color||"#333",backgroundColor:r.backgroundColor||"transparent",textAlign:r.textAlign||"left",lineHeight:r.lineHeight?r.lineHeight+"pt":"normal",letterSpacing:r.letterSpacing?r.letterSpacing+"pt":"normal",textDecoration:r.textDecoration||"none",padding:`${r.contentPaddingTop||0}pt ${r.contentPaddingRight||0}pt ${r.contentPaddingBottom||0}pt ${r.contentPaddingLeft||0}pt`,width:"100%",height:"100%",boxSizing:"border-box",overflow:"hidden",...r.verticalAlign?{display:"flex",alignItems:n[r.verticalAlign]??"flex-start",justifyContent:o[r.textAlign||"left"]??"flex-start"}:{}}}),i=e.computed(()=>l.designMode?l.element.options.testData?l.element.options.testData:l.element.options.formatter||"文本":Ue(l.element.options,l.data));return(r,s)=>(e.openBlock(),e.createElementBlock("div",{class:"print-text",style:e.normalizeStyle(a.value)},e.toDisplayString(i.value),5))}}),Ho={class:"print-image"},Oo=["src"],Go={key:1,class:"image-placeholder"},qo=e.defineComponent({__name:"ImageElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n=e.computed(()=>{const r=l.element.options.src||"";return r?r.includes("{")?l.designMode?Ce(r,fe):Ce(r,l.data?.[0]||{}):r:""}),o=e.ref(!1);function a(){o.value=!0}e.watch(n,()=>{o.value=!1});const i=e.computed(()=>({objectFit:l.element.options.fit||"contain"}));return(r,s)=>(e.openBlock(),e.createElementBlock("div",Ho,[n.value&&!o.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.value,style:e.normalizeStyle(i.value),onError:a},null,44,Oo)):(e.openBlock(),e.createElementBlock("div",Go,"图片"))]))}}),Wo=_(qo,[["__scopeId","data-v-530ee54f"]]),Ko=e.defineComponent({__name:"LongTextElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n={top:"flex-start",middle:"center",bottom:"flex-end"},o={left:"flex-start",center:"center",right:"flex-end"},a=e.computed(()=>{const r=l.element.options;return{fontSize:(r.fontSize||12)+"pt",fontWeight:r.fontWeight||"normal",fontFamily:r.fontFamily||"inherit",color:r.color||"#333",backgroundColor:r.backgroundColor||"transparent",textAlign:r.textAlign||"left",lineHeight:r.lineHeight?r.lineHeight+"pt":"1.5",letterSpacing:r.letterSpacing?r.letterSpacing+"pt":"normal",textIndent:r.longTextIndent?r.longTextIndent+"pt":"0",width:"100%",height:"100%",overflow:"hidden",wordBreak:"break-all",boxSizing:"border-box",...r.verticalAlign?{display:"flex",alignItems:n[r.verticalAlign]??"flex-start",justifyContent:o[r.textAlign||"left"]??"flex-start"}:{}}}),i=e.computed(()=>l.designMode?l.element.options.formatter?l.element.options.formatter:"长文本内容":Ue(l.element.options,l.data));return(r,s)=>(e.openBlock(),e.createElementBlock("div",{class:"print-longtext",style:e.normalizeStyle(a.value)},e.toDisplayString(i.value),5))}}),Yo=["title"],Xo=["title","onClick"],jo=e.defineComponent({__name:"TableContextMenu",props:{visible:{type:Boolean},x:{},y:{},canDeleteRow:{type:Boolean},canDeleteCol:{type:Boolean},mergeDisabledReason:{},canSplit:{type:Boolean},currentRowType:{},rowTypeDisabledReason:{type:Function}},emits:["action"],setup(t,{emit:l}){const n=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],o=l;function a(i,r){o("action",i,r)}return(i,r)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:"table-ctx-menu",style:e.normalizeStyle({left:t.x+"px",top:t.y+"px"}),onMousedown:r[8]||(r[8]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:"menu-item",onClick:r[0]||(r[0]=s=>a("insert-row-above"))},"在上方插入行"),e.createElementVNode("div",{class:"menu-item",onClick:r[1]||(r[1]=s=>a("insert-row-below"))},"在下方插入行"),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canDeleteRow}]),onClick:r[2]||(r[2]=s=>t.canDeleteRow&&a("delete-row"))}," 删除行 ",2),r[9]||(r[9]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),e.createElementVNode("div",{class:"menu-item",onClick:r[3]||(r[3]=s=>a("insert-col-left"))},"在左侧插入列"),e.createElementVNode("div",{class:"menu-item",onClick:r[4]||(r[4]=s=>a("insert-col-right"))},"在右侧插入列"),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canDeleteCol}]),onClick:r[5]||(r[5]=s=>t.canDeleteCol&&a("delete-col"))}," 删除列 ",2),r[10]||(r[10]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!!t.mergeDisabledReason}]),title:t.mergeDisabledReason||"",onClick:r[6]||(r[6]=s=>!t.mergeDisabledReason&&a("merge"))}," 合并单元格 ",10,Yo),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canSplit}]),onClick:r[7]||(r[7]=s=>t.canSplit&&a("split"))}," 拆分单元格 ",2),r[11]||(r[11]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),r[12]||(r[12]=e.createElementVNode("div",{class:"menu-group-title"},"行类型",-1)),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,s=>e.createElementVNode("div",{key:s.value,class:e.normalizeClass(["menu-item",{disabled:!!t.rowTypeDisabledReason(s.value),active:t.currentRowType===s.value}]),title:t.rowTypeDisabledReason(s.value)||"",onClick:d=>!t.rowTypeDisabledReason(s.value)&&a("set-row-type",s.value)},e.toDisplayString(s.label),11,Xo)),64))],36)):e.createCommentVNode("",!0)]))}}),Jo=_(jo,[["__scopeId","data-v-3f0b28d4"]]),Zo={class:"cell-barcode"},Qo=["src"],_o={key:1,class:"cell-barcode-fallback"},el=e.defineComponent({__name:"CellBarcode",props:{cellType:{},value:{},barcodeType:{},qrCodeLevel:{},showText:{type:Boolean},fit:{},maxWidth:{},maxHeight:{}},setup(t){const l=t,n=e.ref(null),o=e.ref(!1),a=e.ref(""),i=e.computed(()=>({objectFit:l.fit||"contain",maxWidth:l.maxWidth?`${l.maxWidth}mm`:"100%",maxHeight:l.maxHeight?`${l.maxHeight}mm`:"100%"})),r=e.computed(()=>({objectFit:l.fit||"contain",maxWidth:l.maxWidth?`${l.maxWidth}mm`:"100%",maxHeight:l.maxHeight?`${l.maxHeight}mm`:"100%"}));function s(){if(o.value=!1,!!n.value)try{tt(n.value,l.value,{format:l.barcodeType||"CODE128",width:1,height:28,displayValue:l.showText!==!1,fontSize:9,margin:0}),o.value=!0}catch{}}async function d(){if(!l.value){a.value="";return}try{a.value=await nt.toDataURL(l.value,{width:96,margin:1,errorCorrectionLevel:l.qrCodeLevel||"M"})}catch{a.value=""}}function u(){l.cellType==="barcode"?s():d()}return e.onMounted(u),e.watch(()=>[l.cellType,l.value,l.barcodeType,l.qrCodeLevel,l.showText],u),(f,m)=>(e.openBlock(),e.createElementBlock("div",Zo,[e.withDirectives((e.openBlock(),e.createElementBlock("svg",{ref_key:"barcodeSvg",ref:n,preserveAspectRatio:"xMidYMid meet",style:e.normalizeStyle(i.value)},null,4)),[[e.vShow,t.cellType==="barcode"&&o.value]]),t.cellType==="qrcode"&&a.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:a.value,alt:"qrcode",style:e.normalizeStyle(r.value)},null,12,Qo)):e.createCommentVNode("",!0),!o.value&&t.cellType==="barcode"?(e.openBlock(),e.createElementBlock("span",_o,e.toDisplayString(t.value||"条码"),1)):e.createCommentVNode("",!0)]))}}),tl=_(el,[["__scopeId","data-v-612f4008"]]),nl={class:"cell-image"},ol=["src"],ll={key:1,class:"image-placeholder"},al=e.defineComponent({__name:"CellImage",props:{value:{},fit:{},maxWidth:{},maxHeight:{},designMode:{type:Boolean},data:{}},setup(t){const l=t,n=e.computed(()=>{const r=l.value||"";return r?r.includes("{")?l.designMode?Ce(r,fe):Ce(r,l.data?.[0]||{}):r:""}),o=e.ref(!1);function a(){o.value=!0}e.watch(n,()=>{o.value=!1});const i=e.computed(()=>({objectFit:l.fit||"contain",maxWidth:l.maxWidth?`${l.maxWidth}mm`:"100%",maxHeight:l.maxHeight?`${l.maxHeight}mm`:"100%"}));return(r,s)=>(e.openBlock(),e.createElementBlock("div",nl,[n.value&&!o.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.value,style:e.normalizeStyle(i.value),onError:a},null,44,ol)):(e.openBlock(),e.createElementBlock("div",ll,"图片"))]))}}),il=_(al,[["__scopeId","data-v-7f838bbb"]]),rl=["rowspan","colspan","onMousedown","onMouseenter","onDblclick","onContextmenu"],sl={key:2,class:"data-placeholder"},dl={key:0,class:"col-resize-layer"},cl=["onMousedown"],ul={key:1,class:"row-badges"},Ye=3.7795275591,ml=.1,pl=e.defineComponent({__name:"TableElement",props:{element:{},designMode:{type:Boolean},isSelected:{type:Boolean},showTableGhostBorder:{type:Boolean},scale:{},data:{}},emits:["dblclick-element","dblclick-cell"],setup(t,{emit:l}){const n={header:"题",data:"数",subtotal:"小",summary:"汇"},o=t,a=l,i=e.inject(xe,{tableSelection:e.ref(null),setTableSelection:()=>{},recordHistory:()=>{},maxTableWidth:e.ref(1/0)}),r=e.computed(()=>o.element.options.tableRows??[]),s=e.computed(()=>o.element.options.tableColWidths??[]),d=e.computed(()=>o.element.options.tableDefaultFontSize??10),u=e.computed(()=>o.element.options.tableDefaultColor??"#333333"),f=e.computed(()=>{const C=i.tableSelection.value;return C&&C.elementId===o.element.id?C:null});function m(C){let $=0;for(let D=0;D<C;D++)$+=r.value[D].height;return $}const y=e.ref(null),B=e.ref([]);function z(){if(!o.designMode)return;const C=y.value;if(!C)return;const $=C.offsetHeight;if($<=0)return;const D=o.element.options,w=$/Ye;Math.abs(w-(D.height??0))>ml&&(D.height=Math.round(w*100)/100);const k=C.offsetTop;B.value=Array.from(C.rows).map(q=>({top:(q.offsetTop-k)/Ye,height:q.offsetHeight/Ye}))}function E(C){return B.value[C]?.top??m(C)}function V(C){return B.value[C]?.height??r.value[C]?.height??0}e.watch(()=>[o.element.options,o.designMode],()=>z(),{deep:!0,flush:"post"}),e.onMounted(()=>{z(),document.fonts?.ready.then(()=>z())});const A=e.computed(()=>{const C=o.element.options.dataSource;if(C&&Array.isArray(fe[C]))return fe[C];for(const $ of Object.values(fe))if(Array.isArray($))return $}),H=e.computed(()=>{if(o.data)return o.data});function W(C){return C.cellType==="barcode"||C.cellType==="qrcode"}function L(C,$){return W($)?vn($.formatter,A.value):$.formatter||""}function G(C,$){const D=o.element.options,w={designMode:o.designMode,showGhostBorder:o.showTableGhostBorder};return{fontFamily:$.fontFamily||"inherit",textAlign:$.align??"left",verticalAlign:$.valign??"middle",fontSize:($.fontSize??d.value)+"pt",fontWeight:$.fontWeight??"normal",color:$.color??u.value,backgroundColor:$.backgroundColor??"transparent",borderTop:Le($.borders?.top,w),borderRight:Le($.borders?.right,w),borderBottom:Le($.borders?.bottom,w),borderLeft:Le($.borders?.left,w),padding:($.padding??D.tableDefaultPadding??1)+"mm",whiteSpace:$.wordWrap??!0?"normal":"nowrap",overflow:$.wordWrap??!0?"visible":"hidden"}}function Y(C,$){const D=f.value;return{"cell-selected":!!D&&C>=D.r1&&C<=D.r2&&$>=D.c1&&$<=D.c2,"row-data-bg":r.value[C].type==="data"}}const J=e.ref(null);function P(C,$){const D=Ct(r.value,C,$);i.setTableSelection({elementId:o.element.id,...D})}function v(C,$,D){!o.designMode||!o.isSelected||(D.stopPropagation(),D.shiftKey&&f.value?P({r:f.value.r1,c:f.value.c1},{r:C,c:$}):(J.value={r:C,c:$},P({r:C,c:$},{r:C,c:$})),window.addEventListener("mouseup",()=>{J.value=null},{once:!0}))}function g(C,$){J.value&&P(J.value,{r:C,c:$})}function M(C,$){o.designMode&&a("dblclick-cell",o.element.id,C,$)}const x=e.reactive({visible:!1,x:0,y:0});function c(C,$,D){if(!o.designMode||!o.isSelected)return;const w=f.value;w&&C>=w.r1&&C<=w.r2&&$>=w.c1&&$<=w.c2||P({r:C,c:$},{r:C,c:$}),x.x=D.clientX,x.y=D.clientY,x.visible=!0,window.addEventListener("mousedown",()=>{x.visible=!1},{once:!0})}const h=e.computed(()=>{const C=f.value;return C?St(r.value,C):"未选择单元格"}),T=e.computed(()=>{const C=f.value;if(!C)return!1;for(let $=C.r1;$<=C.r2;$++)for(let D=C.c1;D<=C.c2;D++){const w=r.value[$].cells[D];if(!w.merged&&((w.rowspan??1)>1||(w.colspan??1)>1))return!0}return!1});function O(C){const $=f.value;if(!$)return"未选择单元格";if($.r1!==$.r2)return"行类型仅支持单行设置";const D=JSON.parse(JSON.stringify(r.value));return Ze(D,$.r1,C)}function X(){Re(o.element.options)}function oe(C,$){const D=i.maxTableWidth.value,w=C.reduce((k,q)=>k+q,0)+C[$];return w>D?`插入后表格总宽 ${Math.round(w*10)/10}mm 超过打印范围宽度 ${D}mm,请先缩小列宽`:null}function ie(C,$){const D=f.value;if(!D)return;x.visible=!1;const w=o.element.options,k=w.tableRows,q=w.tableColWidths;let Z=null;switch(C){case"insert-row-above":mt(k,D.r1,"above");break;case"insert-row-below":mt(k,D.r2,"below");break;case"delete-row":Z=an(k,D.r1);break;case"insert-col-left":Z=oe(q,D.c1),Z||pt(k,q,D.c1,"left");break;case"insert-col-right":Z=oe(q,D.c2),Z||pt(k,q,D.c2,"right");break;case"delete-col":Z=rn(k,q,D.c1);break;case"merge":$t(k,D);break;case"split":Mt(k,D);break;case"set-row-type":Z=Ze(k,D.r1,$);break}if(Z){alert(Z);return}i.setTableSelection(null),X(),i.recordHistory()}const re=e.computed(()=>o.designMode&&!!o.isSelected&&!o.element.options.locked&&s.value.length>1),se=e.computed(()=>s.value.length>1?Array.from({length:s.value.length-1},(C,$)=>$+1):[]);function ae(C){return s.value.slice(0,C).reduce(($,D)=>$+D,0)}const p=e.ref(null);let b=0,N=0;function S(C,$){re.value&&(p.value=C,b=$.clientX,N=s.value[C-1],document.addEventListener("mousemove",U),document.addEventListener("mouseup",K))}function U(C){if(p.value===null)return;const $=o.scale||1,D=(C.clientX-b)/$,w=p.value-1,k=o.element.options.tableColWidths;k[w]=cn(k,w,N+D,i.maxTableWidth.value)}function K(){document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",K),p.value!==null&&(p.value=null,X(),i.recordHistory())}return e.onUnmounted(()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",K)}),(C,$)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["print-table",{"design-mode":t.designMode}]),onContextmenu:$[0]||($[0]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("table",{ref_key:"tableRef",ref:y,style:e.normalizeStyle({fontSize:d.value+"pt",color:u.value})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(D,w)=>(e.openBlock(),e.createElementBlock("col",{key:w,style:e.normalizeStyle({width:D+"mm"})},null,4))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(D,w)=>(e.openBlock(),e.createElementBlock("tr",{key:D.id,style:e.normalizeStyle({height:D.height+"mm"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.cells,(k,q)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.id},[k.merged?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("td",{key:0,rowspan:k.rowspan||1,colspan:k.colspan||1,class:e.normalizeClass(Y(w,q)),style:e.normalizeStyle(G(D,k)),onMousedown:e.withModifiers(Z=>v(w,q,Z),["left"]),onMouseenter:Z=>g(w,q),onDblclick:e.withModifiers(Z=>M(w,q),["stop"]),onContextmenu:e.withModifiers(Z=>c(w,q,Z),["prevent","stop"])},[W(k)?(e.openBlock(),e.createBlock(tl,{key:0,"cell-type":k.cellType,value:L(D,k),"barcode-type":k.barcodeType,"qr-code-level":k.qrCodeLevel,"show-text":k.showBarcodeText,fit:k.fit,"max-width":k.maxWidth,"max-height":k.maxHeight},null,8,["cell-type","value","barcode-type","qr-code-level","show-text","fit","max-width","max-height"])):k.cellType==="image"?(e.openBlock(),e.createBlock(il,{key:1,value:k.formatter||"",fit:k.fit,"max-width":k.maxWidth,"max-height":k.maxHeight,"design-mode":t.designMode,data:H.value},null,8,["value","fit","max-width","max-height","design-mode","data"])):D.type==="data"?(e.openBlock(),e.createElementBlock("span",sl,e.toDisplayString(L(D,k)),1)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(L(D,k)),1)],64))],46,rl))],64))),128))],4))),128))])],4),re.value?(e.openBlock(),e.createElementBlock("div",dl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(se.value,D=>(e.openBlock(),e.createElementBlock("div",{key:D,class:e.normalizeClass(["col-resize-handle",{dragging:p.value===D}]),style:e.normalizeStyle({left:ae(D)+"mm"}),onMousedown:e.withModifiers(w=>S(D,w),["stop","prevent"])},null,46,cl))),128))])):e.createCommentVNode("",!0),t.designMode&&t.isSelected?(e.openBlock(),e.createElementBlock("div",ul,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(D,w)=>(e.openBlock(),e.createElementBlock("span",{key:D.id,class:"row-badge",style:e.normalizeStyle({top:E(w)+"mm",height:V(w)+"mm"})},e.toDisplayString(n[D.type]),5))),128))])):e.createCommentVNode("",!0),e.createVNode(Jo,{visible:x.visible,x:x.x,y:x.y,"can-delete-row":r.value.length>1,"can-delete-col":s.value.length>1,"merge-disabled-reason":h.value,"can-split":T.value,"current-row-type":f.value?r.value[f.value.r1]?.type??null:null,"row-type-disabled-reason":O,onAction:ie},null,8,["visible","x","y","can-delete-row","can-delete-col","merge-disabled-reason","can-split","current-row-type"])],34))}}),fl=_(pl,[["__scopeId","data-v-ce38806a"]]),ht=e.defineComponent({__name:"LineElement",props:{element:{}},setup(t){const l=t,n=e.computed(()=>l.element.printElementType.type==="hline"),o=e.computed(()=>{const a=l.element.options,i=(a.borderWidth||.75)+"pt",r=a.borderStyle||"solid",s=a.borderColor||"#333";return n.value?{width:"100%",height:"0",borderTop:`${i} ${r} ${s}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${i} ${r} ${s}`,boxSizing:"border-box"}});return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:"print-line",style:e.normalizeStyle(o.value)},null,4))}}),bt=e.defineComponent({__name:"ShapeElement",props:{element:{}},setup(t){const l=t,n=e.computed(()=>l.element.printElementType.type==="oval"),o=e.computed(()=>{const a=l.element.options;return{width:"100%",height:"100%",borderWidth:(a.borderWidth||1)+"pt",borderStyle:a.borderStyle||"solid",borderColor:a.borderColor||"#333",backgroundColor:a.backgroundColor||"transparent",borderRadius:n.value?"50%":"0",boxSizing:"border-box"}});return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:"print-shape",style:e.normalizeStyle(o.value)},null,4))}}),vl={class:"print-barcode",ref:"containerRef"},gl=96/25.4,hl=e.defineComponent({__name:"BarcodeElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n=e.ref(null);function o(){if(!n.value)return;const a=l.element.options,i=(l.designMode?a.testData||a.formatter:Ue(a,l.data))||"条码",r=!a.hideTitle,s=(a.fontSize||12)*(96/72),d=(a.height||40)*gl,u=r?s+4:0,f=Math.max(8,d-u);try{tt(n.value,i,{format:a.barcodeType||"CODE128",width:a.barWidth?a.barWidth/2:1,height:f,displayValue:r,fontSize:s,margin:2})}catch{}}return e.onMounted(o),e.watch(()=>[l.element.options.formatter,l.element.options.testData,l.element.options.barcodeType,l.element.options.width,l.element.options.height,l.element.options.barWidth,l.element.options.hideTitle,l.element.options.fontSize],o),(a,i)=>(e.openBlock(),e.createElementBlock("div",vl,[(e.openBlock(),e.createElementBlock("svg",{ref_key:"svgRef",ref:n,preserveAspectRatio:"xMidYMid meet"},null,512))],512))}}),bl=_(hl,[["__scopeId","data-v-a71e7c44"]]),yl={class:"print-qrcode"},kl=["src"],El=e.defineComponent({__name:"QrcodeElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n=e.ref("");async function o(){const a=l.element.options,i=(l.designMode?a.testData||a.formatter:Ue(a,l.data))||"二维码",r=Math.min(a.width||80,a.height||80);try{n.value=await nt.toDataURL(i,{width:r,margin:1,errorCorrectionLevel:String(a.qrCodeLevel??"M")})}catch{n.value=""}}return e.onMounted(o),e.watch(()=>[l.element.options.formatter,l.element.options.testData],o),(a,i)=>(e.openBlock(),e.createElementBlock("div",yl,[n.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.value,alt:"qrcode"},null,8,kl)):e.createCommentVNode("",!0)]))}}),wl=_(El,[["__scopeId","data-v-90b31b7e"]]),Vl=["innerHTML"],Nl=e.defineComponent({__name:"HtmlElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n=e.computed(()=>{if(l.element.options.formatter){const o=l.data&&l.data.length>0?l.data[0]:{},a=Ce(l.element.options.formatter,o??{});return a?Qt.sanitize(a):""}return'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>'});return(o,a)=>(e.openBlock(),e.createElementBlock("div",{class:"print-html",innerHTML:n.value},null,8,Vl))}}),Cl=_(Nl,[["__scopeId","data-v-f0a224c2"]]),Sl=e.defineComponent({__name:"PageNumberElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,n=e.computed(()=>{const a=l.element.options;return{fontSize:(a.fontSize||12)+"pt",fontWeight:a.fontWeight||"normal",fontFamily:a.fontFamily||"inherit",color:a.color||"#333",textAlign:a.textAlign||"left",lineHeight:a.lineHeight?a.lineHeight+"pt":"normal",letterSpacing:a.letterSpacing?a.letterSpacing+"pt":"normal"}}),o=e.computed(()=>l.designMode?l.element.options.title||"{pageIndex}/{totalPages}":l.element.options.title||"");return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:"page-number-element",style:e.normalizeStyle(n.value)},e.toDisplayString(o.value),5))}}),$l=_(Sl,[["__scopeId","data-v-c3750ca3"]]),Ml={key:0,class:"drag-preview"},Bl={key:1,class:"resize-handles"},xl=["onMousedown"],Dl={key:2,class:"selected-indicator"},Tl={class:"position-label"},zl=e.defineComponent({__name:"BaseElement",props:{element:{},isSelected:{type:Boolean},designMode:{type:Boolean},printData:{},scale:{},allElements:{},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},zone:{},adsorbHandler:{type:Function},clearAdsorbGuides:{type:Function}},emits:["select","update:element","drag-start","drag-stop","dblclick-element","dblclick-cell","contextmenu","clone-element"],setup(t,{emit:l}){const n=t,o=l,a=e.ref(null),i=e.inject(zt,null),r=e.computed(()=>i?.value?i.value.has(n.element.id):n.isSelected??!1),s=e.inject(Lt,null),d=e.computed(()=>s?.value.has(n.element.id)??!1),u={text:e.markRaw(Fo),image:e.markRaw(Wo),longText:e.markRaw(Ko),table:e.markRaw(fl),hline:e.markRaw(ht),vline:e.markRaw(ht),rect:e.markRaw(bt),oval:e.markRaw(bt),barcode:e.markRaw(bl),qrcode:e.markRaw(wl),html:e.markRaw(Cl),pageNumber:e.markRaw($l)},{getBindingDisplayState:f}=Uo(),m=e.computed(()=>n.designMode?f(n.element):null),y=e.computed(()=>u[n.element.printElementType.type]),B=e.computed(()=>n.element.printElementType.type==="table"?{showTableGhostBorder:n.showTableGhostBorder,scale:n.scale}:{}),z=e.computed(()=>{const c=n.element.options;return{position:"absolute",left:c.left+"mm",top:c.top+"mm",width:c.width+"mm",height:c.height+"mm",zIndex:c.zIndex||"auto"}}),E=e.computed(()=>{const c=n.element.options;return`x:${Math.round(c.left)} y:${Math.round(c.top)} ${Math.round(c.width)}×${Math.round(c.height)}mm`});let V=0,A=0;const H=e.reactive({disabled:!n.designMode||!!n.element.options.locked,getScale:()=>n.scale||1,onDrag:c=>{const h=c.left-V,T=c.top-A;a.value&&(a.value.style.transform=`translate(${h}mm, ${T}mm)`)},onDragEnd:(c,h)=>{if(h.altKey){const X=JSON.parse(JSON.stringify(n.element));X.id=Ne(),X.options.left=c.left,X.options.top=c.top,o("clone-element",X,{left:c.left,top:c.top}),a.value&&(a.value.style.transform="");return}const T=c.left-V,O=c.top-A;if(n.element.options.left=c.left,n.element.options.top=c.top,a.value&&(a.value.style.transform=""),n.element.options.groupId&&n.allElements)for(const X of n.allElements)X.id!==n.element.id&&X.options.groupId===n.element.options.groupId&&(X.options.left+=T,X.options.top+=O)},onStart:()=>{V=n.element.options.left,A=n.element.options.top,o("select",n.element.id,!1),o("drag-start")},onStop:()=>{n.clearAdsorbGuides?.(),o("drag-stop")},onAdsorb:c=>{let h=c.left,T=c.top;return n.snapToGrid&&(h=Math.round(c.left/5)*5,T=Math.round(c.top/5)*5),n.adsorbHandler?n.adsorbHandler({id:n.element.id,left:h,top:T,width:n.element.options.width,height:n.element.options.height}):{left:h,top:T,lines:[]}}}),{setup:W,cleanup:L,isDragging:G}=Lo(a,H);e.watchEffect(()=>{H.disabled=!n.designMode||!!n.element.options.locked});const Y=e.computed(()=>r.value&&!!n.designMode&&!n.element.options.locked&&n.element.printElementType.type!=="table"),{startResize:J,cleanup:P}=Ao({minWidth:3.5,minHeight:3.5,getScale:()=>n.scale||1,getRect:()=>({left:n.element.options.left,top:n.element.options.top,width:n.element.options.width,height:n.element.options.height}),onResize:c=>{n.element.options.left=c.left,n.element.options.top=c.top,n.element.options.width=c.width,n.element.options.height=c.height},onStart:()=>{o("drag-start")},onStop:()=>{o("drag-stop")}});function v(c){n.designMode&&o("select",n.element.id,c.ctrlKey||c.metaKey)}function g(){n.designMode&&o("dblclick-element",n.element.id)}function M(c,h,T){n.designMode&&o("dblclick-cell",c,h,T)}e.onMounted(()=>{n.designMode&&W()});function x(){L(),P(),n.clearAdsorbGuides?.()}return e.onUnmounted(()=>{x()}),(c,h)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:a,class:e.normalizeClass(["print-element",{selected:r.value,previewed:d.value,"design-mode":t.designMode,locked:t.element.options.locked,hidden:t.element.options.visible===!1,"drag-ghost":e.unref(G),[`type-${t.element.printElementType.type}`]:!0,[`zone-${t.zone||"content"}`]:!0}]),style:e.normalizeStyle(z.value),onMousedown:e.withModifiers(v,["stop"]),onDblclick:e.withModifiers(g,["stop"]),onContextmenu:h[0]||(h[0]=e.withModifiers(T=>c.$emit("contextmenu",t.element.id,T),["prevent","stop"]))},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y.value),e.mergeProps({element:t.element,data:t.printData,"design-mode":t.designMode,"is-selected":r.value},B.value,{onDblclickCell:M}),null,16,["element","data","design-mode","is-selected"])),e.unref(G)?(e.openBlock(),e.createElementBlock("div",Ml)):e.createCommentVNode("",!0),Y.value?(e.openBlock(),e.createElementBlock("div",Bl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Po),T=>(e.openBlock(),e.createElementBlock("div",{key:T,class:e.normalizeClass(["resize-handle",`handle-${T}`]),onMousedown:e.withModifiers(O=>e.unref(J)(T,O),["stop"])},null,42,xl))),128))])):e.createCommentVNode("",!0),r.value&&t.designMode?(e.openBlock(),e.createElementBlock("div",Dl,[e.createElementVNode("div",Tl,e.toDisplayString(E.value),1)])):e.createCommentVNode("",!0),t.designMode&&m.value?(e.openBlock(),e.createElementBlock("div",{key:3,class:"binding-badge",style:e.normalizeStyle({color:m.value.badgeColor})},e.toDisplayString(m.value.badge),5)):e.createCommentVNode("",!0)],38))}}),Xe=_(zl,[["__scopeId","data-v-8172df50"]]);function Ll(t){const l=[];for(let n=0;n<=t+1e-9;n+=5){const o=Math.round(n*100)/100,a=o%10===0;a?l.push({mm:o,major:a,label:String(o)}):l.push({mm:o,major:a})}return l}const je=96/25.4,Ve=16,Pl=e.defineComponent({__name:"Ruler",props:{orientation:{},lengthMM:{},scale:{}},emits:["add-guide"],setup(t,{emit:l}){const n=t,o=l,a=e.ref(null),i=e.computed(()=>n.orientation==="horizontal"?{width:n.lengthMM+"mm",height:Ve+"px"}:{width:Ve+"px",height:n.lengthMM+"mm"});function r(){const m=a.value;if(!m)return;const y=window.devicePixelRatio||1,B=n.lengthMM*je,z=n.orientation==="horizontal";m.width=(z?B:Ve)*y,m.height=(z?Ve:B)*y;const E=m.getContext("2d");if(!E)return;E.scale(y,y);const V=getComputedStyle(m),A=V.getPropertyValue("--pd-ruler-bg").trim()||"#FFFFFF",H=V.getPropertyValue("--pd-ruler").trim()||"#9CA3AF";E.fillStyle=A,E.fillRect(0,0,z?B:Ve,z?Ve:B),E.strokeStyle=H,E.fillStyle=H,E.lineWidth=1,E.font="8px ui-monospace, Menlo, monospace";for(const W of Ll(n.lengthMM)){const L=Math.round(W.mm*je)+.5,G=W.major?8:4;E.beginPath(),z?(E.moveTo(L,0),E.lineTo(L,G)):(E.moveTo(0,L),E.lineTo(G,L)),E.stroke(),W.major&&W.label&&(z?E.fillText(W.label,L+2,14):(E.save(),E.translate(12,L+2),E.rotate(-Math.PI/2),E.fillText(W.label,-E.measureText(W.label).width,0),E.restore()))}}e.watch(()=>[n.lengthMM,n.orientation],r),e.onMounted(r);let s=!1;function d(m){s=!0,m.preventDefault(),window.addEventListener("mousemove",u),window.addEventListener("mouseup",f)}function u(){}function f(m){if(!s)return;s=!1,window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",f);const y=a.value;if(!y)return;const B=y.getBoundingClientRect(),z=n.scale??1,V=(n.orientation==="horizontal"?(m.clientX-B.left)/z:(m.clientY-B.top)/z)/je;V>0&&V<n.lengthMM&&o("add-guide",n.orientation==="horizontal"?"horizontal":"vertical",V)}return(m,y)=>(e.openBlock(),e.createElementBlock("canvas",{ref_key:"canvasRef",ref:a,class:"pd-ruler",style:e.normalizeStyle(i.value),onMousedown:d},null,36))}}),yt=_(Pl,[["__scopeId","data-v-fdb82e87"]]);function Il(t={}){const l=t.adsorbMin??1,n=t.adsorbLineMin??2,o=t.showAdsorbLine??!0,a=e.ref([]),i=e.ref({width:0,height:0}),r={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function s(m){return m==="vCenter"?r.center:m==="hCenter"?r.middle:r[m]??r.left}function d(m,y,B){let z=m.left,E=m.top;const V=[],A={left:m.left,right:m.left+m.width,vCenter:m.left+m.width/2,top:m.top,bottom:m.top+m.height,hCenter:m.top+m.height/2};let H=1/0;for(const L of y){if(L.id===m.id)continue;const G={left:L.left,right:L.left+L.width,vCenter:L.left+L.width/2,top:L.top,bottom:L.top+L.height,hCenter:L.top+L.height/2},Y=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],J=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[P,v]of Y){const g=Math.abs(A[P]-G[v]);g<=l&&g<H&&(H=g,z=m.left+(G[v]-A[P]))}for(const[P,v]of J){const g=Math.abs(A[P]-G[v]);g<=l&&g<H&&(H=g,E=m.top+(G[v]-A[P]))}}if(B){const L={left:z,right:z+m.width,vCenter:z+m.width/2,top:E,bottom:E+m.height,hCenter:E+m.height/2},G=["left","vCenter","right"];for(const J of B.vertical)for(const P of G){const v=Math.abs(L[P]-J);v<=l&&v<H&&(H=v,z=m.left+(J-L[P]))}const Y=["top","hCenter","bottom"];for(const J of B.horizontal)for(const P of Y){const v=Math.abs(L[P]-J);v<=l&&v<H&&(H=v,E=m.top+(J-L[P]))}}const W={left:z,right:z+m.width,vCenter:z+m.width/2,top:E,bottom:E+m.height,hCenter:E+m.height/2};if(o){const L=new Set;for(const G of y){if(G.id===m.id)continue;const Y={left:G.left,right:G.left+G.width,vCenter:G.left+G.width/2,top:G.top,bottom:G.top+G.height,hCenter:G.top+G.height/2},J=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],P=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,g]of J)if(Math.abs(W[v]-Y[g])<=n){const x=`v:${Y[g]}`;L.has(x)||(L.add(x),V.push({type:"vertical",position:Y[g],id:G.id,color:s(v)}))}for(const[v,g]of P)if(Math.abs(W[v]-Y[g])<=n){const x=`h:${Y[g]}`;L.has(x)||(L.add(x),V.push({type:"horizontal",position:Y[g],id:G.id,color:s(v)}))}}}if(B){for(const L of B.vertical)V.some(G=>G.type==="vertical"&&G.position===L)||V.push({type:"vertical",position:L});for(const L of B.horizontal)V.some(G=>G.type==="horizontal"&&G.position===L)||V.push({type:"horizontal",position:L})}return{left:z,top:E,lines:V}}function u(m,y,B){a.value=m,i.value={width:y,height:B}}function f(){a.value=[]}return{check:d,renderLines:u,clearLines:f,guideLines:a,paperSize:i}}function Al(t){const{check:l,renderLines:n,clearLines:o,guideLines:a,paperSize:i}=Il(t.config??{adsorbMin:1,adsorbLineMin:2,showAdsorbLine:!0});function r(d){const u=t.getElements().filter(y=>y.id!==d.id).map(y=>({id:y.id,left:y.options.left,top:y.options.top,width:y.options.width,height:y.options.height})),f=l(d,u,t.getGuides?.()),m=t.getPaperSize();return n(f.lines,m.width,m.height),f}function s(){o()}return{requestAdsorb:r,clearGuides:s,guideLines:a,paperSize:i}}const Rl={key:0,class:"zone-label"},Ul={key:0,class:"zone-height-tip"},Fl={key:0,class:"zone-label"},Hl={key:0,class:"zone-height-tip"},Ol=["onMousedown","onDblclick"],Gl=e.defineComponent({__name:"CanvasPaper",props:{templateData:{},runtimeElements:{},designMode:{type:Boolean},printData:{},scale:{},showRuler:{type:Boolean},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},guides:{}},emits:["select","drag-start","drag-stop","dblclick-element","dblclick-cell","contextmenu","zone-height-change","zone-height-commit","add-guide","guide-move","guide-remove","clone-element"],setup(t,{expose:l,emit:n}){const o=t,a=n,i=e.ref(null),r=e.computed(()=>Se(o.templateData).width),s=e.computed(()=>Se(o.templateData).height),d=e.computed(()=>{const p=o.templateData.margins,b=o.templateData.header.height,N=o.templateData.footer.height,S=r.value-p.left-p.right;return{header:{left:p.left,top:p.top,width:S,height:b},content:{left:p.left,top:p.top+b,width:S,height:s.value-p.top-p.bottom-b-N},footer:{left:p.left,top:s.value-p.bottom-N,width:S,height:N}}});function u(p){return{position:"absolute",left:p.left+"mm",top:p.top+"mm",width:p.width+"mm",height:p.height+"mm"}}const f=e.computed(()=>{const p={header:[],footer:[],content:[]};for(const b of o.runtimeElements)b.zone==="header"?p.header.push(b):b.zone==="footer"?p.footer.push(b):p.content.push(b);return p}),m=e.computed(()=>f.value.header),y=e.computed(()=>f.value.footer),B=e.computed(()=>f.value.content);let z="content";const{requestAdsorb:E,clearGuides:V,guideLines:A,paperSize:H}=Al({getElements:()=>f.value[z],getPaperSize:()=>{const p=d.value[z];return{width:p.width,height:p.height}},getGuides:()=>{const p=[],b=[];for(const N of o.guides??[])N.type==="vertical"?p.push(N.position):b.push(N.position);return{vertical:p,horizontal:b}}});function W(p){z=o.runtimeElements.find(S=>S.id===p.id)?.zone||"content";const N=E(p);return(N.left!==p.left||N.top!==p.top)&&x(N.left+p.width/2,N.top+p.height/2),N}function L(p,b){const N=b.position,S=p.clientX,U=p.clientY,K=o.scale??1,C=25.4/96,$=w=>{const k=(b.type==="vertical"?w.clientX-S:w.clientY-U)/K*C;a("guide-move",b.id,N+k)},D=()=>{window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",D)};window.addEventListener("mousemove",$),window.addEventListener("mouseup",D)}const G=e.computed(()=>({width:r.value+"mm",minHeight:s.value+"mm",background:o.templateData.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",margin:"0 auto",overflow:"hidden",position:"relative",transform:o.scale?`scale(${o.scale})`:void 0,transformOrigin:"0 0"})),Y=e.computed(()=>{const p=o.templateData.margins;return{padding:`${p.top}mm ${p.right}mm ${p.bottom}mm ${p.left}mm`,position:"relative",boxSizing:"border-box",minHeight:s.value+"mm"}}),J=e.computed(()=>o.showRuler!==!1&&!!o.designMode),P=e.computed(()=>({backgroundImage:`url("data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>')}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}));let v=0,g=null;const M=e.ref(null);function x(p,b){v+=1,M.value={left:p,top:b,key:v},g&&clearTimeout(g),g=setTimeout(()=>{M.value=null},300)}const c=e.computed(()=>{const p=o.templateData.watermark;return p?!p.mode||p.mode==="fixed"?!!p.content&&p.content.trim().length>0:!!p.binding:!1}),h=e.computed(()=>{const p=o.templateData.watermark||{},b=p.color||"#cccccc",N=p.opacity??.15,S=p.rotate??-30;let U=T(p);if(p.timestamp){const K=new Date,C=`${K.getFullYear()}-${String(K.getMonth()+1).padStart(2,"0")}-${String(K.getDate()).padStart(2,"0")} ${String(K.getHours()).padStart(2,"0")}:${String(K.getMinutes()).padStart(2,"0")}`;U=U?`${U} ${C}`:C}return{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"0",overflow:"hidden",opacity:String(N),backgroundImage:O(U,b,S),backgroundRepeat:"repeat"}});function T(p){if(!p.mode||p.mode==="fixed")return p.content||"";if(p.binding){const b=o.printData?.[0];return b&&b[p.binding]!==void 0&&b[p.binding]!==null?String(b[p.binding]):p.testData||`[${p.binding}]`}return""}function O(p,b,N){const S=p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),U=`<svg xmlns="http://www.w3.org/2000/svg" width="260" height="180">
|
|
2
|
-
<text x="130" y="90" font-size="16" fill="${
|
|
3
|
-
</svg>`;return`url("data:image/svg+xml,${encodeURIComponent(U)}")`}const X=e.ref(null);function oe(p,b){se(),X.value={zone:p,startY:b.clientY,startH:o.templateData[p].height},window.addEventListener("mousemove",ie),window.addEventListener("mouseup",re)}function ie(p){if(!X.value)return;const{zone:b,startY:N,startH:S}=X.value,K=(p.clientY-N)/(o.scale||1)*25.4/96,C=b==="header"?K:-K,$=Math.min(100,s.value-o.templateData.margins.top-o.templateData.margins.bottom-(b==="header"?o.templateData.footer.height:o.templateData.header.height)-10),D=Math.min($,Math.max(0,Math.round((S+C)*10)/10));a("zone-height-change",b,D)}function re(){if(!X.value)return;const p=X.value.zone;X.value=null,window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",re),a("zone-height-commit",p)}function se(){window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",re),X.value=null}e.onUnmounted(()=>{se(),g&&clearTimeout(g)});function ae(p,b){a("select",p,b)}return l({contentRef:i}),(p,b)=>(e.openBlock(),e.createElementBlock("div",{class:"hiprint-printPaper",style:e.normalizeStyle(G.value)},[e.createElementVNode("div",{class:"hiprint-printPaper-content",ref_key:"contentRef",ref:i,style:e.normalizeStyle(Y.value)},[J.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(yt,{orientation:"horizontal","length-m-m":r.value,scale:t.scale,onAddGuide:b[0]||(b[0]=(N,S)=>a("add-guide",N,S))},null,8,["length-m-m","scale"]),e.createVNode(yt,{orientation:"vertical","length-m-m":s.value,scale:t.scale,onAddGuide:b[1]||(b[1]=(N,S)=>a("add-guide",N,S))},null,8,["length-m-m","scale"])],64)):e.createCommentVNode("",!0),t.showGrid&&t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"grid-bg",style:e.normalizeStyle(P.value)},null,4)):e.createCommentVNode("",!0),M.value?(e.openBlock(),e.createElementBlock("div",{key:M.value.key,class:"snap-indicator",style:e.normalizeStyle({left:M.value.left+"mm",top:M.value.top+"mm"})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",{key:3,class:"watermark-layer",style:e.normalizeStyle(h.value)},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-header",{"design-mode":t.designMode}]),style:e.normalizeStyle(u(d.value.header))},[t.designMode?(e.openBlock(),e.createElementBlock("span",Rl,"页眉")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,N=>(e.openBlock(),e.createBlock(Xe,{key:N.id,element:N,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":m.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"header","adsorb-handler":W,"clear-adsorb-guides":e.unref(V),onSelect:ae,onDragStart:b[2]||(b[2]=S=>p.$emit("drag-start")),onDragStop:b[3]||(b[3]=S=>p.$emit("drag-stop")),onDblclickElement:b[4]||(b[4]=S=>p.$emit("dblclick-element",S)),onDblclickCell:b[5]||(b[5]=(S,U,K)=>p.$emit("dblclick-cell",S,U,K)),onContextmenu:b[6]||(b[6]=(S,U)=>p.$emit("contextmenu",S,U)),onCloneElement:(S,U)=>p.$emit("clone-element",S,U)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128)),t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"zone-resize-handle handle-bottom",onMousedown:b[7]||(b[7]=e.withModifiers(N=>oe("header",N),["prevent","stop"]))},[X.value?.zone==="header"?(e.openBlock(),e.createElementBlock("div",Ul,e.toDisplayString(t.templateData.header.height.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0)],32)):e.createCommentVNode("",!0)],6),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-content",{"design-mode":t.designMode}]),style:e.normalizeStyle(u(d.value.content))},[t.designMode&&t.templateData.firstPageOverlay.height>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zone-overlay",style:e.normalizeStyle({height:t.templateData.firstPageOverlay.height+"mm"})},[...b[19]||(b[19]=[e.createElementVNode("span",{class:"zone-label"},"首页叠加",-1)])],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,N=>(e.openBlock(),e.createBlock(Xe,{key:N.id,element:N,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":B.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"content","adsorb-handler":W,"clear-adsorb-guides":e.unref(V),onSelect:ae,onDragStart:b[8]||(b[8]=S=>p.$emit("drag-start")),onDragStop:b[9]||(b[9]=S=>p.$emit("drag-stop")),onDblclickElement:b[10]||(b[10]=S=>p.$emit("dblclick-element",S)),onDblclickCell:b[11]||(b[11]=(S,U,K)=>p.$emit("dblclick-cell",S,U,K)),onContextmenu:b[12]||(b[12]=(S,U)=>p.$emit("contextmenu",S,U)),onCloneElement:(S,U)=>p.$emit("clone-element",S,U)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128))],6),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-footer",{"design-mode":t.designMode}]),style:e.normalizeStyle(u(d.value.footer))},[t.designMode?(e.openBlock(),e.createElementBlock("span",Fl,"页脚")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,N=>(e.openBlock(),e.createBlock(Xe,{key:N.id,element:N,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":y.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"footer","adsorb-handler":W,"clear-adsorb-guides":e.unref(V),onSelect:ae,onDragStart:b[13]||(b[13]=S=>p.$emit("drag-start")),onDragStop:b[14]||(b[14]=S=>p.$emit("drag-stop")),onDblclickElement:b[15]||(b[15]=S=>p.$emit("dblclick-element",S)),onDblclickCell:b[16]||(b[16]=(S,U,K)=>p.$emit("dblclick-cell",S,U,K)),onContextmenu:b[17]||(b[17]=(S,U)=>p.$emit("contextmenu",S,U)),onCloneElement:(S,U)=>p.$emit("clone-element",S,U)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128)),t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"zone-resize-handle handle-top",onMousedown:b[18]||(b[18]=e.withModifiers(N=>oe("footer",N),["prevent","stop"]))},[X.value?.zone==="footer"?(e.openBlock(),e.createElementBlock("div",Hl,e.toDisplayString(t.templateData.footer.height.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0)],32)):e.createCommentVNode("",!0)],6),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(A),(N,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:e.normalizeClass(["adsorb-guide",[`guide-${N.type}`]]),style:e.normalizeStyle(N.type==="vertical"?{left:N.position+"mm",top:"0",height:e.unref(H).height+"mm",borderLeftColor:N.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:N.position+"mm",left:"0",width:e.unref(H).width+"mm",borderTopColor:N.color||"var(--pd-accent-secondary, #f56c6c)"})},null,6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.guides,N=>(e.openBlock(),e.createElementBlock("div",{key:"mg-"+N.id,class:e.normalizeClass(["manual-guide",[`guide-${N.type}`]]),style:e.normalizeStyle(N.type==="vertical"?{left:N.position+"mm",top:"0",height:s.value+"mm"}:{top:N.position+"mm",left:"0",width:r.value+"mm"}),onMousedown:e.withModifiers(S=>L(S,N),["prevent","stop"]),onDblclick:e.withModifiers(S=>N.id&&a("guide-remove",N.id),["prevent","stop"])},null,46,Ol))),128))],4)],4))}}),ql=_(Gl,[["__scopeId","data-v-eddd2409"]]),Wl={class:"canvas-scroll"},Kl={key:0,class:"overlay-layer"},Yl=["src"],Ie=96/25.4,Xl=e.defineComponent({__name:"CanvasArea",props:{templateData:{},elements:{},scale:{},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},hasClipboard:{type:Boolean},guides:{},overlayVisible:{type:Boolean},screenshotUrl:{},overlayOpacity:{},selectedElementHasGroup:{type:Boolean}},emits:["select","drop-element","drop-field","drag-start","drag-stop","dblclick-element","dblclick-cell","zone-height-change","zone-height-commit","select-all","clear-selection","preview","commit-preview","paste","copy","cut","delete","move-layer","group","ungroup","coordinate","add-guide","guide-move","guide-remove","zoom","clone-element"],setup(t,{emit:l}){const n=t,o=l;function a(v,g){o("select",v,g)}const i=e.ref(null);function r(v){const g=i.value?.querySelector(".hiprint-printPaper");if(!g)return;const M=g.getBoundingClientRect(),x=n.scale||1,c=Pe((v.clientX-M.left)/x),h=Pe((v.clientY-M.top)/x);if(!(c<0||h<0))return{x:c,y:h}}function s(v){const g=r(v),M=v.dataTransfer?.getData("fieldData");if(M)try{const c=JSON.parse(M);o("drop-field",c,g);return}catch{}const x=v.dataTransfer?.getData("elementType");x&&o("drop-element",x,g)}const d=e.reactive({visible:!1,x:0,y:0,w:0,h:0});let u={x:0,y:0};function f(v){return!v||!(v instanceof HTMLElement)?!1:!!(v===i.value||v.classList.contains("canvas-scroll")||v.classList.contains("hiprint-printPaper")||v.classList.contains("hiprint-printPaper-content")||v.classList.contains("zone-layer")||v.classList.contains("grid-bg")||v.classList.contains("watermark-layer"))}function m(v){const g=i.value?.querySelector(".hiprint-printPaper");if(!g)return;const M=g.getBoundingClientRect(),x=n.scale||1,c=Pe((v.clientX-M.left)/x),h=Pe((v.clientY-M.top)/x);if(c<0||h<0){o("coordinate",null);return}o("coordinate",{x:c,y:h})}function y(){o("coordinate",null)}function B(v){if(!(v.ctrlKey||v.metaKey))return;v.preventDefault();const g=n.scale,M=Math.max(.25,Math.min(3,g+(v.deltaY>0?-.1:.1)));if(M===g)return;const x=i.value;if(x){const c=x.getBoundingClientRect(),h=v.clientX-c.left,T=v.clientY-c.top,O=M/g;x.scrollLeft=(x.scrollLeft+h)*O-h,x.scrollTop=(x.scrollTop+T)*O-T}o("zoom",(M-g)*100)}function z(v){v.button!==2&&f(v.target)&&(o("clear-selection"),u={x:v.clientX,y:v.clientY},d.visible=!0,d.x=v.clientX,d.y=v.clientY,d.w=0,d.h=0,window.addEventListener("mousemove",V),window.addEventListener("mouseup",A))}function E(){if(d.w<3||d.h<3)return[];const v=i.value?.querySelector(".hiprint-printPaper");if(!v)return[];const g=v.getBoundingClientRect(),M=n.scale||1,x=d.x<u.x,c=[];for(const h of n.elements){if(h.options.visible===!1||h.options.locked)continue;const T=g.left+h.options.left*Ie*M,O=g.top+h.options.top*Ie*M,X=T+h.options.width*Ie*M,oe=O+h.options.height*Ie*M,ie=T<d.x+d.w&&X>d.x&&O<d.y+d.h&&oe>d.y,re=T>=d.x&&X<=d.x+d.w&&O>=d.y&&oe<=d.y+d.h;(x?re:ie)&&c.push(h.id)}return c}function V(v){const g=v.clientX-u.x,M=v.clientY-u.y;d.x=g>=0?u.x:v.clientX,d.y=M>=0?u.y:v.clientY,d.w=Math.abs(g),d.h=Math.abs(M),o("preview",E())}function A(){window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",A);const v=E();o("preview",v),v.length>0?o("commit-preview"):o("clear-selection"),o("preview",[]),d.visible=!1}const H=e.reactive({visible:!1,x:0,y:0,targetId:null});function W(v,g){if(!g&&!f(v.target))return;const M=i.value?.getBoundingClientRect();M&&(H.x=v.clientX-M.left,H.y=v.clientY-M.top,H.targetId=g??null,H.visible=!0,window.removeEventListener("mousedown",L),setTimeout(()=>{window.addEventListener("mousedown",L,{once:!0})},0))}function L(){H.visible=!1,window.removeEventListener("mousedown",L)}function G(){H.visible=!1,n.hasClipboard&&o("paste")}function Y(){H.visible=!1,o("select-all")}function J(){H.visible=!1,o("clear-selection")}function P(v,g){H.visible=!1,v==="copy"?o("copy"):v==="cut"?o("cut"):v==="paste"?o("paste"):v==="delete"?o("delete"):v==="move-layer"?o("move-layer",g):v==="group"?o("group"):v==="ungroup"&&n.selectedElementHasGroup&&o("ungroup")}return e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",A)}),(v,g)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootRef",ref:i,class:"canvas-area",onDragover:g[21]||(g[21]=e.withModifiers(()=>{},["prevent"])),onDrop:s,onMousedown:z,onMousemove:m,onMouseleave:y,onWheel:B,onContextmenu:e.withModifiers(W,["prevent"])},[e.createElementVNode("div",Wl,[e.createVNode(ql,{"template-data":t.templateData,"runtime-elements":t.elements,"design-mode":!0,"print-data":[],scale:t.scale,"show-grid":t.showGrid,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,guides:t.guides,onSelect:a,onAddGuide:g[0]||(g[0]=(M,x)=>v.$emit("add-guide",M,x)),onGuideMove:g[1]||(g[1]=(M,x)=>v.$emit("guide-move",M,x)),onGuideRemove:g[2]||(g[2]=M=>v.$emit("guide-remove",M)),onDragStart:g[3]||(g[3]=M=>v.$emit("drag-start")),onDragStop:g[4]||(g[4]=M=>v.$emit("drag-stop")),onDblclickElement:g[5]||(g[5]=M=>v.$emit("dblclick-element",M)),onDblclickCell:g[6]||(g[6]=(M,x,c)=>v.$emit("dblclick-cell",M,x,c)),onContextmenu:g[7]||(g[7]=(M,x)=>W(x,M)),onZoneHeightChange:g[8]||(g[8]=(M,x)=>v.$emit("zone-height-change",M,x)),onZoneHeightCommit:g[9]||(g[9]=M=>v.$emit("zone-height-commit",M)),onCloneElement:g[10]||(g[10]=(M,x)=>v.$emit("clone-element",M,x))},null,8,["template-data","runtime-elements","scale","show-grid","snap-to-grid","show-table-ghost-border","guides"]),t.overlayVisible&&t.screenshotUrl?(e.openBlock(),e.createElementBlock("div",Kl,[e.createElementVNode("img",{src:t.screenshotUrl,class:"overlay-image",style:e.normalizeStyle({opacity:t.overlayOpacity??.5})},null,12,Yl)])):e.createCommentVNode("",!0)]),d.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:"marquee-selection",style:e.normalizeStyle({left:d.x+"px",top:d.y+"px",width:d.w+"px",height:d.h+"px"})},null,4)):e.createCommentVNode("",!0),H.visible?(e.openBlock(),e.createElementBlock("div",{key:1,class:"context-menu",style:e.normalizeStyle({left:H.x+"px",top:H.y+"px"})},[H.targetId?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",{class:"context-menu-item",onClick:g[11]||(g[11]=M=>P("copy"))},"复制"),e.createElementVNode("div",{class:"context-menu-item",onClick:g[12]||(g[12]=M=>P("cut"))},"剪切"),e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.hasClipboard}]),onClick:g[13]||(g[13]=M=>P("paste"))},"粘贴",2),e.createElementVNode("div",{class:"context-menu-item",onClick:g[14]||(g[14]=M=>P("delete"))},"删除"),g[22]||(g[22]=e.createElementVNode("div",{class:"context-menu-sep"},null,-1)),e.createElementVNode("div",{class:"context-menu-item",onClick:g[15]||(g[15]=M=>P("move-layer","top"))},"置顶"),e.createElementVNode("div",{class:"context-menu-item",onClick:g[16]||(g[16]=M=>P("move-layer","up"))},"上移"),e.createElementVNode("div",{class:"context-menu-item",onClick:g[17]||(g[17]=M=>P("move-layer","down"))},"下移"),e.createElementVNode("div",{class:"context-menu-item",onClick:g[18]||(g[18]=M=>P("move-layer","bottom"))},"置底"),g[23]||(g[23]=e.createElementVNode("div",{class:"context-menu-sep"},null,-1)),e.createElementVNode("div",{class:"context-menu-item",onClick:g[19]||(g[19]=M=>P("group"))},"编组 Ctrl+G"),e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.selectedElementHasGroup}]),onClick:g[20]||(g[20]=M=>P("ungroup"))},"取消编组 Ctrl+Shift+G",2)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.hasClipboard}]),onClick:G},"粘贴",2),e.createElementVNode("div",{class:"context-menu-item",onClick:Y},"全选"),e.createElementVNode("div",{class:"context-menu-item",onClick:J},"取消选择")],64))],4)):e.createCommentVNode("",!0)],544))}}),jl=_(Xl,[["__scopeId","data-v-c6288512"]]),Jl=[{group:"position-size",groupLabel:"位置与尺寸",items:[{key:"ps-left",keywords:["X","横坐标","left","位置"]},{key:"ps-top",keywords:["Y","纵坐标","top","位置"]},{key:"ps-width",keywords:["W","宽度","width","尺寸"]},{key:"ps-height",keywords:["H","高度","height","尺寸"]}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function Zl(t,l){const n=t.trim().toLowerCase();return n?l.some(o=>o.toLowerCase().includes(n)):!0}function Ql(t){const l=[],n=new Set;for(const o of Jl){const a=o.items.filter(i=>Zl(t,[...i.keywords,o.groupLabel]));if(a.length>0){l.push(o.group);for(const i of a)n.add(i.key)}}return{groups:l,itemKeys:n}}const _l={class:"property-search"},ea=e.defineComponent({__name:"PropertySearch",emits:["search"],setup(t,{emit:l}){const n=e.ref(""),o=l;function a(){o("search",n.value)}return(i,r)=>(e.openBlock(),e.createElementBlock("div",_l,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":r[0]||(r[0]=s=>n.value=s),class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",onInput:a},null,544),[[e.vModelText,n.value]])]))}}),ta=_(ea,[["__scopeId","data-v-10ab6c84"]]),na={class:"group-icon"},oa={class:"group-title"},la={class:"expand-icon"},aa={class:"group-content"},ia=e.defineComponent({__name:"PropertyGroup",props:{title:{},icon:{},defaultExpanded:{type:Boolean},groupKey:{}},setup(t){const l=t,n=e.ref(l.defaultExpanded??!0),a={Document:"≡",Brush:"◧",Setting:"⚙"}[l.icon]||"•";function i(){n.value=!n.value,r()}function r(){const d=`property-group-${l.groupKey}`;try{localStorage.setItem(d,String(n.value))}catch{}}function s(){const d=`property-group-${l.groupKey}`;try{const u=localStorage.getItem(d);u!==null&&(n.value=u==="true")}catch{}}return e.onMounted(()=>{s()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["property-group",{"is-expanded":n.value}])},[e.createElementVNode("div",{class:"group-header",onClick:i},[e.createElementVNode("span",na,e.toDisplayString(e.unref(a)),1),e.createElementVNode("span",oa,e.toDisplayString(t.title),1),e.createElementVNode("span",la,e.toDisplayString(n.value?"▾":"▸"),1)]),e.withDirectives(e.createElementVNode("div",aa,[e.renderSlot(d.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])],2))}}),he=_(ia,[["__scopeId","data-v-2ba57031"]]),ra={class:"pd-stepper"},sa=["disabled"],da=["value","placeholder","min","max","step"],ca=["disabled"],ua=e.defineComponent({__name:"StepperInput",props:{modelValue:{},min:{},max:{},step:{default:1},placeholder:{}},emits:["update:modelValue"],setup(t,{emit:l}){const n=t,o=l,a=e.computed(()=>{const E=String(n.step),V=E.indexOf(".");return V===-1?0:E.length-V-1});function i(E){return Number.isFinite(E)?Number(E.toFixed(a.value)):0}const r=e.computed(()=>{const E=n.modelValue;if(!(E==null||!Number.isFinite(E)))return i(E)}),s=e.ref(r.value===void 0?"":String(r.value));e.watch(r,E=>{s.value=E===void 0?"":String(E)});const d=e.computed(()=>r.value!==void 0?r.value:n.min!==void 0?n.min:0),u=e.computed(()=>n.min!==void 0&&d.value<=n.min),f=e.computed(()=>n.max!==void 0&&d.value>=n.max);function m(E){let V=i(E);return n.min!==void 0&&V<n.min&&(V=n.min),n.max!==void 0&&V>n.max&&(V=n.max),V}function y(E){if(E<0&&u.value||E>0&&f.value)return;const V=m(d.value+E*n.step);s.value=String(V),o("update:modelValue",V)}function B(E){s.value=E.target.value}function z(){const E=s.value.trim();if(E===""){r.value!==void 0&&(s.value=String(r.value));return}const V=Number(E);if(!Number.isFinite(V)){s.value=r.value===void 0?"":String(r.value);return}const A=m(V);s.value=String(A),A!==r.value&&o("update:modelValue",A)}return(E,V)=>(e.openBlock(),e.createElementBlock("div",ra,[e.createElementVNode("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:u.value,title:"减小","aria-label":"减小",onClick:V[0]||(V[0]=A=>y(-1))},"−",8,sa),e.createElementVNode("input",{type:"number",class:"pd-input pd-step-input",value:s.value,placeholder:t.placeholder,min:t.min,max:t.max,step:t.step,onInput:B,onChange:z,onBlur:z,onKeydown:V[1]||(V[1]=e.withKeys(e.withModifiers(A=>A.target.blur(),["prevent"]),["enter"]))},null,40,da),e.createElementVNode("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:f.value,title:"增大","aria-label":"增大",onClick:V[2]||(V[2]=A=>y(1))},"+",8,ca)]))}}),te=_(ua,[["__scopeId","data-v-9722a7cf"]]),ma={class:"position-grid"},pa={class:"pd-field"},fa={class:"pd-field"},va={class:"pd-field"},ga={class:"pd-field"},ha=e.defineComponent({__name:"PositionSizeGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t;function n(o){return l.searching?l.matchedKeys?.has(o)??!0:!0}return(o,a)=>(e.openBlock(),e.createBlock(he,{title:"位置与尺寸",icon:"Location","default-expanded":"","group-key":"position-size"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:a[4]||(a[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",ma,[e.withDirectives(e.createElementVNode("div",pa,[a[5]||(a[5]=e.createElementVNode("span",{class:"pd-label"},"X",-1)),e.createVNode(te,{modelValue:t.element.options.left,"onUpdate:modelValue":a[0]||(a[0]=i=>t.element.options.left=i),min:0},null,8,["modelValue"])],512),[[e.vShow,n("ps-left")]]),e.withDirectives(e.createElementVNode("div",fa,[a[6]||(a[6]=e.createElementVNode("span",{class:"pd-label"},"Y",-1)),e.createVNode(te,{modelValue:t.element.options.top,"onUpdate:modelValue":a[1]||(a[1]=i=>t.element.options.top=i),min:0},null,8,["modelValue"])],512),[[e.vShow,n("ps-top")]]),e.withDirectives(e.createElementVNode("div",va,[a[7]||(a[7]=e.createElementVNode("span",{class:"pd-label"},"W",-1)),e.createVNode(te,{modelValue:t.element.options.width,"onUpdate:modelValue":a[2]||(a[2]=i=>t.element.options.width=i),min:4},null,8,["modelValue"])],512),[[e.vShow,n("ps-width")]]),e.withDirectives(e.createElementVNode("div",ga,[a[8]||(a[8]=e.createElementVNode("span",{class:"pd-label"},"H",-1)),e.createVNode(te,{modelValue:t.element.options.height,"onUpdate:modelValue":a[3]||(a[3]=i=>t.element.options.height=i),min:4},null,8,["modelValue"])],512),[[e.vShow,n("ps-height")]])])],32)]),_:1}))}}),ba=_(ha,[["__scopeId","data-v-572d7719"]]),ya=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],ka=["aria-expanded","title"],Ea={class:"picker-preview"},wa={class:"preset-color-grid"},Va=["title","aria-label","onClick"],Na=e.defineComponent({__name:"PresetColorPicker",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:l}){const n=t,o=l,a=e.ref(!1),i=e.ref(),r=e.ref(),s=e.ref(),d=e.ref({}),u=e.ref(0),f=e.ref(0),m=e.ref(0),y=e.ref("#000000"),B=e.ref(!1),z=e.computed({get:()=>n.modelValue||"#000000",set:p=>o("update:modelValue",p)}),E=e.computed(()=>oe(re(u.value,f.value,m.value))),V=e.computed({get:()=>Math.round(u.value),set:p=>L(se(p),f.value,m.value)});e.watch(z,W,{immediate:!0});function A(p){y.value=p.toUpperCase(),W(p),o("update:modelValue",p)}function H(p){const N=p.target.value.trim();O(N)&&(W(N),o("update:modelValue",X(N)))}function W(p){const b=O(p);if(!b)return;const N=ie(b.r,b.g,b.b);u.value=N.h,f.value=N.s,m.value=N.v,y.value=X(p).toUpperCase()}function L(p,b,N){u.value=se(p),f.value=ae(b),m.value=ae(N),y.value=E.value.toUpperCase(),o("update:modelValue",E.value)}function G(p){p.currentTarget.setPointerCapture(p.pointerId),B.value=!0,P(p)}function Y(p){B.value&&P(p)}function J(p){B.value=!1;const b=p.currentTarget;b.hasPointerCapture(p.pointerId)&&b.releasePointerCapture(p.pointerId)}function P(p){const b=s.value;if(!b)return;const N=b.getBoundingClientRect(),S=ae((p.clientX-N.left)/N.width),U=ae(1-(p.clientY-N.top)/N.height);L(u.value,S,U)}function v(p){const b=p.shiftKey?.1:.02;let N=!0;p.key==="ArrowLeft"?L(u.value,f.value-b,m.value):p.key==="ArrowRight"?L(u.value,f.value+b,m.value):p.key==="ArrowUp"?L(u.value,f.value,m.value+b):p.key==="ArrowDown"?L(u.value,f.value,m.value-b):N=!1,N&&p.preventDefault()}function g(){a.value?x():M()}async function M(){const p=i.value;if(!p)return;W(z.value),a.value=!0,await e.nextTick();const b=p.getBoundingClientRect(),N=190,S=r.value?.offsetHeight??216,U=8,K=Math.min(b.left,window.innerWidth-N-U),C=b.bottom+6,$=C+S>window.innerHeight-U?Math.max(U,b.top-S-6):C;d.value={left:`${Math.max(U,K)}px`,top:`${$}px`}}function x(){a.value=!1}function c(p){const b=p.target;i.value?.contains(b)||r.value?.contains(b)||x()}function h(){a.value&&x()}function T(p){p.key==="Escape"&&a.value&&x()}function O(p){const b=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(p.trim());if(!b)return null;const N=b[1],S=N.length===3?N.split("").map(U=>U+U).join(""):N;return{r:Number.parseInt(S.slice(0,2),16),g:Number.parseInt(S.slice(2,4),16),b:Number.parseInt(S.slice(4,6),16)}}function X(p){const b=O(p);return b?oe(b):"#000000"}function oe({r:p,g:b,b:N}){return`#${[p,b,N].map(S=>Math.round(ae(S/255)*255).toString(16).padStart(2,"0")).join("")}`}function ie(p,b,N){const S=p/255,U=b/255,K=N/255,C=Math.max(S,U,K),$=Math.min(S,U,K),D=C-$;let w=0;return D!==0&&(C===S?w=(U-K)/D%6:C===U?w=(K-S)/D+2:w=(S-U)/D+4,w*=60,w<0&&(w+=360)),{h:w,s:C===0?0:D/C,v:C}}function re(p,b,N){const S=N*b,U=(p%360+360)%360/60,K=S*(1-Math.abs(U%2-1)),[C,$,D]=U<1?[S,K,0]:U<2?[K,S,0]:U<3?[0,S,K]:U<4?[0,K,S]:U<5?[K,0,S]:[S,0,K],w=N-S;return{r:(C+w)*255,g:($+w)*255,b:(D+w)*255}}function se(p){return((Number.isFinite(p)?p:0)%360+360)%360}function ae(p){return Math.min(1,Math.max(0,Number.isFinite(p)?p:0))}return e.onMounted(()=>{document.addEventListener("pointerdown",c,!0),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),document.addEventListener("keydown",T)}),e.onBeforeUnmount(()=>{document.removeEventListener("pointerdown",c,!0),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h),document.removeEventListener("keydown",T)}),(p,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{ref_key:"triggerRef",ref:i,type:"button",class:"preset-color-trigger","aria-expanded":a.value,"aria-haspopup":"dialog",title:t.modelValue||"自动",onClick:g},[e.createElementVNode("span",{class:"preset-color-swatch",style:e.normalizeStyle({background:z.value})},null,4)],8,ka),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[a.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"panelRef",ref:r,class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:e.normalizeStyle(d.value),onPointerdown:b[2]||(b[2]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",Ea,[e.createElementVNode("span",{class:"picker-current",style:e.normalizeStyle({background:E.value})},null,4),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[0]||(b[0]=N=>y.value=N),class:"picker-hex",type:"text",maxlength:"7",spellcheck:"false","aria-label":"颜色值",onInput:H},null,544),[[e.vModelText,y.value]])]),e.createElementVNode("div",{ref_key:"areaRef",ref:s,class:"picker-area",style:e.normalizeStyle({"--picker-hue":`${Math.round(u.value)}deg`}),"aria-label":"自定义颜色",tabindex:"0",onPointerdown:G,onPointermove:Y,onPointerup:J,onPointercancel:J,onKeydown:v},[e.createElementVNode("span",{class:"picker-handle",style:e.normalizeStyle({left:`${f.value*100}%`,top:`${(1-m.value)*100}%`,background:E.value})},null,4)],36),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[1]||(b[1]=N=>V.value=N),class:"picker-hue",type:"range",min:"0",max:"360",step:"1","aria-label":"色相"},null,512),[[e.vModelText,V.value,void 0,{number:!0}]]),b[3]||(b[3]=e.createElementVNode("div",{class:"picker-heading"},"常用颜色",-1)),e.createElementVNode("div",wa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ya),N=>(e.openBlock(),e.createElementBlock("button",{key:N,type:"button",class:e.normalizeClass(["preset-color-item",{active:N.toLowerCase()===E.value.toLowerCase()}]),style:e.normalizeStyle({background:N}),title:N,"aria-label":N,onClick:S=>A(N)},null,14,Va))),128))])],36)):e.createCommentVNode("",!0)]))],64))}}),ge=_(Na,[["__scopeId","data-v-db3c3d71"]]),Ca={class:"pd-field"},Sa={class:"pd-field"},$a={class:"pd-field"},Ma={class:"pd-radio-group",role:"radiogroup"},Ba={class:"pd-radio"},xa={class:"pd-radio"},Da={class:"pd-radio"},Ta={class:"pd-field"},za={class:"pd-radio-group",role:"radiogroup"},La={class:"pd-radio"},Pa={class:"pd-radio"},Ia={class:"pd-radio"},Aa={class:"color-row"},Ra={class:"pd-field"},Ua={class:"pd-field"},Fa={class:"pd-field"},Ha={class:"pd-field"},Oa={key:1,class:"pd-empty"},Ga=e.defineComponent({__name:"AppearanceGroup",props:{element:{},isTextType:{type:Boolean},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t;function n(a){return l.searching?l.matchedKeys?.has(a)??!0:!0}const o=e.computed(()=>l.element.printElementType.type==="table");return(a,i)=>(e.openBlock(),e.createBlock(he,{title:"外观",icon:"Brush","default-expanded":"","group-key":"appearance"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:i[12]||(i[12]=e.withModifiers(()=>{},["prevent"]))},[t.isTextType?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.withDirectives(e.createElementVNode("div",Ca,[i[13]||(i[13]=e.createElementVNode("span",{class:"pd-label"},"字体大小",-1)),e.createVNode(te,{modelValue:t.element.options.fontSize,"onUpdate:modelValue":i[0]||(i[0]=r=>t.element.options.fontSize=r),min:8,max:72},null,8,["modelValue"])],512),[[e.vShow,n("ap-font-size")]]),e.withDirectives(e.createElementVNode("div",Sa,[i[15]||(i[15]=e.createElementVNode("span",{class:"pd-label"},"字体粗细",-1)),e.withDirectives(e.createElementVNode("select",{class:"pd-select","onUpdate:modelValue":i[1]||(i[1]=r=>t.element.options.fontWeight=r),style:{width:"100%"}},[...i[14]||(i[14]=[e.createElementVNode("option",{value:"normal"},"正常",-1),e.createElementVNode("option",{value:"bold"},"粗体",-1),e.createElementVNode("option",{value:"bolder"},"更粗",-1),e.createElementVNode("option",{value:"lighter"},"细体",-1)])],512),[[e.vModelSelect,t.element.options.fontWeight]])],512),[[e.vShow,n("ap-font-weight")]]),e.withDirectives(e.createElementVNode("div",$a,[i[19]||(i[19]=e.createElementVNode("span",{class:"pd-label"},"对齐",-1)),e.createElementVNode("div",Ma,[e.createElementVNode("label",Ba,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[2]||(i[2]=r=>t.element.options.textAlign=r),value:"left"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),i[16]||(i[16]=e.createElementVNode("span",null,"左",-1))]),e.createElementVNode("label",xa,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[3]||(i[3]=r=>t.element.options.textAlign=r),value:"center"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),i[17]||(i[17]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Da,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[4]||(i[4]=r=>t.element.options.textAlign=r),value:"right"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),i[18]||(i[18]=e.createElementVNode("span",null,"右",-1))])])],512),[[e.vShow,n("ap-align")]]),e.withDirectives(e.createElementVNode("div",Ta,[i[23]||(i[23]=e.createElementVNode("span",{class:"pd-label"},"垂直对齐",-1)),e.createElementVNode("div",za,[e.createElementVNode("label",La,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[5]||(i[5]=r=>t.element.options.verticalAlign=r),value:"top"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),i[20]||(i[20]=e.createElementVNode("span",null,"顶",-1))]),e.createElementVNode("label",Pa,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[6]||(i[6]=r=>t.element.options.verticalAlign=r),value:"middle"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),i[21]||(i[21]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Ia,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[7]||(i[7]=r=>t.element.options.verticalAlign=r),value:"bottom"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),i[22]||(i[22]=e.createElementVNode("span",null,"底",-1))])])],512),[[e.vShow,n("ap-vertical-align")]]),e.createElementVNode("div",Aa,[e.withDirectives(e.createElementVNode("div",Ra,[i[24]||(i[24]=e.createElementVNode("span",{class:"pd-label"},"颜色",-1)),e.createVNode(ge,{modelValue:t.element.options.color,"onUpdate:modelValue":i[8]||(i[8]=r=>t.element.options.color=r)},null,8,["modelValue"])],512),[[e.vShow,n("ap-color")]]),e.withDirectives(e.createElementVNode("div",Ua,[i[25]||(i[25]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(ge,{modelValue:t.element.options.backgroundColor,"onUpdate:modelValue":i[9]||(i[9]=r=>t.element.options.backgroundColor=r)},null,8,["modelValue"])],512),[[e.vShow,n("ap-bg-color")]])]),e.withDirectives(e.createElementVNode("div",Fa,[i[26]||(i[26]=e.createElementVNode("span",{class:"pd-label"},"行高",-1)),e.createVNode(te,{modelValue:t.element.options.lineHeight,"onUpdate:modelValue":i[10]||(i[10]=r=>t.element.options.lineHeight=r),min:0,max:100},null,8,["modelValue"])],512),[[e.vShow,n("ap-line-height")]]),e.withDirectives(e.createElementVNode("div",Ha,[i[27]||(i[27]=e.createElementVNode("span",{class:"pd-label"},"字间距",-1)),e.createVNode(te,{modelValue:t.element.options.letterSpacing,"onUpdate:modelValue":i[11]||(i[11]=r=>t.element.options.letterSpacing=r),min:0,max:20,step:.5},null,8,["modelValue"])],512),[[e.vShow,n("ap-letter-spacing")]])],64)):e.createCommentVNode("",!0),!t.isTextType&&!o.value?(e.openBlock(),e.createElementBlock("p",Oa,"当前元素不支持外观设置")):e.createCommentVNode("",!0)],32)]),_:1}))}}),qa=_(Ga,[["__scopeId","data-v-2b604a48"]]),Wa={class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},Ka={class:"pd-dialog-header"},Ya={class:"expression-editor"},Xa={class:"ee-nav"},ja={class:"ee-nav-tabs"},Ja={class:"ee-content"},Za={class:"ee-content-search"},Qa=["placeholder"],_a={class:"ee-content-list"},ei={class:"ee-field-group-icon"},ti=["onDblclick"],ni={class:"ee-field-info"},oi={class:"ee-item-label"},li={class:"ee-item-key"},ai={key:0,class:"pd-empty"},ii=["onDblclick"],ri={class:"ee-field-info"},si={class:"ee-item-label"},di={class:"ee-item-key"},ci={class:"ee-func-group"},ui=["onDblclick"],mi={class:"ee-field-info"},pi={class:"ee-item-label"},fi={class:"ee-item-key"},vi={class:"ee-func-group"},gi=["onDblclick"],hi={class:"ee-field-info"},bi={class:"ee-item-label"},yi={class:"ee-item-key"},ki={class:"ee-editor"},Ei={class:"ee-editor-section"},wi={class:"ee-editor-section"},Vi={class:"pd-dialog-footer"},Ni=e.defineComponent({__name:"ExpressionEditor",props:{modelValue:{type:Boolean},expression:{},fields:{}},emits:["update:modelValue","update:expression"],setup(t,{emit:l}){const n=t,o=l,a=e.computed({get:()=>n.modelValue,set:P=>o("update:modelValue",P)}),i=e.ref("field"),r=e.computed(()=>{switch(i.value){case"field":return"搜索字段...";case"variable":return"搜索变量...";case"function":return"搜索函数...";default:return"搜索..."}}),s=e.ref(""),d=e.computed(()=>At(It(n.fields??[]),s.value));e.watch(a,P=>{P&&(V.value=n.expression||"")});function u(P){const{insideParens:v}=y();Y(v?P.fieldKey:`{${P.fieldKey}}`)}function f(P){const{insideParens:v}=y();Y(v?P.template.replace(/^\{|\}$/g,""):P.template)}function m(P){const{insideBlock:v}=y(),g=v?P.template:`{${P.template}}`,M=g.indexOf("(")+1;Y(g,M)}function y(){const v=A.value?.selectionStart??V.value.length,g=V.value.substring(0,v);let M=!1;const x=g.lastIndexOf("{");x!==-1&&!g.slice(x+1).includes("}")&&(M=!0);let c=!1;const h=g.lastIndexOf("(");return h!==-1&&!g.slice(h+1).includes(")")&&(c=!0),{insideBlock:M,insideParens:c}}const B=e.computed(()=>{if(!s.value.trim())return L;const P=s.value.trim().toLowerCase();return L.filter(v=>v.label.toLowerCase().includes(P)||v.name.toLowerCase().includes(P))}),z=e.computed(()=>{if(!s.value.trim())return H;const P=s.value.trim().toLowerCase();return H.filter(v=>v.label.toLowerCase().includes(P)||v.name.toLowerCase().includes(P))}),E=e.computed(()=>{if(!s.value.trim())return W;const P=s.value.trim().toLowerCase();return W.filter(v=>v.label.toLowerCase().includes(P)||v.name.toLowerCase().includes(P))}),V=e.ref(n.expression||""),A=e.ref(null);e.watch(()=>n.expression,P=>{V.value=P||""});const H=[{name:"SUM",label:"求和",template:"SUM()"},{name:"AVG",label:"平均值",template:"AVG()"},{name:"COUNT",label:"计数",template:"COUNT()"},{name:"MIN",label:"最小值",template:"MIN()"},{name:"MAX",label:"最大值",template:"MAX()"}],W=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],L=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],G=e.computed(()=>{if(!V.value.trim())return"(输入表达式后预览)";try{const P={...fe,pageIndex:1,totalPages:1,printDate:new Date().toISOString().split("T")[0],printTime:Date.now()},v=Ce(V.value,P);return v==null?"(无法计算)":String(v)}catch{return"(表达式错误)"}});function Y(P,v=P.length){const g=A.value;if(!g){V.value+=P;return}const M=g.selectionStart,x=g.selectionEnd,c=V.value.substring(0,M),h=V.value.substring(x);V.value=c+P+h;const T=M+v;e.nextTick(()=>{g.focus(),g.selectionStart=g.selectionEnd=T})}function J(){o("update:expression",V.value),a.value=!1}return(P,v)=>a.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"pd-dialog-overlay",onKeydown:v[7]||(v[7]=e.withKeys(g=>a.value=!1,["esc"]))},[e.createElementVNode("section",Wa,[e.createElementVNode("header",Ka,[v[8]||(v[8]=e.createElementVNode("strong",{id:"expression-editor-title"},"编辑表达式",-1)),e.createElementVNode("button",{type:"button",class:"pd-close","aria-label":"关闭",onClick:v[0]||(v[0]=g=>a.value=!1)},"×")]),e.createElementVNode("div",Ya,[e.createElementVNode("div",Xa,[v[9]||(v[9]=e.createElementVNode("div",{class:"ee-nav-title"},"类型",-1)),e.createElementVNode("div",ja,[e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:i.value==="field"}]),onClick:v[1]||(v[1]=g=>i.value="field")}," 📁 字段 ",2),e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:i.value==="variable"}]),onClick:v[2]||(v[2]=g=>i.value="variable")}," 🔧 变量 ",2),e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:i.value==="function"}]),onClick:v[3]||(v[3]=g=>i.value="function")}," ⚡ 函数 ",2)])]),e.createElementVNode("div",Ja,[e.createElementVNode("div",Za,[e.withDirectives(e.createElementVNode("input",{class:"pd-input","onUpdate:modelValue":v[4]||(v[4]=g=>s.value=g),placeholder:r.value},null,8,Qa),[[e.vModelText,s.value]])]),e.createElementVNode("div",_a,[i.value==="field"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,g=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:g.key||"_top"},[g.key?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ee-field-group",{"is-list":g.isList}])},[e.createElementVNode("span",ei,e.toDisplayString(g.isList?"📋":"📁"),1),e.createElementVNode("span",null,e.toDisplayString(g.label),1)],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.fields,M=>(e.openBlock(),e.createElementBlock("div",{key:M.fieldKey,class:"ee-list-item ee-field-item",style:e.normalizeStyle({paddingLeft:g.key?"22px":"10px"}),onDblclick:x=>u(M)},[e.createElementVNode("div",ni,[e.createElementVNode("span",oi,e.toDisplayString(M.fieldLabel),1),e.createElementVNode("span",li,e.toDisplayString(M.fieldKey),1)])],44,ti))),128))],64))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("p",ai,"暂无字段")):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),i.value==="variable"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(B.value,g=>(e.openBlock(),e.createElementBlock("div",{key:g.name,class:"ee-list-item",onDblclick:M=>f(g)},[e.createElementVNode("div",ri,[e.createElementVNode("span",si,e.toDisplayString(g.label),1),e.createElementVNode("span",di,e.toDisplayString(g.template),1)])],40,ii))),128)):e.createCommentVNode("",!0),i.value==="function"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",ci,[v[10]||(v[10]=e.createElementVNode("div",{class:"ee-func-group-title"},"聚合函数",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,g=>(e.openBlock(),e.createElementBlock("div",{key:g.name,class:"ee-list-item",onDblclick:M=>m(g)},[e.createElementVNode("div",mi,[e.createElementVNode("span",pi,e.toDisplayString(g.label),1),e.createElementVNode("span",fi,e.toDisplayString(g.name)+"()",1)])],40,ui))),128))]),e.createElementVNode("div",vi,[v[11]||(v[11]=e.createElementVNode("div",{class:"ee-func-group-title"},"格式化函数",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,g=>(e.openBlock(),e.createElementBlock("div",{key:g.name,class:"ee-list-item",onDblclick:M=>m(g)},[e.createElementVNode("div",hi,[e.createElementVNode("span",bi,e.toDisplayString(g.label),1),e.createElementVNode("span",yi,e.toDisplayString(g.name)+"()",1)])],40,gi))),128))])],64)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ki,[e.createElementVNode("div",Ei,[v[12]||(v[12]=e.createElementVNode("div",{class:"ee-editor-title"},"表达式编辑",-1)),e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:A,"onUpdate:modelValue":v[5]||(v[5]=g=>V.value=g),class:"ee-textarea",rows:"6",placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容"},null,512),[[e.vModelText,V.value]])]),e.createElementVNode("div",wi,[v[13]||(v[13]=e.createElementVNode("div",{class:"ee-editor-title"},"预览结果",-1)),e.createElementVNode("div",{class:e.normalizeClass(["ee-preview",{"ee-preview-error":G.value==="(表达式错误)"}])},e.toDisplayString(G.value),3)]),v[14]||(v[14]=e.createStaticVNode('<div class="ee-help-section" data-v-86008c29><div class="ee-help-title" data-v-86008c29>帮助信息</div><div class="ee-help-grid" data-v-86008c29><div class="ee-help-card ee-help-field" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>输入方式</div><div class="ee-help-card-content" data-v-86008c29> 双击左侧字段、变量、函数即可插入到表达式输入框中<br data-v-86008c29> 静态数据直接输入即可,如:供应商名称<br data-v-86008c29> 动态解析字段、变量、函数必须用 {} 包裹<br data-v-86008c29> 示例:{SUM(supplier.name)}<br data-v-86008c29> 注意:只能嵌套一层 </div></div><div class="ee-help-card ee-help-function" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>函数使用</div><div class="ee-help-card-content" data-v-86008c29> SUM(字段) - 求和<br data-v-86008c29> AVG(字段) - 平均值<br data-v-86008c29> COUNT(字段) - 计数<br data-v-86008c29> IF(条件, 真值, 假值) - 条件判断 </div></div><div class="ee-help-card ee-help-variable" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>系统变量</div><div class="ee-help-card-content" data-v-86008c29> {pageIndex} - 当前页码<br data-v-86008c29> {totalPages} - 总页数<br data-v-86008c29> {printDate} - 打印日期 </div></div><div class="ee-help-card ee-help-conditional" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>示例</div><div class="ee-help-card-content" data-v-86008c29> 静态文本:供应商名称<br data-v-86008c29> 动态字段:{supplier.name}<br data-v-86008c29> 函数调用:{SUM(amount)}<br data-v-86008c29> 条件判断:{IF(amount>1000, "大单", "小单")} </div></div></div></div>',1))])]),e.createElementVNode("footer",Vi,[e.createElementVNode("button",{type:"button",class:"pd-button",onClick:v[6]||(v[6]=g=>a.value=!1)},"取消"),e.createElementVNode("button",{type:"button",class:"pd-button primary",onClick:J},"确定")])])],32)):e.createCommentVNode("",!0)}}),st=_(Ni,[["__scopeId","data-v-86008c29"]]),Ci={class:"pd-field"},Si={class:"pd-label"},$i=["value","placeholder"],Mi=e.defineComponent({__name:"BindingControl",props:{descriptor:{},modelValue:{},fields:{}},emits:["update:modelValue"],setup(t,{emit:l}){const n=l,o=e.ref(!1);function a(){o.value=!0}return(i,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",Ci,[e.createElementVNode("span",Si,e.toDisplayString(t.descriptor.label),1),e.createElementVNode("input",{value:t.modelValue,class:"pd-input",placeholder:t.descriptor.placeholder||"输入内容,支持 {字段} 表达式",onInput:r[0]||(r[0]=s=>n("update:modelValue",s.target.value)),onDblclick:a},null,40,$i)]),e.createVNode(st,{modelValue:o.value,"onUpdate:modelValue":r[1]||(r[1]=s=>o.value=s),fields:t.fields,expression:t.modelValue,"onUpdate:expression":r[2]||(r[2]=s=>n("update:modelValue",s))},null,8,["modelValue","fields","expression"])],64))}}),Bi=_(Mi,[["__scopeId","data-v-135d160a"]]),xi={class:"pd-field"},Di=["value"],Ti=["value"],zi={class:"pd-field"},Li={class:"pd-field"},Pi={class:"pd-field"},Ii={class:"pd-field"},Ai={style:{width:"60px"}},Ri=e.defineComponent({__name:"TableSettingsGroup",props:{element:{},fields:{}},setup(t){const l=t,n=e.inject(xe,null),o=e.computed(()=>l.fields.filter(r=>r.fieldType==="list").map(r=>({label:r.fieldLabel,value:r.fieldKey})));function a(r){l.element.options.dataSource=r||void 0,n?.recordHistory()}function i(r,s){if(s===void 0)return;const d=l.element.options.tableColWidths,u=n?.maxTableWidth.value??1/0,f=d.reduce((m,y,B)=>B===r?m:m+y,0);if(f+s>u){const m=Math.max(5,Math.round((u-f)*10)/10);alert(`表格总宽不能超过打印范围宽度 ${u}mm,列${r+1} 已调整为 ${m}mm`),d[r]=m}else d[r]=s;Re(l.element.options),n?.recordHistory()}return(r,s)=>(e.openBlock(),e.createBlock(he,{title:"表格设置",icon:"Grid","default-expanded":"","group-key":"table-settings"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:s[4]||(s[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",xi,[s[5]||(s[5]=e.createElementVNode("span",{class:"pd-label"},"列表数据源字段",-1)),e.createElementVNode("select",{value:t.element.options.dataSource,class:"pd-select",style:{width:"100%"},onChange:s[0]||(s[0]=d=>a(d.target.value))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,d=>(e.openBlock(),e.createElementBlock("option",{key:d.value,value:d.value},e.toDisplayString(d.label),9,Ti))),128))],40,Di)]),e.createElementVNode("div",zi,[s[6]||(s[6]=e.createElementVNode("span",{class:"pd-label"},"默认字号 (pt)",-1)),e.createVNode(te,{modelValue:t.element.options.tableDefaultFontSize,"onUpdate:modelValue":s[1]||(s[1]=d=>t.element.options.tableDefaultFontSize=d),min:5,max:72,placeholder:"默认"},null,8,["modelValue"])]),e.createElementVNode("div",Li,[s[7]||(s[7]=e.createElementVNode("span",{class:"pd-label"},"默认文字颜色",-1)),e.createVNode(ge,{modelValue:t.element.options.tableDefaultColor,"onUpdate:modelValue":s[2]||(s[2]=d=>t.element.options.tableDefaultColor=d)},null,8,["modelValue"])]),e.createElementVNode("div",Pi,[s[8]||(s[8]=e.createElementVNode("span",{class:"pd-label"},"默认内边距 (mm)",-1)),e.createVNode(te,{modelValue:t.element.options.tableDefaultPadding,"onUpdate:modelValue":s[3]||(s[3]=d=>t.element.options.tableDefaultPadding=d),min:0,max:10,step:.5,placeholder:"默认"},null,8,["modelValue"])]),e.createElementVNode("div",Ii,[s[9]||(s[9]=e.createElementVNode("span",{class:"pd-label"},"列宽 (mm)",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.element.options.tableColWidths,(d,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"col-width-row"},[e.createElementVNode("span",Ai,"列"+e.toDisplayString(u+1),1),e.createVNode(te,{"model-value":d,min:5,max:200,"onUpdate:modelValue":f=>i(u,f)},null,8,["model-value","onUpdate:modelValue"])]))),128))])],32)]),_:1}))}}),Ui=_(Ri,[["__scopeId","data-v-2860c993"]]),Fi={class:"border-row"},Hi={class:"pd-field"},Oi={class:"pd-field"},Gi={class:"pd-field"},qi=e.defineComponent({__name:"BorderBgGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t;function n(o){return l.searching?l.matchedKeys?.has(o)??!0:!0}return(o,a)=>(e.openBlock(),e.createBlock(he,{title:"边框与背景",icon:"Picture","default-expanded":"","group-key":"border-bg"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:a[3]||(a[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Fi,[e.withDirectives(e.createElementVNode("div",Hi,[a[4]||(a[4]=e.createElementVNode("span",{class:"pd-label"},"边框宽度",-1)),e.createVNode(te,{modelValue:t.element.options.borderWidth,"onUpdate:modelValue":a[0]||(a[0]=i=>t.element.options.borderWidth=i),min:0,max:20,step:.25},null,8,["modelValue"])],512),[[e.vShow,n("bb-border-width")]]),e.withDirectives(e.createElementVNode("div",Oi,[a[5]||(a[5]=e.createElementVNode("span",{class:"pd-label"},"边框颜色",-1)),e.createVNode(ge,{modelValue:t.element.options.borderColor,"onUpdate:modelValue":a[1]||(a[1]=i=>t.element.options.borderColor=i)},null,8,["modelValue"])],512),[[e.vShow,n("bb-border-color")]])]),e.withDirectives(e.createElementVNode("div",Gi,[a[6]||(a[6]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(ge,{modelValue:t.element.options.backgroundColor,"onUpdate:modelValue":a[2]||(a[2]=i=>t.element.options.backgroundColor=i)},null,8,["modelValue"])],512),[[e.vShow,n("bb-bg-color")]])],32)]),_:1}))}}),Wi=_(qi,[["__scopeId","data-v-84aa55dc"]]),Ki={class:"advanced-row"},Yi={class:"pd-field"},Xi={class:"pd-field"},ji={class:"pd-field"},Ji={class:"pd-field"},Zi=e.defineComponent({__name:"AdvancedGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},emits:["delete-element"],setup(t){const l=t;function n(o){return l.searching?l.matchedKeys?.has(o)??!0:!0}return(o,a)=>(e.openBlock(),e.createBlock(he,{title:"高级设置",icon:"Setting","group-key":"advanced"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:a[4]||(a[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Ki,[e.withDirectives(e.createElementVNode("div",Yi,[a[5]||(a[5]=e.createElementVNode("span",{class:"pd-label"},"锁定",-1)),e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"pd-switch","onUpdate:modelValue":a[0]||(a[0]=i=>t.element.options.locked=i)},null,512),[[e.vModelCheckbox,t.element.options.locked]])],512),[[e.vShow,n("ad-locked")]]),e.withDirectives(e.createElementVNode("div",Xi,[a[6]||(a[6]=e.createElementVNode("span",{class:"pd-label"},"每页重复",-1)),e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"pd-switch","onUpdate:modelValue":a[1]||(a[1]=i=>t.element.options.fixed=i)},null,512),[[e.vModelCheckbox,t.element.options.fixed]])],512),[[e.vShow,n("ad-fixed")]])]),e.withDirectives(e.createElementVNode("div",ji,[a[7]||(a[7]=e.createElementVNode("span",{class:"pd-label"},"层级",-1)),e.createVNode(te,{modelValue:t.element.options.zIndex,"onUpdate:modelValue":a[2]||(a[2]=i=>t.element.options.zIndex=i),min:0,max:999},null,8,["modelValue"])],512),[[e.vShow,n("ad-z-index")]]),e.withDirectives(e.createElementVNode("div",Ji,[e.createElementVNode("button",{type:"button",class:"pd-button danger",onClick:a[3]||(a[3]=i=>o.$emit("delete-element"))}," 删除元素 ")],512),[[e.vShow,n("ad-delete")]])],32)]),_:1}))}}),Qi=_(Zi,[["__scopeId","data-v-84bf7a55"]]),_i={key:0,class:"pd-field"},er=["checked"],tr={class:"pd-field"},nr=["checked"],or={class:"pd-field"},lr=["checked"],kt=e.defineComponent({__name:"PaginationGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t,n=e.computed(()=>l.element.printElementType.type==="table"),o=e.computed({get:()=>l.element.options.tablePagination?.enabled??!0,set:()=>{}});function a(f){l.element.options.tablePagination={enabled:f}}const i=e.computed({get:()=>l.element.options.pagination?.pageable??!0,set:()=>{}}),r=e.computed({get:()=>l.element.options.pagination?.keepWithNext??!1,set:()=>{}});function s(f){l.element.options.pagination={pageable:f,keepWithNext:r.value}}function d(f){l.element.options.pagination={pageable:i.value,keepWithNext:f}}function u(f){return l.searching?l.matchedKeys?.has(f)??!0:!0}return(f,m)=>(e.openBlock(),e.createBlock(he,{title:"分页配置",icon:"Document","group-key":"pagination"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:m[3]||(m[3]=e.withModifiers(()=>{},["prevent"]))},[n.value?e.withDirectives((e.openBlock(),e.createElementBlock("div",_i,[m[4]||(m[4]=e.createElementVNode("span",{class:"pd-label"},"启用分页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:o.value,onChange:m[0]||(m[0]=y=>a(y.target.checked))},null,40,er)],512)),[[e.vShow,u("pg-enabled")]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.withDirectives(e.createElementVNode("div",tr,[m[5]||(m[5]=e.createElementVNode("span",{class:"pd-label"},"参与分页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:i.value,onChange:m[1]||(m[1]=y=>s(y.target.checked))},null,40,nr)],512),[[e.vShow,u("pg-pageable")]]),e.withDirectives(e.createElementVNode("div",or,[m[6]||(m[6]=e.createElementVNode("span",{class:"pd-label"},"与下元素同页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:r.value,onChange:m[2]||(m[2]=y=>d(y.target.checked))},null,40,lr)],512),[[e.vShow,u("pg-keep-with-next")]])],64))],32)]),_:1}))}}),ar={class:"image-content-upload"},ir=["disabled"],rr=e.defineComponent({__name:"ImageContentUpload",props:{disabled:{type:Boolean}},emits:["success"],setup(t,{emit:l}){const n=t,o=l,a=e.ref(!1),i=e.inject(rt,e.computed(()=>{})),r=e.computed(()=>n.disabled||a.value||!i.value);async function s(d){const u=d.target,f=u.files?.[0];if(f){if(!f.type.startsWith("image/")){alert("仅支持上传图片文件"),u.value="";return}if(!i.value){alert("图片上传能力未配置"),u.value="";return}a.value=!0;try{const m=await i.value(f);m?o("success",m):alert("图片上传失败")}catch(m){alert(m instanceof Error?m.message:"图片上传失败")}finally{a.value=!1,u.value=""}}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",ar,[e.createElementVNode("label",{class:e.normalizeClass(["pd-button small upload-label",{disabled:r.value}])},[u[0]||(u[0]=e.createElementVNode("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})],-1)),e.createTextVNode(" "+e.toDisplayString(a.value?"上传中...":"上传图片")+" ",1),e.createElementVNode("input",{class:"visually-hidden",type:"file",accept:"image/*",disabled:r.value,onChange:s},null,40,ir)],2),u[1]||(u[1]=e.createElementVNode("p",{class:"upload-tip"},"支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",-1))]))}}),sr=_(rr,[["__scopeId","data-v-b730e8e6"]]),dr={class:"pd-field"},cr=["value"],ur={class:"pd-field"},mr={key:0,class:"pd-field"},pr=["checked"],fr=e.defineComponent({__name:"TableRowGroup",props:{element:{},selection:{}},setup(t){const l=t,n=e.inject(xe),o=e.computed(()=>l.element.options.tableRows[l.selection.r1]);function a(s){const d=Ze(l.element.options.tableRows,l.selection.r1,s);if(d){alert(d);return}n.recordHistory()}function i(s){s!==void 0&&(o.value.height=s,Re(l.element.options),n.recordHistory())}function r(s){o.value.repeatOnPage=s,n.recordHistory()}return(s,d)=>(e.openBlock(),e.createBlock(he,{title:"行属性",icon:"Grid","default-expanded":"","group-key":"table-row"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:d[2]||(d[2]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",dr,[d[4]||(d[4]=e.createElementVNode("span",{class:"pd-label"},"行类型",-1)),e.createElementVNode("select",{value:o.value.type,class:"pd-select",style:{width:"100%"},onChange:d[0]||(d[0]=u=>a(u.target.value))},[...d[3]||(d[3]=[e.createElementVNode("option",{value:"header"},"标题行",-1),e.createElementVNode("option",{value:"data"},"数据行",-1),e.createElementVNode("option",{value:"subtotal"},"小计行(每页小计)",-1),e.createElementVNode("option",{value:"summary"},"汇总行",-1)])],40,cr)]),e.createElementVNode("div",ur,[d[5]||(d[5]=e.createElementVNode("span",{class:"pd-label"},"行高 (mm)",-1)),e.createVNode(te,{"model-value":o.value.height,min:3,max:100,step:.5,"onUpdate:modelValue":i},null,8,["model-value"])]),o.value.type==="header"?(e.openBlock(),e.createElementBlock("div",mr,[d[6]||(d[6]=e.createElementVNode("span",{class:"pd-label"},"每页顶部重复",-1)),e.createElementVNode("input",{checked:o.value.repeatOnPage??!1,type:"checkbox",class:"pd-switch",onInput:d[1]||(d[1]=u=>r(!!u.target.checked))},null,40,pr)])):e.createCommentVNode("",!0)],32)]),_:1}))}}),vr={class:"pd-field"},gr={class:"pd-radio-group",role:"radiogroup"},hr={class:"pd-radio"},br=["checked"],yr={class:"pd-radio"},kr=["checked"],Er={class:"pd-radio"},wr=["checked"],Vr={class:"pd-radio"},Nr=["checked"],Cr={key:0,class:"pd-field"},Sr=["value"],$r={key:1,class:"pd-field"},Mr=["checked"],Br={key:2,class:"pd-field"},xr=["value"],Dr={key:3,class:"pd-field"},Tr=["value"],zr={key:4,class:"pd-field"},Lr={key:5,class:"pd-field"},Pr={class:"pd-field"},Ir=["value"],Ar={class:"pd-field"},Rr={class:"pd-radio-group",role:"radiogroup"},Ur={class:"pd-radio"},Fr=["checked"],Hr={class:"pd-radio"},Or=["checked"],Gr={class:"pd-radio"},qr=["checked"],Wr={class:"pd-field"},Kr={class:"pd-radio-group",role:"radiogroup"},Yr={class:"pd-radio"},Xr=["checked"],jr={class:"pd-radio"},Jr=["checked"],Zr={class:"pd-radio"},Qr=["checked"],_r={class:"cell-style-grid"},es={class:"pd-field"},ts=["value"],ns={class:"pd-field"},os={class:"pd-field"},ls=["checked"],as={class:"pd-field"},is={class:"pd-field"},rs={class:"border-style-row"},ss={style:{width:"112px","flex-shrink":"0"}},ds={class:"pd-button-group border-presets"},cs={class:"pd-checkbox-group"},us={class:"pd-checkbox"},ms={class:"pd-checkbox"},ps={class:"pd-checkbox"},fs={class:"pd-checkbox"},vs={class:"pd-field"},gs={class:"pd-field"},hs=["checked"],bs={class:"merge-btns"},ys=["disabled","title"],ks=["disabled"],Es=e.defineComponent({__name:"TableCellGroup",props:{element:{},selection:{},fields:{}},setup(t,{expose:l}){const n=t,o=e.inject(xe),a=e.computed(()=>n.element.options.tableRows),i=e.computed(()=>{const x=at(a.value,n.selection.r1,n.selection.c1);return a.value[x.r].cells[x.c]}),r=e.ref(!1),s=e.ref(""),d=e.computed(()=>i.value.cellType==="barcode"),u=e.computed(()=>i.value.cellType==="qrcode"),f=e.computed(()=>i.value.cellType==="image");function m(x){V(c=>{c.align=x})}function y(x){V(c=>{c.valign=x})}function B(x){V(c=>{c.cellType=x==="text"?void 0:x,x!=="barcode"&&(c.barcodeType=void 0,c.showBarcodeText=void 0),x!=="qrcode"&&(c.qrCodeLevel=void 0)})}function z(){s.value=i.value.formatter||"",r.value=!0}function E(x){V(c=>{c.formatter=x||void 0})}function V(x){const c=n.selection;for(let h=c.r1;h<=c.r2;h++)for(let T=c.c1;T<=c.c2;T++){const O=a.value[h].cells[T];O.merged||x(O)}o.recordHistory()}const A=e.ref("solid"),H=e.ref(.75),W=e.ref("#333333"),L=e.ref([]);function G(){return{width:H.value,style:A.value,color:W.value}}function Y(x){sn(a.value,n.selection,x,G()),o.recordHistory()}function J(x){const c=x.target,h=new Set(L.value);c.checked?h.add(c.value):h.delete(c.value),L.value=[...h];const T=G();V(O=>{const X={...O.borders??{}};for(const oe of["top","right","bottom","left"])h.has(oe)?X[oe]={...T}:delete X[oe];O.borders=X})}const P=e.computed(()=>St(a.value,n.selection)),v=e.computed(()=>{const x=n.selection;for(let c=x.r1;c<=x.r2;c++)for(let h=x.c1;h<=x.c2;h++){const T=a.value[c].cells[h];if(!T.merged&&((T.rowspan??1)>1||(T.colspan??1)>1))return!0}return!1});function g(){$t(a.value,n.selection),o.recordHistory()}function M(){Mt(a.value,n.selection),o.recordHistory()}return l({openFormatterEditor:z}),(x,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(he,{title:"单元格",icon:"Menu","default-expanded":"","group-key":"table-cell"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:c[39]||(c[39]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",vr,[c[45]||(c[45]=e.createElementVNode("span",{class:"pd-label"},"单元格类型",-1)),e.createElementVNode("div",gr,[e.createElementVNode("label",hr,[e.createElementVNode("input",{type:"radio",value:"text",checked:(i.value.cellType||"text")==="text",onChange:c[0]||(c[0]=h=>B(h.target.value))},null,40,br),c[41]||(c[41]=e.createElementVNode("span",null,"文本",-1))]),e.createElementVNode("label",yr,[e.createElementVNode("input",{type:"radio",value:"barcode",checked:i.value.cellType==="barcode",onChange:c[1]||(c[1]=h=>B(h.target.value))},null,40,kr),c[42]||(c[42]=e.createElementVNode("span",null,"条形码",-1))]),e.createElementVNode("label",Er,[e.createElementVNode("input",{type:"radio",value:"qrcode",checked:i.value.cellType==="qrcode",onChange:c[2]||(c[2]=h=>B(h.target.value))},null,40,wr),c[43]||(c[43]=e.createElementVNode("span",null,"二维码",-1))]),e.createElementVNode("label",Vr,[e.createElementVNode("input",{type:"radio",value:"image",checked:i.value.cellType==="image",onChange:c[3]||(c[3]=h=>B(h.target.value))},null,40,Nr),c[44]||(c[44]=e.createElementVNode("span",null,"图片",-1))])])]),d.value?(e.openBlock(),e.createElementBlock("div",Cr,[c[47]||(c[47]=e.createElementVNode("span",{class:"pd-label"},"码制",-1)),e.createElementVNode("select",{value:i.value.barcodeType||"CODE128",class:"pd-select",onChange:c[4]||(c[4]=h=>V(T=>{T.barcodeType=h.target.value||void 0}))},[...c[46]||(c[46]=[e.createElementVNode("option",{value:"CODE128"},"CODE128(通用)",-1),e.createElementVNode("option",{value:"EAN13"},"EAN13(商品码)",-1),e.createElementVNode("option",{value:"EAN8"},"EAN8",-1),e.createElementVNode("option",{value:"UPC"},"UPC",-1),e.createElementVNode("option",{value:"CODE39"},"CODE39",-1),e.createElementVNode("option",{value:"ITF14"},"ITF14",-1)])],40,Sr)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",$r,[c[48]||(c[48]=e.createElementVNode("span",{class:"pd-label"},"显示文本",-1)),e.createElementVNode("input",{checked:i.value.showBarcodeText!==!1,type:"checkbox",class:"pd-switch",onInput:c[5]||(c[5]=h=>V(T=>{T.showBarcodeText=!!h.target.checked}))},null,40,Mr)])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",Br,[c[50]||(c[50]=e.createElementVNode("span",{class:"pd-label"},"纠错级别",-1)),e.createElementVNode("select",{value:i.value.qrCodeLevel||"M",class:"pd-select",onChange:c[6]||(c[6]=h=>V(T=>{T.qrCodeLevel=h.target.value||void 0}))},[...c[49]||(c[49]=[e.createElementVNode("option",{value:"L"},"L(最低,容量大)",-1),e.createElementVNode("option",{value:"M"},"M(推荐)",-1),e.createElementVNode("option",{value:"Q"},"Q",-1),e.createElementVNode("option",{value:"H"},"H(最高)",-1)])],40,xr)])):e.createCommentVNode("",!0),d.value||u.value||f.value?(e.openBlock(),e.createElementBlock("div",Dr,[c[52]||(c[52]=e.createElementVNode("span",{class:"pd-label"},"缩放模式",-1)),e.createElementVNode("select",{value:i.value.fit||"contain",class:"pd-select",onChange:c[7]||(c[7]=h=>V(T=>{T.fit=h.target.value}))},[...c[51]||(c[51]=[e.createElementVNode("option",{value:"contain"},"包含(保持比例)",-1),e.createElementVNode("option",{value:"cover"},"覆盖(保持比例)",-1),e.createElementVNode("option",{value:"fill"},"拉伸填满",-1),e.createElementVNode("option",{value:"none"},"原始尺寸",-1),e.createElementVNode("option",{value:"scale-down"},"缩小(保持比例)",-1)])],40,Tr)])):e.createCommentVNode("",!0),d.value||u.value||f.value?(e.openBlock(),e.createElementBlock("div",zr,[c[53]||(c[53]=e.createElementVNode("span",{class:"pd-label"},"最大宽度 (mm)",-1)),e.createVNode(te,{"model-value":i.value.maxWidth,min:1,max:200,placeholder:"默认","onUpdate:modelValue":c[8]||(c[8]=h=>V(T=>{T.maxWidth=h??void 0}))},null,8,["model-value"])])):e.createCommentVNode("",!0),d.value||u.value||f.value?(e.openBlock(),e.createElementBlock("div",Lr,[c[54]||(c[54]=e.createElementVNode("span",{class:"pd-label"},"最大高度 (mm)",-1)),e.createVNode(te,{"model-value":i.value.maxHeight,min:1,max:200,placeholder:"默认","onUpdate:modelValue":c[9]||(c[9]=h=>V(T=>{T.maxHeight=h??void 0}))},null,8,["model-value"])])):e.createCommentVNode("",!0),e.createElementVNode("div",Pr,[c[55]||(c[55]=e.createElementVNode("span",{class:"pd-label"},"内容",-1)),e.createElementVNode("input",{value:i.value.formatter||"",class:"pd-input",placeholder:"输入内容,支持 {字段} 表达式",onInput:c[10]||(c[10]=h=>V(T=>{T.formatter=h.target.value||void 0})),onDblclick:z},null,40,Ir)]),e.createElementVNode("div",Ar,[c[59]||(c[59]=e.createElementVNode("span",{class:"pd-label"},"水平对齐",-1)),e.createElementVNode("div",Rr,[e.createElementVNode("label",Ur,[e.createElementVNode("input",{type:"radio",value:"left",checked:i.value.align==="left",onChange:c[11]||(c[11]=h=>m(h.target.value))},null,40,Fr),c[56]||(c[56]=e.createElementVNode("span",null,"左",-1))]),e.createElementVNode("label",Hr,[e.createElementVNode("input",{type:"radio",value:"center",checked:i.value.align==="center",onChange:c[12]||(c[12]=h=>m(h.target.value))},null,40,Or),c[57]||(c[57]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Gr,[e.createElementVNode("input",{type:"radio",value:"right",checked:i.value.align==="right",onChange:c[13]||(c[13]=h=>m(h.target.value))},null,40,qr),c[58]||(c[58]=e.createElementVNode("span",null,"右",-1))])])]),e.createElementVNode("div",Wr,[c[63]||(c[63]=e.createElementVNode("span",{class:"pd-label"},"垂直对齐",-1)),e.createElementVNode("div",Kr,[e.createElementVNode("label",Yr,[e.createElementVNode("input",{type:"radio",value:"top",checked:i.value.valign==="top",onChange:c[14]||(c[14]=h=>y(h.target.value))},null,40,Xr),c[60]||(c[60]=e.createElementVNode("span",null,"上",-1))]),e.createElementVNode("label",jr,[e.createElementVNode("input",{type:"radio",value:"middle",checked:i.value.valign==="middle",onChange:c[15]||(c[15]=h=>y(h.target.value))},null,40,Jr),c[61]||(c[61]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Zr,[e.createElementVNode("input",{type:"radio",value:"bottom",checked:i.value.valign==="bottom",onChange:c[16]||(c[16]=h=>y(h.target.value))},null,40,Qr),c[62]||(c[62]=e.createElementVNode("span",null,"下",-1))])])]),e.createElementVNode("div",_r,[e.createElementVNode("div",es,[c[65]||(c[65]=e.createElementVNode("span",{class:"pd-label"},"字体",-1)),e.createElementVNode("select",{value:i.value.fontFamily,class:"pd-select",placeholder:"继承默认",onChange:c[17]||(c[17]=h=>V(T=>{T.fontFamily=h.target.value||void 0}))},[...c[64]||(c[64]=[e.createElementVNode("option",{value:"SimSun"},"宋体",-1),e.createElementVNode("option",{value:"SimHei"},"黑体",-1),e.createElementVNode("option",{value:"Microsoft YaHei"},"微软雅黑",-1),e.createElementVNode("option",{value:"KaiTi"},"楷体",-1),e.createElementVNode("option",{value:"FangSong"},"仿宋",-1),e.createElementVNode("option",{value:"Arial"},"Arial",-1)])],40,ts)]),e.createElementVNode("div",ns,[c[66]||(c[66]=e.createElementVNode("span",{class:"pd-label"},"字号 (pt)",-1)),e.createVNode(te,{"model-value":i.value.fontSize,min:5,max:72,placeholder:"默认","onUpdate:modelValue":c[18]||(c[18]=h=>V(T=>{T.fontSize=h??void 0}))},null,8,["model-value"])]),e.createElementVNode("div",os,[c[67]||(c[67]=e.createElementVNode("span",{class:"pd-label"},"加粗",-1)),e.createElementVNode("input",{checked:i.value.fontWeight==="bold",type:"checkbox",class:"pd-switch",onInput:c[19]||(c[19]=h=>V(T=>{T.fontWeight=h.target.checked?"bold":void 0}))},null,40,ls)]),e.createElementVNode("div",as,[c[68]||(c[68]=e.createElementVNode("span",{class:"pd-label"},"文字颜色",-1)),e.createVNode(ge,{"model-value":i.value.color,"onUpdate:modelValue":c[20]||(c[20]=h=>V(T=>{T.color=h}))},null,8,["model-value"])]),e.createElementVNode("div",is,[c[69]||(c[69]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(ge,{"model-value":i.value.backgroundColor,"onUpdate:modelValue":c[21]||(c[21]=h=>V(T=>{T.backgroundColor=h}))},null,8,["model-value"])])]),c[77]||(c[77]=e.createElementVNode("h3",{class:"pd-divider"},"边框",-1)),e.createElementVNode("div",rs,[e.withDirectives(e.createElementVNode("select",{class:"pd-select","onUpdate:modelValue":c[22]||(c[22]=h=>A.value=h),style:{width:"90px"}},[...c[70]||(c[70]=[e.createElementVNode("option",{value:"solid"},"实线",-1),e.createElementVNode("option",{value:"dashed"},"虚线",-1),e.createElementVNode("option",{value:"dotted"},"点线",-1),e.createElementVNode("option",{value:"double"},"双线",-1)])],512),[[e.vModelSelect,A.value]]),e.createElementVNode("div",ss,[e.createVNode(te,{modelValue:H.value,"onUpdate:modelValue":c[23]||(c[23]=h=>H.value=h),min:.25,max:5,step:.25},null,8,["modelValue"])]),e.createVNode(ge,{modelValue:W.value,"onUpdate:modelValue":c[24]||(c[24]=h=>W.value=h)},null,8,["modelValue"])]),e.createElementVNode("div",ds,[e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[25]||(c[25]=h=>Y("all"))},"全部"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[26]||(c[26]=h=>Y("outer"))},"外侧"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[27]||(c[27]=h=>Y("inner"))},"内部"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[28]||(c[28]=h=>Y("none"))},"无")]),e.createElementVNode("div",cs,[e.createElementVNode("label",us,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[29]||(c[29]=h=>L.value=h),value:"top",onChange:c[30]||(c[30]=h=>J(h))},null,544),[[e.vModelCheckbox,L.value]]),c[71]||(c[71]=e.createElementVNode("span",null,"上",-1))]),e.createElementVNode("label",ms,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[31]||(c[31]=h=>L.value=h),value:"right",onChange:c[32]||(c[32]=h=>J(h))},null,544),[[e.vModelCheckbox,L.value]]),c[72]||(c[72]=e.createElementVNode("span",null,"右",-1))]),e.createElementVNode("label",ps,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[33]||(c[33]=h=>L.value=h),value:"bottom",onChange:c[34]||(c[34]=h=>J(h))},null,544),[[e.vModelCheckbox,L.value]]),c[73]||(c[73]=e.createElementVNode("span",null,"下",-1))]),e.createElementVNode("label",fs,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[35]||(c[35]=h=>L.value=h),value:"left",onChange:c[36]||(c[36]=h=>J(h))},null,544),[[e.vModelCheckbox,L.value]]),c[74]||(c[74]=e.createElementVNode("span",null,"左",-1))])]),e.createElementVNode("div",vs,[c[75]||(c[75]=e.createElementVNode("span",{class:"pd-label"},"内边距 (mm)",-1)),e.createVNode(te,{"model-value":i.value.padding,min:0,max:10,step:.5,placeholder:"默认","onUpdate:modelValue":c[37]||(c[37]=h=>V(T=>{T.padding=h??void 0}))},null,8,["model-value"])]),e.createElementVNode("div",gs,[c[76]||(c[76]=e.createElementVNode("span",{class:"pd-label"},"自动换行",-1)),e.createElementVNode("input",{checked:i.value.wordWrap??!0,type:"checkbox",class:"pd-switch",onInput:c[38]||(c[38]=h=>V(T=>{T.wordWrap=!!h.target.checked}))},null,40,hs)]),e.createElementVNode("div",bs,[e.createElementVNode("button",{type:"button",class:"pd-button small",disabled:!!P.value,title:P.value||"",onClick:g}," 合并单元格 ",8,ys),e.createElementVNode("button",{type:"button",class:"pd-button small",disabled:!v.value,onClick:M},"拆分单元格",8,ks)])],32)]),_:1}),e.createVNode(st,{modelValue:r.value,"onUpdate:modelValue":c[40]||(c[40]=h=>r.value=h),fields:t.fields,expression:s.value,"onUpdate:expression":E},null,8,["modelValue","fields","expression"])],64))}}),ws=_(Es,[["__scopeId","data-v-e9669bd2"]]),Vs={text:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],longText:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],barcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],qrcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],image:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],table:[]};function Rt(t,l,n,o){return t==="data"?[{targetPath:`options.tableRows[${l}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:o,placeholder:"{name}"}]:t==="subtotal"?[{targetPath:`options.tableRows[${l}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:t==="summary"?[{targetPath:`options.tableRows[${l}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${l}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function Ns(t){const l=t.printElementType.type,n=Vs[l]??[],o=[];if(l==="table"){const a=t.options.dataSource;for(const[i,r]of(t.options.tableRows??[]).entries())for(const[s,d]of r.cells.entries())d.merged||o.push(...Rt(r.type,i,s,a))}return[...n,...o]}const Cs={key:0,class:"prop-collapsed"},Ss={class:"prop-head"},$s={class:"pd-tabs prop-tabs"},Ms={class:"pd-tab-bar",role:"tablist"},Bs={class:"pd-tab-pane",role:"tabpanel"},xs={class:"property-content"},Ds={key:1,class:"pd-empty"},Ts={class:"pd-tab-pane",role:"tabpanel"},zs={class:"pd-field"},Ls=["value"],Ps=["value"],Is={key:0,class:"pd-field"},As={class:"custom-size-grid"},Rs={class:"pd-field"},Us={class:"pd-radio-group",role:"radiogroup"},Fs={class:"pd-radio"},Hs=["checked"],Os={class:"pd-radio"},Gs=["checked"],qs={class:"pd-field"},Ws={class:"page-bg-row"},Ks={class:"margin-grid"},Ys={class:"pd-field"},Xs={class:"pd-field"},js={class:"pd-field"},Js={class:"pd-field"},Zs={class:"pd-field"},Qs={class:"pd-field"},_s={class:"pd-field"},ed=e.defineComponent({__name:"PropertyPanel",props:{element:{},templateData:{},fields:{},activeTab:{},tableSelection:{},recordHistory:{type:Function},collapsed:{type:Boolean}},emits:["delete-element","update:templateData","update:activeTab","toggle-collapse"],setup(t,{emit:l}){const n=t,o=l,a=Qe,i=e.ref(""),r=e.computed(()=>n.element?["text","longText"].includes(n.element.printElementType.type):!1),s=e.computed(()=>n.element?n.element.printElementType.type==="image":!1),d=e.computed(()=>!n.element||n.element.printElementType.type!=="table"?!1:!!n.tableSelection&&n.tableSelection.elementId===n.element.id),u=e.computed(()=>n.element?n.element.printElementType.type==="table":!1),f=e.computed(()=>Ql(i.value)),m=e.computed(()=>f.value.groups),y=e.computed(()=>f.value.itemKeys),B=e.computed(()=>!!i.value.trim()),z=e.computed(()=>{if(!n.element)return[];if(n.element.printElementType.type==="table"&&n.tableSelection){const{r1:w,c1:k}=n.tableSelection,q=n.element.options.tableRows;if(q&&q[w]){const Z=q[w],de=n.element.options.fields?.[0]?.dataSource;return Rt(Z.type,w,k,de)}}return Ns(n.element)});function E(w){return w.split(".").flatMap(k=>{const q=k.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!q)return[k];const Z=q[1],de=[...q[2].matchAll(/\[(\d+)\]/g)].map(pe=>Number(pe[1]));return[Z,...de]})}function V(w){return n.element?E(w).reduce((Z,de)=>Z==null?"":Z[de],n.element)??"":""}function A(w,k){if(!n.element)return;const q=E(w),Z=q.pop(),de=q.reduce((pe,be)=>((pe[be]===void 0||pe[be]===null)&&(pe[be]={}),pe[be]),n.element);de[Z]=k||void 0,n.recordHistory?.()}function H(w){i.value=w}function W(w){n.element&&A("options.src",w)}const L=e.computed(()=>n.templateData?.paperSize||"A4"),G=e.computed(()=>n.templateData?.orientation||"portrait"),Y=e.computed({get:()=>n.templateData?.pageBackground||"#ffffff",set:w=>ie(w)}),J=e.computed(()=>n.templateData?.margins.top??10),P=e.computed(()=>n.templateData?.margins.bottom??10),v=e.computed(()=>n.templateData?.margins.left??10),g=e.computed(()=>n.templateData?.margins.right??10),M=e.computed(()=>n.templateData?.header.height??10),x=e.computed(()=>n.templateData?.footer.height??10),c=e.computed(()=>n.templateData?.firstPageOverlay.height??0),h=e.computed(()=>n.templateData?.customWidth??210),T=e.computed(()=>n.templateData?.customHeight??297);function O(w){n.templateData&&o("update:templateData",{...n.templateData,...w})}function X(w){if(w==="CUSTOM"){O({paperSize:"CUSTOM"});return}a[w]&&O({paperSize:w})}function oe(w){O({orientation:String(w)})}function ie(w){const k=w&&w.toLowerCase()!=="#ffffff"&&w.toLowerCase()!=="#fff"?w:void 0;O(k===void 0?{pageBackground:void 0}:{pageBackground:k})}function re(){O({pageBackground:void 0})}function se(w){w!==void 0&&O({customWidth:w})}function ae(w){w!==void 0&&O({customHeight:w})}function p(w){w!==void 0&&O({margins:{...n.templateData.margins,top:w}})}function b(w){w!==void 0&&O({margins:{...n.templateData.margins,bottom:w}})}function N(w){w!==void 0&&O({margins:{...n.templateData.margins,left:w}})}function S(w){w!==void 0&&O({margins:{...n.templateData.margins,right:w}})}function U(w){w!==void 0&&O({header:{...n.templateData.header,height:w}})}function K(w){w!==void 0&&O({footer:{...n.templateData.footer,height:w}})}function C(w){w!==void 0&&O({firstPageOverlay:{...n.templateData.firstPageOverlay,height:w}})}const $=e.computed(()=>n.activeTab||"page");function D(w){o("update:activeTab",w),o("toggle-collapse")}return(w,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["property-panel",{collapsed:t.collapsed}])},[t.collapsed?(e.openBlock(),e.createElementBlock("div",Cs,[e.createElementVNode("button",{class:"pc-btn",title:"展开属性台",onClick:k[0]||(k[0]=q=>D($.value))},"«"),e.createElementVNode("button",{class:e.normalizeClass(["pc-btn",{on:$.value==="element"}]),title:"元素属性",onClick:k[1]||(k[1]=q=>D("element"))},"▦",2),e.createElementVNode("button",{class:e.normalizeClass(["pc-btn",{on:$.value==="page"}]),title:"页面属性",onClick:k[2]||(k[2]=q=>D("page"))},"▤",2)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Ss,[k[12]||(k[12]=e.createElementVNode("span",{class:"prop-title"},"属性台",-1)),e.createElementVNode("button",{class:"collapse-btn",title:"收起属性台",onClick:k[3]||(k[3]=q=>w.$emit("toggle-collapse"))},"»")]),e.createElementVNode("div",$s,[e.createElementVNode("div",Ms,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:(t.activeTab||"page")==="element"}]),onClick:k[4]||(k[4]=q=>w.$emit("update:activeTab","element"))},"元素属性",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:(t.activeTab||"page")==="page"}]),onClick:k[5]||(k[5]=q=>w.$emit("update:activeTab","page"))},"页面属性",2)]),e.withDirectives(e.createElementVNode("div",Bs,[t.element?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(ta,{onSearch:H}),e.createElementVNode("div",xs,[m.value.includes("position-size")&&!d.value?(e.openBlock(),e.createBlock(ba,{key:0,element:t.element,"matched-keys":y.value,searching:B.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),m.value.includes("appearance")?(e.openBlock(),e.createBlock(qa,{key:1,element:t.element,"is-text-type":r.value,"matched-keys":y.value,searching:B.value},null,8,["element","is-text-type","matched-keys","searching"])):e.createCommentVNode("",!0),m.value.includes("binding")?(e.openBlock(),e.createBlock(he,{key:2,title:"内容",icon:"Document","default-expanded":"","group-key":"binding"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,q=>(e.openBlock(),e.createBlock(Bi,{key:q.targetPath,descriptor:q,fields:t.fields,"model-value":V(q.targetPath),"onUpdate:modelValue":Z=>A(q.targetPath,Z)},null,8,["descriptor","fields","model-value","onUpdate:modelValue"]))),128)),s.value?(e.openBlock(),e.createBlock(sr,{key:0,onSuccess:W})):e.createCommentVNode("",!0)]),_:1})):e.createCommentVNode("",!0),u.value&&t.tableSelection&&t.tableSelection.elementId===t.element.id?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(fr,{element:t.element,selection:t.tableSelection},null,8,["element","selection"]),e.createVNode(ws,{element:t.element,selection:t.tableSelection,fields:t.fields},null,8,["element","selection","fields"])],64)):e.createCommentVNode("",!0),u.value&&m.value.includes("content")?(e.openBlock(),e.createBlock(Ui,{key:4,element:t.element,fields:t.fields},null,8,["element","fields"])):e.createCommentVNode("",!0),m.value.includes("border-bg")?(e.openBlock(),e.createBlock(Wi,{key:5,element:t.element,"matched-keys":y.value,searching:B.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),m.value.includes("pagination")&&u.value?(e.openBlock(),e.createBlock(kt,{key:6,element:t.element,"matched-keys":y.value,searching:B.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),m.value.includes("pagination")&&!u.value?(e.openBlock(),e.createBlock(kt,{key:7,element:t.element,"matched-keys":y.value,searching:B.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),m.value.includes("advanced")?(e.openBlock(),e.createBlock(Qi,{key:8,element:t.element,"matched-keys":y.value,searching:B.value,onDeleteElement:k[6]||(k[6]=q=>w.$emit("delete-element"))},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0)])],64)):(e.openBlock(),e.createElementBlock("p",Ds,"请在画布中选择一个元素"))],512),[[e.vShow,(t.activeTab||"page")==="element"]]),e.withDirectives(e.createElementVNode("div",Ts,[e.createElementVNode("form",{class:"pd-form",onSubmit:k[11]||(k[11]=e.withModifiers(()=>{},["prevent"]))},[k[28]||(k[28]=e.createElementVNode("h3",{class:"pd-divider"},"纸张设置",-1)),e.createElementVNode("div",zs,[k[14]||(k[14]=e.createElementVNode("span",{class:"pd-label"},"纸张尺寸",-1)),e.createElementVNode("select",{value:L.value,class:"pd-select",onChange:k[7]||(k[7]=q=>X(q.target.value)),style:{width:"100%"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),(q,Z)=>(e.openBlock(),e.createElementBlock("option",{key:Z,value:Z},e.toDisplayString(Z),9,Ps))),128)),k[13]||(k[13]=e.createElementVNode("option",{value:"CUSTOM"},"自定义",-1))],40,Ls)]),L.value==="CUSTOM"?(e.openBlock(),e.createElementBlock("div",Is,[k[16]||(k[16]=e.createElementVNode("span",{class:"pd-label"},"自定义宽高 (mm)",-1)),e.createElementVNode("div",As,[e.createVNode(te,{"model-value":h.value,min:25,max:2e3,"onUpdate:modelValue":se},null,8,["model-value"]),k[15]||(k[15]=e.createElementVNode("span",{class:"custom-size-x"},"×",-1)),e.createVNode(te,{"model-value":T.value,min:25,max:2e3,"onUpdate:modelValue":ae},null,8,["model-value"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",Rs,[k[19]||(k[19]=e.createElementVNode("span",{class:"pd-label"},"方向",-1)),e.createElementVNode("div",Us,[e.createElementVNode("label",Fs,[e.createElementVNode("input",{type:"radio",value:"portrait",checked:G.value==="portrait",onChange:k[8]||(k[8]=q=>oe(q.target.value))},null,40,Hs),k[17]||(k[17]=e.createElementVNode("span",null,"纵向",-1))]),e.createElementVNode("label",Os,[e.createElementVNode("input",{type:"radio",value:"landscape",checked:G.value==="landscape",onChange:k[9]||(k[9]=q=>oe(q.target.value))},null,40,Gs),k[18]||(k[18]=e.createElementVNode("span",null,"横向",-1))])])]),e.createElementVNode("div",qs,[k[20]||(k[20]=e.createElementVNode("span",{class:"pd-label"},"页面背景色",-1)),e.createElementVNode("div",Ws,[e.createVNode(ge,{modelValue:Y.value,"onUpdate:modelValue":k[10]||(k[10]=q=>Y.value=q),class:"page-bg-picker"},null,8,["modelValue"]),e.createElementVNode("button",{type:"button",class:"pd-reset",title:"恢复为默认白色",onClick:re},"默认")])]),k[29]||(k[29]=e.createElementVNode("h3",{class:"pd-divider"},"页边距 (mm)",-1)),e.createElementVNode("div",Ks,[e.createElementVNode("div",Ys,[k[21]||(k[21]=e.createElementVNode("span",{class:"pd-label"},"上",-1)),e.createVNode(te,{"model-value":J.value,min:0,max:50,"onUpdate:modelValue":p},null,8,["model-value"])]),e.createElementVNode("div",Xs,[k[22]||(k[22]=e.createElementVNode("span",{class:"pd-label"},"下",-1)),e.createVNode(te,{"model-value":P.value,min:0,max:50,"onUpdate:modelValue":b},null,8,["model-value"])]),e.createElementVNode("div",js,[k[23]||(k[23]=e.createElementVNode("span",{class:"pd-label"},"左",-1)),e.createVNode(te,{"model-value":v.value,min:0,max:50,"onUpdate:modelValue":N},null,8,["model-value"])]),e.createElementVNode("div",Js,[k[24]||(k[24]=e.createElementVNode("span",{class:"pd-label"},"右",-1)),e.createVNode(te,{"model-value":g.value,min:0,max:50,"onUpdate:modelValue":S},null,8,["model-value"])])]),k[30]||(k[30]=e.createElementVNode("h3",{class:"pd-divider"},"三区高度 (mm)",-1)),e.createElementVNode("div",Zs,[k[25]||(k[25]=e.createElementVNode("span",{class:"pd-label"},"页眉高度",-1)),e.createVNode(te,{"model-value":M.value,min:0,max:100,step:.1,"onUpdate:modelValue":U},null,8,["model-value"])]),e.createElementVNode("div",Qs,[k[26]||(k[26]=e.createElementVNode("span",{class:"pd-label"},"页脚高度",-1)),e.createVNode(te,{"model-value":x.value,min:0,max:100,step:.1,"onUpdate:modelValue":K},null,8,["model-value"])]),e.createElementVNode("div",_s,[k[27]||(k[27]=e.createElementVNode("span",{class:"pd-label"},"首页叠加高度",-1)),e.createVNode(te,{"model-value":c.value,min:0,max:200,"onUpdate:modelValue":C},null,8,["model-value"])])],32)],512),[[e.vShow,(t.activeTab||"page")==="page"]])])],64))],2))}}),td=_(ed,[["__scopeId","data-v-93072c2b"]]),nd={class:"status-bar"},od={key:0,class:"status-item coord"},ld={class:"status-item"},ad={class:"status-item"},id={class:"status-item status-paper"},rd=e.defineComponent({__name:"StatusBar",props:{coordinate:{},scale:{},elementCount:{},selectedCount:{},paper:{},dirty:{type:Boolean}},setup(t){return(l,n)=>(e.openBlock(),e.createElementBlock("div",nd,[t.coordinate?(e.openBlock(),e.createElementBlock("span",od," x:"+e.toDisplayString(t.coordinate.x.toFixed(1))+" y:"+e.toDisplayString(t.coordinate.y.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0),e.createElementVNode("span",ld,"缩放 "+e.toDisplayString(t.scale)+"%",1),e.createElementVNode("span",ad,"元素 "+e.toDisplayString(t.elementCount)+e.toDisplayString(t.selectedCount?` (选中 ${t.selectedCount})`:""),1),e.createElementVNode("span",{class:e.normalizeClass(["status-dirty",{on:t.dirty}])},[n[0]||(n[0]=e.createElementVNode("span",{class:"dirty-dot"},null,-1)),e.createTextVNode(e.toDisplayString(t.dirty?"未保存":"已保存"),1)],2),e.createElementVNode("span",id,e.toDisplayString(t.paper),1)]))}}),sd=_(rd,[["__scopeId","data-v-eb34e9a7"]]),Et="print-studio:left",wt="print-studio:right";function Vt(t,l){try{const n=localStorage.getItem(t);return n===null?l:n==="1"}catch{return l}}function dd(){const t=e.ref(Vt(Et,!1)),l=e.ref(Vt(wt,!1)),n=e.ref(!1);e.watch(t,r=>{try{localStorage.setItem(Et,r?"1":"0")}catch{}},{flush:"sync"}),e.watch(l,r=>{try{localStorage.setItem(wt,r?"1":"0")}catch{}},{flush:"sync"});function o(){t.value=!t.value}function a(){l.value=!l.value}function i(){n.value=!1}return{leftCollapsed:t,rightCollapsed:l,toggleLeft:o,toggleRight:a,dirty:n,markSaved:i}}const cd={class:"designer-container"},ud={class:"designer-body"},md=e.defineComponent({__name:"PrintDesigner",props:{initialTemplate:{},initialElements:{},fields:{},isEdit:{type:Boolean},requestScreenshot:{type:Function},uploadImage:{type:Function},loadDefaultTemplate:{type:Function}},emits:["preview","save"],setup(t,{expose:l,emit:n}){const o=t,a=n,{leftCollapsed:i,rightCollapsed:r,toggleLeft:s,toggleRight:d,dirty:u,markSaved:f}=dd(),{scale:m,showGrid:y,snapToGrid:B,showTableGhostBorder:z,templateData:E,elements:V,fields:A,selectedIds:H,selectedElement:W,select:L,clearSelection:G,selectAll:Y,previewIds:J,setPreview:P,commitPreview:v,hasClipboard:g,copy:M,paste:x,cutSelected:c,canUndo:h,canRedo:T,undo:O,redo:X,alignSelected:oe,groupSelected:ie,ungroupSelected:re,deleteSelected:se,dragStart:ae,dragStop:p,addElement:b,addFieldElement:N,moveLayer:S,updateTemplateData:U,fitToWindow:K,getTemplateJson:C,loadTemplate:$,tableSelection:D,setTableSelection:w,recordHistory:k}=Ln({initialTemplate:o.initialTemplate,initialElements:o.initialElements,initialFields:o.fields});e.watch([V,E],()=>{u.value=!0},{deep:!0});const{guides:q,addGuide:Z,moveGuide:de,removeGuide:pe}=In(E,k),be=e.computed(()=>{const I=E.value,{width:R}=Se(I);return R-I.margins.left-I.margins.right});e.provide(xe,{tableSelection:D,setTableSelection:w,recordHistory:k,maxTableWidth:be}),e.provide(zt,H),e.provide(Lt,J),e.provide(rt,e.computed(()=>o.uploadImage)),e.watch(W,I=>{(!I||I.printElementType.type!=="table")&&w(null)});const $e=e.ref(null),ye=e.ref(!1),Ee=e.ref(""),He=e.ref(.5);async function Oe(){if(ye.value){ye.value=!1;return}const I=C();if(!I){alert("模板数据为空");return}if(!o.requestScreenshot){alert("截图服务未配置");return}try{const R=await o.requestScreenshot({templateJson:I,printData:fe});Ee.value&&URL.revokeObjectURL(Ee.value),Ee.value=URL.createObjectURL(R),ye.value=!0}catch{alert("截图生成失败")}}const De=e.ref(null);function Ge(I){De.value=I}const qe=e.computed(()=>{const I=E.value,R=Se(I),ne=I.orientation==="landscape"?"横向":"纵向";return`${I.paperSize} ${ne} ${Math.round(R.width)}×${Math.round(R.height)}mm`});function F(){const I=$e.value?.$el;I&&K(I.clientWidth,I.clientHeight)}function Q(I){m.value=Math.min(200,Math.max(50,m.value+I))}function j(I){const R=I.target.tagName;R==="INPUT"||R==="TEXTAREA"||R==="SELECT"||(I.ctrlKey||I.metaKey)&&I.key==="0"&&(I.preventDefault(),F())}e.onMounted(()=>document.addEventListener("keydown",j)),e.onUnmounted(()=>document.removeEventListener("keydown",j));function ee(I){const R=E.value.header.height,ne=E.value.footer.height;U(I),I.header.height<R&&ue("header"),I.footer.height<ne&&ue("footer")}function ve(I,R){E.value={...E.value,[I]:{...E.value[I],height:R}}}function le(I){U({...E.value}),ue(I)}function ue(I){const R=Fe(E.value)[I];V.value.some(me=>me.zone===I&&(me.options.top+me.options.height>R.height||me.options.left+me.options.width>R.width))&&alert(`${I==="header"?"页眉":"页脚"}高度已小于区域内元素,请手动调整元素位置`)}function we(){const I=E.value.firstPageOverlay,R={options:{left:0,top:0,width:50,height:10,title:"首页叠加"},printElementType:{type:"text",title:"首页叠加"}};E.value={...E.value,firstPageOverlay:{...I,elements:[...I.elements,R]}}}const dt=L;function Ot(I){const R=V.value.find(ne=>ne.id===I);R&&(R.options.visible=R.options.visible===!1)}function Gt(I){const R=V.value.find(ne=>ne.id===I);R&&(R.options.locked=!R.options.locked)}const Me=e.ref("page");e.watch(W,I=>{Me.value=I?"element":"page"});const qt={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},Be=e.ref(!1),Te=e.ref(null),We=e.ref("");function Wt(I){const R=V.value.find(me=>me.id===I);if(!R||(L(I,!1),Me.value="element",R.options.locked))return;const ne=qt[R.printElementType.type];ne&&(Te.value={kind:"element",element:R,field:ne},We.value=R.options[ne]||"",Be.value=!0)}function Kt(I,R,ne){const me=V.value.find(Zt=>Zt.id===I);if(!me||(L(I,!1),Me.value="element",me.options.locked))return;const ct=me.options.tableRows??[],ut=at(ct,R,ne),Ke=ct[ut.r]?.cells[ut.c];Ke&&(Te.value={kind:"cell",cell:Ke},We.value=Ke.formatter||"",Be.value=!0)}function Yt(I){const R=Te.value;R?.kind==="element"?R.element.options[R.field]=I||void 0:R?.kind==="cell"&&(R.cell.formatter=I||void 0),k(),Be.value=!1,Te.value=null}function Xt(I,R){V.value.push(I),L(I.id,!1),k()}e.watch(()=>o.initialTemplate,I=>{I&&$(I,o.initialElements)}),e.watch(()=>o.initialElements,I=>{I&&!o.initialTemplate&&(E.value={...E.value,elements:I.map(R=>({...R,options:{...R.options},printElementType:{...R.printElementType}}))})}),e.watch(()=>o.fields,I=>{A.value=I||[]}),l({getTemplateJson:C});async function jt(){if(o.loadDefaultTemplate&&confirm("将覆盖当前画布内容,是否继续?"))try{const I=await o.loadDefaultTemplate();if(!I){alert("未获取到默认布局");return}$(I),alert("默认布局已加载")}catch{alert("加载默认布局失败")}}function Jt(){a("save",JSON.stringify(C())),f()}return(I,R)=>(e.openBlock(),e.createElementBlock("div",cd,[e.createVNode(_n,{"is-edit":t.isEdit,"can-undo":e.unref(h),"can-redo":e.unref(T),"has-multi-selection":e.unref(H).size>=2,"has-selection":e.unref(H).size>=1,"show-grid":e.unref(y),"snap-to-grid":e.unref(B),"show-table-ghost-border":e.unref(z),"selected-element-has-group":!!e.unref(W)?.options.groupId,"overlay-visible":ye.value,"show-load-default":!!t.loadDefaultTemplate,scale:e.unref(m),"onUpdate:scale":R[0]||(R[0]=ne=>e.isRef(m)?m.value=ne:null),onPreview:R[1]||(R[1]=ne=>I.$emit("preview")),onSave:Jt,onLoadDefault:jt,onUndo:e.unref(O),onRedo:e.unref(X),onAlign:R[2]||(R[2]=ne=>e.unref(oe)(ne)),onMoveLayer:e.unref(S),onToggleGrid:R[3]||(R[3]=ne=>y.value=!e.unref(y)),onToggleSnap:R[4]||(R[4]=ne=>B.value=!e.unref(B)),onToggleTableGhostBorder:R[5]||(R[5]=ne=>z.value=!e.unref(z)),onToggleOverlay:Oe,onGroup:e.unref(ie),onUngroup:e.unref(re),onAddOverlayElement:we,onFitWindow:F,onZoom:Q},null,8,["is-edit","can-undo","can-redo","has-multi-selection","has-selection","show-grid","snap-to-grid","show-table-ghost-border","selected-element-has-group","overlay-visible","show-load-default","scale","onUndo","onRedo","onMoveLayer","onGroup","onUngroup"]),e.createElementVNode("div",ud,[e.createVNode(zo,{fields:e.unref(A),elements:e.unref(V),"selected-ids":e.unref(H),collapsed:e.unref(i),onSelect:e.unref(dt),onMoveLayer:e.unref(S),onToggleVisible:Ot,onToggleLocked:Gt,onToggleCollapse:e.unref(s)},null,8,["fields","elements","selected-ids","collapsed","onSelect","onMoveLayer","onToggleCollapse"]),e.createVNode(jl,{ref_key:"canvasAreaRef",ref:$e,"template-data":e.unref(E),elements:e.unref(V),scale:e.unref(m)/100,"show-grid":e.unref(y),"snap-to-grid":e.unref(B),"show-table-ghost-border":e.unref(z),"has-clipboard":e.unref(g),guides:e.unref(q),"overlay-visible":ye.value,"screenshot-url":Ee.value,"overlay-opacity":He.value,"selected-element-has-group":!!e.unref(W)?.options.groupId,onSelect:e.unref(dt),onDropElement:e.unref(b),onDropField:e.unref(N),onDragStart:e.unref(ae),onDragStop:e.unref(p),onDblclickElement:Wt,onDblclickCell:Kt,onZoneHeightChange:ve,onZoneHeightCommit:le,onSelectAll:e.unref(Y),onClearSelection:e.unref(G),onPreview:e.unref(P),onCommitPreview:e.unref(v),onPaste:e.unref(x),onCopy:e.unref(M),onCut:e.unref(c),onDelete:e.unref(se),onMoveLayer:e.unref(S),onCoordinate:Ge,onGroup:e.unref(ie),onUngroup:e.unref(re),onAddGuide:e.unref(Z),onGuideMove:e.unref(de),onGuideRemove:e.unref(pe),onZoom:Q,onCloneElement:Xt},null,8,["template-data","elements","scale","show-grid","snap-to-grid","show-table-ghost-border","has-clipboard","guides","overlay-visible","screenshot-url","overlay-opacity","selected-element-has-group","onSelect","onDropElement","onDropField","onDragStart","onDragStop","onSelectAll","onClearSelection","onPreview","onCommitPreview","onPaste","onCopy","onCut","onDelete","onMoveLayer","onGroup","onUngroup","onAddGuide","onGuideMove","onGuideRemove"]),e.createVNode(td,{element:e.unref(W),"template-data":e.unref(E),fields:e.unref(A),"table-selection":e.unref(D),"record-history":e.unref(k),collapsed:e.unref(r),"active-tab":Me.value,"onUpdate:activeTab":R[6]||(R[6]=ne=>Me.value=ne),onDeleteElement:e.unref(se),"onUpdate:templateData":ee,onToggleCollapse:e.unref(d)},null,8,["element","template-data","fields","table-selection","record-history","collapsed","active-tab","onDeleteElement","onToggleCollapse"])]),e.createVNode(sd,{coordinate:De.value,scale:e.unref(m),"element-count":e.unref(V).length,"selected-count":e.unref(H).size,paper:qe.value,dirty:e.unref(u)},null,8,["coordinate","scale","element-count","selected-count","paper","dirty"]),e.createVNode(st,{modelValue:Be.value,"onUpdate:modelValue":R[7]||(R[7]=ne=>Be.value=ne),fields:e.unref(A),expression:We.value,"onUpdate:expression":Yt},null,8,["modelValue","fields","expression"])]))}}),pd=_(md,[["__scopeId","data-v-f6f16901"]]),Je=3.7795275591,Ae=3e3;async function Ut(t,l,n,o){const a=ce.bindData(t,l,n),i=await fd(a,o),r=ce.paginate(a,i);return{html:ce.generateHtml(a,r,l,{codeRenderer:o}),pageCount:r.length,pageLayouts:r}}async function fd(t,l){const n=ce.getPaperDimensions(t),o=ce.generateHtml(t,[],void 0,{isMeasurementPass:!0,codeRenderer:l}),a=document.createElement("iframe");a.setAttribute("aria-hidden","true"),a.style.cssText=`position:fixed;left:-10000px;top:0;width:${n.width}mm;height:${n.height}mm;border:0;visibility:hidden;pointer-events:none;`,document.body.appendChild(a);try{const i=a.contentWindow,r=a.contentDocument;if(!i||!r)throw new Error("无法创建测量 iframe");r.open(),r.write(o),r.close(),await vd(i);const s=hd(r),d=new Map,u=new Map(t.elements.map(f=>[f.id,f]));for(const f of s){const y=u.get(f.id)?.options?._repeatHeaderCount??0;d.set(f.id,{id:f.id,measuredHeight:f.height,measuredRowHeights:f.rowHeights,repeatHeaderHeight:f.rowHeights&&y>0?f.rowHeights.slice(0,y).reduce((B,z)=>B+z,0):0})}return d}finally{a.remove()}}function vd(t){return new Promise(l=>{let n=!1;const o=()=>{n||(n=!0,l())},a=setTimeout(o,Ae),i=async()=>{try{const r=t.document.fonts;r?.ready&&await Promise.race([r.ready,Nt(Ae)]),await Promise.race([gd(t.document),Nt(Ae)])}catch{}finally{clearTimeout(a),o()}};t.document.readyState==="complete"?i():(t.addEventListener("load",()=>{i()},{once:!0}),setTimeout(o,Ae))})}function Nt(t){return new Promise((l,n)=>setTimeout(()=>n(new Error("timeout")),t))}function gd(t){const l=Array.from(t.images??[]);return Promise.all(l.map(n=>n.complete?Promise.resolve():new Promise(o=>{n.addEventListener("load",()=>o(),{once:!0}),n.addEventListener("error",()=>o(),{once:!0})}))).then(()=>{})}function hd(t){const l=[],n=t.querySelectorAll("[data-measure-id]");for(const o of n){const a=o,i=a.getAttribute("data-measure-id");if(!i)continue;const r=a.offsetHeight,s=a.querySelector("table.print-table");if(s){const d=[],u=s.querySelectorAll("tbody > tr[data-row-index]");for(const f of u)d.push(f.offsetHeight/Je);l.push({id:i,height:r/Je,rowHeights:d})}else l.push({id:i,height:r/Je})}return l}const Ft="http://www.w3.org/2000/svg";function bd(t,l){const n=document.createElementNS(Ft,"svg");return tt(n,t,{format:l.barcodeType||"CODE128",width:Math.max(1,(l.barWidth??2)/2),height:30,displayValue:l.showText!==!1,fontSize:l.fontSize??10,margin:0,marginBottom:2}),n.outerHTML}function yd(t,l){const n=(l.qrCodeLevel??"M").toUpperCase(),a=nt.create(t,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=a.size,r=4,s=4*r,d=i*r+s*2;let u="";for(let f=0;f<i;f++)for(let m=0;m<i;m++)a.get(m,f)&&(u+=`<rect x="${s+m*r}" y="${s+f*r}" width="${r}" height="${r}" fill="#000"/>`);return`<svg xmlns="${Ft}" viewBox="0 0 ${d} ${d}" width="${d}" height="${d}" shape-rendering="crispEdges">${u}</svg>`}const Ht={render(t,l,n={}){if(!t)throw new Error("empty barcode value");return l==="qrcode"?yd(t,n):bd(t,n)}},kd={class:"print-html-preview"},Ed={key:0,class:"print-html-preview-error"},wd={key:1,class:"print-html-preview-loading"},Vd=e.defineComponent({__name:"PrintHtmlPreview",props:{templateJson:{},printData:{},baseUrl:{}},emits:["rendered","error"],setup(t,{expose:l,emit:n}){const o=t,a=n,i=e.ref(),r=e.ref(!1),s=e.ref("");let d=0;async function u(){if(!o.templateJson){s.value="",r.value=!1;return}const m=++d;r.value=!0,s.value="";try{const{html:y,pageCount:B}=await Ut(o.templateJson,o.printData,o.baseUrl,Ht);if(m!==d)return;const z=i.value?.contentWindow?.document;z&&(z.open(),z.write(y),z.close()),a("rendered",B)}catch(y){if(m!==d)return;s.value=y instanceof Error?y.message:"未知错误",a("error",s.value)}finally{m===d&&(r.value=!1)}}function f(){const m=i.value?.contentWindow;m&&(m.focus(),m.print())}return e.watch(()=>[o.templateJson,o.printData,o.baseUrl],()=>{u()},{immediate:!0,deep:!0}),e.onBeforeUnmount(()=>{d++}),l({print:f,rerender:u}),(m,y)=>(e.openBlock(),e.createElementBlock("div",kd,[s.value?(e.openBlock(),e.createElementBlock("div",Ed,[e.createElementVNode("span",null,"预览渲染失败:"+e.toDisplayString(s.value),1)])):r.value?(e.openBlock(),e.createElementBlock("div",wd,"预览渲染中…")):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("iframe",{ref_key:"iframeRef",ref:i,class:"print-html-preview-iframe",title:"打印预览"},null,512),[[e.vShow,!r.value&&!s.value]])]))}}),Nd=_(Vd,[["__scopeId","data-v-1841dcea"]]);exports.DEFAULT_DEMO_DATA=fe;exports.PrintDesigner=pd;exports.PrintHtmlPreview=Nd;exports.UPLOAD_IMAGE_KEY=rt;exports.browserCodeRenderer=Ht;exports.createDefaultTemplate=Pt;exports.getDemoData=xt;exports.renderHtmlPages=Ut;exports.toRuntimePool=et;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),ue=require("@worm-vue3-print/core"),it=require("jsbarcode"),rt=require("qrcode"),oo=require("dompurify");function no(){let t=0;return function(){return t+=1,`cell-${Date.now().toString(36)}-${t}`}}function lo(){let t=0;return function(){return t+=1,`row-${Date.now().toString(36)}-${t}`}}const ao=no(),io=lo(),Re={width:.75,style:"solid",color:"#333333"};function st(t){return JSON.parse(JSON.stringify(t))}function dt(t){return{id:ao(),borders:{top:{...Re},right:{...Re},bottom:{...Re},left:{...Re}},...t}}function ro(){const t=[50,50,50],a=(n,l)=>({id:io(),type:n,height:8,...l!==void 0?{repeatOnPage:l}:{},cells:t.map(()=>dt())}),o=a("header",!0);return o.cells.forEach((n,l)=>{n.formatter=`列${l+1}`,n.align="center",n.fontWeight="bold"}),{rows:[o,a("data"),a("subtotal"),a("summary")],colWidths:t}}function ct(t,a,o){if(!t[a].cells[o].merged)return{r:a,c:o};for(let n=a;n>=0;n--)for(let l=o;l>=0;l--){const r=t[n].cells[l];if(r.merged)continue;const i=r.rowspan??1,s=r.colspan??1;if(n+i-1>=a&&l+s-1>=o)return{r:n,c:l}}return{r:a,c:o}}function Ce(t,a,o){const n=ct(t,a,o),l=t[n.r].cells[n.c];return{r1:n.r,c1:n.c,r2:n.r+(l.rowspan??1)-1,c2:n.c+(l.colspan??1)-1}}function xt(t,a,o){let n={r1:Math.min(a.r,o.r),c1:Math.min(a.c,o.c),r2:Math.max(a.r,o.r),c2:Math.max(a.c,o.c)};for(;;){let l=!1;for(let r=n.r1;r<=n.r2;r++)for(let i=n.c1;i<=n.c2;i++){const s=Ce(t,r,i),c={r1:Math.min(n.r1,s.r1),c1:Math.min(n.c1,s.c1),r2:Math.max(n.r2,s.r2),c2:Math.max(n.c2,s.c2)};(c.r1!==n.r1||c.c1!==n.c1||c.r2!==n.r2||c.c2!==n.c2)&&(n=c,l=!0)}if(!l)return n}}function Bt(t,a){if((a.r2-a.r1+1)*(a.c2-a.c1+1)<2)return"至少选择 2 个单元格";const n=new Set;for(let r=a.r1;r<=a.r2;r++)n.add(t[r].type);if(n.size>1)return"合并区域不能跨越不同类型的行";const l=xt(t,{r:a.r1,c:a.c1},{r:a.r2,c:a.c2});return l.r1!==a.r1||l.c1!==a.c1||l.r2!==a.r2||l.c2!==a.c2?"选区与已有合并区域部分重叠":null}function Dt(t,a){const o=t[a.r1].cells[a.c1],n=[];for(let l=a.r1;l<=a.r2;l++)for(let r=a.c1;r<=a.c2;r++){const i=t[l].cells[r];i.formatter&&n.push(i.formatter),!(l===a.r1&&r===a.c1)&&(i.merged=!0,i.rowspan=1,i.colspan=1,i.formatter="")}o.rowspan=a.r2-a.r1+1,o.colspan=a.c2-a.c1+1,o.formatter=n.join(" ")}function Tt(t,a){for(let o=a.r1;o<=a.r2;o++)for(let n=a.c1;n<=a.c2;n++){const l=t[o].cells[n];if(!l.merged&&((l.rowspan??1)>1||(l.colspan??1)>1)){const r=Ce(t,o,n),i=l;for(let s=r.r1;s<=r.r2;s++)for(let c=r.c1;c<=r.c2;c++){const d=t[s].cells[c];d.merged=!1,d.rowspan=1,d.colspan=1,so(i,d)}l.rowspan=1,l.colspan=1}}}function so(t,a){t!==a&&(a.align=t.align,a.valign=t.valign,a.fontSize=t.fontSize,a.fontWeight=t.fontWeight,a.color=t.color,a.backgroundColor=t.backgroundColor,a.borders=t.borders?st(t.borders):void 0,a.padding=t.padding,a.wordWrap=t.wordWrap)}function gt(t,a,o){const n=o==="above"?a:a+1,l=t[a],r=l.cells.length,i=l.type==="data"?"header":l.type,s={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:i,height:l.height,cells:Array.from({length:r},()=>dt())};for(let c=0;c<r;c++)if(n>0&&n<t.length){const d=Ce(t,n-1,c);if(d.r1<n&&d.r2>=n){const p=t[d.r1].cells[d.c1];p.rowspan=(p.rowspan??1)+1,s.cells[c].merged=!0}}t.splice(n,0,s)}function co(t,a){if(t.length<=1)return"不能删除最后一行";const o=t[a],n=o.cells.length;for(let l=0;l<n;l++){const r=o.cells[l];if(!r.merged&&(r.rowspan??1)>1){const i=t[a+1].cells[l];Object.assign(i,st(r),{id:i.id}),i.rowspan=(r.rowspan??1)-1,i.merged=!1}else if(r.merged){const i=Ce(t,a,l);if(i.r1<a&&i.c1===l){const s=t[i.r1].cells[i.c1];s.rowspan=(s.rowspan??1)-1}}}return t.splice(a,1),null}function ht(t,a,o,n){const l=n==="left"?o:o+1;a.splice(l,0,a[o]);for(const r of t){const i=dt();if(l>0&&l<r.cells.length){const s=t.indexOf(r),c=Ce(t,s,l-1);if(c.c1<l&&c.c2>=l){const d=t[c.r1].cells[c.c1];s===c.r1&&(d.colspan=(d.colspan??1)+1),i.merged=!0}}r.cells.splice(l,0,i)}}function uo(t,a,o){if(a.length<=1)return"不能删除最后一列";for(let n=0;n<t.length;n++){const l=t[n].cells[o];if(!l.merged&&(l.colspan??1)>1){const r=t[n].cells[o+1];Object.assign(r,st(l),{id:r.id}),r.colspan=(l.colspan??1)-1,r.merged=!1}else if(l.merged){const r=Ce(t,n,o);if(r.c1<o&&r.r1===n){const i=t[r.r1].cells[r.c1];i.colspan=(i.colspan??1)-1}}}for(const n of t)n.cells.splice(o,1);return a.splice(o,1),null}function ot(t,a,o){if(o==="data"){const n=t.findIndex((l,r)=>l.type==="data"&&r!==a);if(n>=0)return`数据行已存在(第 ${n+1} 行),全表最多一行`}if(o==="header"){for(let n=0;n<a;n++)if(t[n].type!=="header")return"标题行必须从表格顶部连续设置"}if(o==="subtotal"||o==="summary"){const n=t.findIndex(l=>l.type==="data");if(n<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(a<n)return"小计/汇总行必须位于数据行之后"}if(o==="subtotal"&&t.slice(0,a).some(n=>n.type==="summary"))return"小计行必须位于汇总行之前";if(o==="summary"&&t.slice(a+1).some(n=>n.type==="subtotal"))return"汇总行必须位于小计行之后";if(t[a].type==="header"&&o!=="header"){for(let n=a+1;n<t.length;n++)if(t[n].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}return t[a].type=o,o!=="header"&&delete t[a].repeatOnPage,null}function mo(t,a,o,n){for(let l=a.r1;l<=a.r2;l++)for(let r=a.c1;r<=a.c2;r++){const i=t[l].cells[r];if(i.merged)continue;if(o==="none"){delete i.borders;continue}const s=Ce(t,l,r),c=s.r1===a.r1,d=s.r2===a.r2,p=s.c1===a.c1,v=s.c2===a.c2,w={...i.borders??{}};o==="all"?(w.top={...n},w.bottom={...n},w.left={...n},w.right={...n}):o==="outer"?(c&&(w.top={...n}),d&&(w.bottom={...n}),p&&(w.left={...n}),v&&(w.right={...n})):o==="inner"&&(c||(w.top={...n}),d||(w.bottom={...n}),p||(w.left={...n}),v||(w.right={...n})),i.borders=w}}const po="1px dashed rgba(0,0,0,0.18)";function He(t,a={}){return t&&t.style!=="none"?`${t.width}pt ${t.style} ${t.color}`:a.designMode&&a.showGhostBorder!==!1?po:"none"}function qe(t){const a=(t.tableColWidths??[]).reduce((n,l)=>n+l,0),o=(t.tableRows??[]).reduce((n,l)=>n+l.height,0);t.width=Math.round(a*100)/100,t.height=Math.round(o*100)/100}const bt=5;function fo(t,a,o,n){const l=t.reduce((s,c,d)=>d===a?s:s+c,0),r=n===1/0?1/0:Math.max(bt,n-l),i=Math.round(o*10)/10;return Math.min(Math.max(i,bt),r)}function Me(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function vo(t){const a={left:7,top:17.6,width:42.3,height:7.1};switch(t){case"text":return{...a,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...a,width:28.2,height:28.2,fit:"contain"};case"longText":return{...a,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:o,colWidths:n}=ro(),l=n.reduce((i,s)=>i+s,0),r=o.reduce((i,s)=>i+s.height,0);return{...a,width:l,height:r,tableMode:"dynamic",tableRows:o,tableColWidths:n,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"hline":return{...a,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...a,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...a,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...a,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...a,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...a,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...a,width:28.2,height:28.2};default:return a}}function zt(t,a){const o={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:Me(),options:{...vo(t),...a},printElementType:{type:t,title:o[t]?.title||t}}}const ut=new ue.TemplateEngine;function go(){return ge}const ge={supplier:{name:"鑫达五金有限公司",phone:"0571-88776655",address:"杭州市萧山区经济开发区88号"},receiver:{name:"李四",phone:"13912345678",address:"杭州市余杭区文一西路998号"},order:{no:"PO20260801001",date:"2026-08-01",total:69543.75},goods:[{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:100,price:.5,amount:50,remark:"A级"},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:117,price:.75,amount:87.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:134,price:1,amount:134,remark:""},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:151,price:1.25,amount:188.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:168,price:1.5,amount:252,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:185,price:1.75,amount:323.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:202,price:2,amount:404,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:219,price:2.25,amount:492.75,remark:"A级"},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:236,price:2.5,amount:590,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:253,price:2.75,amount:695.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×20",unit:"个",qty:270,price:3,amount:810,remark:""},{name:"不锈钢螺母 M10",spec:"M16×21",unit:"套",qty:287,price:3.25,amount:932.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×22",unit:"盒",qty:304,price:3.5,amount:1064,remark:""},{name:"六角螺栓 M14",spec:"M5×23",unit:"支",qty:321,price:3.75,amount:1203.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×24",unit:"袋",qty:338,price:4,amount:1352,remark:"A级"},{name:"平垫圈 M6",spec:"M4×25",unit:"件",qty:355,price:4.25,amount:1508.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×26",unit:"根",qty:372,price:4.5,amount:1674,remark:""},{name:"双头螺柱 M20",spec:"M8×27",unit:"包",qty:389,price:4.75,amount:1847.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×28",unit:"只",qty:406,price:5,amount:2030,remark:""},{name:"十字盘头钉 M3",spec:"M12×29",unit:"组",qty:423,price:5.25,amount:2220.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×30",unit:"个",qty:440,price:.5,amount:220,remark:""},{name:"不锈钢螺母 M10",spec:"M16×31",unit:"套",qty:457,price:.75,amount:342.75,remark:"A级"},{name:"弹簧垫圈 M12",spec:"M6×32",unit:"盒",qty:474,price:1,amount:474,remark:""},{name:"六角螺栓 M14",spec:"M5×33",unit:"支",qty:491,price:1.25,amount:613.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×34",unit:"袋",qty:508,price:1.5,amount:762,remark:""},{name:"平垫圈 M6",spec:"M4×35",unit:"件",qty:525,price:1.75,amount:918.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×36",unit:"根",qty:542,price:2,amount:1084,remark:""},{name:"双头螺柱 M20",spec:"M8×37",unit:"包",qty:559,price:2.25,amount:1257.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×38",unit:"只",qty:576,price:2.5,amount:1440,remark:"A级"},{name:"十字盘头钉 M3",spec:"M12×39",unit:"组",qty:593,price:2.75,amount:1630.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×40",unit:"个",qty:610,price:3,amount:1830,remark:""},{name:"不锈钢螺母 M10",spec:"M16×41",unit:"套",qty:627,price:3.25,amount:2037.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×42",unit:"盒",qty:644,price:3.5,amount:2254,remark:""},{name:"六角螺栓 M14",spec:"M5×43",unit:"支",qty:661,price:3.75,amount:2478.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×44",unit:"袋",qty:678,price:4,amount:2712,remark:""},{name:"平垫圈 M6",spec:"M4×45",unit:"件",qty:695,price:4.25,amount:2953.75,remark:"A级"},{name:"自攻螺钉 M5",spec:"M3×46",unit:"根",qty:712,price:4.5,amount:3204,remark:""},{name:"双头螺柱 M20",spec:"M8×47",unit:"包",qty:729,price:4.75,amount:3462.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×48",unit:"只",qty:746,price:5,amount:3730,remark:""},{name:"十字盘头钉 M3",spec:"M12×49",unit:"组",qty:763,price:5.25,amount:4005.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:780,price:.5,amount:390,remark:""},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:797,price:.75,amount:597.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:814,price:1,amount:814,remark:"A级"},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:831,price:1.25,amount:1038.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:848,price:1.5,amount:1272,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:865,price:1.75,amount:1513.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:882,price:2,amount:1764,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:899,price:2.25,amount:2022.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:916,price:2.5,amount:2290,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:933,price:2.75,amount:2565.75,remark:"A级"}]},ho={MONEY:ue.formatMoney,CONCAT:(...t)=>t.filter(a=>a!=null).join(""),IF:ue.ifFn,FORMAT:t=>typeof t!="number"?String(t):t.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(t,a,o)=>String(t).slice(a,o?a+o:void 0),LEN:t=>String(t).length,ROUND:(t,a)=>Number(Number(t).toFixed(a)),NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(t,a)=>t!=null&&t!==""?String(t):a,PAD:(t,a,o)=>String(t).padStart(a,o),REPLACE:(t,a,o)=>String(t).replace(new RegExp(a,"g"),o),JSON:t=>JSON.stringify(t,null,2),DATE:ue.formatDate,UPPER:ue.toUpperCaseAmount};for(const[t,a]of Object.entries(ho))ut.registerFunction(t,a);function bo(t,a,o){switch(t.toUpperCase()){case"SUM":return ue.sum(o,a);case"AVG":return ue.avg(o,a);case"COUNT":return ue.count(o,a);case"MIN":return ue.min(o,a);case"MAX":return ue.max(o,a);default:return 0}}function $e(t,a){if(!t)return"";if(!t.includes("{"))return t;const o=Array.isArray(a.rows)?a.rows:[];let n=t.replace(/\{([^}]+)\}/g,(l,r)=>{let i=r.trim();return i=i.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(s,c,d)=>{const p=d.trim().replace(/^['"]|['"]$/g,"");return String(bo(c,p,o))}),`{${i}}`});try{return ut.render(n,a)}catch{return t}}function yo(t){return zt("text",{formatter:`{${t.fieldKey}}`,title:t.fieldLabel})}function We(t,a){if(t.formatter){if(!a||a.length===0)return"";const o=a[0];try{return ut.render(t.formatter,o??{})}catch{return t.formatter}}return""}function yt(t){let a=ge;for(const o of t.split(".")){if(a==null)return;a=Array.isArray(a)?a[0]?.[o]:a[o]}return a}function ko(t,a){const o=a?.[0];return(t??"").replace(/\{([^{}]+)\}/g,(l,r)=>{const i=r.trim(),s=i.includes(".")?yt(i):o?.[i]??yt(i);return s==null?"":String(s)}).trim()||"1234567890128"}function Eo(t){return t/2.83464566929}function Fe(t){return t*(25.4/96)}function he(t){return t*(96/25.4)}const wo=["left","top","width","height"];function Vo(t){const a={...t.options};for(const o of wo){const n=a[o];typeof n=="number"&&Number.isFinite(n)&&(a[o]=No(Eo(n)))}return{...t,options:a}}function No(t){return Math.round(t*100)/100}function Co(t){if(t.unit==="mm")return t;const a=o=>o?.map(Vo)??[];return{...t,unit:"mm",elements:a(t.elements),header:t.header?{...t.header,elements:a(t.header.elements)}:t.header,footer:t.footer?{...t.footer,elements:a(t.footer.elements)}:t.footer,firstPageOverlay:t.firstPageOverlay?{...t.firstPageOverlay,elements:a(t.firstPageOverlay.elements)}:t.firstPageOverlay}}const nt={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:216,height:279},Legal:{width:216,height:356}};function Ee(t){let a;return t.paperSize==="CUSTOM"?a={width:t.customWidth??210,height:t.customHeight??297}:a=nt[t.paperSize]||nt.A4,t.orientation==="landscape"?{width:a.height,height:a.width}:a}const So=25,mt=5;function Mo(t){return Math.max(So,t)}function $o(t,a,o=1.1){const n=a>0?t*o:t/o;return Mo(Math.round(n))}function Lt(t,a,o,n,l=.9){if(o<=0||n<=0)return 100;const r=Math.min(t/o,a/n)*l,i=Math.round(r*100);return Math.max(mt,i)}const Pt=["text","image","hline","vline","rect","oval","barcode","qrcode"];function xo(t){return Ee(t)}function Ye(t){const a=xo(t),o=t.margins,n=t.header.height,l=t.footer.height,r=a.width-o.left-o.right,i=a.height-o.top-o.bottom-n-l,s=(c,d,p,v)=>({left:c,top:d,width:p,height:v});return{header:s(o.left,o.top,r,n),content:s(o.left,o.top+n,r,i),footer:s(o.left,a.height-o.bottom-l,r,l)}}function At(t,a,o){const n=Ye(t);return n.footer.height>0&&o>=n.footer.top?"footer":n.header.height>0&&o<n.header.top+n.header.height?"header":"content"}function lt(t,a){const o=t.options;o.width=Math.min(o.width,a.width),o.height=Math.min(o.height,a.height),o.left=Math.min(Math.max(0,o.left),a.width-o.width),o.top=Math.min(Math.max(0,o.top),a.height-o.height)}function Bo(t,a){const o=Ye(a),n=t.zone||"content",l=o[n],r=l.left+t.options.left+t.options.width/2,i=l.top+t.options.top+t.options.height/2;let s=At(a,r,i),c=!1;if(s!=="content"&&!Pt.includes(t.printElementType.type)&&(s="content",c=!0),s!==n){const d=o[s];t.options.left=l.left+t.options.left-d.left,t.options.top=l.top+t.options.top-d.top,t.zone=s}return s!=="content"?lt(t,o[s]):c&<(t,o.content),{rejected:c}}const It=Symbol("selected-ids"),Rt=Symbol("preview-ids");function Do(t){const a=e.ref(new Set),o=e.ref(new Set),n=e.computed(()=>t.value.filter(w=>a.value.has(w.id))),l=e.computed(()=>a.value.size>0);function r(w,L=!1){if(L){const H=new Set(a.value);H.has(w)?H.delete(w):H.add(w),a.value=H}else a.value=new Set([w])}function i(){a.value=new Set}function s(w){a.value=new Set(w)}function c(w){o.value=new Set(w)}function d(){o.value=new Set}function p(){a.value=new Set(o.value),o.value=new Set}function v(){const w=n.value;if(w.length===0)return null;let L=1/0,H=1/0,D=-1/0,$=-1/0;return w.forEach(R=>{L=Math.min(L,R.options.left),H=Math.min(H,R.options.top),D=Math.max(D,R.options.left+R.options.width),$=Math.max($,R.options.top+R.options.height)}),{left:L,top:H,width:D-L,height:$-H}}return{selectedIds:a,selectedElements:n,hasSelection:l,select:r,clearSelection:i,selectAll:s,getSelectionBounds:v,previewIds:o,setPreview:c,clearPreview:d,commitPreview:p}}function To(){const t=e.ref(null);function a(l){t.value=l.map(r=>({options:{...r.options},printElementType:{...r.printElementType}}))}function o(l=10){return t.value?t.value.map(r=>({id:Me(),options:{...r.options,left:r.options.left+l,top:r.options.top+l},printElementType:{...r.printElementType}})):null}function n(){return t.value!==null&&t.value.length>0}return{clipboard:t,copy:a,paste:o,hasData:n}}function zo(){function t(a,o){if(a.length<2)return;const n={minLeft:Math.min(...a.map(l=>l.options.left)),maxRight:Math.max(...a.map(l=>l.options.left+l.options.width)),minTop:Math.min(...a.map(l=>l.options.top)),maxBottom:Math.max(...a.map(l=>l.options.top+l.options.height))};switch(o){case"left":a.forEach(l=>{l.options.left=n.minLeft});break;case"right":a.forEach(l=>{l.options.left=n.maxRight-l.options.width});break;case"top":a.forEach(l=>{l.options.top=n.minTop});break;case"bottom":a.forEach(l=>{l.options.top=n.maxBottom-l.options.height});break;case"vertical":{const l=n.minLeft+(n.maxRight-n.minLeft)/2;a.forEach(r=>{r.options.left=l-r.options.width/2});break}case"horizontal":{const l=n.minTop+(n.maxBottom-n.minTop)/2;a.forEach(r=>{r.options.top=l-r.options.height/2});break}case"distributeHor":{const l=[...a].sort((c,d)=>c.options.left-d.options.left),r=l.reduce((c,d)=>c+d.options.width,0),i=(n.maxRight-n.minLeft-r)/(l.length-1);let s=n.minLeft;l.forEach(c=>{c.options.left=s,s+=c.options.width+i});break}case"distributeVer":{const l=[...a].sort((c,d)=>c.options.top-d.options.top),r=l.reduce((c,d)=>c+d.options.height,0),i=(n.maxBottom-n.minTop-r)/(l.length-1);let s=n.minTop;l.forEach(c=>{c.options.top=s,s+=c.options.height+i});break}}}return{align:t}}function Lo(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function Po(){function t(n,l){if(n.filter(s=>l.has(s.id)).length<2)return n;const i=Lo();return n.map(s=>l.has(s.id)?{...s,options:{...s.options,groupId:i}}:s)}function a(n,l){const r=n.filter(s=>l.has(s.id)),i=new Set(r.map(s=>s.options.groupId).filter(Boolean));return n.map(s=>s.options.groupId&&i.has(s.options.groupId)?{...s,options:{...s.options,groupId:void 0}}:s)}function o(n,l){const r=n.find(s=>s.id===l);if(!r?.options.groupId)return new Set([l]);const i=new Set;for(const s of n)s.options.groupId===r.options.groupId&&i.add(s.id);return i}return{group:t,ungroup:a,getGroupedIds:o}}function Ao(t){const o=e.ref([]),n=e.ref([]),l=e.ref(!1),r=e.ref(!1);function i(){l.value=o.value.length>0,r.value=n.value.length>0}function s(L){return{elements:JSON.parse(JSON.stringify(L?.elements??[])),templateData:JSON.parse(JSON.stringify(L?.templateData??{}))}}function c(L){return s(L)}function d(L){o.value.push(c(L)),n.value=[],o.value.length>50&&o.value.shift(),i()}function p(L){if(o.value.length===0)return null;const H=o.value.pop();return n.value.push(L?c(L):s(H)),i(),o.value.length>0?s(o.value[o.value.length-1]):null}function v(L){if(n.value.length===0)return null;const H=n.value.pop();return o.value.push(L?c(L):s(H)),i(),s(H)}function w(){o.value=[],n.value=[],i()}return{push:d,undo:p,redo:v,canUndo:l,canRedo:r,clear:w}}const Io=1,Ro=10,Ho=.5;function Fo(t){function a(l){const r=l.target.tagName;if(r==="INPUT"||r==="TEXTAREA"||r==="SELECT")return;const i=l.ctrlKey||l.metaKey;if(l.key.startsWith("Arrow")){l.preventDefault();const s=l.shiftKey?Ro:l.ctrlKey?Ho:Io,c=l.key==="ArrowLeft"?-s:l.key==="ArrowRight"?s:0,d=l.key==="ArrowUp"?-s:l.key==="ArrowDown"?s:0;t.onMove?.(c,d);return}if(l.key==="Delete"||l.key==="Backspace"){l.preventDefault(),t.onDelete?.();return}if(i){const s=l.key.toLowerCase();s==="c"?(l.preventDefault(),t.onCopy?.()):s==="v"?(l.preventDefault(),t.onPaste?.()):s==="a"?(l.preventDefault(),t.onSelectAll?.()):s==="d"?(l.preventDefault(),t.onDuplicate?.()):s==="z"?(l.preventDefault(),l.shiftKey?t.onRedo?.():t.onUndo?.()):s==="y"?(l.preventDefault(),t.onRedo?.()):s==="1"?(l.preventDefault(),t.onResetZoom?.()):s==="l"?(l.preventDefault(),t.onAlignLeft?.()):s==="r"?(l.preventDefault(),t.onAlignRight?.()):s==="e"?(l.preventDefault(),t.onAlignCenterH?.()):s==="t"?(l.preventDefault(),t.onAlignTop?.()):s==="b"?(l.preventDefault(),t.onAlignBottom?.()):s==="g"&&(l.preventDefault(),l.shiftKey?t.onUngroup?.():t.onGroup?.())}}function o(){document.addEventListener("keydown",a)}function n(){document.removeEventListener("keydown",a)}return{setup:o,cleanup:n}}function Ht(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},firstPageOverlay:{height:0,elements:[]},elements:[],watermark:{}}}function at(t){const a=(o,n)=>(o??[]).map(l=>{const r={...l.options};return(l.printElementType?.type??l.type)==="table"&&qe(r),{id:l.id||Me(),zone:n,options:r,printElementType:{...l.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},firstPageOverlay:{height:t.firstPageOverlay?.height??0,elements:[...t.firstPageOverlay?.elements??[]]},guides:[...t.guides??[]],elements:[...a(t.elements??[],"content"),...a(t.header?.elements??[],"header"),...a(t.footer?.elements??[],"footer")]}}function Uo(t={}){const a=e.ref(100),o=e.ref(!0),n=e.ref(!0),l=e.ref(!1),r=e.ref(!0),i=e.ref(at(t.initialTemplate||Ht())),s=e.computed({get:()=>i.value.elements,set:q=>{i.value.elements=q}}),c=e.ref(t.initialFields||[]),{selectedIds:d,selectedElements:p,select:v,clearSelection:w,selectAll:L,previewIds:H,setPreview:D,clearPreview:$,commitPreview:R}=Do(s),{group:W,ungroup:J}=Po(),{copy:A,paste:G,hasData:K}=To(),{align:S}=zo(),{push:M,undo:x,redo:B,canUndo:T,canRedo:z}=Ao(),u=e.computed(()=>{if(d.value.size===0)return null;const q=d.value.values().next().value;return s.value.find(ee=>ee.id===q)||null}),V=e.ref(null);function O(q){V.value=q}function X(){return{elements:s.value.map(q=>({id:q.id,zone:q.zone,options:JSON.parse(JSON.stringify(q.options)),printElementType:{...q.printElementType}})),templateData:{paperSize:i.value.paperSize,orientation:i.value.orientation,margins:{...i.value.margins},header:{height:i.value.header.height,elements:[]},footer:{height:i.value.footer.height,elements:[]},firstPageOverlay:{height:i.value.firstPageOverlay.height,elements:[]},elements:[],customWidth:i.value.customWidth,customHeight:i.value.customHeight,watermark:i.value.watermark?{...i.value.watermark}:void 0,guides:[...i.value.guides??[]]}}}function Z(){M(X())}function j(){const q=x(X());q?.templateData&&(i.value={...q.templateData,elements:q.elements})}function ce(){const q=B(X());q?.templateData&&(i.value={...q.templateData,elements:q.elements})}function ie(){A(p.value)}function se(){A(p.value),F()}function le(){const q=G();q&&q.length>0&&(s.value.push(...q),Z())}function P(){A(p.value);const q=G();q&&q.length>0&&(q.forEach(ee=>{ee.options.left+=5,ee.options.top+=5}),s.value.push(...q),v(q[0].id,!1),Z())}function g(){a.value=100}const E=e.computed(()=>K());let f=!1,m=null;const k=300;function h(q,ee){const Q=p.value.filter(oe=>!oe.options.locked);Q.length!==0&&(Q.forEach(oe=>{oe.options.left+=q,oe.options.top+=ee}),f||(f=!0,Z()),m&&clearTimeout(m),m=setTimeout(()=>{f=!1,m=null},k))}function C(){L(s.value.map(q=>q.id))}function N(q){S(p.value,q),Z()}function y(){s.value=W(s.value,d.value),Z()}function b(){s.value=J(s.value,d.value),Z()}function F(){d.value.size!==0&&(s.value=s.value.filter(q=>!d.value.has(q.id)),w(),Z())}const{setup:Y,cleanup:ae}=Fo({onMove:h,onDelete:F,onCopy:ie,onPaste:le,onSelectAll:C,onUndo:j,onRedo:ce,onDuplicate:P,onResetZoom:g,onAlignLeft:()=>N("left"),onAlignRight:()=>N("right"),onAlignCenterH:()=>N("vertical"),onAlignTop:()=>N("top"),onAlignBottom:()=>N("bottom"),onGroup:y,onUngroup:b});let re=null;function ve(){re=X()}function xe(){if(!re)return;const q=new Map(re.elements.map(de=>[de.id,de]));let ee=!1;for(const de of s.value){const pe=q.get(de.id);if(!pe)continue;(pe.options.left!==de.options.left||pe.options.top!==de.options.top||pe.options.width!==de.options.width||pe.options.height!==de.options.height)&&Bo(de,i.value).rejected&&(ee=!0)}ee&&alert("该元素类型不能放入页眉/页脚");const Q=de=>`${de.id}:${de.zone||"content"}:${de.options.left},${de.options.top},${de.options.width},${de.options.height}`,oe=re.elements.map(Q).join("|"),ke=X().elements.map(Q).join("|");re=null,oe!==ke&&Z()}function be(q,ee){const Q=At(i.value,ee.x,ee.y);if(Q!=="content"&&!Pt.includes(q.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const oe=Ye(i.value)[Q];return q.zone=Q,q.options.left=ee.x-oe.left,q.options.top=ee.y-oe.top,Q!=="content"&<(q,oe),!0}function ye(q,ee){const Q=zt(q);ee&&!be(Q,ee)||(s.value.push(Q),v(Q.id,!1),Z())}function Ne(q,ee){const Q=yo(q);ee&&!be(Q,ee)||(s.value.push(Q),v(Q.id,!1),Z())}function Ke(q){if(d.value.size===0)return;const ee=d.value.values().next().value,Q=s.value.find(Se=>Se.id===ee);if(!Q)return;const oe=Q.options.zIndex??0,ke=s.value.map(Se=>Se.options.zIndex??0),de=Math.max(...ke,0),pe=Math.min(...ke,0);switch(q){case"top":Q.options.zIndex=de+1;break;case"bottom":Q.options.zIndex=pe-1;break;case"up":Q.options.zIndex=oe+1;break;case"down":Q.options.zIndex=oe-1;break}Z()}function Xe(q,ee){const{width:Q,height:oe}=Ee(i.value),ke=96/25.4;a.value=Lt(q,ee,Q*ke,oe*ke)}function Ae(q){i.value={...q},Z()}function je(){const q=s.value,ee=Q=>q.filter(oe=>(oe.zone||"content")===Q).map(oe=>({id:oe.id,type:oe.printElementType.type,options:{...oe.options},printElementType:{...oe.printElementType}}));return{unit:"mm",...i.value,header:{...i.value.header,elements:ee("header")},footer:{...i.value.footer,elements:ee("footer")},firstPageOverlay:{...i.value.firstPageOverlay,elements:i.value.firstPageOverlay.elements.map(Q=>({id:Q.id||Me(),type:Q.printElementType?.type||"text",options:{...Q.options},printElementType:{...Q.printElementType}}))},elements:ee("content"),guides:[...i.value.guides??[]]}}function Je(q,ee){const Q=Co(q);i.value=at(Q),ee&&(i.value={...i.value,elements:ee.map(oe=>({...oe,id:oe.id||Me(),zone:oe.zone||"content",options:{...oe.options},printElementType:{...oe.printElementType}}))}),M(X())}return M(X()),e.onMounted(()=>Y()),e.onUnmounted(()=>{ae(),m&&(clearTimeout(m),m=null)}),{scale:a,showRuler:o,showGrid:n,snapToGrid:l,showTableGhostBorder:r,templateData:i,elements:s,fields:c,selectedIds:d,selectedElements:p,selectedElement:u,select:v,clearSelection:w,selectAll:C,previewIds:H,setPreview:D,clearPreview:$,commitPreview:R,hasClipboard:E,copy:ie,paste:le,cutSelected:se,tableSelection:V,setTableSelection:O,canUndo:T,canRedo:z,undo:j,redo:ce,recordHistory:Z,alignSelected:N,groupSelected:y,ungroupSelected:b,deleteSelected:F,duplicateSelected:P,resetZoom:g,dragStart:ve,dragStop:xe,addElement:ye,addFieldElement:Ne,moveLayer:Ke,fitToWindow:Xe,updateTemplateData:Ae,getTemplateJson:je,loadTemplate:Je}}let kt=0;function Oo(){return kt+=1,`guide-${kt}`}function Go(t,a){const o=e.computed(()=>t.value.guides??[]);function n(c){t.value={...t.value,guides:c([...t.value.guides??[]])},a()}function l(c,d){n(p=>(p.push({type:c,position:d,id:Oo()}),p))}function r(c,d){n(p=>p.map(v=>v.id===c?{...v,position:d}:v))}function i(c){n(d=>d.filter(p=>p.id!==c))}function s(){const c=[],d=[];for(const p of o.value)p.type==="vertical"?c.push(p.position):d.push(p.position);return{vertical:c,horizontal:d}}return{guides:o,addGuide:l,moveGuide:r,removeGuide:i,getGuidePositions:s}}const Pe=Symbol("table-edit"),pt=Symbol("print-upload-image"),qo=e.defineComponent({__name:"HelpButton",emits:["click"],setup(t){return(a,o)=>(e.openBlock(),e.createElementBlock("button",{class:"help-button",title:"帮助文档",onClick:o[0]||(o[0]=n=>a.$emit("click"))},[...o[1]||(o[1]=[e.createElementVNode("span",{class:"help-icon"},"?",-1)])]))}}),_=(t,a)=>{const o=t.__vccOpts||t;for(const[n,l]of a)o[n]=l;return o},Wo=_(qo,[["__scopeId","data-v-80ccab03"]]),Yo={class:"designer-toolbar"},Ko={class:"tb-group"},Xo={class:"tb-title"},jo={class:"tb-title-name"},Jo={class:"tb-group"},Zo=["disabled"],Qo=["disabled"],_o={key:0,class:"tb-group"},en={key:1,class:"tb-group"},tn={key:2,class:"tb-group"},on={key:3,class:"tb-group"},nn={class:"tb-group"},ln={class:"tb-zoom"},an={key:4,class:"tb-group"},rn={class:"tb-group"},sn={class:"tb-group"},dn=e.defineComponent({__name:"DesignerToolbar",props:e.mergeModels({isEdit:{type:Boolean},canUndo:{type:Boolean},canRedo:{type:Boolean},hasMultiSelection:{type:Boolean},hasSelection:{type:Boolean},showRuler:{type:Boolean,default:!0},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},selectedElementHasGroup:{type:Boolean},overlayVisible:{type:Boolean},showLoadDefault:{type:Boolean},showHelp:{type:Boolean,default:!0}},{scale:{default:100},scaleModifiers:{}}),emits:e.mergeModels(["preview","save","load-default","undo","redo","align","move-layer","toggle-ruler","toggle-grid","toggle-snap","toggle-table-ghost-border","toggle-overlay","group","ungroup","add-overlay-element","fit-window","zoom","help"],["update:scale"]),setup(t){const a=e.useModel(t,"scale");return(o,n)=>(e.openBlock(),e.createElementBlock("div",Yo,[e.createElementVNode("div",Ko,[n[30]||(n[30]=e.createStaticVNode('<span class="tb-mark" aria-hidden="true" data-v-e6d10b59><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-e6d10b59><rect x="5" y="3" width="14" height="18" rx="2.5" data-v-e6d10b59></rect><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" data-v-e6d10b59></line><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" data-v-e6d10b59></line><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" data-v-e6d10b59></line></svg></span>',1)),e.createElementVNode("div",Xo,[e.createElementVNode("span",jo,e.toDisplayString(t.isEdit?"编辑模板":"新建模板"),1),n[29]||(n[29]=e.createElementVNode("span",{class:"tb-title-sub"},"打印模板设计器",-1))])]),e.createElementVNode("div",Jo,[e.createElementVNode("button",{class:"tb-btn tb-icon",disabled:!t.canUndo,onClick:n[0]||(n[0]=l=>o.$emit("undo")),"data-tip":"撤销"},"↶",8,Zo),e.createElementVNode("button",{class:"tb-btn tb-icon",disabled:!t.canRedo,onClick:n[1]||(n[1]=l=>o.$emit("redo")),"data-tip":"重做"},"↷",8,Qo)]),t.hasMultiSelection?(e.openBlock(),e.createElementBlock("div",_o,[e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[2]||(n[2]=l=>o.$emit("align","left")),title:"左对齐"},"⇤"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[3]||(n[3]=l=>o.$emit("align","right")),title:"右对齐"},"⇥"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[4]||(n[4]=l=>o.$emit("align","top")),title:"顶对齐"},"⇡"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[5]||(n[5]=l=>o.$emit("align","bottom")),title:"底对齐"},"⇣"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[6]||(n[6]=l=>o.$emit("align","vertical")),title:"水平居中"},"↔"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[7]||(n[7]=l=>o.$emit("align","horizontal")),title:"垂直居中"},"↕"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[8]||(n[8]=l=>o.$emit("align","distributeHor")),title:"水平分布"},"⇔"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[9]||(n[9]=l=>o.$emit("align","distributeVer")),title:"垂直分布"},"⇕")])):e.createCommentVNode("",!0),t.hasMultiSelection?(e.openBlock(),e.createElementBlock("div",en,[e.createElementVNode("button",{class:"tb-btn",onClick:n[10]||(n[10]=l=>o.$emit("group")),title:"组合"},"组合")])):e.createCommentVNode("",!0),!t.hasMultiSelection&&t.selectedElementHasGroup?(e.openBlock(),e.createElementBlock("div",tn,[e.createElementVNode("button",{class:"tb-btn",onClick:n[11]||(n[11]=l=>o.$emit("ungroup")),title:"取消组合"},"取消组合")])):e.createCommentVNode("",!0),t.hasSelection?(e.openBlock(),e.createElementBlock("div",on,[e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[12]||(n[12]=l=>o.$emit("move-layer","top")),"data-tip":"置顶"},"⤒"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[13]||(n[13]=l=>o.$emit("move-layer","up")),"data-tip":"上移一层"},"↑"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[14]||(n[14]=l=>o.$emit("move-layer","down")),"data-tip":"下移一层"},"↓"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[15]||(n[15]=l=>o.$emit("move-layer","bottom")),"data-tip":"置底"},"⤓")])):e.createCommentVNode("",!0),e.createElementVNode("div",nn,[e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showRuler}]),"data-tip":"显示/隐藏标尺",onClick:n[16]||(n[16]=l=>o.$emit("toggle-ruler"))},[...n[31]||(n[31]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 标尺 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showGrid}]),"data-tip":"显示/隐藏网格背景",onClick:n[17]||(n[17]=l=>o.$emit("toggle-grid"))},[...n[32]||(n[32]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 网格 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showTableGhostBorder}]),"data-tip":"显示/隐藏无边框表格的虚拟虚线",onClick:n[18]||(n[18]=l=>o.$emit("toggle-table-ghost-border"))},[...n[33]||(n[33]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 虚框 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.snapToGrid}]),"data-tip":"开启/关闭元素吸附到网格",onClick:n[19]||(n[19]=l=>o.$emit("toggle-snap"))},[...n[34]||(n[34]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 吸附 ",-1)])],2),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[20]||(n[20]=l=>o.$emit("fit-window")),"data-tip":"适应窗口"},"⤢"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[21]||(n[21]=l=>o.$emit("zoom",-10)),"data-tip":"缩小"},"−"),e.createElementVNode("span",ln,e.toDisplayString(a.value)+"%",1),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[22]||(n[22]=l=>o.$emit("zoom",10)),"data-tip":"放大"},"+")]),n[35]||(n[35]=e.createElementVNode("div",{class:"tb-spacer"},null,-1)),t.showHelp?(e.openBlock(),e.createElementBlock("div",an,[e.createVNode(Wo,{onClick:n[23]||(n[23]=l=>o.$emit("help"))})])):e.createCommentVNode("",!0),e.createElementVNode("div",rn,[e.createElementVNode("button",{class:"tb-btn",onClick:n[24]||(n[24]=l=>o.$emit("add-overlay-element"))},"首页专属"),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{warn:t.overlayVisible}]),onClick:n[25]||(n[25]=l=>o.$emit("toggle-overlay"))},"叠层对比",2)]),e.createElementVNode("div",sn,[t.showLoadDefault?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn-secondary",onClick:n[26]||(n[26]=l=>o.$emit("load-default"))},"加载默认布局")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"btn-secondary",onClick:n[27]||(n[27]=l=>o.$emit("preview"))},"预览"),e.createElementVNode("button",{class:"btn-primary",onClick:n[28]||(n[28]=l=>o.$emit("save"))},"保存")])]))}}),cn=_(dn,[["__scopeId","data-v-e6d10b59"]]),un={class:"layer-panel"},mn=["onClick"],pn={class:"layer-icon"},fn={class:"layer-name"},vn={key:0,class:"layer-zone"},gn={class:"layer-zindex"},hn={key:0,class:"layer-actions"},bn=e.defineComponent({__name:"LayerPanel",props:{elements:{},selectedIds:{}},emits:["select","move-layer"],setup(t){const a=t,o=e.computed(()=>[...a.elements].sort((s,c)=>(c.options.zIndex??0)-(s.options.zIndex??0))),n={text:"T",longText:"¶",table:"⊞",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function l(s){return n[s.printElementType.type]||"?"}function r(s){return s.options.title||s.printElementType.title||s.printElementType.type}function i(s){return s.zone==="header"?"页眉":s.zone==="footer"?"页脚":""}return(s,c)=>(e.openBlock(),e.createElementBlock("div",un,[c[4]||(c[4]=e.createElementVNode("div",{class:"panel-title"},"图层",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:e.normalizeClass(["layer-item",{active:t.selectedIds.has(d.id)}]),onClick:p=>s.$emit("select",d.id,!1)},[e.createElementVNode("span",pn,e.toDisplayString(l(d)),1),e.createElementVNode("span",fn,e.toDisplayString(r(d)),1),i(d)?(e.openBlock(),e.createElementBlock("span",vn,e.toDisplayString(i(d)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",gn,"z:"+e.toDisplayString(d.options.zIndex??0),1)],10,mn))),128)),o.value.length>0?(e.openBlock(),e.createElementBlock("div",hn,[e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[0]||(c[0]=d=>s.$emit("move-layer","top")),title:"置顶"}," ⤒ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[1]||(c[1]=d=>s.$emit("move-layer","up")),title:"上移"}," ↑ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[2]||(c[2]=d=>s.$emit("move-layer","down")),title:"下移"}," ↓ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[3]||(c[3]=d=>s.$emit("move-layer","bottom")),title:"置底"}," ⤓ ")])):e.createCommentVNode("",!0)]))}}),yn=_(bn,[["__scopeId","data-v-d091c3fa"]]);function Ft(t){const a=[...t].sort((i,s)=>(i.sortOrder??0)-(s.sortOrder??0)),o=new Map,n=[];for(const i of a){const s=i.fieldKey.indexOf(".");if(s===-1)continue;const c=i.fieldKey.slice(0,s);let d=o.get(c);d||(d={key:c,label:c,isList:!1,fields:[]},o.set(c,d),n.push(c)),d.fields.push(i)}const l=[],r=[];for(const i of a){if(i.fieldKey.includes("."))continue;const s=o.get(i.fieldKey);s?(s.label=i.fieldLabel,s.isList=i.fieldType==="list"):r.push(i)}r.length&&l.push({key:"",label:"",isList:!1,fields:r});for(const i of n)l.push(o.get(i));return l}function Ut(t,a){const o=a.trim().toLowerCase();return o?t.map(n=>({...n,fields:n.fields.filter(l=>l.fieldLabel.toLowerCase().includes(o)||l.fieldKey.toLowerCase().includes(o))})).filter(n=>n.fields.length>0):t}const kn={class:"field-tree-panel"},En={class:"tree-container"},wn=["onClick"],Vn={class:"expand-icon"},Nn={class:"node-icon"},Cn={class:"group-label"},Sn=["onDragstart"],Mn={class:"node-label"},$n={class:"node-key"},xn={key:0,class:"pd-empty"},Bn=e.defineComponent({__name:"FieldTreePanel",props:{fields:{}},emits:["field-drag"],setup(t,{emit:a}){const o=t,n=a,l=e.ref(""),r=e.ref(new Set),i=e.computed(()=>!!l.value.trim()),s=e.computed(()=>Ut(Ft(o.fields),l.value));function c(p){const v=new Set(r.value);v.has(p)?v.delete(p):v.add(p),r.value=v}function d(p,v){p.dataTransfer?.setData("fieldData",JSON.stringify({fieldKey:v.fieldKey,fieldLabel:v.fieldLabel})),p.dataTransfer&&(p.dataTransfer.effectAllowed="copy"),n("field-drag",v)}return(p,v)=>(e.openBlock(),e.createElementBlock("div",kn,[v[2]||(v[2]=e.createElementVNode("div",{class:"panel-title"},"业务字段",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[0]||(v[0]=w=>l.value=w),class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段"},null,512),[[e.vModelText,l.value]]),e.createElementVNode("div",En,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,w=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:w.key||"_top"},[w.key?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["field-group-header",{"is-list":w.isList}]),onClick:L=>c(w.key)},[e.createElementVNode("span",Vn,e.toDisplayString(r.value.has(w.key)&&!i.value?"▶":"▼"),1),e.createElementVNode("span",Nn,e.toDisplayString(w.isList?"📋":"📁"),1),e.createElementVNode("span",Cn,e.toDisplayString(w.label),1)],10,wn)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.fields,L=>(e.openBlock(),e.createElementBlock("div",{key:L.fieldKey,class:"field-row",draggable:"true",style:e.normalizeStyle({paddingLeft:(w.key?22:8)+"px"}),onDragstart:H=>d(H,L)},[v[1]||(v[1]=e.createElementVNode("span",{class:"node-icon"},"📄",-1)),e.createElementVNode("span",Mn,e.toDisplayString(L.fieldLabel),1),e.createElementVNode("span",$n,"("+e.toDisplayString(L.fieldKey)+")",1)],44,Sn))),128))],512),[[e.vShow,!w.key||i.value||!r.value.has(w.key)]])],64))),128))]),s.value.length===0?(e.openBlock(),e.createElementBlock("p",xn,"暂无字段")):e.createCommentVNode("",!0)]))}}),Dn=_(Bn,[["__scopeId","data-v-cc814de0"]]),Tn={key:0,class:"left-collapsed"},zn={class:"left-head"},Ln={class:"pd-tabs left-tabs"},Pn={class:"pd-tab-bar",role:"tablist"},An={class:"pd-tab-pane",role:"tabpanel"},In=["onDragstart"],Rn={class:"material-icon"},Hn={class:"material-label"},Fn={class:"pd-tab-pane",role:"tabpanel"},Un={class:"pd-tab-pane",role:"tabpanel"},On=e.defineComponent({__name:"LeftPanel",props:{fields:{},elements:{},selectedIds:{},collapsed:{type:Boolean}},emits:["select","move-layer","toggle-visible","toggle-locked","field-drag","toggle-collapse"],setup(t,{emit:a}){const o=a,n=e.ref("elements"),l=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}];function r(c,d){c.dataTransfer?.setData("elementType",d)}function i(c){o("field-drag",c)}function s(c){n.value=c,o("toggle-collapse")}return(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["left-panel",{collapsed:t.collapsed}])},[t.collapsed?(e.openBlock(),e.createElementBlock("div",Tn,[e.createElementVNode("button",{class:"lc-btn",title:"展开素材台",onClick:d[0]||(d[0]=p=>s(n.value))},"»"),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:n.value==="elements"}]),title:"元素",onClick:d[1]||(d[1]=p=>s("elements"))},"▦",2),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:n.value==="fields"}]),title:"字段",onClick:d[2]||(d[2]=p=>s("fields"))},"⊛",2),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:n.value==="layers"}]),title:"图层",onClick:d[3]||(d[3]=p=>s("layers"))},"≡",2)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",zn,[d[12]||(d[12]=e.createElementVNode("span",{class:"left-title"},"素材台",-1)),e.createElementVNode("button",{class:"collapse-btn",title:"收起素材台",onClick:d[4]||(d[4]=p=>c.$emit("toggle-collapse"))},"«")]),e.createElementVNode("div",Ln,[e.createElementVNode("div",Pn,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:n.value==="elements"}]),onClick:d[5]||(d[5]=p=>n.value="elements")},"元素",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:n.value==="fields"}]),onClick:d[6]||(d[6]=p=>n.value="fields")},"字段",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:n.value==="layers"}]),onClick:d[7]||(d[7]=p=>n.value="layers")},"图层",2)]),e.withDirectives(e.createElementVNode("div",An,[d[13]||(d[13]=e.createElementVNode("div",{class:"panel-title"},"拖拽元素到画布",-1)),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,p=>e.createElementVNode("div",{key:p.type,class:"material-card",draggable:"true",onDragstart:v=>r(v,p.type)},[e.createElementVNode("span",Rn,e.toDisplayString(p.icon),1),e.createElementVNode("span",Hn,e.toDisplayString(p.label),1)],40,In)),64))],512),[[e.vShow,n.value==="elements"]]),e.withDirectives(e.createElementVNode("div",Fn,[e.createVNode(Dn,{fields:t.fields,onFieldDrag:i},null,8,["fields"])],512),[[e.vShow,n.value==="fields"]]),e.withDirectives(e.createElementVNode("div",Un,[e.createVNode(yn,{elements:t.elements,"selected-ids":t.selectedIds,onSelect:d[8]||(d[8]=(p,v)=>c.$emit("select",p,v)),onMoveLayer:d[9]||(d[9]=p=>c.$emit("move-layer",p)),onToggleVisible:d[10]||(d[10]=p=>c.$emit("toggle-visible",p)),onToggleLocked:d[11]||(d[11]=p=>c.$emit("toggle-locked",p))},null,8,["elements","selected-ids"])],512),[[e.vShow,n.value==="layers"]])])],64))],2))}}),Gn=_(On,[["__scopeId","data-v-eb646f19"]]),fe=22,Qe=[1,2,5,10,20,50,100,200,500,1e3];function qn(t,a=64){const o=t*3.7795275590551185;for(const n of Qe)if(n*o>=a)return n;return Qe[Qe.length-1]}function Wn(t){const a=Math.floor(Math.log10(t)+1e-9),o=t/10**a;return o===5||o===1&&t>=10?t/5:o===2?t/2:null}function Yn(t){return Math.round(t*1e3)/1e3}function Kn(t,a,o){if(a<t||o<=0)return[];const l=Wn(o)??o,r=Math.ceil(t/l-1e-9)*l,i=Math.floor((a-r)/l+1e-9),s=[];for(let c=0;c<=i;c++){const d=Yn(r+c*l);Math.abs(d/o-Math.round(d/o))<1e-6?s.push({mm:d,major:!0,label:String(d)}):s.push({mm:d,major:!1})}return s}function Xn(t,a){const o=e.ref(!1),n=e.ref(null);let l=0,r=0,i=0,s=0,c=!1;function d(D){if(a.disabled)return;const $=D.target;if(!($ instanceof HTMLElement)||$.classList.contains("resize-handle"))return;o.value=!0,c=D.altKey,l=D.clientX,r=D.clientY;const R=t.value;R&&(i=parseFloat(R.style.left)||0,s=parseFloat(R.style.top)||0,n.value={left:i,top:s,width:parseFloat(R.style.width)||0,height:parseFloat(R.style.height)||0},a.onStart?.({altKey:c}),document.addEventListener("mousemove",v),document.addEventListener("mouseup",w),D.preventDefault())}function p(D){const $=a.getScale?.()??1;let R=i+(D.clientX-l)/$,W=s+(D.clientY-r)/$;if(a.axis==="x"&&(W=s),a.axis==="y"&&(R=i),a.onAdsorb){const J=t.value;if(J){const A=parseFloat(J.style.width)||0,G=parseFloat(J.style.height)||0,K=a.onAdsorb({left:R,top:W,width:A,height:G});R=K.left,W=K.top}}return{left:R,top:W}}function v(D){const $=p(D);n.value&&(n.value.left=$.left,n.value.top=$.top),a.onDrag($)}function w(D){o.value=!1;const $=p(D);a.onDragEnd?.($,{altKey:c}),a.onStop?.(),n.value=null,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",w)}function L(){const D=t.value;D&&D.removeEventListener("mousedown",d),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",w)}function H(){L();const D=t.value;D&&D.addEventListener("mousedown",d)}return{isDragging:o,dragPreview:n,setup:H,cleanup:L}}const jn=["nw","n","ne","e","se","s","sw","w"];function Jn(t,a,o,n,l,r){let{left:i,top:s,width:c,height:d}=a;switch(t){case"e":c=Math.max(l,a.width+o);break;case"w":c=Math.max(l,a.width-o),i=a.left+a.width-c;break;case"s":d=Math.max(r,a.height+n);break;case"n":d=Math.max(r,a.height-n),s=a.top+a.height-d;break;case"se":c=Math.max(l,a.width+o),d=Math.max(r,a.height+n);break;case"sw":c=Math.max(l,a.width-o),i=a.left+a.width-c,d=Math.max(r,a.height+n);break;case"ne":c=Math.max(l,a.width+o),d=Math.max(r,a.height-n),s=a.top+a.height-d;break;case"nw":c=Math.max(l,a.width-o),i=a.left+a.width-c,d=Math.max(r,a.height-n),s=a.top+a.height-d;break}return{left:i,top:s,width:c,height:d}}function Zn(t){let a=0,o=0,n={left:0,top:0,width:0,height:0},l=null;function r(d,p){l=d,a=p.clientX,o=p.clientY,n={...t.getRect()},t.onStart?.(),document.addEventListener("mousemove",i),document.addEventListener("mouseup",s),p.preventDefault()}function i(d){if(!l)return;const p=t.getScale?.()||1,v=(d.clientX-a)/p,w=(d.clientY-o)/p,L=t.minWidth||20,H=t.minHeight||20;t.onResize(Jn(l,n,v,w,L,H))}function s(){l=null,t.onStop?.(),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)}function c(){document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)}return{startResize:r,cleanup:c}}const Qn=e.defineComponent({__name:"TextElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o={top:"flex-start",middle:"center",bottom:"flex-end"},n={left:"flex-start",center:"center",right:"flex-end"},l=e.computed(()=>{const i=a.element.options;return{fontSize:(i.fontSize||12)+"pt",fontWeight:i.fontWeight||"normal",fontFamily:i.fontFamily||"inherit",color:i.color||"#333",backgroundColor:i.backgroundColor||"transparent",textAlign:i.textAlign||"left",lineHeight:i.lineHeight?i.lineHeight+"pt":"normal",letterSpacing:i.letterSpacing?i.letterSpacing+"pt":"normal",textDecoration:i.textDecoration||"none",padding:`${i.contentPaddingTop||0}pt ${i.contentPaddingRight||0}pt ${i.contentPaddingBottom||0}pt ${i.contentPaddingLeft||0}pt`,width:"100%",height:"100%",boxSizing:"border-box",overflow:"hidden",...i.verticalAlign?{display:"flex",alignItems:o[i.verticalAlign]??"flex-start",justifyContent:n[i.textAlign||"left"]??"flex-start"}:{}}}),r=e.computed(()=>a.designMode?a.element.options.testData?a.element.options.testData:a.element.options.formatter||"文本":We(a.element.options,a.data));return(i,s)=>(e.openBlock(),e.createElementBlock("div",{class:"print-text",style:e.normalizeStyle(l.value)},e.toDisplayString(r.value),5))}}),_n={class:"print-image"},el=["src"],tl={key:1,class:"image-placeholder"},ol=e.defineComponent({__name:"ImageElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o=e.computed(()=>{const i=a.element.options.src||"";return i?i.includes("{")?a.designMode?$e(i,ge):$e(i,a.data?.[0]||{}):i:""}),n=e.ref(!1);function l(){n.value=!0}e.watch(o,()=>{n.value=!1});const r=e.computed(()=>({objectFit:a.element.options.fit||"contain"}));return(i,s)=>(e.openBlock(),e.createElementBlock("div",_n,[o.value&&!n.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.value,style:e.normalizeStyle(r.value),onError:l},null,44,el)):(e.openBlock(),e.createElementBlock("div",tl,"图片"))]))}}),nl=_(ol,[["__scopeId","data-v-530ee54f"]]),ll=e.defineComponent({__name:"LongTextElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o={top:"flex-start",middle:"center",bottom:"flex-end"},n={left:"flex-start",center:"center",right:"flex-end"},l=e.computed(()=>{const i=a.element.options;return{fontSize:(i.fontSize||12)+"pt",fontWeight:i.fontWeight||"normal",fontFamily:i.fontFamily||"inherit",color:i.color||"#333",backgroundColor:i.backgroundColor||"transparent",textAlign:i.textAlign||"left",lineHeight:i.lineHeight?i.lineHeight+"pt":"1.5",letterSpacing:i.letterSpacing?i.letterSpacing+"pt":"normal",textIndent:i.longTextIndent?i.longTextIndent+"pt":"0",width:"100%",height:"100%",overflow:"hidden",wordBreak:"break-all",boxSizing:"border-box",...i.verticalAlign?{display:"flex",alignItems:o[i.verticalAlign]??"flex-start",justifyContent:n[i.textAlign||"left"]??"flex-start"}:{}}}),r=e.computed(()=>a.designMode?a.element.options.formatter?a.element.options.formatter:"长文本内容":We(a.element.options,a.data));return(i,s)=>(e.openBlock(),e.createElementBlock("div",{class:"print-longtext",style:e.normalizeStyle(l.value)},e.toDisplayString(r.value),5))}}),al=["title"],il=["title","onClick"],rl=e.defineComponent({__name:"TableContextMenu",props:{visible:{type:Boolean},x:{},y:{},canDeleteRow:{type:Boolean},canDeleteCol:{type:Boolean},mergeDisabledReason:{},canSplit:{type:Boolean},currentRowType:{},rowTypeDisabledReason:{type:Function}},emits:["action"],setup(t,{emit:a}){const o=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],n=a;function l(r,i){n("action",r,i)}return(r,i)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:"table-ctx-menu",style:e.normalizeStyle({left:t.x+"px",top:t.y+"px"}),onMousedown:i[8]||(i[8]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:"menu-item",onClick:i[0]||(i[0]=s=>l("insert-row-above"))},"在上方插入行"),e.createElementVNode("div",{class:"menu-item",onClick:i[1]||(i[1]=s=>l("insert-row-below"))},"在下方插入行"),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canDeleteRow}]),onClick:i[2]||(i[2]=s=>t.canDeleteRow&&l("delete-row"))}," 删除行 ",2),i[9]||(i[9]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),e.createElementVNode("div",{class:"menu-item",onClick:i[3]||(i[3]=s=>l("insert-col-left"))},"在左侧插入列"),e.createElementVNode("div",{class:"menu-item",onClick:i[4]||(i[4]=s=>l("insert-col-right"))},"在右侧插入列"),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canDeleteCol}]),onClick:i[5]||(i[5]=s=>t.canDeleteCol&&l("delete-col"))}," 删除列 ",2),i[10]||(i[10]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!!t.mergeDisabledReason}]),title:t.mergeDisabledReason||"",onClick:i[6]||(i[6]=s=>!t.mergeDisabledReason&&l("merge"))}," 合并单元格 ",10,al),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canSplit}]),onClick:i[7]||(i[7]=s=>t.canSplit&&l("split"))}," 拆分单元格 ",2),i[11]||(i[11]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),i[12]||(i[12]=e.createElementVNode("div",{class:"menu-group-title"},"行类型",-1)),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,s=>e.createElementVNode("div",{key:s.value,class:e.normalizeClass(["menu-item",{disabled:!!t.rowTypeDisabledReason(s.value),active:t.currentRowType===s.value}]),title:t.rowTypeDisabledReason(s.value)||"",onClick:c=>!t.rowTypeDisabledReason(s.value)&&l("set-row-type",s.value)},e.toDisplayString(s.label),11,il)),64))],36)):e.createCommentVNode("",!0)]))}}),sl=_(rl,[["__scopeId","data-v-3f0b28d4"]]),dl={class:"cell-barcode"},cl=["src"],ul={key:1,class:"cell-barcode-fallback"},ml=e.defineComponent({__name:"CellBarcode",props:{cellType:{},value:{},barcodeType:{},qrCodeLevel:{},showText:{type:Boolean},fit:{},maxWidth:{},maxHeight:{}},setup(t){const a=t,o=e.ref(null),n=e.ref(!1),l=e.ref(""),r=e.computed(()=>({objectFit:a.fit||"contain",maxWidth:a.maxWidth?`${a.maxWidth}mm`:"100%",maxHeight:a.maxHeight?`${a.maxHeight}mm`:"100%"})),i=e.computed(()=>({objectFit:a.fit||"contain",maxWidth:a.maxWidth?`${a.maxWidth}mm`:"100%",maxHeight:a.maxHeight?`${a.maxHeight}mm`:"100%"}));function s(){if(n.value=!1,!!o.value)try{it(o.value,a.value,{format:a.barcodeType||"CODE128",width:1,height:28,displayValue:a.showText!==!1,fontSize:9,margin:0}),n.value=!0}catch{}}async function c(){if(!a.value){l.value="";return}try{l.value=await rt.toDataURL(a.value,{width:96,margin:1,errorCorrectionLevel:a.qrCodeLevel||"M"})}catch{l.value=""}}function d(){a.cellType==="barcode"?s():c()}return e.onMounted(d),e.watch(()=>[a.cellType,a.value,a.barcodeType,a.qrCodeLevel,a.showText],d),(p,v)=>(e.openBlock(),e.createElementBlock("div",dl,[e.withDirectives((e.openBlock(),e.createElementBlock("svg",{ref_key:"barcodeSvg",ref:o,preserveAspectRatio:"xMidYMid meet",style:e.normalizeStyle(r.value)},null,4)),[[e.vShow,t.cellType==="barcode"&&n.value]]),t.cellType==="qrcode"&&l.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:l.value,alt:"qrcode",style:e.normalizeStyle(i.value)},null,12,cl)):e.createCommentVNode("",!0),!n.value&&t.cellType==="barcode"?(e.openBlock(),e.createElementBlock("span",ul,e.toDisplayString(t.value||"条码"),1)):e.createCommentVNode("",!0)]))}}),pl=_(ml,[["__scopeId","data-v-612f4008"]]),fl={class:"cell-image"},vl=["src"],gl={key:1,class:"image-placeholder"},hl=e.defineComponent({__name:"CellImage",props:{value:{},fit:{},maxWidth:{},maxHeight:{},designMode:{type:Boolean},data:{}},setup(t){const a=t,o=e.computed(()=>{const i=a.value||"";return i?i.includes("{")?a.designMode?$e(i,ge):$e(i,a.data?.[0]||{}):i:""}),n=e.ref(!1);function l(){n.value=!0}e.watch(o,()=>{n.value=!1});const r=e.computed(()=>({objectFit:a.fit||"contain",maxWidth:a.maxWidth?`${a.maxWidth}mm`:"100%",maxHeight:a.maxHeight?`${a.maxHeight}mm`:"100%"}));return(i,s)=>(e.openBlock(),e.createElementBlock("div",fl,[o.value&&!n.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.value,style:e.normalizeStyle(r.value),onError:l},null,44,vl)):(e.openBlock(),e.createElementBlock("div",gl,"图片"))]))}}),bl=_(hl,[["__scopeId","data-v-7f838bbb"]]),yl=["rowspan","colspan","onMousedown","onMouseenter","onDblclick","onContextmenu"],kl={key:2,class:"data-placeholder"},El={key:0,class:"col-resize-layer"},wl=["aria-label","onMousedown"],Vl={key:1,class:"row-badges"},Ue=3.7795275591,Nl=.1,Cl=e.defineComponent({__name:"TableElement",props:{element:{},designMode:{type:Boolean},isSelected:{type:Boolean},showTableGhostBorder:{type:Boolean},scale:{},data:{}},emits:["dblclick-element","dblclick-cell"],setup(t,{emit:a}){const o={header:"题",data:"数",subtotal:"小",summary:"汇"},n=t,l=a,r=e.inject(Pe,{tableSelection:e.ref(null),setTableSelection:()=>{},recordHistory:()=>{},maxTableWidth:e.ref(1/0)}),i=e.computed(()=>n.element.options.tableRows??[]),s=e.computed(()=>n.element.options.tableColWidths??[]),c=e.computed(()=>n.element.options.tableDefaultFontSize??10),d=e.computed(()=>n.element.options.tableDefaultColor??"#333333"),p=e.computed(()=>{const h=r.tableSelection.value;return h&&h.elementId===n.element.id?h:null});function v(h){let C=0;for(let N=0;N<h;N++)C+=i.value[N].height;return C}const w=e.ref(null),L=e.ref([]);function H(){if(!n.designMode)return;const h=w.value;if(!h)return;const C=h.offsetHeight;if(C<=0)return;const N=n.element.options,y=C/Ue;Math.abs(y-(N.height??0))>Nl&&(N.height=Math.round(y*100)/100);const b=h.offsetTop;L.value=Array.from(h.rows).map(F=>({top:(F.offsetTop-b)/Ue,height:F.offsetHeight/Ue}))}function D(h){return L.value[h]?.top??v(h)}function $(h){return L.value[h]?.height??i.value[h]?.height??0}e.watch(()=>[n.element.options,n.designMode],()=>H(),{deep:!0,flush:"post"}),e.onMounted(()=>{H(),document.fonts?.ready.then(()=>H())});const R=e.computed(()=>{const h=n.element.options.dataSource;if(h&&Array.isArray(ge[h]))return ge[h];for(const C of Object.values(ge))if(Array.isArray(C))return C}),W=e.computed(()=>{if(n.data)return n.data});function J(h){return h.cellType==="barcode"||h.cellType==="qrcode"}function A(h,C){return J(C)?ko(C.formatter,R.value):C.formatter||""}function G(h,C){const N=n.element.options,y={designMode:n.designMode,showGhostBorder:n.showTableGhostBorder};return{fontFamily:C.fontFamily||"inherit",textAlign:C.align??"left",verticalAlign:C.valign??"middle",fontSize:(C.fontSize??c.value)+"pt",fontWeight:C.fontWeight??"normal",color:C.color??d.value,backgroundColor:C.backgroundColor??"transparent",borderTop:He(C.borders?.top,y),borderRight:He(C.borders?.right,y),borderBottom:He(C.borders?.bottom,y),borderLeft:He(C.borders?.left,y),padding:(C.padding??N.tableDefaultPadding??1)+"mm",whiteSpace:C.wordWrap??!0?"normal":"nowrap",overflow:C.wordWrap??!0?"visible":"hidden"}}function K(h,C){const N=p.value;return{"cell-selected":!!N&&h>=N.r1&&h<=N.r2&&C>=N.c1&&C<=N.c2,"row-data-bg":i.value[h].type==="data"}}const S=e.ref(null);function M(h,C){const N=xt(i.value,h,C);r.setTableSelection({elementId:n.element.id,...N})}function x(h,C,N){!n.designMode||!n.isSelected||(N.stopPropagation(),N.shiftKey&&p.value?M({r:p.value.r1,c:p.value.c1},{r:h,c:C}):(S.value={r:h,c:C},M({r:h,c:C},{r:h,c:C})),window.addEventListener("mouseup",()=>{S.value=null},{once:!0}))}function B(h,C){S.value&&M(S.value,{r:h,c:C})}function T(h,C){n.designMode&&l("dblclick-cell",n.element.id,h,C)}const z=e.reactive({visible:!1,x:0,y:0});function u(h,C,N){if(!n.designMode||!n.isSelected)return;const y=p.value;y&&h>=y.r1&&h<=y.r2&&C>=y.c1&&C<=y.c2||M({r:h,c:C},{r:h,c:C}),z.x=N.clientX,z.y=N.clientY,z.visible=!0,window.addEventListener("mousedown",()=>{z.visible=!1},{once:!0})}const V=e.computed(()=>{const h=p.value;return h?Bt(i.value,h):"未选择单元格"}),O=e.computed(()=>{const h=p.value;if(!h)return!1;for(let C=h.r1;C<=h.r2;C++)for(let N=h.c1;N<=h.c2;N++){const y=i.value[C].cells[N];if(!y.merged&&((y.rowspan??1)>1||(y.colspan??1)>1))return!0}return!1});function X(h){const C=p.value;if(!C)return"未选择单元格";if(C.r1!==C.r2)return"行类型仅支持单行设置";const N=JSON.parse(JSON.stringify(i.value));return ot(N,C.r1,h)}function Z(){qe(n.element.options)}function j(h,C){const N=r.maxTableWidth.value,y=h.reduce((b,F)=>b+F,0)+h[C];return y>N?`插入后表格总宽 ${Math.round(y*10)/10}mm 超过打印范围宽度 ${N}mm,请先缩小列宽`:null}function ce(h,C){const N=p.value;if(!N)return;z.visible=!1;const y=n.element.options,b=y.tableRows,F=y.tableColWidths;let Y=null;switch(h){case"insert-row-above":gt(b,N.r1,"above");break;case"insert-row-below":gt(b,N.r2,"below");break;case"delete-row":Y=co(b,N.r1);break;case"insert-col-left":Y=j(F,N.c1),Y||ht(b,F,N.c1,"left");break;case"insert-col-right":Y=j(F,N.c2),Y||ht(b,F,N.c2,"right");break;case"delete-col":Y=uo(b,F,N.c1);break;case"merge":Dt(b,N);break;case"split":Tt(b,N);break;case"set-row-type":Y=ot(b,N.r1,C);break}if(Y){alert(Y);return}r.setTableSelection(null),Z(),r.recordHistory()}const ie=e.computed(()=>n.designMode&&!!n.isSelected&&!n.element.options.locked&&s.value.length>=1),se=e.computed(()=>Array.from({length:s.value.length},(h,C)=>C+1));function le(h){return s.value.slice(0,h).reduce((C,N)=>C+N,0)}const P=e.ref(null);let g=0,E=0;function f(h,C){ie.value&&(P.value=h,g=C.clientX,E=s.value[h-1],document.addEventListener("mousemove",m),document.addEventListener("mouseup",k))}function m(h){if(P.value===null)return;const C=n.scale||1,N=(h.clientX-g)/(C*Ue),y=P.value-1,b=n.element.options.tableColWidths;b[y]=fo(b,y,E+N,r.maxTableWidth.value),Z()}function k(){document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",k),P.value!==null&&(P.value=null,Z(),r.recordHistory())}return e.onUnmounted(()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",k)}),(h,C)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["print-table",{"design-mode":t.designMode}]),onContextmenu:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("table",{ref_key:"tableRef",ref:w,style:e.normalizeStyle({fontSize:c.value+"pt",color:d.value})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(N,y)=>(e.openBlock(),e.createElementBlock("col",{key:y,style:e.normalizeStyle({width:N+"mm"})},null,4))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(N,y)=>(e.openBlock(),e.createElementBlock("tr",{key:N.id,style:e.normalizeStyle({height:N.height+"mm"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.cells,(b,F)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:b.id},[b.merged?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("td",{key:0,rowspan:b.rowspan||1,colspan:b.colspan||1,class:e.normalizeClass(K(y,F)),style:e.normalizeStyle(G(N,b)),onMousedown:e.withModifiers(Y=>x(y,F,Y),["left"]),onMouseenter:Y=>B(y,F),onDblclick:e.withModifiers(Y=>T(y,F),["stop"]),onContextmenu:e.withModifiers(Y=>u(y,F,Y),["prevent","stop"])},[J(b)?(e.openBlock(),e.createBlock(pl,{key:0,"cell-type":b.cellType,value:A(N,b),"barcode-type":b.barcodeType,"qr-code-level":b.qrCodeLevel,"show-text":b.showBarcodeText,fit:b.fit,"max-width":b.maxWidth,"max-height":b.maxHeight},null,8,["cell-type","value","barcode-type","qr-code-level","show-text","fit","max-width","max-height"])):b.cellType==="image"?(e.openBlock(),e.createBlock(bl,{key:1,value:b.formatter||"",fit:b.fit,"max-width":b.maxWidth,"max-height":b.maxHeight,"design-mode":t.designMode,data:W.value},null,8,["value","fit","max-width","max-height","design-mode","data"])):N.type==="data"?(e.openBlock(),e.createElementBlock("span",kl,e.toDisplayString(A(N,b)),1)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(A(N,b)),1)],64))],46,yl))],64))),128))],4))),128))])],4),ie.value?(e.openBlock(),e.createElementBlock("div",El,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(se.value,N=>(e.openBlock(),e.createElementBlock("div",{key:N,class:e.normalizeClass(["col-resize-handle",{dragging:P.value===N}]),role:"separator","aria-label":"列宽手柄"+N,style:e.normalizeStyle({left:le(N)+"mm"}),onMousedown:e.withModifiers(y=>f(N,y),["stop","prevent"])},null,46,wl))),128))])):e.createCommentVNode("",!0),t.designMode&&t.isSelected?(e.openBlock(),e.createElementBlock("div",Vl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(N,y)=>(e.openBlock(),e.createElementBlock("span",{key:N.id,class:"row-badge",style:e.normalizeStyle({top:D(y)+"mm",height:$(y)+"mm"})},e.toDisplayString(o[N.type]),5))),128))])):e.createCommentVNode("",!0),e.createVNode(sl,{visible:z.visible,x:z.x,y:z.y,"can-delete-row":i.value.length>1,"can-delete-col":s.value.length>1,"merge-disabled-reason":V.value,"can-split":O.value,"current-row-type":p.value?i.value[p.value.r1]?.type??null:null,"row-type-disabled-reason":X,onAction:ce},null,8,["visible","x","y","can-delete-row","can-delete-col","merge-disabled-reason","can-split","current-row-type"])],34))}}),Sl=_(Cl,[["__scopeId","data-v-980bb07d"]]),Et=e.defineComponent({__name:"LineElement",props:{element:{}},setup(t){const a=t,o=e.computed(()=>a.element.printElementType.type==="hline"),n=e.computed(()=>{const l=a.element.options,r=(l.borderWidth||.75)+"pt",i=l.borderStyle||"solid",s=l.borderColor||"#333";return o.value?{width:"100%",height:"0",borderTop:`${r} ${i} ${s}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${r} ${i} ${s}`,boxSizing:"border-box"}});return(l,r)=>(e.openBlock(),e.createElementBlock("div",{class:"print-line",style:e.normalizeStyle(n.value)},null,4))}}),wt=e.defineComponent({__name:"ShapeElement",props:{element:{}},setup(t){const a=t,o=e.computed(()=>a.element.printElementType.type==="oval"),n=e.computed(()=>{const l=a.element.options;return{width:"100%",height:"100%",borderWidth:(l.borderWidth||1)+"pt",borderStyle:l.borderStyle||"solid",borderColor:l.borderColor||"#333",backgroundColor:l.backgroundColor||"transparent",borderRadius:o.value?"50%":"0",boxSizing:"border-box"}});return(l,r)=>(e.openBlock(),e.createElementBlock("div",{class:"print-shape",style:e.normalizeStyle(n.value)},null,4))}}),Ml={class:"print-barcode",ref:"containerRef"},$l=96/25.4,xl=e.defineComponent({__name:"BarcodeElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o=e.ref(null);function n(){if(!o.value)return;const l=a.element.options,r=(a.designMode?l.testData||l.formatter:We(l,a.data))||"条码",i=!l.hideTitle,s=(l.fontSize||12)*(96/72),c=(l.height||40)*$l,d=i?s+4:0,p=Math.max(8,c-d);try{it(o.value,r,{format:l.barcodeType||"CODE128",width:l.barWidth?l.barWidth/2:1,height:p,displayValue:i,fontSize:s,margin:2})}catch{}}return e.onMounted(n),e.watch(()=>[a.element.options.formatter,a.element.options.testData,a.element.options.barcodeType,a.element.options.width,a.element.options.height,a.element.options.barWidth,a.element.options.hideTitle,a.element.options.fontSize],n),(l,r)=>(e.openBlock(),e.createElementBlock("div",Ml,[(e.openBlock(),e.createElementBlock("svg",{ref_key:"svgRef",ref:o,preserveAspectRatio:"xMidYMid meet"},null,512))],512))}}),Bl=_(xl,[["__scopeId","data-v-a71e7c44"]]),Dl={class:"print-qrcode"},Tl=["src"],zl=e.defineComponent({__name:"QrcodeElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o=e.ref("");async function n(){const l=a.element.options,r=(a.designMode?l.testData||l.formatter:We(l,a.data))||"二维码",i=Math.min(l.width||80,l.height||80);try{o.value=await rt.toDataURL(r,{width:i,margin:1,errorCorrectionLevel:String(l.qrCodeLevel??"M")})}catch{o.value=""}}return e.onMounted(n),e.watch(()=>[a.element.options.formatter,a.element.options.testData],n),(l,r)=>(e.openBlock(),e.createElementBlock("div",Dl,[o.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.value,alt:"qrcode"},null,8,Tl)):e.createCommentVNode("",!0)]))}}),Ll=_(zl,[["__scopeId","data-v-90b31b7e"]]),Pl=["innerHTML"],Al=e.defineComponent({__name:"HtmlElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o=e.computed(()=>{if(a.element.options.formatter){const n=a.data&&a.data.length>0?a.data[0]:{},l=$e(a.element.options.formatter,n??{});return l?oo.sanitize(l):""}return'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>'});return(n,l)=>(e.openBlock(),e.createElementBlock("div",{class:"print-html",innerHTML:o.value},null,8,Pl))}}),Il=_(Al,[["__scopeId","data-v-f0a224c2"]]),Rl=e.defineComponent({__name:"PageNumberElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const a=t,o=e.computed(()=>{const l=a.element.options;return{fontSize:(l.fontSize||12)+"pt",fontWeight:l.fontWeight||"normal",fontFamily:l.fontFamily||"inherit",color:l.color||"#333",textAlign:l.textAlign||"left",lineHeight:l.lineHeight?l.lineHeight+"pt":"normal",letterSpacing:l.letterSpacing?l.letterSpacing+"pt":"normal"}}),n=e.computed(()=>a.designMode?a.element.options.title||"{pageIndex}/{totalPages}":a.element.options.title||"");return(l,r)=>(e.openBlock(),e.createElementBlock("div",{class:"page-number-element",style:e.normalizeStyle(o.value)},e.toDisplayString(n.value),5))}}),Hl=_(Rl,[["__scopeId","data-v-c3750ca3"]]),Fl={key:0,class:"drag-preview"},Ul={key:1,class:"resize-handles"},Ol=["onMousedown"],Gl={key:2,class:"selected-indicator"},ql={class:"position-label"},Wl=e.defineComponent({__name:"BaseElement",props:{element:{},isSelected:{type:Boolean},designMode:{type:Boolean},printData:{},scale:{},allElements:{},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},zone:{},adsorbHandler:{type:Function},clearAdsorbGuides:{type:Function}},emits:["select","update:element","drag-start","drag-stop","dblclick-element","dblclick-cell","contextmenu","clone-element"],setup(t,{emit:a}){const o=t,n=a,l=e.ref(null),r=e.inject(It,null),i=e.computed(()=>r?.value?r.value.has(o.element.id):o.isSelected??!1),s=e.inject(Rt,null),c=e.computed(()=>s?.value.has(o.element.id)??!1),d={text:e.markRaw(Qn),image:e.markRaw(nl),longText:e.markRaw(ll),table:e.markRaw(Sl),hline:e.markRaw(Et),vline:e.markRaw(Et),rect:e.markRaw(wt),oval:e.markRaw(wt),barcode:e.markRaw(Bl),qrcode:e.markRaw(Ll),html:e.markRaw(Il),pageNumber:e.markRaw(Hl)},p=e.computed(()=>d[o.element.printElementType.type]),v=e.computed(()=>o.element.printElementType.type==="table"?{showTableGhostBorder:o.showTableGhostBorder,scale:o.scale}:{}),w=e.computed(()=>{const T=o.element.options;return{position:"absolute",left:T.left+"mm",top:T.top+"mm",width:T.width+"mm",height:T.height+"mm",zIndex:T.zIndex||"auto"}}),L=e.computed(()=>{const T=o.element.options;return`x:${Math.round(T.left)} y:${Math.round(T.top)} ${Math.round(T.width)}×${Math.round(T.height)}mm`});let H=0,D=0;const $=e.reactive({disabled:!o.designMode||!!o.element.options.locked,getScale:()=>(o.scale||1)*he(1),onDrag:T=>{const z=T.left-H,u=T.top-D;l.value&&(l.value.style.transform=`translate(${z}mm, ${u}mm)`)},onDragEnd:(T,z)=>{if(z.altKey){const O=JSON.parse(JSON.stringify(o.element));O.id=Me(),O.options.left=T.left,O.options.top=T.top,n("clone-element",O,{left:T.left,top:T.top}),l.value&&(l.value.style.transform="");return}const u=T.left-H,V=T.top-D;if(o.element.options.left=T.left,o.element.options.top=T.top,l.value&&(l.value.style.transform=""),o.element.options.groupId&&o.allElements)for(const O of o.allElements)O.id!==o.element.id&&O.options.groupId===o.element.options.groupId&&(O.options.left+=u,O.options.top+=V)},onStart:()=>{H=o.element.options.left,D=o.element.options.top,n("select",o.element.id,!1),n("drag-start")},onStop:()=>{o.clearAdsorbGuides?.(),n("drag-stop")},onAdsorb:T=>{let z=T.left,u=T.top;return o.snapToGrid&&(z=Math.round(T.left/5)*5,u=Math.round(T.top/5)*5),o.adsorbHandler?o.adsorbHandler({id:o.element.id,left:z,top:u,width:o.element.options.width,height:o.element.options.height}):{left:z,top:u,lines:[]}}}),{setup:R,cleanup:W,isDragging:J}=Xn(l,$);e.watchEffect(()=>{$.disabled=!o.designMode||!!o.element.options.locked});const A=e.computed(()=>i.value&&!!o.designMode&&!o.element.options.locked&&o.element.printElementType.type!=="table"),{startResize:G,cleanup:K}=Zn({minWidth:3.5,minHeight:3.5,getScale:()=>(o.scale||1)*he(1),getRect:()=>({left:o.element.options.left,top:o.element.options.top,width:o.element.options.width,height:o.element.options.height}),onResize:T=>{o.element.options.left=T.left,o.element.options.top=T.top,o.element.options.width=T.width,o.element.options.height=T.height},onStart:()=>{n("drag-start")},onStop:()=>{n("drag-stop")}});function S(T){o.designMode&&n("select",o.element.id,T.ctrlKey||T.metaKey)}function M(){o.designMode&&n("dblclick-element",o.element.id)}function x(T,z,u){o.designMode&&n("dblclick-cell",T,z,u)}e.onMounted(()=>{o.designMode&&R()});function B(){W(),K(),o.clearAdsorbGuides?.()}return e.onUnmounted(()=>{B()}),(T,z)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:l,class:e.normalizeClass(["print-element",{selected:i.value,previewed:c.value,"design-mode":t.designMode,locked:t.element.options.locked,hidden:t.element.options.visible===!1,"drag-ghost":e.unref(J),[`type-${t.element.printElementType.type}`]:!0,[`zone-${t.zone||"content"}`]:!0}]),style:e.normalizeStyle(w.value),onMousedown:e.withModifiers(S,["stop"]),onDblclick:e.withModifiers(M,["stop"]),onContextmenu:z[0]||(z[0]=e.withModifiers(u=>T.$emit("contextmenu",t.element.id,u),["prevent","stop"]))},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p.value),e.mergeProps({element:t.element,data:t.printData,"design-mode":t.designMode,"is-selected":i.value},v.value,{onDblclickCell:x}),null,16,["element","data","design-mode","is-selected"])),e.unref(J)?(e.openBlock(),e.createElementBlock("div",Fl)):e.createCommentVNode("",!0),A.value?(e.openBlock(),e.createElementBlock("div",Ul,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(jn),u=>(e.openBlock(),e.createElementBlock("div",{key:u,class:e.normalizeClass(["resize-handle",`handle-${u}`]),onMousedown:e.withModifiers(V=>e.unref(G)(u,V),["stop"])},null,42,Ol))),128))])):e.createCommentVNode("",!0),i.value&&t.designMode?(e.openBlock(),e.createElementBlock("div",Gl,[e.createElementVNode("div",ql,e.toDisplayString(L.value),1)])):e.createCommentVNode("",!0)],38))}}),_e=_(Wl,[["__scopeId","data-v-64c495e7"]]);function Yl(t={}){const a=t.adsorbMin??1,o=t.adsorbLineMin??2,n=t.showAdsorbLine??!0,l=e.ref([]),r=e.ref({width:0,height:0}),i={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function s(v){return v==="vCenter"?i.center:v==="hCenter"?i.middle:i[v]??i.left}function c(v,w,L){let H=v.left,D=v.top;const $=[],R={left:v.left,right:v.left+v.width,vCenter:v.left+v.width/2,top:v.top,bottom:v.top+v.height,hCenter:v.top+v.height/2};let W=1/0;for(const A of w){if(A.id===v.id)continue;const G={left:A.left,right:A.left+A.width,vCenter:A.left+A.width/2,top:A.top,bottom:A.top+A.height,hCenter:A.top+A.height/2},K=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],S=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[M,x]of K){const B=Math.abs(R[M]-G[x]);B<=a&&B<W&&(W=B,H=v.left+(G[x]-R[M]))}for(const[M,x]of S){const B=Math.abs(R[M]-G[x]);B<=a&&B<W&&(W=B,D=v.top+(G[x]-R[M]))}}if(L){const A={left:H,right:H+v.width,vCenter:H+v.width/2,top:D,bottom:D+v.height,hCenter:D+v.height/2},G=["left","vCenter","right"];for(const S of L.vertical)for(const M of G){const x=Math.abs(A[M]-S);x<=a&&x<W&&(W=x,H=v.left+(S-A[M]))}const K=["top","hCenter","bottom"];for(const S of L.horizontal)for(const M of K){const x=Math.abs(A[M]-S);x<=a&&x<W&&(W=x,D=v.top+(S-A[M]))}}const J={left:H,right:H+v.width,vCenter:H+v.width/2,top:D,bottom:D+v.height,hCenter:D+v.height/2};if(n){const A=new Set;for(const G of w){if(G.id===v.id)continue;const K={left:G.left,right:G.left+G.width,vCenter:G.left+G.width/2,top:G.top,bottom:G.top+G.height,hCenter:G.top+G.height/2},S=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],M=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[x,B]of S)if(Math.abs(J[x]-K[B])<=o){const z=`v:${K[B]}`;A.has(z)||(A.add(z),$.push({type:"vertical",position:K[B],id:G.id,color:s(x)}))}for(const[x,B]of M)if(Math.abs(J[x]-K[B])<=o){const z=`h:${K[B]}`;A.has(z)||(A.add(z),$.push({type:"horizontal",position:K[B],id:G.id,color:s(x)}))}}}if(L){for(const A of L.vertical)$.some(G=>G.type==="vertical"&&G.position===A)||$.push({type:"vertical",position:A});for(const A of L.horizontal)$.some(G=>G.type==="horizontal"&&G.position===A)||$.push({type:"horizontal",position:A})}return{left:H,top:D,lines:$}}function d(v,w,L){l.value=v,r.value={width:w,height:L}}function p(){l.value=[]}return{check:c,renderLines:d,clearLines:p,guideLines:l,paperSize:r}}function Kl(t){const{check:a,renderLines:o,clearLines:n,guideLines:l,paperSize:r}=Yl(t.config??{adsorbMin:1,adsorbLineMin:2,showAdsorbLine:!0});function i(c){const d=t.getElements().filter(w=>w.id!==c.id).map(w=>({id:w.id,left:w.options.left,top:w.options.top,width:w.options.width,height:w.options.height})),p=a(c,d,t.getGuides?.()),v=t.getPaperSize();return o(p.lines,v.width,v.height),p}function s(){n()}return{requestAdsorb:i,clearGuides:s,guideLines:l,paperSize:r}}const Xl={key:0,class:"zone-label"},jl={key:0,class:"zone-height-tip"},Jl={key:0,class:"zone-label"},Zl={key:0,class:"zone-height-tip"},Ql=["onMousedown","onDblclick"],_l=e.defineComponent({__name:"CanvasPaper",props:{templateData:{},runtimeElements:{},designMode:{type:Boolean},printData:{},scale:{},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},guides:{}},emits:["select","drag-start","drag-stop","dblclick-element","dblclick-cell","contextmenu","zone-height-change","zone-height-commit","guide-move","guide-remove","clone-element"],setup(t,{expose:a,emit:o}){const n=t,l=o,r=e.ref(null),i=e.computed(()=>Ee(n.templateData).width),s=e.computed(()=>Ee(n.templateData).height),c=e.computed(()=>`${8/(n.scale||1)}px`),d=e.computed(()=>{const g=n.scale||1,E=he(i.value)*g,f=he(s.value)*g;return{width:E+"px",height:f+"px",position:"relative"}}),p=e.computed(()=>{const g=n.templateData.margins,E=n.templateData.header.height,f=n.templateData.footer.height,m=i.value-g.left-g.right;return{header:{left:g.left,top:g.top,width:m,height:E},content:{left:g.left,top:g.top+E,width:m,height:s.value-g.top-g.bottom-E-f},footer:{left:g.left,top:s.value-g.bottom-f,width:m,height:f}}});function v(g){return{position:"absolute",left:g.left+"mm",top:g.top+"mm",width:g.width+"mm",height:g.height+"mm"}}const w=e.computed(()=>{const g={header:[],footer:[],content:[]};for(const E of n.runtimeElements)E.zone==="header"?g.header.push(E):E.zone==="footer"?g.footer.push(E):g.content.push(E);return g}),L=e.computed(()=>w.value.header),H=e.computed(()=>w.value.footer),D=e.computed(()=>w.value.content);let $="content";const{requestAdsorb:R,clearGuides:W,guideLines:J,paperSize:A}=Kl({getElements:()=>w.value[$],getPaperSize:()=>{const g=p.value[$];return{width:g.width,height:g.height}},getGuides:()=>{const g=[],E=[];for(const f of n.guides??[])f.type==="vertical"?g.push(f.position):E.push(f.position);return{vertical:g,horizontal:E}}});function G(g){$=n.runtimeElements.find(m=>m.id===g.id)?.zone||"content";const f=R(g);return(f.left!==g.left||f.top!==g.top)&&u(f.left+g.width/2,f.top+g.height/2),f}function K(g,E){const f=E.position,m=g.clientX,k=g.clientY,h=n.scale??1,C=25.4/96,N=b=>{const F=(E.type==="vertical"?b.clientX-m:b.clientY-k)/h*C,Y=E.type==="vertical"?i.value:s.value,ae=Math.min(Math.max(f+F,0),Y);l("guide-move",E.id,ae)},y=()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",y)};window.addEventListener("mousemove",N),window.addEventListener("mouseup",y)}const S=e.computed(()=>({width:i.value+"mm",minHeight:s.value+"mm",background:n.templateData.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:n.scale?`scale(${n.scale})`:void 0,transformOrigin:"0 0"})),M=e.computed(()=>{const g=n.templateData.margins;return{padding:`${g.top}mm ${g.right}mm ${g.bottom}mm ${g.left}mm`,position:"relative",boxSizing:"border-box",minHeight:s.value+"mm"}}),x=e.computed(()=>({backgroundImage:`url("data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>')}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}));let B=0,T=null;const z=e.ref(null);function u(g,E){B+=1,z.value={left:g,top:E,key:B},T&&clearTimeout(T),T=setTimeout(()=>{z.value=null},300)}const V=e.computed(()=>{const g=n.templateData.watermark;return g?!g.mode||g.mode==="fixed"?!!g.content&&g.content.trim().length>0:!!g.binding:!1}),O=e.computed(()=>{const g=n.templateData.watermark||{},E=g.color||"#cccccc",f=g.opacity??.15,m=g.rotate??-30;let k=X(g);if(g.timestamp){const h=new Date,C=`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")} ${String(h.getHours()).padStart(2,"0")}:${String(h.getMinutes()).padStart(2,"0")}`;k=k?`${k} ${C}`:C}return{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"0",overflow:"hidden",opacity:String(f),backgroundImage:Z(k,E,m),backgroundRepeat:"repeat"}});function X(g){if(!g.mode||g.mode==="fixed")return g.content||"";if(g.binding){const E=n.printData?.[0];return E&&E[g.binding]!==void 0&&E[g.binding]!==null?String(E[g.binding]):g.testData||`[${g.binding}]`}return""}function Z(g,E,f){const m=g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),k=`<svg xmlns="http://www.w3.org/2000/svg" width="260" height="180">
|
|
2
|
+
<text x="130" y="90" font-size="16" fill="${E}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${f},130,90)">${m}</text>
|
|
3
|
+
</svg>`;return`url("data:image/svg+xml,${encodeURIComponent(k)}")`}const j=e.ref(null);function ce(g,E){le(),j.value={zone:g,startY:E.clientY,startH:n.templateData[g].height},window.addEventListener("mousemove",ie),window.addEventListener("mouseup",se)}function ie(g){if(!j.value)return;const{zone:E,startY:f,startH:m}=j.value,h=(g.clientY-f)/(n.scale||1)*25.4/96,C=E==="header"?h:-h,N=Math.min(100,s.value-n.templateData.margins.top-n.templateData.margins.bottom-(E==="header"?n.templateData.footer.height:n.templateData.header.height)-10),y=Math.min(N,Math.max(0,Math.round((m+C)*10)/10));l("zone-height-change",E,y)}function se(){if(!j.value)return;const g=j.value.zone;j.value=null,window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",se),l("zone-height-commit",g)}function le(){window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",se),j.value=null}e.onUnmounted(()=>{le(),T&&clearTimeout(T)});function P(g,E){l("select",g,E)}return a({contentRef:r}),(g,E)=>(e.openBlock(),e.createElementBlock("div",{class:"paper-wrapper",style:e.normalizeStyle(d.value)},[e.createElementVNode("div",{class:"hiprint-printPaper",style:e.normalizeStyle(S.value)},[e.createElementVNode("div",{class:"hiprint-printPaper-content",ref_key:"contentRef",ref:r,style:e.normalizeStyle(M.value)},[t.showGrid&&t.designMode?(e.openBlock(),e.createElementBlock("div",{key:0,class:"grid-bg",style:e.normalizeStyle(x.value)},null,4)):e.createCommentVNode("",!0),z.value?(e.openBlock(),e.createElementBlock("div",{key:z.value.key,class:"snap-indicator",style:e.normalizeStyle({left:z.value.left+"mm",top:z.value.top+"mm"})},null,4)):e.createCommentVNode("",!0),V.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"watermark-layer",style:e.normalizeStyle(O.value)},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-header",{"design-mode":t.designMode}]),style:e.normalizeStyle(v(p.value.header))},[t.designMode?(e.openBlock(),e.createElementBlock("span",Xl,"页眉")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,f=>(e.openBlock(),e.createBlock(_e,{key:f.id,element:f,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":L.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"header","adsorb-handler":G,"clear-adsorb-guides":e.unref(W),onSelect:P,onDragStart:E[0]||(E[0]=m=>g.$emit("drag-start")),onDragStop:E[1]||(E[1]=m=>g.$emit("drag-stop")),onDblclickElement:E[2]||(E[2]=m=>g.$emit("dblclick-element",m)),onDblclickCell:E[3]||(E[3]=(m,k,h)=>g.$emit("dblclick-cell",m,k,h)),onContextmenu:E[4]||(E[4]=(m,k)=>g.$emit("contextmenu",m,k)),onCloneElement:(m,k)=>g.$emit("clone-element",m,k)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128)),t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"zone-resize-handle handle-bottom",onMousedown:E[5]||(E[5]=e.withModifiers(f=>ce("header",f),["prevent","stop"]))},[j.value?.zone==="header"?(e.openBlock(),e.createElementBlock("div",jl,e.toDisplayString(t.templateData.header.height.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0)],32)):e.createCommentVNode("",!0)],6),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-content",{"design-mode":t.designMode}]),style:e.normalizeStyle(v(p.value.content))},[t.designMode&&t.templateData.firstPageOverlay.height>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zone-overlay",style:e.normalizeStyle({height:t.templateData.firstPageOverlay.height+"mm"})},[...E[17]||(E[17]=[e.createElementVNode("span",{class:"zone-label"},"首页叠加",-1)])],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,f=>(e.openBlock(),e.createBlock(_e,{key:f.id,element:f,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":D.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"content","adsorb-handler":G,"clear-adsorb-guides":e.unref(W),onSelect:P,onDragStart:E[6]||(E[6]=m=>g.$emit("drag-start")),onDragStop:E[7]||(E[7]=m=>g.$emit("drag-stop")),onDblclickElement:E[8]||(E[8]=m=>g.$emit("dblclick-element",m)),onDblclickCell:E[9]||(E[9]=(m,k,h)=>g.$emit("dblclick-cell",m,k,h)),onContextmenu:E[10]||(E[10]=(m,k)=>g.$emit("contextmenu",m,k)),onCloneElement:(m,k)=>g.$emit("clone-element",m,k)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128))],6),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-footer",{"design-mode":t.designMode}]),style:e.normalizeStyle(v(p.value.footer))},[t.designMode?(e.openBlock(),e.createElementBlock("span",Jl,"页脚")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.value,f=>(e.openBlock(),e.createBlock(_e,{key:f.id,element:f,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":H.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"footer","adsorb-handler":G,"clear-adsorb-guides":e.unref(W),onSelect:P,onDragStart:E[11]||(E[11]=m=>g.$emit("drag-start")),onDragStop:E[12]||(E[12]=m=>g.$emit("drag-stop")),onDblclickElement:E[13]||(E[13]=m=>g.$emit("dblclick-element",m)),onDblclickCell:E[14]||(E[14]=(m,k,h)=>g.$emit("dblclick-cell",m,k,h)),onContextmenu:E[15]||(E[15]=(m,k)=>g.$emit("contextmenu",m,k)),onCloneElement:(m,k)=>g.$emit("clone-element",m,k)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128)),t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"zone-resize-handle handle-top",onMousedown:E[16]||(E[16]=e.withModifiers(f=>ce("footer",f),["prevent","stop"]))},[j.value?.zone==="footer"?(e.openBlock(),e.createElementBlock("div",Zl,e.toDisplayString(t.templateData.footer.height.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0)],32)):e.createCommentVNode("",!0)],6),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(J),(f,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:e.normalizeClass(["adsorb-guide",[`guide-${f.type}`]]),style:e.normalizeStyle(f.type==="vertical"?{left:f.position+"mm",top:"0",height:e.unref(A).height+"mm",borderLeftColor:f.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:f.position+"mm",left:"0",width:e.unref(A).width+"mm",borderTopColor:f.color||"var(--pd-accent-secondary, #f56c6c)"})},null,6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.guides,f=>(e.openBlock(),e.createElementBlock("div",{key:"mg-"+f.id,class:e.normalizeClass(["manual-guide",[`guide-${f.type}`]]),style:e.normalizeStyle(f.type==="vertical"?{left:f.position+"mm",top:"0",height:s.value+"mm","--guide-hit":c.value}:{top:f.position+"mm",left:"0",width:i.value+"mm","--guide-hit":c.value}),onMousedown:e.withModifiers(m=>K(m,f),["prevent","stop"]),onDblclick:e.withModifiers(m=>f.id&&l("guide-remove",f.id),["prevent","stop"])},null,46,Ql))),128))],4)],4)],4))}}),ea=_(_l,[["__scopeId","data-v-a511ac20"]]),ta=e.defineComponent({__name:"Ruler",props:{orientation:{},viewportPx:{},originPx:{},paperLengthMM:{},scale:{},cursorPx:{}},emits:["add-guide","guide-dragging"],setup(t,{emit:a}){const o=t,n=a,l=e.computed(()=>o.orientation==="horizontal"),r=e.computed(()=>l.value?"vertical":"horizontal"),i=e.ref(null),s=e.ref(null),c=e.computed(()=>s.value??o.cursorPx??null),d=e.computed(()=>l.value?{width:o.viewportPx+"px",height:fe+"px"}:{width:fe+"px",height:o.viewportPx+"px"});let p=0;function v(){p||(p=requestAnimationFrame(()=>{p=0,w()}))}function w(){const S=i.value;if(!S)return;const M=S.getContext("2d");if(!M)return;const x=window.devicePixelRatio||1,B=Math.max(0,Math.round(o.viewportPx)),T=fe;S.width=(l.value?B:T)*x,S.height=(l.value?T:B)*x,M.setTransform(x,0,0,x,0,0);const z=getComputedStyle(S),u=z.getPropertyValue("--pd-ruler-bg").trim()||"#F8F9FC",V=z.getPropertyValue("--pd-ruler").trim()||"#9AA1AF",O=z.getPropertyValue("--pd-accent").trim()||"#165DFF";M.fillStyle=u,M.fillRect(0,0,l.value?B:T,l.value?T:B);const X=o.scale>0?o.scale:1,Z=he(1)*X;if(Z<=0)return;const j=-o.originPx/Z,ce=(B-o.originPx)/Z,ie=qn(X),se=Kn(j,ce,ie);L(M,se,Z,V,!0),L(M,se,Z,V,!1),H(M,0,O),H(M,o.paperLengthMM,O);const le=c.value;if(le!==null&&le>=0&&le<=B){if(M.strokeStyle=O,M.lineWidth=1.5,M.beginPath(),l.value){const P=Math.round(le)+.5;M.moveTo(P,0),M.lineTo(P,T)}else{const P=Math.round(le)+.5;M.moveTo(0,P),M.lineTo(T,P)}M.stroke()}}function L(S,M,x,B,T){S.strokeStyle=B,S.fillStyle=B,S.globalAlpha=T?.32:1,S.lineWidth=1,S.font="9px ui-monospace, Menlo, monospace",S.textBaseline="top";for(const z of M){if((z.mm<0||z.mm>o.paperLengthMM)!==T)continue;const V=Math.round(o.originPx+z.mm*x)+.5,O=z.major?8:4;S.beginPath(),l.value?(S.moveTo(V,0),S.lineTo(V,O)):(S.moveTo(0,V),S.lineTo(O,V)),S.stroke(),z.major&&z.label&&(l.value?S.fillText(z.label,V+2,11):(S.save(),S.translate(11,V+2),S.rotate(-Math.PI/2),S.fillText(z.label,0,0),S.restore()))}S.globalAlpha=1}function H(S,M,x){const B=he(1)*(o.scale>0?o.scale:1),T=Math.round(o.originPx+M*B)+.5;T<=0||T>=o.viewportPx||(S.strokeStyle=x,S.globalAlpha=.55,S.lineWidth=1,S.beginPath(),l.value?(S.moveTo(T,0),S.lineTo(T,fe)):(S.moveTo(0,T),S.lineTo(fe,T)),S.stroke(),S.globalAlpha=1)}e.watch(()=>[o.viewportPx,o.originPx,o.paperLengthMM,o.scale,o.cursorPx,o.orientation],v),e.onMounted(v),e.onBeforeUnmount(()=>{p&&cancelAnimationFrame(p)});let D=!1;function $(S){const M=i.value;if(!M)return null;const x=M.getBoundingClientRect(),B=l.value?S.clientX-x.left:S.clientY-x.top;if(B<0||B>o.viewportPx)return null;const T=he(1)*(o.scale>0?o.scale:1);return(B-o.originPx)/T}function R(S){D=!0,S.preventDefault(),window.addEventListener("mousemove",G),window.addEventListener("mouseup",K),A(S)}function W(S){const M=i.value;if(!M)return;const x=M.getBoundingClientRect();s.value=l.value?S.clientX-x.left:S.clientY-x.top,v()}function J(){s.value=null,v()}function A(S){const M=$(S);n("guide-dragging",M)}function G(S){D&&A(S)}function K(S){if(!D)return;D=!1,window.removeEventListener("mousemove",G),window.removeEventListener("mouseup",K);const M=$(S);M!==null&&M>=0&&M<=o.paperLengthMM&&n("add-guide",r.value,M),n("guide-dragging",null)}return e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",G),window.removeEventListener("mouseup",K)}),(S,M)=>(e.openBlock(),e.createElementBlock("canvas",{ref_key:"canvasRef",ref:i,class:e.normalizeClass(["pd-ruler",`is-${t.orientation}`]),style:e.normalizeStyle(d.value),onMousedown:R,onMousemove:W,onMouseleave:J},null,38))}}),Vt=_(ta,[["__scopeId","data-v-eec37db4"]]),oa={class:"canvas-scroll"},na={key:0,class:"overlay-layer"},la=["src"],Oe=96/25.4,aa=e.defineComponent({__name:"CanvasArea",props:{templateData:{},elements:{},scale:{},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},hasClipboard:{type:Boolean},guides:{},overlayVisible:{type:Boolean},screenshotUrl:{},overlayOpacity:{},selectedElementHasGroup:{type:Boolean},showRuler:{type:Boolean,default:!0}},emits:["select","drop-element","drop-field","drag-start","drag-stop","dblclick-element","dblclick-cell","zone-height-change","zone-height-commit","select-all","clear-selection","preview","commit-preview","paste","copy","cut","delete","move-layer","group","ungroup","coordinate","add-guide","guide-move","guide-remove","zoom","clone-element"],setup(t,{expose:a,emit:o}){const n=t,l=o;function r(f,m){l("select",f,m)}const i=e.ref(null),s=e.computed(()=>Ee(n.templateData).width),c=e.computed(()=>Ee(n.templateData).height),d=e.reactive({originX:0,originY:0,viewW:0,viewH:0,paperScale:1}),p=e.reactive({x:null,y:null}),v=e.reactive({x:0,y:0}),w=e.computed(()=>({transform:`translate(${v.x}px, ${v.y}px)`}));function L(){const f=i.value,m=f?.querySelector(".hiprint-printPaper");if(!f||!m)return;const k=f.getBoundingClientRect(),h=m.getBoundingClientRect(),C=n.scale||1,N=h.width/he(s.value);d.paperScale=Math.abs(N-C)<.002?C:N,d.originX=h.left-k.left-fe,d.originY=h.top-k.top-fe,d.viewW=f.clientWidth-fe,d.viewH=f.clientHeight-fe}function H(){v.x=i.value?.scrollLeft??0,v.y=i.value?.scrollTop??0,L()}let D=null,$=0;function R(){cancelAnimationFrame($);const f=performance.now()+220,m=()=>{L(),performance.now()<f&&($=requestAnimationFrame(m))};$=requestAnimationFrame(m)}const W=e.ref(null);function J(f,m){W.value=m===null?null:{type:f,mm:m}}const A=e.computed(()=>{const f=W.value,m=i.value?.querySelector(".hiprint-printPaper");if(!f||!m)return{};const k=m.getBoundingClientRect(),h=k.width/he(s.value),C=he(f.mm)*(h>0?h:n.scale||1);return f.type==="vertical"?{left:k.left+C+"px",top:k.top+"px",height:k.height+"px"}:{left:k.left+"px",top:k.top+C+"px",width:k.width+"px"}});function G(f){const m=i.value?.querySelector(".hiprint-printPaper");if(!m)return;const k=m.getBoundingClientRect(),h=n.scale||1,C=Fe((f.clientX-k.left)/h),N=Fe((f.clientY-k.top)/h);if(!(C<0||N<0))return{x:C,y:N}}function K(f){const m=G(f),k=f.dataTransfer?.getData("fieldData");if(k)try{const C=JSON.parse(k);l("drop-field",C,m);return}catch{}const h=f.dataTransfer?.getData("elementType");h&&l("drop-element",h,m)}const S=e.reactive({visible:!1,x:0,y:0,w:0,h:0});let M={x:0,y:0};function x(f){return!f||!(f instanceof HTMLElement)?!1:!!(f===i.value||f.classList.contains("canvas-scroll")||f.classList.contains("hiprint-printPaper")||f.classList.contains("hiprint-printPaper-content")||f.classList.contains("zone-layer")||f.classList.contains("grid-bg")||f.classList.contains("watermark-layer"))}function B(f){const m=i.value,k=m?.querySelector(".hiprint-printPaper");if(!m||!k)return;const h=m.getBoundingClientRect();p.x=f.clientX-h.left-fe,p.y=f.clientY-h.top-fe;const C=k.getBoundingClientRect(),N=n.scale||1,y=Fe((f.clientX-C.left)/N),b=Fe((f.clientY-C.top)/N);if(y<0||b<0){l("coordinate",null);return}l("coordinate",{x:y,y:b})}function T(){l("coordinate",null),p.x=null,p.y=null}function z(f){if(!(f.ctrlKey||f.metaKey))return;f.preventDefault();const m=n.scale||1,k=Math.round(m*100),h=$o(k,f.deltaY>0?-1:1);if(h===k)return;const C=h/100,N=i.value;let y=null;if(N){const b=N.getBoundingClientRect(),F=getComputedStyle(N),Y=parseFloat(F.paddingLeft)||0,ae=parseFloat(F.paddingTop)||0;y={x:N.scrollLeft+(f.clientX-b.left)-Y,y:N.scrollTop+(f.clientY-b.top)-ae,ratio:C/m,mouseX:f.clientX-b.left,mouseY:f.clientY-b.top}}if(l("zoom",h-k),N&&y){const b=y;e.nextTick(()=>{const F=getComputedStyle(N),Y=parseFloat(F.paddingLeft)||0,ae=parseFloat(F.paddingTop)||0;N.scrollLeft=b.x*b.ratio-b.mouseX+Y,N.scrollTop=b.y*b.ratio-b.mouseY+ae})}}function u(f){const m=i.value;if(!m)return;const k=Math.max(mt,Math.round(f)),h=Math.round((n.scale||1)*100);if(k===h)return;const C=n.scale||1,y=k/100/C,b=getComputedStyle(m),F=parseFloat(b.paddingLeft)||0,Y=parseFloat(b.paddingTop)||0,ae=m.clientWidth/2,re=m.clientHeight/2,ve=m.scrollLeft+ae-F,xe=m.scrollTop+re-Y;l("zoom",k-h),e.nextTick(()=>{const be=getComputedStyle(m),ye=parseFloat(be.paddingLeft)||0,Ne=parseFloat(be.paddingTop)||0;m.scrollLeft=ve*y-ae+ye,m.scrollTop=xe*y-re+Ne})}function V(f){f.button!==2&&x(f.target)&&(l("clear-selection"),M={x:f.clientX,y:f.clientY},S.visible=!0,S.x=f.clientX,S.y=f.clientY,S.w=0,S.h=0,window.addEventListener("mousemove",X),window.addEventListener("mouseup",Z))}function O(){if(S.w<3||S.h<3)return[];const f=i.value?.querySelector(".hiprint-printPaper");if(!f)return[];const m=f.getBoundingClientRect(),k=n.scale||1,h=S.x<M.x,C=[];for(const N of n.elements){if(N.options.visible===!1||N.options.locked)continue;const y=m.left+N.options.left*Oe*k,b=m.top+N.options.top*Oe*k,F=y+N.options.width*Oe*k,Y=b+N.options.height*Oe*k,ae=y<S.x+S.w&&F>S.x&&b<S.y+S.h&&Y>S.y,re=y>=S.x&&F<=S.x+S.w&&b>=S.y&&Y<=S.y+S.h;(h?re:ae)&&C.push(N.id)}return C}function X(f){const m=f.clientX-M.x,k=f.clientY-M.y;S.x=m>=0?M.x:f.clientX,S.y=k>=0?M.y:f.clientY,S.w=Math.abs(m),S.h=Math.abs(k),l("preview",O())}function Z(){window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",Z);const f=O();l("preview",f),f.length>0?l("commit-preview"):l("clear-selection"),l("preview",[]),S.visible=!1}const j=e.reactive({visible:!1,x:0,y:0,targetId:null});function ce(f,m){if(!m&&!x(f.target))return;const k=i.value?.getBoundingClientRect();k&&(j.x=f.clientX-k.left,j.y=f.clientY-k.top,j.targetId=m??null,j.visible=!0,window.removeEventListener("mousedown",ie),setTimeout(()=>{window.addEventListener("mousedown",ie,{once:!0})},0))}function ie(){j.visible=!1,window.removeEventListener("mousedown",ie)}function se(){j.visible=!1,n.hasClipboard&&l("paste")}function le(){j.visible=!1,l("select-all")}function P(){j.visible=!1,l("clear-selection")}function g(f,m){j.visible=!1,f==="copy"?l("copy"):f==="cut"?l("cut"):f==="paste"?l("paste"):f==="delete"?l("delete"):f==="move-layer"?l("move-layer",m):f==="group"?l("group"):f==="ungroup"&&n.selectedElementHasGroup&&l("ungroup")}e.onMounted(()=>{e.nextTick(L),i.value&&typeof ResizeObserver<"u"&&(D=new ResizeObserver(L),D.observe(i.value))}),e.watch(()=>n.scale,R),e.watch([s,c],()=>e.nextTick(L));function E(){const f=i.value;if(!f)return;let m=0,k=0,h=0;const C=performance.now()+800,N=()=>{const{scrollWidth:y,scrollHeight:b}=f;if(y===k&&b===h?m++:m=0,k=y,h=b,m>=2||performance.now()>C){const F=f.scrollWidth,Y=f.scrollHeight,ae=f.clientWidth,re=f.clientHeight;f.scrollLeft=Math.max(0,(F-ae)/2),f.scrollTop=Math.max(0,(Y-re)/2);return}requestAnimationFrame(N)};requestAnimationFrame(N)}return a({centerScroll:E,fitToWindow:u}),e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",Z),D?.disconnect(),cancelAnimationFrame($)}),(f,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootRef",ref:i,class:"canvas-area",onDragover:m[24]||(m[24]=e.withModifiers(()=>{},["prevent"])),onDrop:K,onMousedown:V,onMousemove:B,onMouseleave:T,onWheel:z,onScroll:H,onContextmenu:e.withModifiers(ce,["prevent"])},[e.createElementVNode("div",oa,[e.createVNode(ea,{"template-data":t.templateData,"runtime-elements":t.elements,"design-mode":!0,"print-data":[],scale:t.scale,"show-grid":t.showGrid,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,guides:t.guides,onSelect:r,onGuideMove:m[0]||(m[0]=(k,h)=>f.$emit("guide-move",k,h)),onGuideRemove:m[1]||(m[1]=k=>f.$emit("guide-remove",k)),onDragStart:m[2]||(m[2]=k=>f.$emit("drag-start")),onDragStop:m[3]||(m[3]=k=>f.$emit("drag-stop")),onDblclickElement:m[4]||(m[4]=k=>f.$emit("dblclick-element",k)),onDblclickCell:m[5]||(m[5]=(k,h,C)=>f.$emit("dblclick-cell",k,h,C)),onContextmenu:m[6]||(m[6]=(k,h)=>ce(h,k)),onZoneHeightChange:m[7]||(m[7]=(k,h)=>f.$emit("zone-height-change",k,h)),onZoneHeightCommit:m[8]||(m[8]=k=>f.$emit("zone-height-commit",k)),onCloneElement:m[9]||(m[9]=(k,h)=>f.$emit("clone-element",k,h))},null,8,["template-data","runtime-elements","scale","show-grid","snap-to-grid","show-table-ghost-border","guides"]),t.overlayVisible&&t.screenshotUrl?(e.openBlock(),e.createElementBlock("div",na,[e.createElementVNode("img",{src:t.screenshotUrl,class:"overlay-image",style:e.normalizeStyle({opacity:t.overlayOpacity??.5})},null,12,la)])):e.createCommentVNode("",!0)]),t.showRuler?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ruler-overlay",style:e.normalizeStyle(w.value)},[m[25]||(m[25]=e.createElementVNode("div",{class:"ruler-corner"},null,-1)),e.createVNode(Vt,{orientation:"horizontal","viewport-px":d.viewW,"origin-px":d.originX,"paper-length-m-m":s.value,scale:d.paperScale,"cursor-px":p.x,onAddGuide:m[10]||(m[10]=(k,h)=>l("add-guide",k,h)),onGuideDragging:m[11]||(m[11]=k=>J("vertical",k))},null,8,["viewport-px","origin-px","paper-length-m-m","scale","cursor-px"]),e.createVNode(Vt,{orientation:"vertical","viewport-px":d.viewH,"origin-px":d.originY,"paper-length-m-m":c.value,scale:d.paperScale,"cursor-px":p.y,onAddGuide:m[12]||(m[12]=(k,h)=>l("add-guide",k,h)),onGuideDragging:m[13]||(m[13]=k=>J("horizontal",k))},null,8,["viewport-px","origin-px","paper-length-m-m","scale","cursor-px"])],4)):e.createCommentVNode("",!0),W.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["ruler-guide-preview",`guide-${W.value.type}`]),style:e.normalizeStyle(A.value)},null,6)):e.createCommentVNode("",!0),S.visible?(e.openBlock(),e.createElementBlock("div",{key:2,class:"marquee-selection",style:e.normalizeStyle({left:S.x+"px",top:S.y+"px",width:S.w+"px",height:S.h+"px"})},null,4)):e.createCommentVNode("",!0),j.visible?(e.openBlock(),e.createElementBlock("div",{key:3,class:"context-menu",style:e.normalizeStyle({left:j.x+"px",top:j.y+"px"})},[j.targetId?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",{class:"context-menu-item",onClick:m[14]||(m[14]=k=>g("copy"))},"复制"),e.createElementVNode("div",{class:"context-menu-item",onClick:m[15]||(m[15]=k=>g("cut"))},"剪切"),e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.hasClipboard}]),onClick:m[16]||(m[16]=k=>g("paste"))},"粘贴",2),e.createElementVNode("div",{class:"context-menu-item",onClick:m[17]||(m[17]=k=>g("delete"))},"删除"),m[26]||(m[26]=e.createElementVNode("div",{class:"context-menu-sep"},null,-1)),e.createElementVNode("div",{class:"context-menu-item",onClick:m[18]||(m[18]=k=>g("move-layer","top"))},"置顶"),e.createElementVNode("div",{class:"context-menu-item",onClick:m[19]||(m[19]=k=>g("move-layer","up"))},"上移"),e.createElementVNode("div",{class:"context-menu-item",onClick:m[20]||(m[20]=k=>g("move-layer","down"))},"下移"),e.createElementVNode("div",{class:"context-menu-item",onClick:m[21]||(m[21]=k=>g("move-layer","bottom"))},"置底"),m[27]||(m[27]=e.createElementVNode("div",{class:"context-menu-sep"},null,-1)),e.createElementVNode("div",{class:"context-menu-item",onClick:m[22]||(m[22]=k=>g("group"))},"编组 Ctrl+G"),e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.selectedElementHasGroup}]),onClick:m[23]||(m[23]=k=>g("ungroup"))},"取消编组 Ctrl+Shift+G",2)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.hasClipboard}]),onClick:se},"粘贴",2),e.createElementVNode("div",{class:"context-menu-item",onClick:le},"全选"),e.createElementVNode("div",{class:"context-menu-item",onClick:P},"取消选择")],64))],4)):e.createCommentVNode("",!0)],544))}}),ia=_(aa,[["__scopeId","data-v-c84c019a"]]),ra=[{group:"position-size",groupLabel:"位置与尺寸",items:[{key:"ps-left",keywords:["X","横坐标","left","位置"]},{key:"ps-top",keywords:["Y","纵坐标","top","位置"]},{key:"ps-width",keywords:["W","宽度","width","尺寸"]},{key:"ps-height",keywords:["H","高度","height","尺寸"]}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function sa(t,a){const o=t.trim().toLowerCase();return o?a.some(n=>n.toLowerCase().includes(o)):!0}function da(t){const a=[],o=new Set;for(const n of ra){const l=n.items.filter(r=>sa(t,[...r.keywords,n.groupLabel]));if(l.length>0){a.push(n.group);for(const r of l)o.add(r.key)}}return{groups:a,itemKeys:o}}const ca={class:"property-search"},ua=e.defineComponent({__name:"PropertySearch",emits:["search"],setup(t,{emit:a}){const o=e.ref(""),n=a;function l(){n("search",o.value)}return(r,i)=>(e.openBlock(),e.createElementBlock("div",ca,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[0]||(i[0]=s=>o.value=s),class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",onInput:l},null,544),[[e.vModelText,o.value]])]))}}),ma=_(ua,[["__scopeId","data-v-10ab6c84"]]),pa={class:"group-icon"},fa={class:"group-title"},va={class:"expand-icon"},ga={class:"group-content"},ha=e.defineComponent({__name:"PropertyGroup",props:{title:{},icon:{},defaultExpanded:{type:Boolean},groupKey:{}},setup(t){const a=t,o=e.ref(a.defaultExpanded??!0),l={Document:"≡",Brush:"◧",Setting:"⚙"}[a.icon]||"•";function r(){o.value=!o.value,i()}function i(){const c=`property-group-${a.groupKey}`;try{localStorage.setItem(c,String(o.value))}catch{}}function s(){const c=`property-group-${a.groupKey}`;try{const d=localStorage.getItem(c);d!==null&&(o.value=d==="true")}catch{}}return e.onMounted(()=>{s()}),(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["property-group",{"is-expanded":o.value}])},[e.createElementVNode("div",{class:"group-header",onClick:r},[e.createElementVNode("span",pa,e.toDisplayString(e.unref(l)),1),e.createElementVNode("span",fa,e.toDisplayString(t.title),1),e.createElementVNode("span",va,e.toDisplayString(o.value?"▾":"▸"),1)]),e.withDirectives(e.createElementVNode("div",ga,[e.renderSlot(c.$slots,"default",{},void 0,!0)],512),[[e.vShow,o.value]])],2))}}),Ve=_(ha,[["__scopeId","data-v-2ba57031"]]),ba={class:"pd-stepper"},ya=["disabled"],ka=["value","placeholder","min","max","step"],Ea=["disabled"],wa=e.defineComponent({__name:"StepperInput",props:{modelValue:{},min:{},max:{},step:{default:1},placeholder:{}},emits:["update:modelValue"],setup(t,{emit:a}){const o=t,n=a,l=e.computed(()=>{const D=String(o.step),$=D.indexOf(".");return $===-1?0:D.length-$-1});function r(D){return Number.isFinite(D)?Number(D.toFixed(l.value)):0}const i=e.computed(()=>{const D=o.modelValue;if(!(D==null||!Number.isFinite(D)))return r(D)}),s=e.ref(i.value===void 0?"":String(i.value));e.watch(i,D=>{s.value=D===void 0?"":String(D)});const c=e.computed(()=>i.value!==void 0?i.value:o.min!==void 0?o.min:0),d=e.computed(()=>o.min!==void 0&&c.value<=o.min),p=e.computed(()=>o.max!==void 0&&c.value>=o.max);function v(D){let $=r(D);return o.min!==void 0&&$<o.min&&($=o.min),o.max!==void 0&&$>o.max&&($=o.max),$}function w(D){if(D<0&&d.value||D>0&&p.value)return;const $=v(c.value+D*o.step);s.value=String($),n("update:modelValue",$)}function L(D){s.value=D.target.value}function H(){const D=s.value.trim();if(D===""){i.value!==void 0&&(s.value=String(i.value));return}const $=Number(D);if(!Number.isFinite($)){s.value=i.value===void 0?"":String(i.value);return}const R=v($);s.value=String(R),R!==i.value&&n("update:modelValue",R)}return(D,$)=>(e.openBlock(),e.createElementBlock("div",ba,[e.createElementVNode("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:d.value,title:"减小","aria-label":"减小",onClick:$[0]||($[0]=R=>w(-1))},"−",8,ya),e.createElementVNode("input",{type:"number",class:"pd-input pd-step-input",value:s.value,placeholder:t.placeholder,min:t.min,max:t.max,step:t.step,onInput:L,onChange:H,onBlur:H,onKeydown:$[1]||($[1]=e.withKeys(e.withModifiers(R=>R.target.blur(),["prevent"]),["enter"]))},null,40,ka),e.createElementVNode("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:p.value,title:"增大","aria-label":"增大",onClick:$[2]||($[2]=R=>w(1))},"+",8,Ea)]))}}),ne=_(wa,[["__scopeId","data-v-9722a7cf"]]),Va={class:"position-grid"},Na={class:"pd-field"},Ca={class:"pd-field"},Sa={class:"pd-field"},Ma={class:"pd-field"},$a=e.defineComponent({__name:"PositionSizeGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const a=t;function o(n){return a.searching?a.matchedKeys?.has(n)??!0:!0}return(n,l)=>(e.openBlock(),e.createBlock(Ve,{title:"位置与尺寸",icon:"Location","default-expanded":"","group-key":"position-size"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:l[4]||(l[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Va,[e.withDirectives(e.createElementVNode("div",Na,[l[5]||(l[5]=e.createElementVNode("span",{class:"pd-label"},"X",-1)),e.createVNode(ne,{modelValue:t.element.options.left,"onUpdate:modelValue":l[0]||(l[0]=r=>t.element.options.left=r),min:0},null,8,["modelValue"])],512),[[e.vShow,o("ps-left")]]),e.withDirectives(e.createElementVNode("div",Ca,[l[6]||(l[6]=e.createElementVNode("span",{class:"pd-label"},"Y",-1)),e.createVNode(ne,{modelValue:t.element.options.top,"onUpdate:modelValue":l[1]||(l[1]=r=>t.element.options.top=r),min:0},null,8,["modelValue"])],512),[[e.vShow,o("ps-top")]]),e.withDirectives(e.createElementVNode("div",Sa,[l[7]||(l[7]=e.createElementVNode("span",{class:"pd-label"},"W",-1)),e.createVNode(ne,{modelValue:t.element.options.width,"onUpdate:modelValue":l[2]||(l[2]=r=>t.element.options.width=r),min:4},null,8,["modelValue"])],512),[[e.vShow,o("ps-width")]]),e.withDirectives(e.createElementVNode("div",Ma,[l[8]||(l[8]=e.createElementVNode("span",{class:"pd-label"},"H",-1)),e.createVNode(ne,{modelValue:t.element.options.height,"onUpdate:modelValue":l[3]||(l[3]=r=>t.element.options.height=r),min:4},null,8,["modelValue"])],512),[[e.vShow,o("ps-height")]])])],32)]),_:1}))}}),xa=_($a,[["__scopeId","data-v-572d7719"]]),Ba=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Da=["aria-expanded","title"],Ta={class:"picker-preview"},za={class:"preset-color-grid"},La=["title","aria-label","onClick"],Pa=e.defineComponent({__name:"PresetColorPicker",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:a}){const o=t,n=a,l=e.ref(!1),r=e.ref(),i=e.ref(),s=e.ref(),c=e.ref({}),d=e.ref(0),p=e.ref(0),v=e.ref(0),w=e.ref("#000000"),L=e.ref(!1),H=e.computed({get:()=>o.modelValue||"#000000",set:P=>n("update:modelValue",P)}),D=e.computed(()=>j(ie(d.value,p.value,v.value))),$=e.computed({get:()=>Math.round(d.value),set:P=>A(se(P),p.value,v.value)});e.watch(H,J,{immediate:!0});function R(P){w.value=P.toUpperCase(),J(P),n("update:modelValue",P)}function W(P){const E=P.target.value.trim();X(E)&&(J(E),n("update:modelValue",Z(E)))}function J(P){const g=X(P);if(!g)return;const E=ce(g.r,g.g,g.b);d.value=E.h,p.value=E.s,v.value=E.v,w.value=Z(P).toUpperCase()}function A(P,g,E){d.value=se(P),p.value=le(g),v.value=le(E),w.value=D.value.toUpperCase(),n("update:modelValue",D.value)}function G(P){P.currentTarget.setPointerCapture(P.pointerId),L.value=!0,M(P)}function K(P){L.value&&M(P)}function S(P){L.value=!1;const g=P.currentTarget;g.hasPointerCapture(P.pointerId)&&g.releasePointerCapture(P.pointerId)}function M(P){const g=s.value;if(!g)return;const E=g.getBoundingClientRect(),f=le((P.clientX-E.left)/E.width),m=le(1-(P.clientY-E.top)/E.height);A(d.value,f,m)}function x(P){const g=P.shiftKey?.1:.02;let E=!0;P.key==="ArrowLeft"?A(d.value,p.value-g,v.value):P.key==="ArrowRight"?A(d.value,p.value+g,v.value):P.key==="ArrowUp"?A(d.value,p.value,v.value+g):P.key==="ArrowDown"?A(d.value,p.value,v.value-g):E=!1,E&&P.preventDefault()}function B(){l.value?z():T()}async function T(){const P=r.value;if(!P)return;J(H.value),l.value=!0,await e.nextTick();const g=P.getBoundingClientRect(),E=190,f=i.value?.offsetHeight??216,m=8,k=Math.min(g.left,window.innerWidth-E-m),h=g.bottom+6,C=h+f>window.innerHeight-m?Math.max(m,g.top-f-6):h;c.value={left:`${Math.max(m,k)}px`,top:`${C}px`}}function z(){l.value=!1}function u(P){const g=P.target;r.value?.contains(g)||i.value?.contains(g)||z()}function V(){l.value&&z()}function O(P){P.key==="Escape"&&l.value&&z()}function X(P){const g=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(P.trim());if(!g)return null;const E=g[1],f=E.length===3?E.split("").map(m=>m+m).join(""):E;return{r:Number.parseInt(f.slice(0,2),16),g:Number.parseInt(f.slice(2,4),16),b:Number.parseInt(f.slice(4,6),16)}}function Z(P){const g=X(P);return g?j(g):"#000000"}function j({r:P,g,b:E}){return`#${[P,g,E].map(f=>Math.round(le(f/255)*255).toString(16).padStart(2,"0")).join("")}`}function ce(P,g,E){const f=P/255,m=g/255,k=E/255,h=Math.max(f,m,k),C=Math.min(f,m,k),N=h-C;let y=0;return N!==0&&(h===f?y=(m-k)/N%6:h===m?y=(k-f)/N+2:y=(f-m)/N+4,y*=60,y<0&&(y+=360)),{h:y,s:h===0?0:N/h,v:h}}function ie(P,g,E){const f=E*g,m=(P%360+360)%360/60,k=f*(1-Math.abs(m%2-1)),[h,C,N]=m<1?[f,k,0]:m<2?[k,f,0]:m<3?[0,f,k]:m<4?[0,k,f]:m<5?[k,0,f]:[f,0,k],y=E-f;return{r:(h+y)*255,g:(C+y)*255,b:(N+y)*255}}function se(P){return((Number.isFinite(P)?P:0)%360+360)%360}function le(P){return Math.min(1,Math.max(0,Number.isFinite(P)?P:0))}return e.onMounted(()=>{document.addEventListener("pointerdown",u,!0),window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),document.addEventListener("keydown",O)}),e.onBeforeUnmount(()=>{document.removeEventListener("pointerdown",u,!0),window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V),document.removeEventListener("keydown",O)}),(P,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{ref_key:"triggerRef",ref:r,type:"button",class:"preset-color-trigger","aria-expanded":l.value,"aria-haspopup":"dialog",title:t.modelValue||"自动",onClick:B},[e.createElementVNode("span",{class:"preset-color-swatch",style:e.normalizeStyle({background:H.value})},null,4)],8,Da),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[l.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:e.normalizeStyle(c.value),onPointerdown:g[2]||(g[2]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",Ta,[e.createElementVNode("span",{class:"picker-current",style:e.normalizeStyle({background:D.value})},null,4),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=E=>w.value=E),class:"picker-hex",type:"text",maxlength:"7",spellcheck:"false","aria-label":"颜色值",onInput:W},null,544),[[e.vModelText,w.value]])]),e.createElementVNode("div",{ref_key:"areaRef",ref:s,class:"picker-area",style:e.normalizeStyle({"--picker-hue":`${Math.round(d.value)}deg`}),"aria-label":"自定义颜色",tabindex:"0",onPointerdown:G,onPointermove:K,onPointerup:S,onPointercancel:S,onKeydown:x},[e.createElementVNode("span",{class:"picker-handle",style:e.normalizeStyle({left:`${p.value*100}%`,top:`${(1-v.value)*100}%`,background:D.value})},null,4)],36),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[1]||(g[1]=E=>$.value=E),class:"picker-hue",type:"range",min:"0",max:"360",step:"1","aria-label":"色相"},null,512),[[e.vModelText,$.value,void 0,{number:!0}]]),g[3]||(g[3]=e.createElementVNode("div",{class:"picker-heading"},"常用颜色",-1)),e.createElementVNode("div",za,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Ba),E=>(e.openBlock(),e.createElementBlock("button",{key:E,type:"button",class:e.normalizeClass(["preset-color-item",{active:E.toLowerCase()===D.value.toLowerCase()}]),style:e.normalizeStyle({background:E}),title:E,"aria-label":E,onClick:f=>R(E)},null,14,La))),128))])],36)):e.createCommentVNode("",!0)]))],64))}}),we=_(Pa,[["__scopeId","data-v-db3c3d71"]]),Aa={class:"pd-field"},Ia={class:"pd-field"},Ra={class:"pd-field"},Ha={class:"pd-radio-group",role:"radiogroup"},Fa={class:"pd-radio"},Ua={class:"pd-radio"},Oa={class:"pd-radio"},Ga={class:"pd-field"},qa={class:"pd-radio-group",role:"radiogroup"},Wa={class:"pd-radio"},Ya={class:"pd-radio"},Ka={class:"pd-radio"},Xa={class:"color-row"},ja={class:"pd-field"},Ja={class:"pd-field"},Za={class:"pd-field"},Qa={class:"pd-field"},_a={key:1,class:"pd-empty"},ei=e.defineComponent({__name:"AppearanceGroup",props:{element:{},isTextType:{type:Boolean},matchedKeys:{},searching:{type:Boolean}},setup(t){const a=t;function o(l){return a.searching?a.matchedKeys?.has(l)??!0:!0}const n=e.computed(()=>a.element.printElementType.type==="table");return(l,r)=>(e.openBlock(),e.createBlock(Ve,{title:"外观",icon:"Brush","default-expanded":"","group-key":"appearance"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:r[12]||(r[12]=e.withModifiers(()=>{},["prevent"]))},[t.isTextType?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.withDirectives(e.createElementVNode("div",Aa,[r[13]||(r[13]=e.createElementVNode("span",{class:"pd-label"},"字体大小",-1)),e.createVNode(ne,{modelValue:t.element.options.fontSize,"onUpdate:modelValue":r[0]||(r[0]=i=>t.element.options.fontSize=i),min:8,max:72},null,8,["modelValue"])],512),[[e.vShow,o("ap-font-size")]]),e.withDirectives(e.createElementVNode("div",Ia,[r[15]||(r[15]=e.createElementVNode("span",{class:"pd-label"},"字体粗细",-1)),e.withDirectives(e.createElementVNode("select",{class:"pd-select","onUpdate:modelValue":r[1]||(r[1]=i=>t.element.options.fontWeight=i),style:{width:"100%"}},[...r[14]||(r[14]=[e.createElementVNode("option",{value:"normal"},"正常",-1),e.createElementVNode("option",{value:"bold"},"粗体",-1),e.createElementVNode("option",{value:"bolder"},"更粗",-1),e.createElementVNode("option",{value:"lighter"},"细体",-1)])],512),[[e.vModelSelect,t.element.options.fontWeight]])],512),[[e.vShow,o("ap-font-weight")]]),e.withDirectives(e.createElementVNode("div",Ra,[r[19]||(r[19]=e.createElementVNode("span",{class:"pd-label"},"对齐",-1)),e.createElementVNode("div",Ha,[e.createElementVNode("label",Fa,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":r[2]||(r[2]=i=>t.element.options.textAlign=i),value:"left"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),r[16]||(r[16]=e.createElementVNode("span",null,"左",-1))]),e.createElementVNode("label",Ua,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":r[3]||(r[3]=i=>t.element.options.textAlign=i),value:"center"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),r[17]||(r[17]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Oa,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":r[4]||(r[4]=i=>t.element.options.textAlign=i),value:"right"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),r[18]||(r[18]=e.createElementVNode("span",null,"右",-1))])])],512),[[e.vShow,o("ap-align")]]),e.withDirectives(e.createElementVNode("div",Ga,[r[23]||(r[23]=e.createElementVNode("span",{class:"pd-label"},"垂直对齐",-1)),e.createElementVNode("div",qa,[e.createElementVNode("label",Wa,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":r[5]||(r[5]=i=>t.element.options.verticalAlign=i),value:"top"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),r[20]||(r[20]=e.createElementVNode("span",null,"顶",-1))]),e.createElementVNode("label",Ya,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":r[6]||(r[6]=i=>t.element.options.verticalAlign=i),value:"middle"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),r[21]||(r[21]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Ka,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":r[7]||(r[7]=i=>t.element.options.verticalAlign=i),value:"bottom"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),r[22]||(r[22]=e.createElementVNode("span",null,"底",-1))])])],512),[[e.vShow,o("ap-vertical-align")]]),e.createElementVNode("div",Xa,[e.withDirectives(e.createElementVNode("div",ja,[r[24]||(r[24]=e.createElementVNode("span",{class:"pd-label"},"颜色",-1)),e.createVNode(we,{modelValue:t.element.options.color,"onUpdate:modelValue":r[8]||(r[8]=i=>t.element.options.color=i)},null,8,["modelValue"])],512),[[e.vShow,o("ap-color")]]),e.withDirectives(e.createElementVNode("div",Ja,[r[25]||(r[25]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(we,{modelValue:t.element.options.backgroundColor,"onUpdate:modelValue":r[9]||(r[9]=i=>t.element.options.backgroundColor=i)},null,8,["modelValue"])],512),[[e.vShow,o("ap-bg-color")]])]),e.withDirectives(e.createElementVNode("div",Za,[r[26]||(r[26]=e.createElementVNode("span",{class:"pd-label"},"行高",-1)),e.createVNode(ne,{modelValue:t.element.options.lineHeight,"onUpdate:modelValue":r[10]||(r[10]=i=>t.element.options.lineHeight=i),min:0,max:100},null,8,["modelValue"])],512),[[e.vShow,o("ap-line-height")]]),e.withDirectives(e.createElementVNode("div",Qa,[r[27]||(r[27]=e.createElementVNode("span",{class:"pd-label"},"字间距",-1)),e.createVNode(ne,{modelValue:t.element.options.letterSpacing,"onUpdate:modelValue":r[11]||(r[11]=i=>t.element.options.letterSpacing=i),min:0,max:20,step:.5},null,8,["modelValue"])],512),[[e.vShow,o("ap-letter-spacing")]])],64)):e.createCommentVNode("",!0),!t.isTextType&&!n.value?(e.openBlock(),e.createElementBlock("p",_a,"当前元素不支持外观设置")):e.createCommentVNode("",!0)],32)]),_:1}))}}),ti=_(ei,[["__scopeId","data-v-2b604a48"]]),oi={class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},ni={class:"pd-dialog-header"},li={class:"expression-editor"},ai={class:"ee-nav"},ii={class:"ee-nav-tabs"},ri={class:"ee-content"},si={class:"ee-content-search"},di=["placeholder"],ci={class:"ee-content-list"},ui={class:"ee-field-group-icon"},mi=["onDblclick"],pi={class:"ee-field-info"},fi={class:"ee-item-label"},vi={class:"ee-item-key"},gi={key:0,class:"pd-empty"},hi=["onDblclick"],bi={class:"ee-field-info"},yi={class:"ee-item-label"},ki={class:"ee-item-key"},Ei={class:"ee-func-group"},wi=["onDblclick"],Vi={class:"ee-field-info"},Ni={class:"ee-item-label"},Ci={class:"ee-item-key"},Si={class:"ee-func-group"},Mi=["onDblclick"],$i={class:"ee-field-info"},xi={class:"ee-item-label"},Bi={class:"ee-item-key"},Di={class:"ee-editor"},Ti={class:"ee-editor-section"},zi={class:"ee-editor-section"},Li={class:"pd-dialog-footer"},Pi=e.defineComponent({__name:"ExpressionEditor",props:{modelValue:{type:Boolean},expression:{},fields:{}},emits:["update:modelValue","update:expression"],setup(t,{emit:a}){const o=t,n=a,l=e.computed({get:()=>o.modelValue,set:M=>n("update:modelValue",M)}),r=e.ref("field"),i=e.computed(()=>{switch(r.value){case"field":return"搜索字段...";case"variable":return"搜索变量...";case"function":return"搜索函数...";default:return"搜索..."}}),s=e.ref(""),c=e.computed(()=>Ut(Ft(o.fields??[]),s.value));e.watch(l,M=>{M&&($.value=o.expression||"")});function d(M){const{insideParens:x}=w();K(x?M.fieldKey:`{${M.fieldKey}}`)}function p(M){const{insideParens:x}=w();K(x?M.template.replace(/^\{|\}$/g,""):M.template)}function v(M){const{insideBlock:x}=w(),B=x?M.template:`{${M.template}}`,T=B.indexOf("(")+1;K(B,T)}function w(){const x=R.value?.selectionStart??$.value.length,B=$.value.substring(0,x);let T=!1;const z=B.lastIndexOf("{");z!==-1&&!B.slice(z+1).includes("}")&&(T=!0);let u=!1;const V=B.lastIndexOf("(");return V!==-1&&!B.slice(V+1).includes(")")&&(u=!0),{insideBlock:T,insideParens:u}}const L=e.computed(()=>{if(!s.value.trim())return A;const M=s.value.trim().toLowerCase();return A.filter(x=>x.label.toLowerCase().includes(M)||x.name.toLowerCase().includes(M))}),H=e.computed(()=>{if(!s.value.trim())return W;const M=s.value.trim().toLowerCase();return W.filter(x=>x.label.toLowerCase().includes(M)||x.name.toLowerCase().includes(M))}),D=e.computed(()=>{if(!s.value.trim())return J;const M=s.value.trim().toLowerCase();return J.filter(x=>x.label.toLowerCase().includes(M)||x.name.toLowerCase().includes(M))}),$=e.ref(o.expression||""),R=e.ref(null);e.watch(()=>o.expression,M=>{$.value=M||""});const W=[{name:"SUM",label:"求和",template:"SUM()"},{name:"AVG",label:"平均值",template:"AVG()"},{name:"COUNT",label:"计数",template:"COUNT()"},{name:"MIN",label:"最小值",template:"MIN()"},{name:"MAX",label:"最大值",template:"MAX()"}],J=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],A=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],G=e.computed(()=>{if(!$.value.trim())return"(输入表达式后预览)";try{const M={...ge,pageIndex:1,totalPages:1,printDate:new Date().toISOString().split("T")[0],printTime:Date.now()},x=$e($.value,M);return x==null?"(无法计算)":String(x)}catch{return"(表达式错误)"}});function K(M,x=M.length){const B=R.value;if(!B){$.value+=M;return}const T=B.selectionStart,z=B.selectionEnd,u=$.value.substring(0,T),V=$.value.substring(z);$.value=u+M+V;const O=T+x;e.nextTick(()=>{B.focus(),B.selectionStart=B.selectionEnd=O})}function S(){n("update:expression",$.value),l.value=!1}return(M,x)=>l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"pd-dialog-overlay",onKeydown:x[7]||(x[7]=e.withKeys(B=>l.value=!1,["esc"]))},[e.createElementVNode("section",oi,[e.createElementVNode("header",ni,[x[8]||(x[8]=e.createElementVNode("strong",{id:"expression-editor-title"},"编辑表达式",-1)),e.createElementVNode("button",{type:"button",class:"pd-close","aria-label":"关闭",onClick:x[0]||(x[0]=B=>l.value=!1)},"×")]),e.createElementVNode("div",li,[e.createElementVNode("div",ai,[x[9]||(x[9]=e.createElementVNode("div",{class:"ee-nav-title"},"类型",-1)),e.createElementVNode("div",ii,[e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:r.value==="field"}]),onClick:x[1]||(x[1]=B=>r.value="field")}," 📁 字段 ",2),e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:r.value==="variable"}]),onClick:x[2]||(x[2]=B=>r.value="variable")}," 🔧 变量 ",2),e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:r.value==="function"}]),onClick:x[3]||(x[3]=B=>r.value="function")}," ⚡ 函数 ",2)])]),e.createElementVNode("div",ri,[e.createElementVNode("div",si,[e.withDirectives(e.createElementVNode("input",{class:"pd-input","onUpdate:modelValue":x[4]||(x[4]=B=>s.value=B),placeholder:i.value},null,8,di),[[e.vModelText,s.value]])]),e.createElementVNode("div",ci,[r.value==="field"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,B=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:B.key||"_top"},[B.key?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ee-field-group",{"is-list":B.isList}])},[e.createElementVNode("span",ui,e.toDisplayString(B.isList?"📋":"📁"),1),e.createElementVNode("span",null,e.toDisplayString(B.label),1)],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.fields,T=>(e.openBlock(),e.createElementBlock("div",{key:T.fieldKey,class:"ee-list-item ee-field-item",style:e.normalizeStyle({paddingLeft:B.key?"22px":"10px"}),onDblclick:z=>d(T)},[e.createElementVNode("div",pi,[e.createElementVNode("span",fi,e.toDisplayString(T.fieldLabel),1),e.createElementVNode("span",vi,e.toDisplayString(T.fieldKey),1)])],44,mi))),128))],64))),128)),c.value.length===0?(e.openBlock(),e.createElementBlock("p",gi,"暂无字段")):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),r.value==="variable"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(L.value,B=>(e.openBlock(),e.createElementBlock("div",{key:B.name,class:"ee-list-item",onDblclick:T=>p(B)},[e.createElementVNode("div",bi,[e.createElementVNode("span",yi,e.toDisplayString(B.label),1),e.createElementVNode("span",ki,e.toDisplayString(B.template),1)])],40,hi))),128)):e.createCommentVNode("",!0),r.value==="function"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Ei,[x[10]||(x[10]=e.createElementVNode("div",{class:"ee-func-group-title"},"聚合函数",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.value,B=>(e.openBlock(),e.createElementBlock("div",{key:B.name,class:"ee-list-item",onDblclick:T=>v(B)},[e.createElementVNode("div",Vi,[e.createElementVNode("span",Ni,e.toDisplayString(B.label),1),e.createElementVNode("span",Ci,e.toDisplayString(B.name)+"()",1)])],40,wi))),128))]),e.createElementVNode("div",Si,[x[11]||(x[11]=e.createElementVNode("div",{class:"ee-func-group-title"},"格式化函数",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,B=>(e.openBlock(),e.createElementBlock("div",{key:B.name,class:"ee-list-item",onDblclick:T=>v(B)},[e.createElementVNode("div",$i,[e.createElementVNode("span",xi,e.toDisplayString(B.label),1),e.createElementVNode("span",Bi,e.toDisplayString(B.name)+"()",1)])],40,Mi))),128))])],64)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Di,[e.createElementVNode("div",Ti,[x[12]||(x[12]=e.createElementVNode("div",{class:"ee-editor-title"},"表达式编辑",-1)),e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:R,"onUpdate:modelValue":x[5]||(x[5]=B=>$.value=B),class:"ee-textarea",rows:"6",placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容"},null,512),[[e.vModelText,$.value]])]),e.createElementVNode("div",zi,[x[13]||(x[13]=e.createElementVNode("div",{class:"ee-editor-title"},"预览结果",-1)),e.createElementVNode("div",{class:e.normalizeClass(["ee-preview",{"ee-preview-error":G.value==="(表达式错误)"}])},e.toDisplayString(G.value),3)]),x[14]||(x[14]=e.createStaticVNode('<div class="ee-help-section" data-v-86008c29><div class="ee-help-title" data-v-86008c29>帮助信息</div><div class="ee-help-grid" data-v-86008c29><div class="ee-help-card ee-help-field" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>输入方式</div><div class="ee-help-card-content" data-v-86008c29> 双击左侧字段、变量、函数即可插入到表达式输入框中<br data-v-86008c29> 静态数据直接输入即可,如:供应商名称<br data-v-86008c29> 动态解析字段、变量、函数必须用 {} 包裹<br data-v-86008c29> 示例:{SUM(supplier.name)}<br data-v-86008c29> 注意:只能嵌套一层 </div></div><div class="ee-help-card ee-help-function" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>函数使用</div><div class="ee-help-card-content" data-v-86008c29> SUM(字段) - 求和<br data-v-86008c29> AVG(字段) - 平均值<br data-v-86008c29> COUNT(字段) - 计数<br data-v-86008c29> IF(条件, 真值, 假值) - 条件判断 </div></div><div class="ee-help-card ee-help-variable" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>系统变量</div><div class="ee-help-card-content" data-v-86008c29> {pageIndex} - 当前页码<br data-v-86008c29> {totalPages} - 总页数<br data-v-86008c29> {printDate} - 打印日期 </div></div><div class="ee-help-card ee-help-conditional" data-v-86008c29><div class="ee-help-card-title" data-v-86008c29>示例</div><div class="ee-help-card-content" data-v-86008c29> 静态文本:供应商名称<br data-v-86008c29> 动态字段:{supplier.name}<br data-v-86008c29> 函数调用:{SUM(amount)}<br data-v-86008c29> 条件判断:{IF(amount>1000, "大单", "小单")} </div></div></div></div>',1))])]),e.createElementVNode("footer",Li,[e.createElementVNode("button",{type:"button",class:"pd-button",onClick:x[6]||(x[6]=B=>l.value=!1)},"取消"),e.createElementVNode("button",{type:"button",class:"pd-button primary",onClick:S},"确定")])])],32)):e.createCommentVNode("",!0)}}),ft=_(Pi,[["__scopeId","data-v-86008c29"]]),Ai={class:"pd-field"},Ii={class:"pd-label"},Ri=["value","placeholder"],Hi=e.defineComponent({__name:"BindingControl",props:{descriptor:{},modelValue:{},fields:{}},emits:["update:modelValue"],setup(t,{emit:a}){const o=a,n=e.ref(!1);function l(){n.value=!0}return(r,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",Ai,[e.createElementVNode("span",Ii,e.toDisplayString(t.descriptor.label),1),e.createElementVNode("input",{value:t.modelValue,class:"pd-input",placeholder:t.descriptor.placeholder||"输入内容,支持 {字段} 表达式",onInput:i[0]||(i[0]=s=>o("update:modelValue",s.target.value)),onDblclick:l},null,40,Ri)]),e.createVNode(ft,{modelValue:n.value,"onUpdate:modelValue":i[1]||(i[1]=s=>n.value=s),fields:t.fields,expression:t.modelValue,"onUpdate:expression":i[2]||(i[2]=s=>o("update:modelValue",s))},null,8,["modelValue","fields","expression"])],64))}}),Fi=_(Hi,[["__scopeId","data-v-135d160a"]]),Ui={class:"pd-field"},Oi=["value"],Gi=["value"],qi={class:"pd-field"},Wi={class:"pd-field"},Yi={class:"pd-field"},Ki={class:"pd-field"},Xi={style:{width:"60px"}},ji=e.defineComponent({__name:"TableSettingsGroup",props:{element:{},fields:{}},setup(t){const a=t,o=e.inject(Pe,null),n=e.computed(()=>a.fields.filter(i=>i.fieldType==="list").map(i=>({label:i.fieldLabel,value:i.fieldKey})));function l(i){a.element.options.dataSource=i||void 0,o?.recordHistory()}function r(i,s){if(s===void 0)return;const c=a.element.options.tableColWidths,d=o?.maxTableWidth.value??1/0,p=c.reduce((v,w,L)=>L===i?v:v+w,0);if(p+s>d){const v=Math.max(5,Math.round((d-p)*10)/10);alert(`表格总宽不能超过打印范围宽度 ${d}mm,列${i+1} 已调整为 ${v}mm`),c[i]=v}else c[i]=s;qe(a.element.options),o?.recordHistory()}return(i,s)=>(e.openBlock(),e.createBlock(Ve,{title:"表格设置",icon:"Grid","default-expanded":"","group-key":"table-settings"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:s[4]||(s[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Ui,[s[5]||(s[5]=e.createElementVNode("span",{class:"pd-label"},"列表数据源字段",-1)),e.createElementVNode("select",{value:t.element.options.dataSource,class:"pd-select",style:{width:"100%"},onChange:s[0]||(s[0]=c=>l(c.target.value))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,c=>(e.openBlock(),e.createElementBlock("option",{key:c.value,value:c.value},e.toDisplayString(c.label),9,Gi))),128))],40,Oi)]),e.createElementVNode("div",qi,[s[6]||(s[6]=e.createElementVNode("span",{class:"pd-label"},"默认字号 (pt)",-1)),e.createVNode(ne,{modelValue:t.element.options.tableDefaultFontSize,"onUpdate:modelValue":s[1]||(s[1]=c=>t.element.options.tableDefaultFontSize=c),min:5,max:72,placeholder:"默认"},null,8,["modelValue"])]),e.createElementVNode("div",Wi,[s[7]||(s[7]=e.createElementVNode("span",{class:"pd-label"},"默认文字颜色",-1)),e.createVNode(we,{modelValue:t.element.options.tableDefaultColor,"onUpdate:modelValue":s[2]||(s[2]=c=>t.element.options.tableDefaultColor=c)},null,8,["modelValue"])]),e.createElementVNode("div",Yi,[s[8]||(s[8]=e.createElementVNode("span",{class:"pd-label"},"默认内边距 (mm)",-1)),e.createVNode(ne,{modelValue:t.element.options.tableDefaultPadding,"onUpdate:modelValue":s[3]||(s[3]=c=>t.element.options.tableDefaultPadding=c),min:0,max:10,step:.5,placeholder:"默认"},null,8,["modelValue"])]),e.createElementVNode("div",Ki,[s[9]||(s[9]=e.createElementVNode("span",{class:"pd-label"},"列宽 (mm)",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.element.options.tableColWidths,(c,d)=>(e.openBlock(),e.createElementBlock("div",{key:d,class:"col-width-row"},[e.createElementVNode("span",Xi,"列"+e.toDisplayString(d+1),1),e.createVNode(ne,{"model-value":c,min:5,max:200,"onUpdate:modelValue":p=>r(d,p)},null,8,["model-value","onUpdate:modelValue"])]))),128))])],32)]),_:1}))}}),Ji=_(ji,[["__scopeId","data-v-2860c993"]]),Zi={class:"border-row"},Qi={class:"pd-field"},_i={class:"pd-field"},er={class:"pd-field"},tr=e.defineComponent({__name:"BorderBgGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const a=t;function o(n){return a.searching?a.matchedKeys?.has(n)??!0:!0}return(n,l)=>(e.openBlock(),e.createBlock(Ve,{title:"边框与背景",icon:"Picture","default-expanded":"","group-key":"border-bg"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:l[3]||(l[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Zi,[e.withDirectives(e.createElementVNode("div",Qi,[l[4]||(l[4]=e.createElementVNode("span",{class:"pd-label"},"边框宽度",-1)),e.createVNode(ne,{modelValue:t.element.options.borderWidth,"onUpdate:modelValue":l[0]||(l[0]=r=>t.element.options.borderWidth=r),min:0,max:20,step:.25},null,8,["modelValue"])],512),[[e.vShow,o("bb-border-width")]]),e.withDirectives(e.createElementVNode("div",_i,[l[5]||(l[5]=e.createElementVNode("span",{class:"pd-label"},"边框颜色",-1)),e.createVNode(we,{modelValue:t.element.options.borderColor,"onUpdate:modelValue":l[1]||(l[1]=r=>t.element.options.borderColor=r)},null,8,["modelValue"])],512),[[e.vShow,o("bb-border-color")]])]),e.withDirectives(e.createElementVNode("div",er,[l[6]||(l[6]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(we,{modelValue:t.element.options.backgroundColor,"onUpdate:modelValue":l[2]||(l[2]=r=>t.element.options.backgroundColor=r)},null,8,["modelValue"])],512),[[e.vShow,o("bb-bg-color")]])],32)]),_:1}))}}),or=_(tr,[["__scopeId","data-v-84aa55dc"]]),nr={class:"advanced-row"},lr={class:"pd-field"},ar={class:"pd-field"},ir={class:"pd-field"},rr={class:"pd-field"},sr=e.defineComponent({__name:"AdvancedGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},emits:["delete-element"],setup(t){const a=t;function o(n){return a.searching?a.matchedKeys?.has(n)??!0:!0}return(n,l)=>(e.openBlock(),e.createBlock(Ve,{title:"高级设置",icon:"Setting","group-key":"advanced"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:l[4]||(l[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",nr,[e.withDirectives(e.createElementVNode("div",lr,[l[5]||(l[5]=e.createElementVNode("span",{class:"pd-label"},"锁定",-1)),e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"pd-switch","onUpdate:modelValue":l[0]||(l[0]=r=>t.element.options.locked=r)},null,512),[[e.vModelCheckbox,t.element.options.locked]])],512),[[e.vShow,o("ad-locked")]]),e.withDirectives(e.createElementVNode("div",ar,[l[6]||(l[6]=e.createElementVNode("span",{class:"pd-label"},"每页重复",-1)),e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"pd-switch","onUpdate:modelValue":l[1]||(l[1]=r=>t.element.options.fixed=r)},null,512),[[e.vModelCheckbox,t.element.options.fixed]])],512),[[e.vShow,o("ad-fixed")]])]),e.withDirectives(e.createElementVNode("div",ir,[l[7]||(l[7]=e.createElementVNode("span",{class:"pd-label"},"层级",-1)),e.createVNode(ne,{modelValue:t.element.options.zIndex,"onUpdate:modelValue":l[2]||(l[2]=r=>t.element.options.zIndex=r),min:0,max:999},null,8,["modelValue"])],512),[[e.vShow,o("ad-z-index")]]),e.withDirectives(e.createElementVNode("div",rr,[e.createElementVNode("button",{type:"button",class:"pd-button danger",onClick:l[3]||(l[3]=r=>n.$emit("delete-element"))}," 删除元素 ")],512),[[e.vShow,o("ad-delete")]])],32)]),_:1}))}}),dr=_(sr,[["__scopeId","data-v-84bf7a55"]]),cr={key:0,class:"pd-field"},ur=["checked"],mr={class:"pd-field"},pr=["checked"],fr={class:"pd-field"},vr=["checked"],Nt=e.defineComponent({__name:"PaginationGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const a=t,o=e.computed(()=>a.element.printElementType.type==="table"),n=e.computed({get:()=>a.element.options.tablePagination?.enabled??!0,set:()=>{}});function l(p){a.element.options.tablePagination={enabled:p}}const r=e.computed({get:()=>a.element.options.pagination?.pageable??!0,set:()=>{}}),i=e.computed({get:()=>a.element.options.pagination?.keepWithNext??!1,set:()=>{}});function s(p){a.element.options.pagination={pageable:p,keepWithNext:i.value}}function c(p){a.element.options.pagination={pageable:r.value,keepWithNext:p}}function d(p){return a.searching?a.matchedKeys?.has(p)??!0:!0}return(p,v)=>(e.openBlock(),e.createBlock(Ve,{title:"分页配置",icon:"Document","group-key":"pagination"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:v[3]||(v[3]=e.withModifiers(()=>{},["prevent"]))},[o.value?e.withDirectives((e.openBlock(),e.createElementBlock("div",cr,[v[4]||(v[4]=e.createElementVNode("span",{class:"pd-label"},"启用分页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:n.value,onChange:v[0]||(v[0]=w=>l(w.target.checked))},null,40,ur)],512)),[[e.vShow,d("pg-enabled")]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.withDirectives(e.createElementVNode("div",mr,[v[5]||(v[5]=e.createElementVNode("span",{class:"pd-label"},"参与分页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:r.value,onChange:v[1]||(v[1]=w=>s(w.target.checked))},null,40,pr)],512),[[e.vShow,d("pg-pageable")]]),e.withDirectives(e.createElementVNode("div",fr,[v[6]||(v[6]=e.createElementVNode("span",{class:"pd-label"},"与下元素同页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:i.value,onChange:v[2]||(v[2]=w=>c(w.target.checked))},null,40,vr)],512),[[e.vShow,d("pg-keep-with-next")]])],64))],32)]),_:1}))}}),gr={class:"image-content-upload"},hr=["disabled"],br=e.defineComponent({__name:"ImageContentUpload",props:{disabled:{type:Boolean}},emits:["success"],setup(t,{emit:a}){const o=t,n=a,l=e.ref(!1),r=e.inject(pt,e.computed(()=>{})),i=e.computed(()=>o.disabled||l.value||!r.value);async function s(c){const d=c.target,p=d.files?.[0];if(p){if(!p.type.startsWith("image/")){alert("仅支持上传图片文件"),d.value="";return}if(!r.value){alert("图片上传能力未配置"),d.value="";return}l.value=!0;try{const v=await r.value(p);v?n("success",v):alert("图片上传失败")}catch(v){alert(v instanceof Error?v.message:"图片上传失败")}finally{l.value=!1,d.value=""}}}return(c,d)=>(e.openBlock(),e.createElementBlock("div",gr,[e.createElementVNode("label",{class:e.normalizeClass(["pd-button small upload-label",{disabled:i.value}])},[d[0]||(d[0]=e.createElementVNode("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})],-1)),e.createTextVNode(" "+e.toDisplayString(l.value?"上传中...":"上传图片")+" ",1),e.createElementVNode("input",{class:"visually-hidden",type:"file",accept:"image/*",disabled:i.value,onChange:s},null,40,hr)],2),d[1]||(d[1]=e.createElementVNode("p",{class:"upload-tip"},"支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",-1))]))}}),yr=_(br,[["__scopeId","data-v-b730e8e6"]]),kr={class:"pd-field"},Er=["value"],wr={class:"pd-field"},Vr={key:0,class:"pd-field"},Nr=["checked"],Cr=e.defineComponent({__name:"TableRowGroup",props:{element:{},selection:{}},setup(t){const a=t,o=e.inject(Pe),n=e.computed(()=>a.element.options.tableRows[a.selection.r1]);function l(s){const c=ot(a.element.options.tableRows,a.selection.r1,s);if(c){alert(c);return}o.recordHistory()}function r(s){s!==void 0&&(n.value.height=s,qe(a.element.options),o.recordHistory())}function i(s){n.value.repeatOnPage=s,o.recordHistory()}return(s,c)=>(e.openBlock(),e.createBlock(Ve,{title:"行属性",icon:"Grid","default-expanded":"","group-key":"table-row"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:c[2]||(c[2]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",kr,[c[4]||(c[4]=e.createElementVNode("span",{class:"pd-label"},"行类型",-1)),e.createElementVNode("select",{value:n.value.type,class:"pd-select",style:{width:"100%"},onChange:c[0]||(c[0]=d=>l(d.target.value))},[...c[3]||(c[3]=[e.createElementVNode("option",{value:"header"},"标题行",-1),e.createElementVNode("option",{value:"data"},"数据行",-1),e.createElementVNode("option",{value:"subtotal"},"小计行(每页小计)",-1),e.createElementVNode("option",{value:"summary"},"汇总行",-1)])],40,Er)]),e.createElementVNode("div",wr,[c[5]||(c[5]=e.createElementVNode("span",{class:"pd-label"},"行高 (mm)",-1)),e.createVNode(ne,{"model-value":n.value.height,min:3,max:100,step:.5,"onUpdate:modelValue":r},null,8,["model-value"])]),n.value.type==="header"?(e.openBlock(),e.createElementBlock("div",Vr,[c[6]||(c[6]=e.createElementVNode("span",{class:"pd-label"},"每页顶部重复",-1)),e.createElementVNode("input",{checked:n.value.repeatOnPage??!1,type:"checkbox",class:"pd-switch",onInput:c[1]||(c[1]=d=>i(!!d.target.checked))},null,40,Nr)])):e.createCommentVNode("",!0)],32)]),_:1}))}}),Sr={class:"pd-field"},Mr={class:"pd-radio-group",role:"radiogroup"},$r={class:"pd-radio"},xr=["checked"],Br={class:"pd-radio"},Dr=["checked"],Tr={class:"pd-radio"},zr=["checked"],Lr={class:"pd-radio"},Pr=["checked"],Ar={key:0,class:"pd-field"},Ir=["value"],Rr={key:1,class:"pd-field"},Hr=["checked"],Fr={key:2,class:"pd-field"},Ur=["value"],Or={key:3,class:"pd-field"},Gr=["value"],qr={key:4,class:"pd-field"},Wr={key:5,class:"pd-field"},Yr={class:"pd-field"},Kr=["value"],Xr={class:"pd-field"},jr={class:"pd-radio-group",role:"radiogroup"},Jr={class:"pd-radio"},Zr=["checked"],Qr={class:"pd-radio"},_r=["checked"],es={class:"pd-radio"},ts=["checked"],os={class:"pd-field"},ns={class:"pd-radio-group",role:"radiogroup"},ls={class:"pd-radio"},as=["checked"],is={class:"pd-radio"},rs=["checked"],ss={class:"pd-radio"},ds=["checked"],cs={class:"cell-style-grid"},us={class:"pd-field"},ms=["value"],ps={class:"pd-field"},fs={class:"pd-field"},vs=["checked"],gs={class:"pd-field"},hs={class:"pd-field"},bs={class:"border-style-row"},ys={style:{width:"112px","flex-shrink":"0"}},ks={class:"pd-button-group border-presets"},Es={class:"pd-checkbox-group"},ws={class:"pd-checkbox"},Vs={class:"pd-checkbox"},Ns={class:"pd-checkbox"},Cs={class:"pd-checkbox"},Ss={class:"pd-field"},Ms={class:"pd-field"},$s=["checked"],xs={class:"merge-btns"},Bs=["disabled","title"],Ds=["disabled"],Ts=e.defineComponent({__name:"TableCellGroup",props:{element:{},selection:{},fields:{}},setup(t,{expose:a}){const o=t,n=e.inject(Pe),l=e.computed(()=>o.element.options.tableRows),r=e.computed(()=>{const z=ct(l.value,o.selection.r1,o.selection.c1);return l.value[z.r].cells[z.c]}),i=e.ref(!1),s=e.ref(""),c=e.computed(()=>r.value.cellType==="barcode"),d=e.computed(()=>r.value.cellType==="qrcode"),p=e.computed(()=>r.value.cellType==="image");function v(z){$(u=>{u.align=z})}function w(z){$(u=>{u.valign=z})}function L(z){$(u=>{u.cellType=z==="text"?void 0:z,z!=="barcode"&&(u.barcodeType=void 0,u.showBarcodeText=void 0),z!=="qrcode"&&(u.qrCodeLevel=void 0)})}function H(){s.value=r.value.formatter||"",i.value=!0}function D(z){$(u=>{u.formatter=z||void 0})}function $(z){const u=o.selection;for(let V=u.r1;V<=u.r2;V++)for(let O=u.c1;O<=u.c2;O++){const X=l.value[V].cells[O];X.merged||z(X)}n.recordHistory()}const R=e.ref("solid"),W=e.ref(.75),J=e.ref("#333333"),A=e.ref([]);function G(){return{width:W.value,style:R.value,color:J.value}}function K(z){mo(l.value,o.selection,z,G()),n.recordHistory()}function S(z){const u=z.target,V=new Set(A.value);u.checked?V.add(u.value):V.delete(u.value),A.value=[...V];const O=G();$(X=>{const Z={...X.borders??{}};for(const j of["top","right","bottom","left"])V.has(j)?Z[j]={...O}:delete Z[j];X.borders=Z})}const M=e.computed(()=>Bt(l.value,o.selection)),x=e.computed(()=>{const z=o.selection;for(let u=z.r1;u<=z.r2;u++)for(let V=z.c1;V<=z.c2;V++){const O=l.value[u].cells[V];if(!O.merged&&((O.rowspan??1)>1||(O.colspan??1)>1))return!0}return!1});function B(){Dt(l.value,o.selection),n.recordHistory()}function T(){Tt(l.value,o.selection),n.recordHistory()}return a({openFormatterEditor:H}),(z,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Ve,{title:"单元格",icon:"Menu","default-expanded":"","group-key":"table-cell"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:u[39]||(u[39]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Sr,[u[45]||(u[45]=e.createElementVNode("span",{class:"pd-label"},"单元格类型",-1)),e.createElementVNode("div",Mr,[e.createElementVNode("label",$r,[e.createElementVNode("input",{type:"radio",value:"text",checked:(r.value.cellType||"text")==="text",onChange:u[0]||(u[0]=V=>L(V.target.value))},null,40,xr),u[41]||(u[41]=e.createElementVNode("span",null,"文本",-1))]),e.createElementVNode("label",Br,[e.createElementVNode("input",{type:"radio",value:"barcode",checked:r.value.cellType==="barcode",onChange:u[1]||(u[1]=V=>L(V.target.value))},null,40,Dr),u[42]||(u[42]=e.createElementVNode("span",null,"条形码",-1))]),e.createElementVNode("label",Tr,[e.createElementVNode("input",{type:"radio",value:"qrcode",checked:r.value.cellType==="qrcode",onChange:u[2]||(u[2]=V=>L(V.target.value))},null,40,zr),u[43]||(u[43]=e.createElementVNode("span",null,"二维码",-1))]),e.createElementVNode("label",Lr,[e.createElementVNode("input",{type:"radio",value:"image",checked:r.value.cellType==="image",onChange:u[3]||(u[3]=V=>L(V.target.value))},null,40,Pr),u[44]||(u[44]=e.createElementVNode("span",null,"图片",-1))])])]),c.value?(e.openBlock(),e.createElementBlock("div",Ar,[u[47]||(u[47]=e.createElementVNode("span",{class:"pd-label"},"码制",-1)),e.createElementVNode("select",{value:r.value.barcodeType||"CODE128",class:"pd-select",onChange:u[4]||(u[4]=V=>$(O=>{O.barcodeType=V.target.value||void 0}))},[...u[46]||(u[46]=[e.createElementVNode("option",{value:"CODE128"},"CODE128(通用)",-1),e.createElementVNode("option",{value:"EAN13"},"EAN13(商品码)",-1),e.createElementVNode("option",{value:"EAN8"},"EAN8",-1),e.createElementVNode("option",{value:"UPC"},"UPC",-1),e.createElementVNode("option",{value:"CODE39"},"CODE39",-1),e.createElementVNode("option",{value:"ITF14"},"ITF14",-1)])],40,Ir)])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",Rr,[u[48]||(u[48]=e.createElementVNode("span",{class:"pd-label"},"显示文本",-1)),e.createElementVNode("input",{checked:r.value.showBarcodeText!==!1,type:"checkbox",class:"pd-switch",onInput:u[5]||(u[5]=V=>$(O=>{O.showBarcodeText=!!V.target.checked}))},null,40,Hr)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",Fr,[u[50]||(u[50]=e.createElementVNode("span",{class:"pd-label"},"纠错级别",-1)),e.createElementVNode("select",{value:r.value.qrCodeLevel||"M",class:"pd-select",onChange:u[6]||(u[6]=V=>$(O=>{O.qrCodeLevel=V.target.value||void 0}))},[...u[49]||(u[49]=[e.createElementVNode("option",{value:"L"},"L(最低,容量大)",-1),e.createElementVNode("option",{value:"M"},"M(推荐)",-1),e.createElementVNode("option",{value:"Q"},"Q",-1),e.createElementVNode("option",{value:"H"},"H(最高)",-1)])],40,Ur)])):e.createCommentVNode("",!0),c.value||d.value||p.value?(e.openBlock(),e.createElementBlock("div",Or,[u[52]||(u[52]=e.createElementVNode("span",{class:"pd-label"},"缩放模式",-1)),e.createElementVNode("select",{value:r.value.fit||"contain",class:"pd-select",onChange:u[7]||(u[7]=V=>$(O=>{O.fit=V.target.value}))},[...u[51]||(u[51]=[e.createElementVNode("option",{value:"contain"},"包含(保持比例)",-1),e.createElementVNode("option",{value:"cover"},"覆盖(保持比例)",-1),e.createElementVNode("option",{value:"fill"},"拉伸填满",-1),e.createElementVNode("option",{value:"none"},"原始尺寸",-1),e.createElementVNode("option",{value:"scale-down"},"缩小(保持比例)",-1)])],40,Gr)])):e.createCommentVNode("",!0),c.value||d.value||p.value?(e.openBlock(),e.createElementBlock("div",qr,[u[53]||(u[53]=e.createElementVNode("span",{class:"pd-label"},"最大宽度 (mm)",-1)),e.createVNode(ne,{"model-value":r.value.maxWidth,min:1,max:200,placeholder:"默认","onUpdate:modelValue":u[8]||(u[8]=V=>$(O=>{O.maxWidth=V??void 0}))},null,8,["model-value"])])):e.createCommentVNode("",!0),c.value||d.value||p.value?(e.openBlock(),e.createElementBlock("div",Wr,[u[54]||(u[54]=e.createElementVNode("span",{class:"pd-label"},"最大高度 (mm)",-1)),e.createVNode(ne,{"model-value":r.value.maxHeight,min:1,max:200,placeholder:"默认","onUpdate:modelValue":u[9]||(u[9]=V=>$(O=>{O.maxHeight=V??void 0}))},null,8,["model-value"])])):e.createCommentVNode("",!0),e.createElementVNode("div",Yr,[u[55]||(u[55]=e.createElementVNode("span",{class:"pd-label"},"内容",-1)),e.createElementVNode("input",{value:r.value.formatter||"",class:"pd-input",placeholder:"输入内容,支持 {字段} 表达式",onInput:u[10]||(u[10]=V=>$(O=>{O.formatter=V.target.value||void 0})),onDblclick:H},null,40,Kr)]),e.createElementVNode("div",Xr,[u[59]||(u[59]=e.createElementVNode("span",{class:"pd-label"},"水平对齐",-1)),e.createElementVNode("div",jr,[e.createElementVNode("label",Jr,[e.createElementVNode("input",{type:"radio",value:"left",checked:r.value.align==="left",onChange:u[11]||(u[11]=V=>v(V.target.value))},null,40,Zr),u[56]||(u[56]=e.createElementVNode("span",null,"左",-1))]),e.createElementVNode("label",Qr,[e.createElementVNode("input",{type:"radio",value:"center",checked:r.value.align==="center",onChange:u[12]||(u[12]=V=>v(V.target.value))},null,40,_r),u[57]||(u[57]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",es,[e.createElementVNode("input",{type:"radio",value:"right",checked:r.value.align==="right",onChange:u[13]||(u[13]=V=>v(V.target.value))},null,40,ts),u[58]||(u[58]=e.createElementVNode("span",null,"右",-1))])])]),e.createElementVNode("div",os,[u[63]||(u[63]=e.createElementVNode("span",{class:"pd-label"},"垂直对齐",-1)),e.createElementVNode("div",ns,[e.createElementVNode("label",ls,[e.createElementVNode("input",{type:"radio",value:"top",checked:r.value.valign==="top",onChange:u[14]||(u[14]=V=>w(V.target.value))},null,40,as),u[60]||(u[60]=e.createElementVNode("span",null,"上",-1))]),e.createElementVNode("label",is,[e.createElementVNode("input",{type:"radio",value:"middle",checked:r.value.valign==="middle",onChange:u[15]||(u[15]=V=>w(V.target.value))},null,40,rs),u[61]||(u[61]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",ss,[e.createElementVNode("input",{type:"radio",value:"bottom",checked:r.value.valign==="bottom",onChange:u[16]||(u[16]=V=>w(V.target.value))},null,40,ds),u[62]||(u[62]=e.createElementVNode("span",null,"下",-1))])])]),e.createElementVNode("div",cs,[e.createElementVNode("div",us,[u[65]||(u[65]=e.createElementVNode("span",{class:"pd-label"},"字体",-1)),e.createElementVNode("select",{value:r.value.fontFamily,class:"pd-select",placeholder:"继承默认",onChange:u[17]||(u[17]=V=>$(O=>{O.fontFamily=V.target.value||void 0}))},[...u[64]||(u[64]=[e.createElementVNode("option",{value:"SimSun"},"宋体",-1),e.createElementVNode("option",{value:"SimHei"},"黑体",-1),e.createElementVNode("option",{value:"Microsoft YaHei"},"微软雅黑",-1),e.createElementVNode("option",{value:"KaiTi"},"楷体",-1),e.createElementVNode("option",{value:"FangSong"},"仿宋",-1),e.createElementVNode("option",{value:"Arial"},"Arial",-1)])],40,ms)]),e.createElementVNode("div",ps,[u[66]||(u[66]=e.createElementVNode("span",{class:"pd-label"},"字号 (pt)",-1)),e.createVNode(ne,{"model-value":r.value.fontSize,min:5,max:72,placeholder:"默认","onUpdate:modelValue":u[18]||(u[18]=V=>$(O=>{O.fontSize=V??void 0}))},null,8,["model-value"])]),e.createElementVNode("div",fs,[u[67]||(u[67]=e.createElementVNode("span",{class:"pd-label"},"加粗",-1)),e.createElementVNode("input",{checked:r.value.fontWeight==="bold",type:"checkbox",class:"pd-switch",onInput:u[19]||(u[19]=V=>$(O=>{O.fontWeight=V.target.checked?"bold":void 0}))},null,40,vs)]),e.createElementVNode("div",gs,[u[68]||(u[68]=e.createElementVNode("span",{class:"pd-label"},"文字颜色",-1)),e.createVNode(we,{"model-value":r.value.color,"onUpdate:modelValue":u[20]||(u[20]=V=>$(O=>{O.color=V}))},null,8,["model-value"])]),e.createElementVNode("div",hs,[u[69]||(u[69]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(we,{"model-value":r.value.backgroundColor,"onUpdate:modelValue":u[21]||(u[21]=V=>$(O=>{O.backgroundColor=V}))},null,8,["model-value"])])]),u[77]||(u[77]=e.createElementVNode("h3",{class:"pd-divider"},"边框",-1)),e.createElementVNode("div",bs,[e.withDirectives(e.createElementVNode("select",{class:"pd-select","onUpdate:modelValue":u[22]||(u[22]=V=>R.value=V),style:{width:"90px"}},[...u[70]||(u[70]=[e.createElementVNode("option",{value:"solid"},"实线",-1),e.createElementVNode("option",{value:"dashed"},"虚线",-1),e.createElementVNode("option",{value:"dotted"},"点线",-1),e.createElementVNode("option",{value:"double"},"双线",-1)])],512),[[e.vModelSelect,R.value]]),e.createElementVNode("div",ys,[e.createVNode(ne,{modelValue:W.value,"onUpdate:modelValue":u[23]||(u[23]=V=>W.value=V),min:.25,max:5,step:.25},null,8,["modelValue"])]),e.createVNode(we,{modelValue:J.value,"onUpdate:modelValue":u[24]||(u[24]=V=>J.value=V)},null,8,["modelValue"])]),e.createElementVNode("div",ks,[e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:u[25]||(u[25]=V=>K("all"))},"全部"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:u[26]||(u[26]=V=>K("outer"))},"外侧"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:u[27]||(u[27]=V=>K("inner"))},"内部"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:u[28]||(u[28]=V=>K("none"))},"无")]),e.createElementVNode("div",Es,[e.createElementVNode("label",ws,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":u[29]||(u[29]=V=>A.value=V),value:"top",onChange:u[30]||(u[30]=V=>S(V))},null,544),[[e.vModelCheckbox,A.value]]),u[71]||(u[71]=e.createElementVNode("span",null,"上",-1))]),e.createElementVNode("label",Vs,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":u[31]||(u[31]=V=>A.value=V),value:"right",onChange:u[32]||(u[32]=V=>S(V))},null,544),[[e.vModelCheckbox,A.value]]),u[72]||(u[72]=e.createElementVNode("span",null,"右",-1))]),e.createElementVNode("label",Ns,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":u[33]||(u[33]=V=>A.value=V),value:"bottom",onChange:u[34]||(u[34]=V=>S(V))},null,544),[[e.vModelCheckbox,A.value]]),u[73]||(u[73]=e.createElementVNode("span",null,"下",-1))]),e.createElementVNode("label",Cs,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":u[35]||(u[35]=V=>A.value=V),value:"left",onChange:u[36]||(u[36]=V=>S(V))},null,544),[[e.vModelCheckbox,A.value]]),u[74]||(u[74]=e.createElementVNode("span",null,"左",-1))])]),e.createElementVNode("div",Ss,[u[75]||(u[75]=e.createElementVNode("span",{class:"pd-label"},"内边距 (mm)",-1)),e.createVNode(ne,{"model-value":r.value.padding,min:0,max:10,step:.5,placeholder:"默认","onUpdate:modelValue":u[37]||(u[37]=V=>$(O=>{O.padding=V??void 0}))},null,8,["model-value"])]),e.createElementVNode("div",Ms,[u[76]||(u[76]=e.createElementVNode("span",{class:"pd-label"},"自动换行",-1)),e.createElementVNode("input",{checked:r.value.wordWrap??!0,type:"checkbox",class:"pd-switch",onInput:u[38]||(u[38]=V=>$(O=>{O.wordWrap=!!V.target.checked}))},null,40,$s)]),e.createElementVNode("div",xs,[e.createElementVNode("button",{type:"button",class:"pd-button small",disabled:!!M.value,title:M.value||"",onClick:B}," 合并单元格 ",8,Bs),e.createElementVNode("button",{type:"button",class:"pd-button small",disabled:!x.value,onClick:T},"拆分单元格",8,Ds)])],32)]),_:1}),e.createVNode(ft,{modelValue:i.value,"onUpdate:modelValue":u[40]||(u[40]=V=>i.value=V),fields:t.fields,expression:s.value,"onUpdate:expression":D},null,8,["modelValue","fields","expression"])],64))}}),zs=_(Ts,[["__scopeId","data-v-e9669bd2"]]),Ls={text:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],longText:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],barcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],qrcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],image:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],table:[]};function Ot(t,a,o,n){return t==="data"?[{targetPath:`options.tableRows[${a}].cells[${o}].formatter`,label:"内容",dataSource:"list",listField:n,placeholder:"{name}"}]:t==="subtotal"?[{targetPath:`options.tableRows[${a}].cells[${o}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:t==="summary"?[{targetPath:`options.tableRows[${a}].cells[${o}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${a}].cells[${o}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function Ps(t){const a=t.printElementType.type,o=Ls[a]??[],n=[];if(a==="table"){const l=t.options.dataSource;for(const[r,i]of(t.options.tableRows??[]).entries())for(const[s,c]of i.cells.entries())c.merged||n.push(...Ot(i.type,r,s,l))}return[...o,...n]}const As={key:0,class:"prop-collapsed"},Is={class:"prop-head"},Rs={class:"pd-tabs prop-tabs"},Hs={class:"pd-tab-bar",role:"tablist"},Fs={class:"pd-tab-pane",role:"tabpanel"},Us={class:"property-content"},Os={key:1,class:"pd-empty"},Gs={class:"pd-tab-pane",role:"tabpanel"},qs={class:"pd-field"},Ws=["value"],Ys=["value"],Ks={key:0,class:"pd-field"},Xs={class:"custom-size-grid"},js={class:"pd-field"},Js={class:"pd-radio-group",role:"radiogroup"},Zs={class:"pd-radio"},Qs=["checked"],_s={class:"pd-radio"},ed=["checked"],td={class:"pd-field"},od={class:"page-bg-row"},nd={class:"margin-grid"},ld={class:"pd-field"},ad={class:"pd-field"},id={class:"pd-field"},rd={class:"pd-field"},sd={class:"pd-field"},dd={class:"pd-field"},cd={class:"pd-field"},ud=e.defineComponent({__name:"PropertyPanel",props:{element:{},templateData:{},fields:{},activeTab:{},tableSelection:{},recordHistory:{type:Function},collapsed:{type:Boolean}},emits:["delete-element","update:templateData","update:activeTab","toggle-collapse"],setup(t,{emit:a}){const o=t,n=a,l=nt,r=e.ref(""),i=e.computed(()=>o.element?["text","longText"].includes(o.element.printElementType.type):!1),s=e.computed(()=>o.element?o.element.printElementType.type==="image":!1),c=e.computed(()=>!o.element||o.element.printElementType.type!=="table"?!1:!!o.tableSelection&&o.tableSelection.elementId===o.element.id),d=e.computed(()=>o.element?o.element.printElementType.type==="table":!1),p=e.computed(()=>da(r.value)),v=e.computed(()=>p.value.groups),w=e.computed(()=>p.value.itemKeys),L=e.computed(()=>!!r.value.trim()),H=e.computed(()=>{if(!o.element)return[];if(o.element.printElementType.type==="table"&&o.tableSelection){const{r1:y,c1:b}=o.tableSelection,F=o.element.options.tableRows;if(F&&F[y]){const Y=F[y],ae=o.element.options.fields?.[0]?.dataSource;return Ot(Y.type,y,b,ae)}}return Ps(o.element)});function D(y){return y.split(".").flatMap(b=>{const F=b.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!F)return[b];const Y=F[1],ae=[...F[2].matchAll(/\[(\d+)\]/g)].map(re=>Number(re[1]));return[Y,...ae]})}function $(y){return o.element?D(y).reduce((Y,ae)=>Y==null?"":Y[ae],o.element)??"":""}function R(y,b){if(!o.element)return;const F=D(y),Y=F.pop(),ae=F.reduce((re,ve)=>((re[ve]===void 0||re[ve]===null)&&(re[ve]={}),re[ve]),o.element);ae[Y]=b||void 0,o.recordHistory?.()}function W(y){r.value=y}function J(y){o.element&&R("options.src",y)}const A=e.computed(()=>o.templateData?.paperSize||"A4"),G=e.computed(()=>o.templateData?.orientation||"portrait"),K=e.computed({get:()=>o.templateData?.pageBackground||"#ffffff",set:y=>ce(y)}),S=e.computed(()=>o.templateData?.margins.top??10),M=e.computed(()=>o.templateData?.margins.bottom??10),x=e.computed(()=>o.templateData?.margins.left??10),B=e.computed(()=>o.templateData?.margins.right??10),T=e.computed(()=>o.templateData?.header.height??10),z=e.computed(()=>o.templateData?.footer.height??10),u=e.computed(()=>o.templateData?.firstPageOverlay.height??0),V=e.computed(()=>o.templateData?.customWidth??210),O=e.computed(()=>o.templateData?.customHeight??297);function X(y){o.templateData&&n("update:templateData",{...o.templateData,...y})}function Z(y){if(y==="CUSTOM"){X({paperSize:"CUSTOM"});return}l[y]&&X({paperSize:y})}function j(y){X({orientation:String(y)})}function ce(y){const b=y&&y.toLowerCase()!=="#ffffff"&&y.toLowerCase()!=="#fff"?y:void 0;X(b===void 0?{pageBackground:void 0}:{pageBackground:b})}function ie(){X({pageBackground:void 0})}function se(y){y!==void 0&&X({customWidth:y})}function le(y){y!==void 0&&X({customHeight:y})}function P(y){y!==void 0&&X({margins:{...o.templateData.margins,top:y}})}function g(y){y!==void 0&&X({margins:{...o.templateData.margins,bottom:y}})}function E(y){y!==void 0&&X({margins:{...o.templateData.margins,left:y}})}function f(y){y!==void 0&&X({margins:{...o.templateData.margins,right:y}})}function m(y){y!==void 0&&X({header:{...o.templateData.header,height:y}})}function k(y){y!==void 0&&X({footer:{...o.templateData.footer,height:y}})}function h(y){y!==void 0&&X({firstPageOverlay:{...o.templateData.firstPageOverlay,height:y}})}const C=e.computed(()=>o.activeTab||"page");function N(y){n("update:activeTab",y),n("toggle-collapse")}return(y,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["property-panel",{collapsed:t.collapsed}])},[t.collapsed?(e.openBlock(),e.createElementBlock("div",As,[e.createElementVNode("button",{class:"pc-btn",title:"展开属性台",onClick:b[0]||(b[0]=F=>N(C.value))},"«"),e.createElementVNode("button",{class:e.normalizeClass(["pc-btn",{on:C.value==="element"}]),title:"元素属性",onClick:b[1]||(b[1]=F=>N("element"))},"▦",2),e.createElementVNode("button",{class:e.normalizeClass(["pc-btn",{on:C.value==="page"}]),title:"页面属性",onClick:b[2]||(b[2]=F=>N("page"))},"▤",2)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Is,[b[12]||(b[12]=e.createElementVNode("span",{class:"prop-title"},"属性台",-1)),e.createElementVNode("button",{class:"collapse-btn",title:"收起属性台",onClick:b[3]||(b[3]=F=>y.$emit("toggle-collapse"))},"»")]),e.createElementVNode("div",Rs,[e.createElementVNode("div",Hs,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:(t.activeTab||"page")==="element"}]),onClick:b[4]||(b[4]=F=>y.$emit("update:activeTab","element"))},"元素属性",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:(t.activeTab||"page")==="page"}]),onClick:b[5]||(b[5]=F=>y.$emit("update:activeTab","page"))},"页面属性",2)]),e.withDirectives(e.createElementVNode("div",Fs,[t.element?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(ma,{onSearch:W}),e.createElementVNode("div",Us,[v.value.includes("position-size")&&!c.value?(e.openBlock(),e.createBlock(xa,{key:0,element:t.element,"matched-keys":w.value,searching:L.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),v.value.includes("appearance")?(e.openBlock(),e.createBlock(ti,{key:1,element:t.element,"is-text-type":i.value,"matched-keys":w.value,searching:L.value},null,8,["element","is-text-type","matched-keys","searching"])):e.createCommentVNode("",!0),v.value.includes("binding")?(e.openBlock(),e.createBlock(Ve,{key:2,title:"内容",icon:"Document","default-expanded":"","group-key":"binding"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.value,F=>(e.openBlock(),e.createBlock(Fi,{key:F.targetPath,descriptor:F,fields:t.fields,"model-value":$(F.targetPath),"onUpdate:modelValue":Y=>R(F.targetPath,Y)},null,8,["descriptor","fields","model-value","onUpdate:modelValue"]))),128)),s.value?(e.openBlock(),e.createBlock(yr,{key:0,onSuccess:J})):e.createCommentVNode("",!0)]),_:1})):e.createCommentVNode("",!0),d.value&&t.tableSelection&&t.tableSelection.elementId===t.element.id?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(Cr,{element:t.element,selection:t.tableSelection},null,8,["element","selection"]),e.createVNode(zs,{element:t.element,selection:t.tableSelection,fields:t.fields},null,8,["element","selection","fields"])],64)):e.createCommentVNode("",!0),d.value&&v.value.includes("content")?(e.openBlock(),e.createBlock(Ji,{key:4,element:t.element,fields:t.fields},null,8,["element","fields"])):e.createCommentVNode("",!0),v.value.includes("border-bg")?(e.openBlock(),e.createBlock(or,{key:5,element:t.element,"matched-keys":w.value,searching:L.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),v.value.includes("pagination")&&d.value?(e.openBlock(),e.createBlock(Nt,{key:6,element:t.element,"matched-keys":w.value,searching:L.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),v.value.includes("pagination")&&!d.value?(e.openBlock(),e.createBlock(Nt,{key:7,element:t.element,"matched-keys":w.value,searching:L.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),v.value.includes("advanced")?(e.openBlock(),e.createBlock(dr,{key:8,element:t.element,"matched-keys":w.value,searching:L.value,onDeleteElement:b[6]||(b[6]=F=>y.$emit("delete-element"))},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0)])],64)):(e.openBlock(),e.createElementBlock("p",Os,"请在画布中选择一个元素"))],512),[[e.vShow,(t.activeTab||"page")==="element"]]),e.withDirectives(e.createElementVNode("div",Gs,[e.createElementVNode("form",{class:"pd-form",onSubmit:b[11]||(b[11]=e.withModifiers(()=>{},["prevent"]))},[b[28]||(b[28]=e.createElementVNode("h3",{class:"pd-divider"},"纸张设置",-1)),e.createElementVNode("div",qs,[b[14]||(b[14]=e.createElementVNode("span",{class:"pd-label"},"纸张尺寸",-1)),e.createElementVNode("select",{value:A.value,class:"pd-select",onChange:b[7]||(b[7]=F=>Z(F.target.value)),style:{width:"100%"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l),(F,Y)=>(e.openBlock(),e.createElementBlock("option",{key:Y,value:Y},e.toDisplayString(Y),9,Ys))),128)),b[13]||(b[13]=e.createElementVNode("option",{value:"CUSTOM"},"自定义",-1))],40,Ws)]),A.value==="CUSTOM"?(e.openBlock(),e.createElementBlock("div",Ks,[b[16]||(b[16]=e.createElementVNode("span",{class:"pd-label"},"自定义宽高 (mm)",-1)),e.createElementVNode("div",Xs,[e.createVNode(ne,{"model-value":V.value,min:25,max:2e3,"onUpdate:modelValue":se},null,8,["model-value"]),b[15]||(b[15]=e.createElementVNode("span",{class:"custom-size-x"},"×",-1)),e.createVNode(ne,{"model-value":O.value,min:25,max:2e3,"onUpdate:modelValue":le},null,8,["model-value"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",js,[b[19]||(b[19]=e.createElementVNode("span",{class:"pd-label"},"方向",-1)),e.createElementVNode("div",Js,[e.createElementVNode("label",Zs,[e.createElementVNode("input",{type:"radio",value:"portrait",checked:G.value==="portrait",onChange:b[8]||(b[8]=F=>j(F.target.value))},null,40,Qs),b[17]||(b[17]=e.createElementVNode("span",null,"纵向",-1))]),e.createElementVNode("label",_s,[e.createElementVNode("input",{type:"radio",value:"landscape",checked:G.value==="landscape",onChange:b[9]||(b[9]=F=>j(F.target.value))},null,40,ed),b[18]||(b[18]=e.createElementVNode("span",null,"横向",-1))])])]),e.createElementVNode("div",td,[b[20]||(b[20]=e.createElementVNode("span",{class:"pd-label"},"页面背景色",-1)),e.createElementVNode("div",od,[e.createVNode(we,{modelValue:K.value,"onUpdate:modelValue":b[10]||(b[10]=F=>K.value=F),class:"page-bg-picker"},null,8,["modelValue"]),e.createElementVNode("button",{type:"button",class:"pd-reset",title:"恢复为默认白色",onClick:ie},"默认")])]),b[29]||(b[29]=e.createElementVNode("h3",{class:"pd-divider"},"页边距 (mm)",-1)),e.createElementVNode("div",nd,[e.createElementVNode("div",ld,[b[21]||(b[21]=e.createElementVNode("span",{class:"pd-label"},"上",-1)),e.createVNode(ne,{"model-value":S.value,min:0,max:50,"onUpdate:modelValue":P},null,8,["model-value"])]),e.createElementVNode("div",ad,[b[22]||(b[22]=e.createElementVNode("span",{class:"pd-label"},"下",-1)),e.createVNode(ne,{"model-value":M.value,min:0,max:50,"onUpdate:modelValue":g},null,8,["model-value"])]),e.createElementVNode("div",id,[b[23]||(b[23]=e.createElementVNode("span",{class:"pd-label"},"左",-1)),e.createVNode(ne,{"model-value":x.value,min:0,max:50,"onUpdate:modelValue":E},null,8,["model-value"])]),e.createElementVNode("div",rd,[b[24]||(b[24]=e.createElementVNode("span",{class:"pd-label"},"右",-1)),e.createVNode(ne,{"model-value":B.value,min:0,max:50,"onUpdate:modelValue":f},null,8,["model-value"])])]),b[30]||(b[30]=e.createElementVNode("h3",{class:"pd-divider"},"三区高度 (mm)",-1)),e.createElementVNode("div",sd,[b[25]||(b[25]=e.createElementVNode("span",{class:"pd-label"},"页眉高度",-1)),e.createVNode(ne,{"model-value":T.value,min:0,max:100,step:.1,"onUpdate:modelValue":m},null,8,["model-value"])]),e.createElementVNode("div",dd,[b[26]||(b[26]=e.createElementVNode("span",{class:"pd-label"},"页脚高度",-1)),e.createVNode(ne,{"model-value":z.value,min:0,max:100,step:.1,"onUpdate:modelValue":k},null,8,["model-value"])]),e.createElementVNode("div",cd,[b[27]||(b[27]=e.createElementVNode("span",{class:"pd-label"},"首页叠加高度",-1)),e.createVNode(ne,{"model-value":u.value,min:0,max:200,"onUpdate:modelValue":h},null,8,["model-value"])])],32)],512),[[e.vShow,(t.activeTab||"page")==="page"]])])],64))],2))}}),md=_(ud,[["__scopeId","data-v-93072c2b"]]),pd={class:"status-bar"},fd={key:0,class:"status-item coord"},vd={class:"status-item"},gd={class:"status-item"},hd={class:"status-item status-paper"},bd=e.defineComponent({__name:"StatusBar",props:{coordinate:{},scale:{},elementCount:{},selectedCount:{},paper:{},dirty:{type:Boolean}},setup(t){return(a,o)=>(e.openBlock(),e.createElementBlock("div",pd,[t.coordinate?(e.openBlock(),e.createElementBlock("span",fd," x:"+e.toDisplayString(t.coordinate.x.toFixed(1))+" y:"+e.toDisplayString(t.coordinate.y.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0),e.createElementVNode("span",vd,"缩放 "+e.toDisplayString(t.scale)+"%",1),e.createElementVNode("span",gd,"元素 "+e.toDisplayString(t.elementCount)+e.toDisplayString(t.selectedCount?` (选中 ${t.selectedCount})`:""),1),e.createElementVNode("span",{class:e.normalizeClass(["status-dirty",{on:t.dirty}])},[o[0]||(o[0]=e.createElementVNode("span",{class:"dirty-dot"},null,-1)),e.createTextVNode(e.toDisplayString(t.dirty?"未保存":"已保存"),1)],2),e.createElementVNode("span",hd,e.toDisplayString(t.paper),1)]))}}),yd=_(bd,[["__scopeId","data-v-eb34e9a7"]]),kd={id:"getting-started",title:"快速入门",content:`
|
|
4
|
+
<h2>界面布局</h2>
|
|
5
|
+
<p>打印模板设计器采用三栏布局:</p>
|
|
6
|
+
<ul>
|
|
7
|
+
<li><strong>左侧面板</strong>:字段树和图层管理,用于查看和管理画布上的元素</li>
|
|
8
|
+
<li><strong>中间画布</strong>:设计区域,支持标尺、参考线、网格显示</li>
|
|
9
|
+
<li><strong>右侧面板</strong>:属性设置和模板配置</li>
|
|
10
|
+
<li><strong>顶部工具栏</strong>:常用操作按钮</li>
|
|
11
|
+
<li><strong>底部状态栏</strong>:显示坐标、缩放比例、元素数量</li>
|
|
12
|
+
</ul>
|
|
13
|
+
|
|
14
|
+
<h2>添加第一个元素</h2>
|
|
15
|
+
<ol>
|
|
16
|
+
<li>从左侧面板选择元素类型(文本、图片、条码等)</li>
|
|
17
|
+
<li>拖拽到画布上松开</li>
|
|
18
|
+
<li>选中元素后,通过拖拽调整位置</li>
|
|
19
|
+
<li>拖拽元素边角手柄调整大小</li>
|
|
20
|
+
</ol>
|
|
21
|
+
|
|
22
|
+
<h2>数据绑定基础</h2>
|
|
23
|
+
<p>使用花括号 <code>{field.path}</code> 语法绑定数据字段:</p>
|
|
24
|
+
<pre><code>供应商:{supplier.name}
|
|
25
|
+
日期:{order.date}
|
|
26
|
+
金额:{MONEY(order.total)}</code></pre>
|
|
27
|
+
<p>双击元素可打开表达式编辑器配置绑定。</p>
|
|
28
|
+
|
|
29
|
+
<h2>保存与预览</h2>
|
|
30
|
+
<ul>
|
|
31
|
+
<li>点击工具栏"保存"按钮,模板以 JSON 格式导出</li>
|
|
32
|
+
<li>点击"预览"按钮查看打印效果</li>
|
|
33
|
+
<li>模板数据包含页面设置、元素定义、样式配置</li>
|
|
34
|
+
</ul>
|
|
35
|
+
|
|
36
|
+
<h2>关于项目</h2>
|
|
37
|
+
<p><strong>项目名称:</strong>worm-vue3-print</p>
|
|
38
|
+
<p><strong>仓库地址:</strong><a href="https://gitee.com/liulong_oschina/worm-vue3-print" target="_blank" rel="noopener noreferrer">https://gitee.com/liulong_oschina/worm-vue3-print</a></p>
|
|
39
|
+
<p>基于 Vue 3 的可视化打印模板设计器,支持拖拽式模板编辑、表达式数据绑定和浏览器端打印预览。</p>
|
|
40
|
+
`},Ed={id:"features",title:"功能说明",content:`
|
|
41
|
+
<h2>元素类型</h2>
|
|
42
|
+
<table>
|
|
43
|
+
<thead>
|
|
44
|
+
<tr><th>类型</th><th>说明</th></tr>
|
|
45
|
+
</thead>
|
|
46
|
+
<tbody>
|
|
47
|
+
<tr><td>文本</td><td>静态或动态文本,支持表达式绑定</td></tr>
|
|
48
|
+
<tr><td>长文本</td><td>多行文本,支持自动换行</td></tr>
|
|
49
|
+
<tr><td>数据表格</td><td>动态行列,支持分页、表头重复、序号/小计/汇总</td></tr>
|
|
50
|
+
<tr><td>条形码</td><td>支持 code128 等多种码制</td></tr>
|
|
51
|
+
<tr><td>二维码</td><td>支持 L/M/Q/H 纠错级别</td></tr>
|
|
52
|
+
<tr><td>图片</td><td>静态或动态图片</td></tr>
|
|
53
|
+
<tr><td>线条</td><td>水平线或垂直线</td></tr>
|
|
54
|
+
<tr><td>形状</td><td>矩形、椭圆,支持边框和背景色</td></tr>
|
|
55
|
+
<tr><td>HTML</td><td>自定义 HTML 内容</td></tr>
|
|
56
|
+
<tr><td>页码</td><td>自动页码显示</td></tr>
|
|
57
|
+
</tbody>
|
|
58
|
+
</table>
|
|
59
|
+
|
|
60
|
+
<h2>表达式编辑器</h2>
|
|
61
|
+
<h3>基础语法</h3>
|
|
62
|
+
<p>使用花括号 <code>{}</code> 包裹表达式,花括号外为字面文本。</p>
|
|
63
|
+
|
|
64
|
+
<h3>内置函数</h3>
|
|
65
|
+
<table>
|
|
66
|
+
<thead>
|
|
67
|
+
<tr><th>函数</th><th>说明</th><th>示例</th></tr>
|
|
68
|
+
</thead>
|
|
69
|
+
<tbody>
|
|
70
|
+
<tr><td><code>MONEY(value)</code></td><td>金额格式化(千分位+两位小数)</td><td><code>{MONEY(order.total)}</code> -> "69,543.75"</td></tr>
|
|
71
|
+
<tr><td><code>DATE(value, format)</code></td><td>日期格式化</td><td><code>{DATE(order.date, 'YYYY-MM-DD')}</code></td></tr>
|
|
72
|
+
<tr><td><code>UPPER(value)</code></td><td>数字转大写金额</td><td><code>{UPPER(order.total)}</code> -> "陆万玖仟伍佰肆拾叁元柒角伍分"</td></tr>
|
|
73
|
+
<tr><td><code>IF(cond, true, false)</code></td><td>条件判断</td><td><code>{IF(qty > 100, '大量', '少量')}</code></td></tr>
|
|
74
|
+
<tr><td><code>CONCAT(str1, str2, ...)</code></td><td>字符串拼接</td><td><code>{CONCAT(name, '-', spec)}</code></td></tr>
|
|
75
|
+
<tr><td><code>IFEMPTY(value, default)</code></td><td>空值默认</td><td><code>{IFEMPTY(remark, '无')}</code></td></tr>
|
|
76
|
+
<tr><td><code>ROUND(num, decimals)</code></td><td>四舍五入</td><td><code>{ROUND(price, 2)}</code></td></tr>
|
|
77
|
+
<tr><td><code>NOW()</code></td><td>当前日期</td><td><code>{NOW()}</code></td></tr>
|
|
78
|
+
<tr><td><code>SUBSTR(str, start, len)</code></td><td>子字符串</td><td><code>{SUBSTR(name, 0, 3)}</code></td></tr>
|
|
79
|
+
<tr><td><code>LEN(str)</code></td><td>字符串长度</td><td><code>{LEN(name)}</code></td></tr>
|
|
80
|
+
<tr><td><code>PAD(value, len, char)</code></td><td>左侧补位</td><td><code>{PAD(qty, 5, '0')}</code></td></tr>
|
|
81
|
+
</tbody>
|
|
82
|
+
</table>
|
|
83
|
+
|
|
84
|
+
<h3>聚合函数(表格小计/汇总行使用)</h3>
|
|
85
|
+
<table>
|
|
86
|
+
<thead>
|
|
87
|
+
<tr><th>函数</th><th>说明</th></tr>
|
|
88
|
+
</thead>
|
|
89
|
+
<tbody>
|
|
90
|
+
<tr><td><code>SUM(field)</code></td><td>求和</td></tr>
|
|
91
|
+
<tr><td><code>AVG(field)</code></td><td>平均值</td></tr>
|
|
92
|
+
<tr><td><code>COUNT(field)</code></td><td>计数</td></tr>
|
|
93
|
+
<tr><td><code>MIN(field)</code></td><td>最小值</td></tr>
|
|
94
|
+
<tr><td><code>MAX(field)</code></td><td>最大值</td></tr>
|
|
95
|
+
</tbody>
|
|
96
|
+
</table>
|
|
97
|
+
|
|
98
|
+
<h3>系统变量</h3>
|
|
99
|
+
<table>
|
|
100
|
+
<thead>
|
|
101
|
+
<tr><th>变量</th><th>说明</th></tr>
|
|
102
|
+
</thead>
|
|
103
|
+
<tbody>
|
|
104
|
+
<tr><td><code>pageIndex</code></td><td>当前页码</td></tr>
|
|
105
|
+
<tr><td><code>totalPages</code></td><td>总页数</td></tr>
|
|
106
|
+
<tr><td><code>printDate</code></td><td>打印日期 (YYYY-MM-DD)</td></tr>
|
|
107
|
+
<tr><td><code>printTime</code></td><td>打印时间戳</td></tr>
|
|
108
|
+
</tbody>
|
|
109
|
+
</table>
|
|
110
|
+
|
|
111
|
+
<h2>数据表格配置</h2>
|
|
112
|
+
<h3>行类型</h3>
|
|
113
|
+
<ul>
|
|
114
|
+
<li><strong>标题行 (header)</strong>:可设置每页重复显示</li>
|
|
115
|
+
<li><strong>数据行 (data)</strong>:绑定列表数据源迭代显示</li>
|
|
116
|
+
<li><strong>小计行 (subtotal)</strong>:当前页末尾显示汇总</li>
|
|
117
|
+
<li><strong>汇总行 (summary)</strong>:仅最后一页显示</li>
|
|
118
|
+
</ul>
|
|
119
|
+
|
|
120
|
+
<h3>表格操作</h3>
|
|
121
|
+
<ul>
|
|
122
|
+
<li>右键菜单支持插入/删除行和列</li>
|
|
123
|
+
<li>支持单元格合并/拆分</li>
|
|
124
|
+
<li>支持边框预设:全部/外边框/内边框/无</li>
|
|
125
|
+
<li>无边框表格设计态显示虚拟虚线</li>
|
|
126
|
+
<li><strong>调整列宽</strong>:需要先在左侧面板的图层中选中对应的表格元素,然后才能在画布上拖动列宽分隔线</li>
|
|
127
|
+
<li><strong>调整表格属性</strong>:必须确保当前没有任何单元格被选中。如有选中的单元格,先点击画布空白区域取消选中,再在图层中选择表格元素</li>
|
|
128
|
+
<li><strong>单元格图片处理</strong>:若单元格中图片无法缩小,请将图片处理方式设置为"缩小保持比例"</li>
|
|
129
|
+
</ul>
|
|
130
|
+
|
|
131
|
+
<h2>对齐与吸附</h2>
|
|
132
|
+
<h3>自动对齐</h3>
|
|
133
|
+
<p>拖拽元素时自动显示对齐引导线:</p>
|
|
134
|
+
<ul>
|
|
135
|
+
<li>蓝色:左/顶对齐</li>
|
|
136
|
+
<li>绿色:居中对齐</li>
|
|
137
|
+
<li>橙色:右/底对齐</li>
|
|
138
|
+
</ul>
|
|
139
|
+
|
|
140
|
+
<h3>网格吸附</h3>
|
|
141
|
+
<p>开启吸附功能后,元素自动吸附到网格点。</p>
|
|
142
|
+
|
|
143
|
+
<h3>手动参考线</h3>
|
|
144
|
+
<p>通过标尺区域拖拽添加参考线,参考线参与吸附检测。</p>
|
|
145
|
+
|
|
146
|
+
<h2>图层管理</h2>
|
|
147
|
+
<ul>
|
|
148
|
+
<li>调整元素显示顺序(置顶/置底/上移/下移)</li>
|
|
149
|
+
<li>显示/隐藏元素</li>
|
|
150
|
+
<li>锁定/解锁元素(锁定后不可编辑)</li>
|
|
151
|
+
</ul>
|
|
152
|
+
|
|
153
|
+
<h2>三区布局</h2>
|
|
154
|
+
<p>页面分为三个区域:</p>
|
|
155
|
+
<ul>
|
|
156
|
+
<li><strong>页眉 (header)</strong>:顶部区域</li>
|
|
157
|
+
<li><strong>内容区 (content)</strong>:主体区域</li>
|
|
158
|
+
<li><strong>页脚 (footer)</strong>:底部区域</li>
|
|
159
|
+
</ul>
|
|
160
|
+
<p>页眉/页脚支持的元素类型:文本、图片、线条、形状、条形码、二维码</p>
|
|
161
|
+
|
|
162
|
+
<h2>水印配置</h2>
|
|
163
|
+
<ul>
|
|
164
|
+
<li>支持固定文本或绑定字段</li>
|
|
165
|
+
<li>可设置旋转角度和透明度</li>
|
|
166
|
+
<li>支持显示打印时间戳</li>
|
|
167
|
+
</ul>
|
|
168
|
+
`},wd={id:"shortcuts",title:"快捷键",content:`
|
|
169
|
+
<h2>常用操作</h2>
|
|
170
|
+
<table>
|
|
171
|
+
<thead>
|
|
172
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
173
|
+
</thead>
|
|
174
|
+
<tbody>
|
|
175
|
+
<tr><td><code>Ctrl + C</code></td><td>复制选中元素</td></tr>
|
|
176
|
+
<tr><td><code>Ctrl + V</code></td><td>粘贴元素(偏移 10mm)</td></tr>
|
|
177
|
+
<tr><td><code>Ctrl + D</code></td><td>原地复制(偏移 5mm, 5mm)</td></tr>
|
|
178
|
+
<tr><td><code>Ctrl + A</code></td><td>全选元素</td></tr>
|
|
179
|
+
<tr><td><code>Delete / Backspace</code></td><td>删除选中元素</td></tr>
|
|
180
|
+
<tr><td><code>Ctrl + Z</code></td><td>撤销</td></tr>
|
|
181
|
+
<tr><td><code>Ctrl + Shift + Z</code> / <code>Ctrl + Y</code></td><td>重做</td></tr>
|
|
182
|
+
</tbody>
|
|
183
|
+
</table>
|
|
184
|
+
|
|
185
|
+
<h2>元素移动</h2>
|
|
186
|
+
<table>
|
|
187
|
+
<thead>
|
|
188
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
189
|
+
</thead>
|
|
190
|
+
<tbody>
|
|
191
|
+
<tr><td><code>方向键</code></td><td>移动 1mm</td></tr>
|
|
192
|
+
<tr><td><code>Shift + 方向键</code></td><td>移动 10mm</td></tr>
|
|
193
|
+
<tr><td><code>Ctrl + 方向键</code></td><td>移动 0.5mm</td></tr>
|
|
194
|
+
</tbody>
|
|
195
|
+
</table>
|
|
196
|
+
|
|
197
|
+
<h2>缩放控制</h2>
|
|
198
|
+
<table>
|
|
199
|
+
<thead>
|
|
200
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
201
|
+
</thead>
|
|
202
|
+
<tbody>
|
|
203
|
+
<tr><td><code>Ctrl + 1</code></td><td>重置缩放至 100%</td></tr>
|
|
204
|
+
<tr><td><code>Ctrl + 0</code></td><td>适应窗口</td></tr>
|
|
205
|
+
</tbody>
|
|
206
|
+
</table>
|
|
207
|
+
|
|
208
|
+
<h2>对齐操作(多选时)</h2>
|
|
209
|
+
<table>
|
|
210
|
+
<thead>
|
|
211
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
212
|
+
</thead>
|
|
213
|
+
<tbody>
|
|
214
|
+
<tr><td><code>Ctrl + L</code></td><td>左对齐</td></tr>
|
|
215
|
+
<tr><td><code>Ctrl + R</code></td><td>右对齐</td></tr>
|
|
216
|
+
<tr><td><code>Ctrl + E</code></td><td>水平居中</td></tr>
|
|
217
|
+
<tr><td><code>Ctrl + T</code></td><td>顶对齐</td></tr>
|
|
218
|
+
<tr><td><code>Ctrl + B</code></td><td>底对齐</td></tr>
|
|
219
|
+
</tbody>
|
|
220
|
+
</table>
|
|
221
|
+
|
|
222
|
+
<h2>组合操作</h2>
|
|
223
|
+
<table>
|
|
224
|
+
<thead>
|
|
225
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
226
|
+
</thead>
|
|
227
|
+
<tbody>
|
|
228
|
+
<tr><td><code>Ctrl + G</code></td><td>组合选中元素</td></tr>
|
|
229
|
+
<tr><td><code>Ctrl + Shift + G</code></td><td>取消组合</td></tr>
|
|
230
|
+
</tbody>
|
|
231
|
+
</table>
|
|
232
|
+
|
|
233
|
+
<blockquote>
|
|
234
|
+
<p><strong>注意</strong>:当焦点在输入框、文本框、下拉框内时,快捷键不生效。</p>
|
|
235
|
+
</blockquote>
|
|
236
|
+
`},Vd={id:"faq",title:"常见问题",content:`
|
|
237
|
+
<h2>如何调整纸张大小?</h2>
|
|
238
|
+
<ol>
|
|
239
|
+
<li>在右侧面板选择"页面设置"</li>
|
|
240
|
+
<li>选择预设纸张(A4、A3、A5、Letter、Legal)</li>
|
|
241
|
+
<li>或选择"自定义"输入宽度和高度(mm)</li>
|
|
242
|
+
<li>设置方向:纵向(portrait)或横向(landscape)</li>
|
|
243
|
+
</ol>
|
|
244
|
+
|
|
245
|
+
<h2>如何处理分页?</h2>
|
|
246
|
+
<p>数据表格支持自动分页:</p>
|
|
247
|
+
<ol>
|
|
248
|
+
<li>在表格属性中设置"每页显示行数"</li>
|
|
249
|
+
<li>启用"表头重复"确保跨页时显示标题行</li>
|
|
250
|
+
<li>添加小计行显示当前页汇总</li>
|
|
251
|
+
<li>添加汇总行显示整表汇总</li>
|
|
252
|
+
</ol>
|
|
253
|
+
|
|
254
|
+
<h2>如何导入外部数据?</h2>
|
|
255
|
+
<p>通过组件 props 传入数据:</p>
|
|
256
|
+
<ul>
|
|
257
|
+
<li><code>fields</code>:字段定义数组,用于字段树显示</li>
|
|
258
|
+
<li><code>initialTemplate</code>:初始模板数据</li>
|
|
259
|
+
<li><code>loadDefaultTemplate</code>:加载默认模板的回调函数</li>
|
|
260
|
+
</ul>
|
|
261
|
+
|
|
262
|
+
<h2>如何使用表达式绑定字段?</h2>
|
|
263
|
+
<ol>
|
|
264
|
+
<li>双击元素打开表达式编辑器</li>
|
|
265
|
+
<li>使用 <code>{field.path}</code> 语法绑定字段</li>
|
|
266
|
+
<li>使用内置函数格式化数据(如 <code>{MONEY(price)}</code>)</li>
|
|
267
|
+
<li>点击确认保存</li>
|
|
268
|
+
</ol>
|
|
269
|
+
|
|
270
|
+
<h2>如何调整元素层级?</h2>
|
|
271
|
+
<ol>
|
|
272
|
+
<li>选中一个或多个元素</li>
|
|
273
|
+
<li>点击工具栏的层级按钮:
|
|
274
|
+
<ul>
|
|
275
|
+
<li>⤒ 置顶</li>
|
|
276
|
+
<li>↑ 上移一层</li>
|
|
277
|
+
<li>↓ 下移一层</li>
|
|
278
|
+
<li>⤓ 置底</li>
|
|
279
|
+
</ul>
|
|
280
|
+
</li>
|
|
281
|
+
</ol>
|
|
282
|
+
<p>或使用快捷键在图层面板中调整。</p>
|
|
283
|
+
|
|
284
|
+
<h2>如何组合多个元素?</h2>
|
|
285
|
+
<ol>
|
|
286
|
+
<li>按住 Ctrl 逐个点击选中多个元素</li>
|
|
287
|
+
<li>点击工具栏"组合"按钮,或按 <code>Ctrl + G</code></li>
|
|
288
|
+
<li>组合后点击任一元素可选中整个组</li>
|
|
289
|
+
<li>取消组合:选中组合后点击"取消组合",或按 <code>Ctrl + Shift + G</code></li>
|
|
290
|
+
</ol>
|
|
291
|
+
|
|
292
|
+
<h2>如何使用参考线?</h2>
|
|
293
|
+
<ol>
|
|
294
|
+
<li>在标尺区域拖拽添加参考线</li>
|
|
295
|
+
<li>参考线自动参与吸附检测</li>
|
|
296
|
+
<li>拖拽参考线可调整位置</li>
|
|
297
|
+
<li>双击参考线可删除</li>
|
|
298
|
+
</ol>
|
|
299
|
+
|
|
300
|
+
<h2>如何预览打印效果?</h2>
|
|
301
|
+
<ol>
|
|
302
|
+
<li>点击工具栏"预览"按钮</li>
|
|
303
|
+
<li>预览使用同构渲染管线,确保与实际打印一致</li>
|
|
304
|
+
<li>可通过"叠层对比"功能对比设计稿与截图</li>
|
|
305
|
+
</ol>
|
|
306
|
+
|
|
307
|
+
<h2>模板数据格式是什么?</h2>
|
|
308
|
+
<p>模板以 JSON 格式存储,包含:</p>
|
|
309
|
+
<ul>
|
|
310
|
+
<li><code>paperSize</code>:纸张大小</li>
|
|
311
|
+
<li><code>orientation</code>:方向</li>
|
|
312
|
+
<li><code>margins</code>:页边距</li>
|
|
313
|
+
<li><code>header</code>:页眉配置</li>
|
|
314
|
+
<li><code>footer</code>:页脚配置</li>
|
|
315
|
+
<li><code>elements</code>:元素数组</li>
|
|
316
|
+
<li><code>watermark</code>:水印配置</li>
|
|
317
|
+
</ul>
|
|
318
|
+
|
|
319
|
+
<h2>如何调整表格列宽?</h2>
|
|
320
|
+
<ol>
|
|
321
|
+
<li>在左侧面板的图层列表中,点击选中对应的表格元素</li>
|
|
322
|
+
<li>此时画布上的表格会显示列宽分隔线</li>
|
|
323
|
+
<li>拖动列宽分隔线即可调整列宽</li>
|
|
324
|
+
</ol>
|
|
325
|
+
<blockquote>
|
|
326
|
+
<p><strong>注意</strong>:必须先选中表格元素,才能激活列宽拖动功能。</p>
|
|
327
|
+
</blockquote>
|
|
328
|
+
|
|
329
|
+
<h2>如何调整表格属性?</h2>
|
|
330
|
+
<ol>
|
|
331
|
+
<li>确保当前没有任何单元格被选中(如有选中,点击画布空白区域取消选中)</li>
|
|
332
|
+
<li>在左侧面板的图层列表中,点击选中对应的表格元素</li>
|
|
333
|
+
<li>右侧面板会显示表格属性设置</li>
|
|
334
|
+
</ol>
|
|
335
|
+
<blockquote>
|
|
336
|
+
<p><strong>注意</strong>:如果存在选中的单元格,右侧面板将显示单元格属性而非表格属性。</p>
|
|
337
|
+
</blockquote>
|
|
338
|
+
`},Nd={id:"changelog",title:"更新记录",content:`
|
|
339
|
+
<h2>v1.2.1 <small>2026-09-11</small></h2>
|
|
340
|
+
|
|
341
|
+
<h3>变更</h3>
|
|
342
|
+
<ul>
|
|
343
|
+
<li>工具栏编辑区/层级区/视图区图标按钮统一使用 data-tip 自定义悬浮提示,补齐「网格」「吸附」缺失提示;提升提示层级,不再被画布顶部标尺遮挡。</li>
|
|
344
|
+
<li>优化「适应窗口」:以视口中心为锚点一步缩放到位(与 Ctrl+滚轮同一缩放换算管线),缩放平滑过渡;允许低于交互缩放下限(最小可至 5%),超大纸张也能整版容纳,纸张在画布视口内水平垂直居中。</li>
|
|
345
|
+
<li>新增 <code>showHelp</code> 配置:控制帮助入口(帮助按钮与帮助弹框)显示,默认开启,传入 <code>false</code> 即可隐藏。</li>
|
|
346
|
+
</ul>
|
|
347
|
+
|
|
348
|
+
<h3>修复</h3>
|
|
349
|
+
<ul>
|
|
350
|
+
<li>工具栏悬浮提示气泡被画布顶部固定标尺遮挡无法显示。</li>
|
|
351
|
+
<li>「适应窗口」后超大纸张仍残留滚动条、纸张未在画布视口居中(垂直偏上)。</li>
|
|
352
|
+
</ul>
|
|
353
|
+
|
|
354
|
+
<h3>文档</h3>
|
|
355
|
+
<ul>
|
|
356
|
+
<li>新增打印设计工作台布局线框图文档(<code>docs/中文/打印设计工作台-布局线框图.md</code>),标注各区域名称、功能与对应组件文件。</li>
|
|
357
|
+
</ul>
|
|
358
|
+
|
|
359
|
+
<h2>v1.2.0 <small>2026-09-10</small></h2>
|
|
360
|
+
|
|
361
|
+
<h3>新增</h3>
|
|
362
|
+
<ul>
|
|
363
|
+
<li>帮助文档模态框(HelpModal):内置功能介绍、快捷键一览、常见问题与更新记录,按 Esc 或点击遮罩关闭。</li>
|
|
364
|
+
<li>标尺参考线增强:支持从标尺拖拽添加参考线、双击编辑、删除,参考线对齐吸附实时显示。</li>
|
|
365
|
+
<li>表格列宽拖拽新增末列右边界手柄:可直接拖拽末列右边界调整末列宽,受打印范围宽度与最小列宽 5mm 钳制。</li>
|
|
366
|
+
</ul>
|
|
367
|
+
|
|
368
|
+
<h3>变更</h3>
|
|
369
|
+
<ul>
|
|
370
|
+
<li>优化缩放逻辑:取消放大上限,支持滚轮乘性步进缩放,修复缩放锚点漂移问题。</li>
|
|
371
|
+
<li>移除设计态元素左上角的 fx 绑定标签提示,简化元素视觉呈现。</li>
|
|
372
|
+
</ul>
|
|
373
|
+
|
|
374
|
+
<h3>文档</h3>
|
|
375
|
+
<ul>
|
|
376
|
+
<li>仓库根目录新增 <code>AGENTS.md</code>:AI 代理行为规范,明确代理在本仓库工作时的语言、专家态度、协作约定等强制要求。</li>
|
|
377
|
+
<li>新增 <code>worm-vue3-print</code> 集成支持 skill:包含安装指南、集成 API、故障排查等参考文档。</li>
|
|
378
|
+
</ul>
|
|
379
|
+
|
|
380
|
+
<h3>修复</h3>
|
|
381
|
+
<ul>
|
|
382
|
+
<li>表格列宽拖拽存在的多个缺陷:
|
|
383
|
+
<ul>
|
|
384
|
+
<li>内部列边界向左拖时左列宽度不变,导致边界线不跟随光标。</li>
|
|
385
|
+
<li>px → mm 单位换算缺失,拖拽距离存在约 3.78 倍偏差。</li>
|
|
386
|
+
<li><code>table-layout: fixed</code> 下拖拽过程中表格 CSS <code>width(100%)</code> 与列宽和失配,导致浏览器按比例拉伸列,使边界线与右侧内容偏离光标。</li>
|
|
387
|
+
<li>删除 <code>onColResizeStart</code> 中残留的 <code>document.title</code> 调试代码。</li>
|
|
388
|
+
</ul>
|
|
389
|
+
</li>
|
|
390
|
+
</ul>
|
|
391
|
+
|
|
392
|
+
<h2>v1.1.0 <small>2026-09-06</small></h2>
|
|
393
|
+
|
|
394
|
+
<h3>新增</h3>
|
|
395
|
+
<ul>
|
|
396
|
+
<li>表格元素支持列宽拖拽:设计态选中表格后,在列边界悬停并拖动即可调整该列宽(左侧列),实时更新画布与元素尺寸;受打印范围宽度与最小列宽 5mm 钳制,拖拽结束后计入一次撤销历史。属性面板的列宽数值输入保留作为精确输入兜底。</li>
|
|
397
|
+
<li>表格单元格支持图片类型:单元格可切换为图片类型,设计态支持选择图片与设置 fit/maxWidth/maxHeight,预览与打印输出完整渲染。</li>
|
|
398
|
+
<li>条形码与二维码单元格支持 fit/maxWidth/maxHeight 属性。</li>
|
|
399
|
+
<li>属性面板位置尺寸改用 StepperInput 控件:支持按钮微调数值;StepperInput 支持可选值列表和小数步进。</li>
|
|
400
|
+
<li>新增统一颜色选择器并重构属性面板字段分组。</li>
|
|
401
|
+
<li>支持页面(纸张)背景色 <code>pageBackground</code>,预览与打印/PDF 输出一致。</li>
|
|
402
|
+
<li>支持 canvas 库模式构建与 npm 发布。</li>
|
|
403
|
+
</ul>
|
|
404
|
+
|
|
405
|
+
<h3>修复</h3>
|
|
406
|
+
<ul>
|
|
407
|
+
<li>打印/导出 PDF 保留元素背景色(<code>print-color-adjust: exact</code>)。</li>
|
|
408
|
+
<li>打印预览保留元素重叠,表格下方跟随元素按设计坐标绝对定位并透传层级 z-index。</li>
|
|
409
|
+
<li>打印页眉页脚区域贴页面底部,修复页边距失效。</li>
|
|
410
|
+
<li>条形码渲染缺少 <code>object-fit: contain</code>。</li>
|
|
411
|
+
<li>修复 canvas 测试在 vitest v4 + happy-dom 环境下 <code>localStorage</code> 未定义的问题,补充 mock 以兼容测试环境。</li>
|
|
412
|
+
</ul>
|
|
413
|
+
|
|
414
|
+
<h2>v1.0.0 <small>2026-09-02</small></h2>
|
|
415
|
+
|
|
416
|
+
<h3>新增</h3>
|
|
417
|
+
<ul>
|
|
418
|
+
<li>首次开源发布。</li>
|
|
419
|
+
<li><code>@worm-vue3-print/core</code>:模板表达式引擎与同构渲染管线(HTML 生成 / 分页 / 数据绑定)。</li>
|
|
420
|
+
<li><code>@worm-vue3-print/canvas</code>:Vue 3 可视化打印模板设计器画布。</li>
|
|
421
|
+
<li>渲染微服务拆分为独立仓库 <code>worm-vue3-print-render</code>(仅 Docker 部署,不上 npm)。</li>
|
|
422
|
+
</ul>
|
|
423
|
+
|
|
424
|
+
<blockquote>
|
|
425
|
+
<p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
|
|
426
|
+
</blockquote>
|
|
427
|
+
`},Cd=[kd,Ed,wd,Vd,Nd],Sd={class:"help-modal"},Md={class:"help-modal-header"},$d={class:"help-modal-body"},xd={class:"help-modal-sidebar"},Bd=["onClick"],Dd={class:"help-modal-content"},Td=["innerHTML"],et="worm-print-help-tab",zd=e.defineComponent({__name:"HelpModal",props:{visible:{type:Boolean},initialTab:{default:"getting-started"}},emits:["close","update:tab"],setup(t,{emit:a}){const o=t,n=a,l=Cd,r=e.ref(o.initialTab);e.onMounted(()=>{const d=localStorage.getItem(et);d&&l.some(p=>p.id===d)&&(r.value=d)}),e.watch(()=>o.visible,d=>{if(d){const p=localStorage.getItem(et);p&&l.some(v=>v.id===p)&&(r.value=p)}});function i(d){r.value=d,localStorage.setItem(et,d),n("update:tab",d)}const s=e.computed(()=>l.find(p=>p.id===r.value)?.content||"");function c(d){d.key==="Escape"&&o.visible&&n("close")}return e.onMounted(()=>{document.addEventListener("keydown",c)}),e.onUnmounted(()=>{document.removeEventListener("keydown",c)}),(d,p)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"help-modal"},{default:e.withCtx(()=>[t.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:"help-modal-overlay",onClick:p[1]||(p[1]=e.withModifiers(v=>d.$emit("close"),["self"]))},[e.createElementVNode("div",Sd,[e.createElementVNode("div",Md,[p[2]||(p[2]=e.createElementVNode("div",{class:"help-modal-title-wrap"},[e.createElementVNode("h2",{class:"help-modal-title"},"帮助文档"),e.createElementVNode("span",{class:"help-modal-project"},"worm-vue3-print")],-1)),e.createElementVNode("button",{class:"help-modal-close",title:"关闭",onClick:p[0]||(p[0]=v=>d.$emit("close"))}," × ")]),e.createElementVNode("div",$d,[e.createElementVNode("div",xd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l),v=>(e.openBlock(),e.createElementBlock("button",{key:v.id,class:e.normalizeClass(["help-tab",{active:r.value===v.id}]),onClick:w=>i(v.id)},e.toDisplayString(v.title),11,Bd))),128))]),e.createElementVNode("div",Dd,[e.createElementVNode("div",{class:"help-content",innerHTML:s.value},null,8,Td)])])])])):e.createCommentVNode("",!0)]),_:1})]))}}),Ld=_(zd,[["__scopeId","data-v-31115934"]]),Ct="print-studio:left",St="print-studio:right";function Mt(t,a){try{const o=localStorage.getItem(t);return o===null?a:o==="1"}catch{return a}}function Pd(){const t=e.ref(Mt(Ct,!1)),a=e.ref(Mt(St,!1)),o=e.ref(!1);e.watch(t,i=>{try{localStorage.setItem(Ct,i?"1":"0")}catch{}},{flush:"sync"}),e.watch(a,i=>{try{localStorage.setItem(St,i?"1":"0")}catch{}},{flush:"sync"});function n(){t.value=!t.value}function l(){a.value=!a.value}function r(){o.value=!1}return{leftCollapsed:t,rightCollapsed:a,toggleLeft:n,toggleRight:l,dirty:o,markSaved:r}}const Ad={class:"designer-container"},Id={class:"designer-body"},Rd=e.defineComponent({__name:"PrintDesigner",props:{initialTemplate:{},initialElements:{},fields:{},isEdit:{type:Boolean},requestScreenshot:{type:Function},uploadImage:{type:Function},loadDefaultTemplate:{type:Function},showHelp:{type:Boolean}},emits:["preview","save"],setup(t,{expose:a,emit:o}){const n=t,l=o,r=e.ref(!1);e.watch(()=>n.showHelp,I=>{I===!1&&(r.value=!1)});const{leftCollapsed:i,rightCollapsed:s,toggleLeft:c,toggleRight:d,dirty:p,markSaved:v}=Pd(),{scale:w,showRuler:L,showGrid:H,snapToGrid:D,showTableGhostBorder:$,templateData:R,elements:W,fields:J,selectedIds:A,selectedElement:G,select:K,clearSelection:S,selectAll:M,previewIds:x,setPreview:B,commitPreview:T,hasClipboard:z,copy:u,paste:V,cutSelected:O,canUndo:X,canRedo:Z,undo:j,redo:ce,alignSelected:ie,groupSelected:se,ungroupSelected:le,deleteSelected:P,dragStart:g,dragStop:E,addElement:f,addFieldElement:m,moveLayer:k,updateTemplateData:h,getTemplateJson:C,loadTemplate:N,tableSelection:y,setTableSelection:b,recordHistory:F}=Uo({initialTemplate:n.initialTemplate,initialElements:n.initialElements,initialFields:n.fields});e.watch([W,R],()=>{p.value=!0},{deep:!0});const{guides:Y,addGuide:ae,moveGuide:re,removeGuide:ve}=Go(R,F),xe=e.computed(()=>{const I=R.value,{width:U}=Ee(I);return U-I.margins.left-I.margins.right});e.provide(Pe,{tableSelection:y,setTableSelection:b,recordHistory:F,maxTableWidth:xe}),e.provide(It,A),e.provide(Rt,x),e.provide(pt,e.computed(()=>n.uploadImage)),e.watch(G,I=>{(!I||I.printElementType.type!=="table")&&b(null)});const be=e.ref(null),ye=e.ref(!1),Ne=e.ref(""),Ke=e.ref(.5);async function Xe(){if(ye.value){ye.value=!1;return}const I=C();if(!I){alert("模板数据为空");return}if(!n.requestScreenshot){alert("截图服务未配置");return}try{const U=await n.requestScreenshot({templateJson:I,printData:ge});Ne.value&&URL.revokeObjectURL(Ne.value),Ne.value=URL.createObjectURL(U),ye.value=!0}catch{alert("截图生成失败")}}const Ae=e.ref(null);function je(I){Ae.value=I}const Je=e.computed(()=>{const I=R.value,U=Ee(I),te=I.orientation==="landscape"?"横向":"纵向";return`${I.paperSize} ${te} ${Math.round(U.width)}×${Math.round(U.height)}mm`});function q(){const I=be.value?.$el;if(I){const U=getComputedStyle(I),te=parseFloat(U.paddingLeft)+parseFloat(U.paddingRight),me=parseFloat(U.paddingTop)+parseFloat(U.paddingBottom),Te=Ee(R.value),ze=96/25.4,Le=Lt(I.clientWidth-te,I.clientHeight-me,Te.width*ze,Te.height*ze);be.value?.fitToWindow(Le)}}function ee(I){w.value=Math.max(mt,w.value+I)}function Q(I){const U=I.target.tagName;U==="INPUT"||U==="TEXTAREA"||U==="SELECT"||(I.ctrlKey||I.metaKey)&&I.key==="0"&&(I.preventDefault(),q())}e.onMounted(()=>document.addEventListener("keydown",Q)),e.onUnmounted(()=>document.removeEventListener("keydown",Q));function oe(I){const U=R.value.header.height,te=R.value.footer.height;h(I),I.header.height<U&&pe("header"),I.footer.height<te&&pe("footer")}function ke(I,U){R.value={...R.value,[I]:{...R.value[I],height:U}}}function de(I){h({...R.value}),pe(I)}function pe(I){const U=Ye(R.value)[I];W.value.some(me=>me.zone===I&&(me.options.top+me.options.height>U.height||me.options.left+me.options.width>U.width))&&alert(`${I==="header"?"页眉":"页脚"}高度已小于区域内元素,请手动调整元素位置`)}function Se(){const I=R.value.firstPageOverlay,U={options:{left:0,top:0,width:50,height:10,title:"首页叠加"},printElementType:{type:"text",title:"首页叠加"}};R.value={...R.value,firstPageOverlay:{...I,elements:[...I.elements,U]}}}const vt=K;function Yt(I){const U=W.value.find(te=>te.id===I);U&&(U.options.visible=U.options.visible===!1)}function Kt(I){const U=W.value.find(te=>te.id===I);U&&(U.options.locked=!U.options.locked)}const Be=e.ref("page");e.watch(G,I=>{Be.value=I?"element":"page"});const Xt={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},De=e.ref(!1),Ie=e.ref(null),Ze=e.ref("");function jt(I){const U=W.value.find(me=>me.id===I);if(!U||(K(I,!1),Be.value="element",U.options.locked))return;const te=Xt[U.printElementType.type];te&&(Ie.value={kind:"element",element:U,field:te},Ze.value=U.options[te]||"",De.value=!0)}function Jt(I,U,te){const me=W.value.find(to=>to.id===I);if(!me||(K(I,!1),Be.value="element",me.options.locked))return;const Te=me.options.tableRows??[],ze=ct(Te,U,te),Le=Te[ze.r]?.cells[ze.c];Le&&(Ie.value={kind:"cell",cell:Le},Ze.value=Le.formatter||"",De.value=!0)}function Zt(I){const U=Ie.value;U?.kind==="element"?U.element.options[U.field]=I||void 0:U?.kind==="cell"&&(U.cell.formatter=I||void 0),F(),De.value=!1,Ie.value=null}function Qt(I,U){W.value.push(I),K(I.id,!1),F()}e.watch(()=>n.initialTemplate,I=>{I&&N(I,n.initialElements)}),e.watch(()=>n.initialElements,I=>{I&&!n.initialTemplate&&(R.value={...R.value,elements:I.map(U=>({...U,options:{...U.options},printElementType:{...U.printElementType}}))})}),e.watch(()=>n.fields,I=>{J.value=I||[]}),a({getTemplateJson:C});async function _t(){if(n.loadDefaultTemplate&&confirm("将覆盖当前画布内容,是否继续?"))try{const I=await n.loadDefaultTemplate();if(!I){alert("未获取到默认布局");return}N(I),alert("默认布局已加载")}catch{alert("加载默认布局失败")}}function eo(){l("save",JSON.stringify(C())),v()}return(I,U)=>(e.openBlock(),e.createElementBlock("div",Ad,[e.createVNode(cn,{"is-edit":t.isEdit,"can-undo":e.unref(X),"can-redo":e.unref(Z),"has-multi-selection":e.unref(A).size>=2,"has-selection":e.unref(A).size>=1,"show-ruler":e.unref(L),"show-grid":e.unref(H),"snap-to-grid":e.unref(D),"show-table-ghost-border":e.unref($),"selected-element-has-group":!!e.unref(G)?.options.groupId,"overlay-visible":ye.value,"show-load-default":!!t.loadDefaultTemplate,"show-help":t.showHelp!==!1,scale:e.unref(w),"onUpdate:scale":U[0]||(U[0]=te=>e.isRef(w)?w.value=te:null),onPreview:U[1]||(U[1]=te=>I.$emit("preview")),onSave:eo,onLoadDefault:_t,onUndo:e.unref(j),onRedo:e.unref(ce),onAlign:U[2]||(U[2]=te=>e.unref(ie)(te)),onMoveLayer:e.unref(k),onToggleRuler:U[3]||(U[3]=te=>L.value=!e.unref(L)),onToggleGrid:U[4]||(U[4]=te=>H.value=!e.unref(H)),onToggleSnap:U[5]||(U[5]=te=>D.value=!e.unref(D)),onToggleTableGhostBorder:U[6]||(U[6]=te=>$.value=!e.unref($)),onToggleOverlay:Xe,onGroup:e.unref(se),onUngroup:e.unref(le),onAddOverlayElement:Se,onFitWindow:q,onZoom:ee,onHelp:U[7]||(U[7]=te=>r.value=!0)},null,8,["is-edit","can-undo","can-redo","has-multi-selection","has-selection","show-ruler","show-grid","snap-to-grid","show-table-ghost-border","selected-element-has-group","overlay-visible","show-load-default","show-help","scale","onUndo","onRedo","onMoveLayer","onGroup","onUngroup"]),e.createElementVNode("div",Id,[e.createVNode(Gn,{fields:e.unref(J),elements:e.unref(W),"selected-ids":e.unref(A),collapsed:e.unref(i),onSelect:e.unref(vt),onMoveLayer:e.unref(k),onToggleVisible:Yt,onToggleLocked:Kt,onToggleCollapse:e.unref(c)},null,8,["fields","elements","selected-ids","collapsed","onSelect","onMoveLayer","onToggleCollapse"]),e.createVNode(ia,{ref_key:"canvasAreaRef",ref:be,"template-data":e.unref(R),elements:e.unref(W),scale:e.unref(w)/100,"show-ruler":e.unref(L),"show-grid":e.unref(H),"snap-to-grid":e.unref(D),"show-table-ghost-border":e.unref($),"has-clipboard":e.unref(z),guides:e.unref(Y),"overlay-visible":ye.value,"screenshot-url":Ne.value,"overlay-opacity":Ke.value,"selected-element-has-group":!!e.unref(G)?.options.groupId,onSelect:e.unref(vt),onDropElement:e.unref(f),onDropField:e.unref(m),onDragStart:e.unref(g),onDragStop:e.unref(E),onDblclickElement:jt,onDblclickCell:Jt,onZoneHeightChange:ke,onZoneHeightCommit:de,onSelectAll:e.unref(M),onClearSelection:e.unref(S),onPreview:e.unref(B),onCommitPreview:e.unref(T),onPaste:e.unref(V),onCopy:e.unref(u),onCut:e.unref(O),onDelete:e.unref(P),onMoveLayer:e.unref(k),onCoordinate:je,onGroup:e.unref(se),onUngroup:e.unref(le),onAddGuide:e.unref(ae),onGuideMove:e.unref(re),onGuideRemove:e.unref(ve),onZoom:ee,onCloneElement:Qt},null,8,["template-data","elements","scale","show-ruler","show-grid","snap-to-grid","show-table-ghost-border","has-clipboard","guides","overlay-visible","screenshot-url","overlay-opacity","selected-element-has-group","onSelect","onDropElement","onDropField","onDragStart","onDragStop","onSelectAll","onClearSelection","onPreview","onCommitPreview","onPaste","onCopy","onCut","onDelete","onMoveLayer","onGroup","onUngroup","onAddGuide","onGuideMove","onGuideRemove"]),e.createVNode(md,{element:e.unref(G),"template-data":e.unref(R),fields:e.unref(J),"table-selection":e.unref(y),"record-history":e.unref(F),collapsed:e.unref(s),"active-tab":Be.value,"onUpdate:activeTab":U[8]||(U[8]=te=>Be.value=te),onDeleteElement:e.unref(P),"onUpdate:templateData":oe,onToggleCollapse:e.unref(d)},null,8,["element","template-data","fields","table-selection","record-history","collapsed","active-tab","onDeleteElement","onToggleCollapse"])]),e.createVNode(yd,{coordinate:Ae.value,scale:e.unref(w),"element-count":e.unref(W).length,"selected-count":e.unref(A).size,paper:Je.value,dirty:e.unref(p)},null,8,["coordinate","scale","element-count","selected-count","paper","dirty"]),e.createVNode(ft,{modelValue:De.value,"onUpdate:modelValue":U[9]||(U[9]=te=>De.value=te),fields:e.unref(J),expression:Ze.value,"onUpdate:expression":Zt},null,8,["modelValue","fields","expression"]),e.createVNode(Ld,{visible:r.value,onClose:U[10]||(U[10]=te=>r.value=!1)},null,8,["visible"])]))}}),Hd=_(Rd,[["__scopeId","data-v-8060946b"]]),tt=3.7795275591,Ge=3e3;async function Gt(t,a,o,n){const l=ue.bindData(t,a,o),r=await Fd(l,n),i=ue.paginate(l,r);return{html:ue.generateHtml(l,i,a,{codeRenderer:n}),pageCount:i.length,pageLayouts:i}}async function Fd(t,a){const o=ue.getPaperDimensions(t),n=ue.generateHtml(t,[],void 0,{isMeasurementPass:!0,codeRenderer:a}),l=document.createElement("iframe");l.setAttribute("aria-hidden","true"),l.style.cssText=`position:fixed;left:-10000px;top:0;width:${o.width}mm;height:${o.height}mm;border:0;visibility:hidden;pointer-events:none;`,document.body.appendChild(l);try{const r=l.contentWindow,i=l.contentDocument;if(!r||!i)throw new Error("无法创建测量 iframe");i.open(),i.write(n),i.close(),await Ud(r);const s=Gd(i),c=new Map,d=new Map(t.elements.map(p=>[p.id,p]));for(const p of s){const w=d.get(p.id)?.options?._repeatHeaderCount??0;c.set(p.id,{id:p.id,measuredHeight:p.height,measuredRowHeights:p.rowHeights,repeatHeaderHeight:p.rowHeights&&w>0?p.rowHeights.slice(0,w).reduce((L,H)=>L+H,0):0})}return c}finally{l.remove()}}function Ud(t){return new Promise(a=>{let o=!1;const n=()=>{o||(o=!0,a())},l=setTimeout(n,Ge),r=async()=>{try{const i=t.document.fonts;i?.ready&&await Promise.race([i.ready,$t(Ge)]),await Promise.race([Od(t.document),$t(Ge)])}catch{}finally{clearTimeout(l),n()}};t.document.readyState==="complete"?r():(t.addEventListener("load",()=>{r()},{once:!0}),setTimeout(n,Ge))})}function $t(t){return new Promise((a,o)=>setTimeout(()=>o(new Error("timeout")),t))}function Od(t){const a=Array.from(t.images??[]);return Promise.all(a.map(o=>o.complete?Promise.resolve():new Promise(n=>{o.addEventListener("load",()=>n(),{once:!0}),o.addEventListener("error",()=>n(),{once:!0})}))).then(()=>{})}function Gd(t){const a=[],o=t.querySelectorAll("[data-measure-id]");for(const n of o){const l=n,r=l.getAttribute("data-measure-id");if(!r)continue;const i=l.offsetHeight,s=l.querySelector("table.print-table");if(s){const c=[],d=s.querySelectorAll("tbody > tr[data-row-index]");for(const p of d)c.push(p.offsetHeight/tt);a.push({id:r,height:i/tt,rowHeights:c})}else a.push({id:r,height:i/tt})}return a}const qt="http://www.w3.org/2000/svg";function qd(t,a){const o=document.createElementNS(qt,"svg");return it(o,t,{format:a.barcodeType||"CODE128",width:Math.max(1,(a.barWidth??2)/2),height:30,displayValue:a.showText!==!1,fontSize:a.fontSize??10,margin:0,marginBottom:2}),o.outerHTML}function Wd(t,a){const o=(a.qrCodeLevel??"M").toUpperCase(),l=rt.create(t,{errorCorrectionLevel:["L","M","Q","H"].includes(o)?o:"M"}).modules,r=l.size,i=4,s=4*i,c=r*i+s*2;let d="";for(let p=0;p<r;p++)for(let v=0;v<r;v++)l.get(v,p)&&(d+=`<rect x="${s+v*i}" y="${s+p*i}" width="${i}" height="${i}" fill="#000"/>`);return`<svg xmlns="${qt}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${d}</svg>`}const Wt={render(t,a,o={}){if(!t)throw new Error("empty barcode value");return a==="qrcode"?Wd(t,o):qd(t,o)}},Yd={class:"print-html-preview"},Kd={key:0,class:"print-html-preview-error"},Xd={key:1,class:"print-html-preview-loading"},jd=e.defineComponent({__name:"PrintHtmlPreview",props:{templateJson:{},printData:{},baseUrl:{}},emits:["rendered","error"],setup(t,{expose:a,emit:o}){const n=t,l=o,r=e.ref(),i=e.ref(!1),s=e.ref("");let c=0;async function d(){if(!n.templateJson){s.value="",i.value=!1;return}const v=++c;i.value=!0,s.value="";try{const{html:w,pageCount:L}=await Gt(n.templateJson,n.printData,n.baseUrl,Wt);if(v!==c)return;const H=r.value?.contentWindow?.document;H&&(H.open(),H.write(w),H.close()),l("rendered",L)}catch(w){if(v!==c)return;s.value=w instanceof Error?w.message:"未知错误",l("error",s.value)}finally{v===c&&(i.value=!1)}}function p(){const v=r.value?.contentWindow;v&&(v.focus(),v.print())}return e.watch(()=>[n.templateJson,n.printData,n.baseUrl],()=>{d()},{immediate:!0,deep:!0}),e.onBeforeUnmount(()=>{c++}),a({print:p,rerender:d}),(v,w)=>(e.openBlock(),e.createElementBlock("div",Yd,[s.value?(e.openBlock(),e.createElementBlock("div",Kd,[e.createElementVNode("span",null,"预览渲染失败:"+e.toDisplayString(s.value),1)])):i.value?(e.openBlock(),e.createElementBlock("div",Xd,"预览渲染中…")):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("iframe",{ref_key:"iframeRef",ref:r,class:"print-html-preview-iframe",title:"打印预览"},null,512),[[e.vShow,!i.value&&!s.value]])]))}}),Jd=_(jd,[["__scopeId","data-v-1841dcea"]]);exports.DEFAULT_DEMO_DATA=ge;exports.PrintDesigner=Hd;exports.PrintHtmlPreview=Jd;exports.UPLOAD_IMAGE_KEY=pt;exports.browserCodeRenderer=Wt;exports.createDefaultTemplate=Ht;exports.getDemoData=go;exports.renderHtmlPages=Gt;exports.toRuntimePool=at;
|
|
4
428
|
//# sourceMappingURL=index.cjs.map
|