找回密码
 立即注册

QQ登录

只需一步,快速开始

wilson_19

注册会员

13

主题

31

帖子

120

积分

注册会员

积分
120
wilson_19
注册会员   /  发表于:2024-9-11 10:25  /   查看:256  /  回复:1
1金币

实时数据填充的时候报错,但是我的数据集名称已经完全改成一样的了


  1. <template>
  2.   <div>
  3.     <button @click="generateReport">生成并打印报表</button>
  4.   </div>
  5. </template>

  6. <script>
  7. import { ref, onMounted } from 'vue';
  8. export default {
  9.   name: 'PrintReport',
  10.   setup() {
  11.     const reportLoaded = ref(false);

  12.     // 动态加载 ar-js-core.js 脚本
  13.     const loadScript = (src) => {
  14.       return new Promise((resolve, reject) => {
  15.         const script = document.createElement('script');
  16.         script.src = src;
  17.         script.onload = resolve;
  18.         script.onerror = reject;
  19.         document.head.appendChild(script);
  20.       });
  21.     };

  22.     // 加载 ActiveReportsJS 核心库
  23.     onMounted(() => {
  24.       loadScript('../../../../../node_modules/@grapecity/activereports/dist/ar-js-core.js') // 替换为实际的路径
  25.         .then(() => {
  26.           console.log('ActiveReportsJS 核心库加载成功');
  27.           reportLoaded.value = true;
  28.         })
  29.         .catch((err) => {
  30.           console.error('加载 ActiveReportsJS 核心库失败:', err);
  31.         });
  32.     });

  33.     // 生成报表的方法
  34.     const generateReport = () => {
  35.       if (!window.GC || !window.GC.ActiveReports || !reportLoaded.value) {
  36.         console.error('ActiveReportsJS 核心库未加载或尚未准备好');
  37.         return;
  38.       }

  39.       const ARJS = window.GC.ActiveReports.Core;
  40.       const report = new ARJS.PageReport();

  41.       report
  42.         .load('V2.rdlx-json') // 你的报表文件
  43.         .then(() => {
  44.           const dataSet = {
  45.             name: 'MyData', // 数据集名称必须匹配报表中的名称
  46.             data: [
  47.               { pieceName: 1, colorName1: 'Item 1', barcodeQty: 10 },
  48.               { pieceName: 2, colorName1: 'Item 2', barcodeQty: 20 },
  49.               { pieceName: 3, colorName1: 'Item 3', barcodeQty: 30 },
  50.             ],
  51.           };
  52.           report.dataSets = [dataSet];
  53.           return report.run();
  54.         })
  55.         .then((pageDocument) => {
  56.           pageDocument.print();
  57.         })
  58.         .catch((err) => {
  59.           console.error('生成报表失败: ', err);
  60.         });
  61.     };

  62.     return {
  63.       generateReport,
  64.     };
  65.   },
  66. };
  67. </script>

  68. <style scoped>
  69. button {
  70.   margin-top: 20px;
  71.   padding: 10px 20px;
  72.   background-color: #4caf50;
  73.   color: white;
  74.   border: none;
  75.   border-radius: 5px;
  76.   cursor: pointer;
  77. }
  78. </style>
