1. 程式人生 > >匯出excel資料

匯出excel資料

     <el-form-item>
       <el-button type="info" @click="exportOrderList"><i class="el-icon-upload2"></i>匯出excel</el-button>
      </el-form-item> 
import Fetch from '@/api/statistics'
     exportOrderList() {
        this.loading = true
        setTimeout(() => {
          this.loading = false
        }, 20000)
        let {beginDate, endDate} = this.search
        let params = {beginDate, endDate} 
        Fetch.exportOrderList(params)  //exportOrderList這裡是調介面,從statistics進入的
        this.loading = false  
      },
function exportOrderList(searchData) {
    let data = Object.assign({}, searchData)
    let params = ''
    for (var key in data) {
        if (data[key]) {
            params += (params ? '&' : '?') + key + '=' + data[key]
        }
    }
    params += (params ? '&' : '?') + 'Authorization=' + localStorage.getItem('jwt')
    let url = process.env.GATEWAY_API + '/admin-api/statistic/enterprise/exportStatisticList' + params
    console.log(url, 'url')
        // window.open(url)
}

export default {
    queryStatistics,
    exportOrderList
}