Browse Source

订单和发票信息的导出功能

master
453530270@qq.com 3 years ago
parent
commit
cf198627e4
  1. 16
      src/api/index.js
  2. 4
      src/components/page/afterService/invoice.vue
  3. 6
      src/components/page/order/index.vue

16
src/api/index.js

@ -131,7 +131,21 @@ export const rankingSort = query => {
// 导出订单xls // 导出订单xls
export const xlsdc =query => { export const xlsdc =query => {
return request({ return request({
url: '/admin/order.Order/export', url: '/admin/order.Otrder/export',
method: 'post',
data: query,
//
responseType:'blob',
//请求头
headers:{
"Content-Type":"application/json;charset=UTF-8;"
}
});
};
// 导出发票信息xls
export const fpxlsdc =query => {
return request({
url: '/admin/order.InvoiceManagement2/export',
method: 'post', method: 'post',
data: query, data: query,
// //

4
src/components/page/afterService/invoice.vue

@ -113,7 +113,7 @@
</template> </template>
<script> <script>
import Operation from '../../Operation.vue' import Operation from '../../Operation.vue'
import {InvoiceManagementList,downloadInvoice} from '../../../api/index' import {InvoiceManagementList,downloadInvoice,fpxlsdc} from '../../../api/index'
export default { export default {
data() { data() {
return{ return{
@ -237,7 +237,7 @@ export default {
}, },
// xls // xls
xlsdc(){ xlsdc(){
xlsdc(this.query).then(res=>{ fpxlsdc(this.query).then(res=>{
const fname = new Date().getTime()+".xlsx" const fname = new Date().getTime()+".xlsx"
let bloburl = window.URL.createObjectURL(new Blob([res])) let bloburl = window.URL.createObjectURL(new Blob([res]))
const a = document.createElement('a') const a = document.createElement('a')

6
src/components/page/order/index.vue

@ -263,17 +263,17 @@ export default {
// xls // xls
xlsdc(){ xlsdc(){
xlsdc(this.query).then(res=>{ xlsdc(this.query).then(res=>{
console.log(res)
const fname = new Date().getTime()+".xlsx" const fname = new Date().getTime()+".xlsx"
// let bloburl = window.URL.createObjectURL(res)
let bloburl = window.URL.createObjectURL(new Blob([res])) let bloburl = window.URL.createObjectURL(new Blob([res]))
// let bloburl = 'data:text/csv;charset=utf-8,' + encodeURIComponent(res)
const a = document.createElement('a') const a = document.createElement('a')
a.download = fname a.download = fname
a.href = bloburl a.href = bloburl
// add click // add click
a.click() a.click()
window.URL.revokeObjectURL(bloburl) window.URL.revokeObjectURL(bloburl)
console.log(a) // console.log(a)
}) })
.catch(err=>{ .catch(err=>{
console.error(err) console.error(err)

Loading…
Cancel
Save