vue2 实现表格信息导出的功能

 功能图:

通过点击按钮实现导出功能

 

 

main.js 导入

Vue.component('downloadExcel', JsonExcel)

导出按钮

        <download-excel style="float: right;margin-right: 210px"
                        class="export-btn"
                        :data="dicts"
                        :fields="jsonFields"
                        type="xls"
                        header="字典信息"
                        name="字典信息.xls"
        >
          <el-button type="warning" round size="mini" >导出</el-button>
        </download-excel>

Data

 data() {
    return {
      options: [{
        value: '0',
        label: '正常'
      }, {
        value: '1',
        label: '停用'
      }],
      dicts: [],
      dict: {},
      current: 1,
      total: 0,
      pageSize: 10,
      dialogFormVisible: false,
      formLabelWidth: "120px",
      username: null,
      dictName: "",
      dictType: "",
      dateTime: "", //开始日期+结束日期
      createTime: null,
      updateTime: null,
      value: "",//角色状态选中的值
      jsonFields: {  //导出Excel表格的表头设置
        '字典编号': 'dictId',
        '字典名称': 'dictName',
        '字典类型': 'dictType',
        '状态码': 'status',
        '创建者': 'createBy',
        '创建时间': 'createTime',
        '修改者': 'updateBy',
        '修改时间': 'updateTime',
        '备注': 'remark',
      },

导出按钮需要数据

dicts: [],
jsonFields: {  //导出Excel表格的表头设置
  '字典编号': 'dictId',
  '字典名称': 'dictName',
  '字典类型': 'dictType',
  '状态码': 'status',
  '创建者': 'createBy',
  '创建时间': 'createTime',
  '修改者': 'updateBy',
  '修改时间': 'updateTime',
  '备注': 'remark',
},

jsonFields规定表头,属性为dicts集合里的对象的属性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值