增加导出
This commit is contained in:
@@ -85,3 +85,17 @@ export async function getCouponBizList(params) {
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出产品
|
||||
* @param params 查询条件
|
||||
*/
|
||||
export async function exportProduct(params) {
|
||||
const res = await request.get('/car/product/export', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
@@ -80,6 +80,13 @@
|
||||
查询
|
||||
</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
icon="el-icon-dcustomerload"
|
||||
@click="exportData"
|
||||
>导出</el-button
|
||||
>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -347,11 +354,12 @@
|
||||
|
||||
<script>
|
||||
import { listDictionaryData } from '@/api/system/dictionary-data';
|
||||
import { pageProduct } from '@/api/car/product';
|
||||
import { exportProduct, pageProduct } from '@/api/car/product';
|
||||
import ElDialogWrapper from '@/components/IframePre/index.vue';
|
||||
import RegionsSelect from '@/components/RegionsSelect/index.vue';
|
||||
import CouponBizs from './components/couponBizs.vue';
|
||||
import BrandSelect from '@/components/BrandSelect/index.vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
|
||||
export default {
|
||||
name: 'carProduct',
|
||||
@@ -363,6 +371,7 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '产品列表',
|
||||
where: {
|
||||
title: '',
|
||||
brands: [],
|
||||
@@ -557,6 +566,36 @@
|
||||
showAllBizName(couponId) {
|
||||
this.couponId = couponId;
|
||||
this.showBizList = true;
|
||||
},
|
||||
exportData() {
|
||||
const loading = this.$loading({ lock: true });
|
||||
this.$refs.table.doRequest(({ where, order }) => {
|
||||
exportProduct({ ...where, ...order })
|
||||
.then((data) => {
|
||||
loading.close();
|
||||
const array = [data.columns];
|
||||
data.list.forEach((d) => {
|
||||
let arrayItem = [];
|
||||
for (let key in d) {
|
||||
arrayItem.push(d[key]);
|
||||
}
|
||||
array.push(arrayItem);
|
||||
});
|
||||
writeFile(
|
||||
{
|
||||
SheetNames: ['Sheet1'],
|
||||
Sheets: {
|
||||
Sheet1: utils.aoa_to_sheet(array)
|
||||
}
|
||||
},
|
||||
this.title + '.xlsx'
|
||||
);
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.close();
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user