vue项目中Jimu积木报表的打印设计


前言

积木报表,是一款免费的数据可视化报表,含报表和大屏设计。这里主要是讲报表的打印设计。使用前需要集成到自己项目中,集成部分请查看官网集成文档


一、vu项目中访问积木报表

若JimuReport已经集成到项目中了,输入访问地址: {项目前缀}/jmreport/list,即可访问。
在这里插入图片描述
若需要嵌套到项目中,新建菜单文件Jimu.vue

<template>
  <div v-loading="loading" :style="'height:' + height">
    <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
  </div>
</template>
<script>
export default {
  name: 'Ureport',
  data() {
    return {
      src: '',
      height: document.documentElement.clientHeight - 110 + 'px;',
      loading: true
    }
  },
  created() {
    this.src = `${项目前缀}/jmreport/list?token=${this.$cookie.get('token')}`
  },
  mounted() {
    setTimeout(() => {
      this.loading = false
    }, 230)
    const that = this
    window.onresize = function temp() {
      that.height = document.documentElement.clientHeight - 110 + 'px;'
    }
  },
  methods: {
  }
}
</script>

二、使用步骤

1.报表具体设计

查阅官网在线文档报表设计器

2.项目中使用

在具体项目中,对多个页面的数据报表都进行预览和导出时。

a. 新建公共预览组件

<template>
  <el-dialog :title=title :visible.sync=dialogVisible :before-close="closedDialog" width="75%" :append-to-body="true"
    v-loading="loading" :close-on-click-modal="false">
    <div style="height: 70vh;width: 100%;">
      <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: 'ReportPrint',
  props: {},
  data() {
    return {
      dialogVisible: false,
      src: '',
      loading: true,
      title: ''
    }
  },
  mounted() {
    setTimeout(() => {
      this.loading = false
    }, 230)
  },
  methods: {
    openDialog(title, src) {
      this.src = src
      this.title = title
      this.dialogVisible = true
    },
    closedDialog() {
      this.dialogVisible = false
    }
  }
}
</script>
<style scoped lang="scss">
:deep .el-dialog__body {
  padding: 10px !important;
}
</style>

b. 具体页面中使用

<template>
  <div>
    <el-button @click="toPrint" type="primary">导出</el-button>
    <ReportPrint ref="jimuReportRef" />
  </div>
</template>
<script>
  import ReportPrint from '@/views/components/ReportPrint.vue'
  export default {
    data() {
      return {
       jimuReportRef: null
       }
      },
      methods: {
        toPrint() {
        const title = '报表'
        const reprotId = 'XXXXXXX' // 对应报表模板的reprotId 
        const src = `${项目前缀}/jmreport/view/${reprotId}?token=${this.$cookie.get('token')}`
        this.$refs.jimuReportRef.openDialog(title, src)
      },
    }  
  }
 </script>

Vue使用积木报表进行新建,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了积木报表的相关依赖包。你可以通过在终端运行以下命令来安装: ``` npm install v-charts echarts ``` 2. 在你的Vue组件引入所需的组件。你可以在需要使用积木报表的组件,通过以下方式引入: ```javascript import VeLine from 'v-charts/lib/line' import VeBar from 'v-charts/lib/bar' import VePie from 'v-charts/lib/pie' export default { components: { VeLine, VeBar, VePie }, // ... } ``` 3. 在模板使用相应的组件。你可以在模板使用`<ve-line>`、`<ve-bar>`和`<ve-pie>`等组件来展示相应的图表数据。以下是一个使用折线图的示例: ```html <template> <div> <ve-line :data="chartData"></ve-line> </div> </template> <script> export default { data() { return { chartData: { columns: ['日期', '销量'], rows: [ { '日期': '2021-01-01', '销量': 100 }, { '日期': '2021-01-02', '销量': 200 }, { '日期': '2021-01-03', '销量': 150 }, // ... ] } } } } </script> ``` 在这个示例,`chartData`对象包含了图表的数据,其`columns`定义了图表的列,`rows`定义了图表的行数据。你可以根据自己的需求来修改和展示相应的数据。 以上就是在Vue使用积木报表进行新建的基本步骤。你可以根据需要选择不同的图表组件,并根据相应的数据来展示图表。如果你需要更多的功能和配置,可以参考积木报表和ECharts的官方文档进行深入学习。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值