<el-button type="success" size="mini" @click="exportModal = true">导出数据</el-button>
<el-dialog title="导出数据" :visible.sync="exportModal" width="40%">
<el-form :model="exportForm" ref="ruleForm">
<el-form-item label="订单类型" prop="tab">
<el-select v-model="exportForm.tab" placeholder="请选择">
<el-option
v-for="(item,index) in tabbars"
:key="index" :label="item.name" :value="item.key">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="时间范围" prop="time">
<el-date-picker size="small"
v-model="exportForm.time"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="exportModal = false">取 消</el-button>
<el-button type="primary" @click="exportExcel">确 定</el-button>
</span>
</el-dialog>
exportModal:false,
采用js前端处理技术即可完成下载
this.axios.post(url + params,{},{
token:true,
responseType: 'blob'
}).then(res=>{
this.exportModal = false
if (res.status == 200) {
let url = window.URL.createObjectURL(new Blob([res.data]))
let link= document.createElement('a')
link.style.display='none'
link.href=url
let filename = new Date().getTime() + '.xlsx';
link.setAttribute('download', filename)
document.body.appendChild(link)
link.click()
}
this.layout.hideLoading()
}).catch(err=>{
this.layout.hideLoading()
})
?
|