# 方案一: 调用接口导出Excel

Excel导出分两种: 调用后端接口进行导出 和 纯前端导出两种办法

# 调用接口导出

数据存在分页的情况下, 调用接口导出

# 调用接口导出部分代码

# html部分

    <ButtonIconText
        @click="exportClick()"
        icon="/static/image/common/buttonIcon/export.png"
        >
        导出数据
    </ButtonIconText>
1
2
3
4
5
6

# js部分

        exportClick() {
            this.loading = true;
            var currentPage = this.currentPage - 1;
            var params = {
                Filter: this.formInline.Filter,
                SellerState: this.formInline.SellerState,
                GroupNo: this.formInline.GroupNo,
                Grade: this.formInline.Grade,
                BeginTime: this.CREATE_TIME ? this.CREATE_TIME[0] : "",
                EndTime: this.CREATE_TIME ? this.CREATE_TIME[1] : "",
                ContactName: this.formInline.ContactName,
                SkipCount: currentPage * this.pageSize,
                MaxResultCount: this.pageSize
            };
            sellerSaleListExport(params)
                .then(result => {
                    window.location.href = result;
                    this.loading = false;
                })
                .catch(err => {
                    this.loading = false;
                    this.$notify({
                        title: "失败",
                        message: err,
                        type: "warning"
                    });
                });
        },
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
上次更新: 2020/12/20 下午7:13:16