复制代码
  1. {
  2.     "Name": "multisectionreport1111",
  3.     "Width": "0in",
  4.     "Layers": [
  5.         {
  6.             "Name": "default"
  7.         }
  8.     ],
  9.     "CustomProperties": [
  10.         {
  11.             "Name": "DisplayType",
  12.             "Value": "Page"
  13.         },
  14.         {
  15.             "Name": "SizeType",
  16.             "Value": "Default"
  17.         },
  18.         {
  19.             "Name": "CollapseWhiteSpace",
  20.             "Value": "True"
  21.         }
  22.     ],
  23.     "Version": "7.6.0",
  24.     "Page": {
  25.         "PageWidth": "8.5in",
  26.         "PageHeight": "11in",
  27.         "RightMargin": "0in",
  28.         "LeftMargin": "0in",
  29.         "TopMargin": "0in",
  30.         "BottomMargin": "0in",
  31.         "Columns": 1,
  32.         "ColumnSpacing": "0.5in",
  33.         "PaperOrientation": "Portrait"
  34.     },
  35.     "DataSources": [
  36.         {
  37.             "Name": "MyData",
  38.             "ConnectionProperties": {
  39.                 "DataProvider": "JSONEMBED",
  40.                 "ConnectString": "jsondata="
  41.             }
  42.         }
  43.     ],
  44.     "ReportSections": [
  45.         {
  46.             "Type": "Continuous",
  47.             "Name": "报表区域1",
  48.             "Page": {
  49.                 "PageWidth": "8.5in",
  50.                 "PageHeight": "11in",
  51.                 "RightMargin": "1in",
  52.                 "LeftMargin": "1in",
  53.                 "TopMargin": "1in",
  54.                 "BottomMargin": "1in",
  55.                 "Columns": 1,
  56.                 "ColumnSpacing": "0in",
  57.                 "PaperOrientation": "Portrait"
  58.             },
  59.             "Width": "8.0972in",
  60.             "Body": {
  61.                 "Height": "1.3534in",
  62.                 "ReportItems": [
  63.                     {
  64.                         "Type": "list",
  65.                         "Name": "列表1",
  66.                         "DataSetName": "MyData",
  67.                         "RowsOrColumnsCount": 2,
  68.                         "Style": {
  69.                             "TopBorder": {
  70.                                 "Style": "None"
  71.                             },
  72.                             "BottomBorder": {
  73.                                 "Style": "None"
  74.                             },
  75.                             "LeftBorder": {
  76.                                 "Style": "None"
  77.                             },
  78.                             "RightBorder": {
  79.                                 "Style": "None"
  80.                             },
  81.                             "FontSize": "8pt",
  82.                             "FontWeight": "ExtraLight"
  83.                         },
  84.                         "ReportItems": [
  85.                             {
  86.                                 "Type": "inputfield",
  87.                                 "Name": "输入字段2",
  88.                                 "ZIndex": 18,
  89.                                 "Value": "="裁片號 " & Fields!serialNumber.Value",
  90.                                 "Style": {
  91.                                     "TopBorder": {
  92.                                         "Style": "None"
  93.                                     },
  94.                                     "BottomBorder": {
  95.                                         "Style": "None"
  96.                                     },
  97.                                     "LeftBorder": {
  98.                                         "Style": "None"
  99.                                     },
  100.                                     "RightBorder": {
  101.                                         "Style": "None"
  102.                                     },
  103.                                     "FontSize": "8pt",
  104.                                     "FontWeight": "Bold"
  105.                                 },
  106.                                 "Left": "0.008in",
  107.                                 "Top": "0.2238in",
  108.                                 "Width": "1.2606in",
  109.                                 "Height": "0.191in"
  110.                             },
  111.                             {
  112.                                 "Type": "inputfield",
  113.                                 "Name": "输入字段3",
  114.                                 "ZIndex": 15,
  115.                                 "Value": "="制單 " & Fields!worksheetCode.Value",
  116.                                 "Style": {
  117.                                     "TopBorder": {
  118.                                         "Style": "None"
  119.                                     },
  120.                                     "BottomBorder": {
  121.                                         "Style": "None"
  122.                                     },
  123.                                     "LeftBorder": {
  124.                                         "Style": "None"
  125.                                     },
  126.                                     "RightBorder": {
  127.                                         "Style": "None"
  128.                                     },
  129.                                     "FontSize": "8pt",
  130.                                     "FontWeight": "Bold"
  131.                                 },
  132.                                 "Left": "0.004in",
  133.                                 "Top": "0.4247in",
  134.                                 "Width": "1.2606in",
  135.                                 "Height": "0.1876in"
  136.                             },
  137.                             {
  138.                                 "Type": "inputfield",
  139.                                 "Name": "输入字段4",
  140.                                 "Value": "="尺碼 " & Fields!size.Value",
  141.                                 "Style": {
  142.                                     "TopBorder": {
  143.                                         "Style": "None"
  144.                                     },
  145.                                     "BottomBorder": {
  146.                                         "Style": "None"
  147.                                     },
  148.                                     "LeftBorder": {
  149.                                         "Style": "None"
  150.                                     },
  151.                                     "RightBorder": {
  152.                                         "Style": "None"
  153.                                     },
  154.                                     "FontSize": "8pt",
  155.                                     "FontWeight": "Bold"
  156.                                 },
  157.                                 "Left": "0.004in",
  158.                                 "Top": "0.6123in",
  159.                                 "Width": "1.2606in",
  160.                                 "Height": "0.1876in"
  161.                             },
  162.                             {
  163.                                 "Type": "inputfield",
  164.                                 "Name": "输入字段5",
  165.                                 "ZIndex": 7,
  166.                                 "Value": "="件數 " & Fields!barcodeQty.Value",
  167.                                 "Style": {
  168.                                     "TopBorder": {
  169.                                         "Style": "None"
  170.                                     },
  171.                                     "BottomBorder": {
  172.                                         "Style": "None"
  173.                                     },
  174.                                     "LeftBorder": {
  175.                                         "Style": "None"
  176.                                     },
  177.                                     "RightBorder": {
  178.                                         "Style": "None"
  179.                                     },
  180.                                     "FontSize": "8pt",
  181.                                     "FontWeight": "Bold"
  182.                                 },
  183.                                 "Top": "0.8054in",
  184.                                 "Width": "1.2606in",
  185.                                 "Height": "0.1876in"
  186.                             },
  187.                             {
  188.                                 "Type": "inputfield",
  189.                                 "Name": "输入字段6",
  190.                                 "ZIndex": 9,
  191.                                 "Value": "="單號 " & Fields!splitCode.Value",
  192.                                 "Style": {
  193.                                     "TopBorder": {
  194.                                         "Style": "None"
  195.                                     },
  196.                                     "BottomBorder": {
  197.                                         "Style": "None"
  198.                                     },
  199.                                     "LeftBorder": {
  200.                                         "Style": "None"
  201.                                     },
  202.                                     "RightBorder": {
  203.                                         "Style": "None"
  204.                                     },
  205.                                     "FontSize": "8pt",
  206.                                     "FontWeight": "Bold"
  207.                                 },
  208.                                 "Left": "1.514in",
  209.                                 "Top": "0.008in",
  210.                                 "Width": "1.7665in",
  211.                                 "Height": "0.1876in"
  212.                             },
  213.                             {
  214.                                 "Type": "inputfield",
  215.                                 "Name": "输入字段7",
  216.                                 "ZIndex": 10,
  217.                                 "Value": "="款式 " & Fields!productCode.Value",
  218.                                 "Style": {
  219.                                     "TopBorder": {
  220.                                         "Style": "None"
  221.                                     },
  222.                                     "BottomBorder": {
  223.                                         "Style": "None"
  224.                                     },
  225.                                     "LeftBorder": {
  226.                                         "Style": "None"
  227.                                     },
  228.                                     "RightBorder": {
  229.                                         "Style": "None"
  230.                                     },
  231.                                     "FontSize": "8pt",
  232.                                     "FontWeight": "Bold"
  233.                                 },
  234.                                 "Left": "1.5079in",
  235.                                 "Top": "0.2061in",
  236.                                 "Width": "1.7397in",
  237.                                 "Height": "0.1876in"
  238.                             },
  239.                             {
  240.                                 "Type": "inputfield",
  241.                                 "Name": "输入字段8",
  242.                                 "ZIndex": 11,
  243.                                 "Value": "="顏色 " & Fields!colorName1.Value",
  244.                                 "Style": {
  245.                                     "TopBorder": {
  246.                                         "Style": "None"
  247.                                     },
  248.                                     "BottomBorder": {
  249.                                         "Style": "None"
  250.                                     },
  251.                                     "LeftBorder": {
  252.                                         "Style": "None"
  253.                                     },
  254.                                     "RightBorder": {
  255.                                         "Style": "None"
  256.                                     },
  257.                                     "FontSize": "8pt",
  258.                                     "FontWeight": "Bold"
  259.                                 },
  260.                                 "Left": "1.5203in",
  261.                                 "Top": "0.4193in",
  262.                                 "Width": "1.2605in",
  263.                                 "Height": "0.1876in"
  264.                             },
  265.                             {
  266.                                 "Type": "inputfield",
  267.                                 "Name": "输入字段9",
  268.                                 "ZIndex": 12,
  269.                                 "Value": "="編號 " & Fields!barcodeNum.Value",
  270.                                 "Style": {
  271.                                     "TopBorder": {
  272.                                         "Style": "None"
  273.                                     },
  274.                                     "BottomBorder": {
  275.                                         "Style": "None"
  276.                                     },
  277.                                     "LeftBorder": {
  278.                                         "Style": "None"
  279.                                     },
  280.                                     "RightBorder": {
  281.                                         "Style": "None"
  282.                                     },
  283.                                     "FontSize": "8pt",
  284.                                     "FontWeight": "Bold"
  285.                                 },
  286.                                 "Left": "1.5161in",
  287.                                 "Top": "0.8101in",
  288.                                 "Width": "1.2605in",
  289.                                 "Height": "0.1876in"
  290.                             },
  291.                             {
  292.                                 "Type": "inputfield",
  293.                                 "Name": "输入字段10",
  294.                                 "ZIndex": 13,
  295.                                 "Value": "="床號 " & Fields!bedNum.Value",
  296.                                 "Style": {
  297.                                     "TopBorder": {
  298.                                         "Style": "None"
  299.                                     },
  300.                                     "BottomBorder": {
  301.                                         "Style": "None"
  302.                                     },
  303.                                     "LeftBorder": {
  304.                                         "Style": "None"
  305.                                     },
  306.                                     "RightBorder": {
  307.                                         "Style": "None"
  308.                                     },
  309.                                     "FontSize": "8pt",
  310.                                     "FontWeight": "Bold"
  311.                                 },
  312.                                 "Left": "1.5205in",
  313.                                 "Top": "0.6091in",
  314.                                 "Width": "1.2605in",
  315.                                 "Height": "0.1876in"
  316.                             },
  317.                             {
  318.                                 "Type": "inputfield",
  319.                                 "Name": "输入字段11",
  320.                                 "ZIndex": 14,
  321.                                 "Value": "="裁片名稱 " & Fields!pieceName.Value",
  322.                                 "Style": {
  323.                                     "TopBorder": {
  324.                                         "Style": "None"
  325.                                     },
  326.                                     "BottomBorder": {
  327.                                         "Style": "None"
  328.                                     },
  329.                                     "LeftBorder": {
  330.                                         "Style": "None"
  331.                                     },
  332.                                     "RightBorder": {
  333.                                         "Style": "None"
  334.                                     },
  335.                                     "FontSize": "8pt",
  336.                                     "FontWeight": "Bold"
  337.                                 },
  338.                                 "Left": "1.5018in",
  339.                                 "Top": "1.0336in",
  340.                                 "Width": "1.2605in",
  341.                                 "Height": "0.1876in"
  342.                             },
  343.                             {
  344.                                 "Type": "barcode",
  345.                                 "Name": "条形码1",
  346.                                 "ZIndex": 20,
  347.                                 "Value": "=Fields!qrCodeValue.Value",
  348.                                 "Symbology": "EAN_13",
  349.                                 "CaptionLocation": "Below",
  350.                                 "Style": {
  351.                                     "TopBorder": {
  352.                                         "Style": "None"
  353.                                     },
  354.                                     "BottomBorder": {
  355.                                         "Style": "None"
  356.                                     },
  357.                                     "LeftBorder": {
  358.                                         "Style": "None"
  359.                                     },
  360.                                     "RightBorder": {
  361.                                         "Style": "None"
  362.                                     },
  363.                                     "FontSize": "8pt",
  364.                                     "FontWeight": "ExtraLight"
  365.                                 },
  366.                                 "Left": "0.0521in",
  367.                                 "Top": "1.0234in",
  368.                                 "Width": "1.2837in",
  369.                                 "Height": "0.2615in"
  370.                             },
  371.                             {
  372.                                 "Type": "inputfield",
  373.                                 "Name": "输入字段1",
  374.                                 "ZIndex": 21,
  375.                                 "Value": "="合同 " & Fields!contract.Value",
  376.                                 "Style": {
  377.                                     "TopBorder": {
  378.                                         "Style": "None"
  379.                                     },
  380.                                     "BottomBorder": {
  381.                                         "Style": "None"
  382.                                     },
  383.                                     "LeftBorder": {
  384.                                         "Style": "None"
  385.                                     },
  386.                                     "RightBorder": {
  387.                                         "Style": "None"
  388.                                     },
  389.                                     "FontSize": "8pt",
  390.                                     "FontWeight": "Bold"
  391.                                 },
  392.                                 "Left": "0.004in",
  393.                                 "Top": "0.012in",
  394.                                 "Width": "1.2606in",
  395.                                 "Height": "0.191in"
  396.                             }
  397.                         ],
  398.                         "Width": "8.0972in",
  399.                         "Height": "1.3534in"
  400.                     }
  401.                 ]
  402.             }
  403.         }
  404.     ]
  405. }
复制代码


附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

问题描述:如何实现运行时数据源? 问题解答:猜测您是想实现运行时数据源绑定,可以参考这个链接进行实现 https://demo.grapecity.com.cn/activereportsjs/demos/features/viewer-runtime-data-binding/vue

1 个回复

正序浏览
最佳答案
最佳答案
Bella.YuanWyn认证
超级版主   /  发表于:2024-9-11 10:25:32
来自 2#
问题描述:如何实现运行时数据源?
问题解答:
猜测您是想实现运行时数据源绑定,可以参考这个链接进行实现
https://demo.grapecity.com.cn/ac ... me-data-binding/vue
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部