element 导出功能

导出按钮:

  <el-button type="primary" class="btns c-ff c-main-btn" @click="downLoadAllHand">批量导出</el-button>

调函数:

      // 导出
      downLoadAllHand () {
        const url = `/manage/reader/stat/export`
        const params = {...this.searchForm}
        openForm(url, params, "POST")
      },

  

打开文件:

export const openForm = (url, params, method) => {
  const form = _createElement(({
    tag: 'form',
    attr: {
      id: 'newsForm',
      name: 'newsForm',
      target: '_blank',
      method: method,
      action: url
    }
  }))
  Object.keys(params).forEach(item=>{
    let input = document.createElement('input')
    input.type = 'text'
    input.name = item
    input.value = params[item]
    form.appendChild(input)
  })
  document.body.appendChild(form)
  form.submit()
  document.body.removeChild(form)
}

 

 

 

具体函数:
 
 export const openForm = (url, params, method) => {
  const form = _createElement(({
    tag: 'form',
    attr: {
      id: 'newsForm',
      name: 'newsForm',
      target: '_blank',
      method: method,
      action: url
    }
  }))
  Object.keys(params).forEach(item=>{
    let input = document.createElement('input')
    input.type = 'text'
    input.name = item
    input.value = params[item]
    form.appendChild(input)
  })
  document.body.appendChild(form)
  form.submit()
  document.body.removeChild(form)
}
调函数:
 
downLoadAllHand () {
const url = `/manage/reader/stat/export`
const params = {...this.searchForm}
openForm(url, params, "POST")
},
 
导出按钮:
 
<template slot="moreBtns">
<el-button type="primary" class="btns c-ff c-main-btn" @click="downLoadAllHand">批量导出</el-button>
</template>

 

posted @ 2020-11-11 16:47  1点  阅读(1560)  评论(0编辑  收藏  举报