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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM