|
@@ -14,8 +14,6 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
title: "导 出",
|
|
|
- visible: false,
|
|
|
- loading: false,
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
@@ -23,30 +21,41 @@ export default {
|
|
|
methods: {
|
|
|
//
|
|
|
open() {
|
|
|
- this.visible = true;
|
|
|
- },
|
|
|
- //
|
|
|
- hide() {
|
|
|
- this.visible = false;
|
|
|
- },
|
|
|
- //
|
|
|
- async submit(prop, page) {
|
|
|
- try {
|
|
|
- // try
|
|
|
- this.loading = true;
|
|
|
- const { pageNum, pageSize } = page;
|
|
|
- await this.download(
|
|
|
- "pu/order/generate/export",
|
|
|
- { ...prop, pageNum, pageSize },
|
|
|
- `task_${new Date().getTime()}.xlsx`
|
|
|
- );
|
|
|
- await this.hide();
|
|
|
- } catch (err) {
|
|
|
- // catch
|
|
|
- } finally {
|
|
|
- // loading
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
+ this.$confirm("是否确认导出所有数据项?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "info",
|
|
|
+ beforeClose: async (action, instance, done) => {
|
|
|
+ if (action === "confirm") {
|
|
|
+ instance.confirmButtonLoading = true;
|
|
|
+ instance.confirmButtonText = "下载中...";
|
|
|
+ try {
|
|
|
+ // try
|
|
|
+ const {
|
|
|
+ data,
|
|
|
+ page: { pageNum, pageSize },
|
|
|
+ } = this.$props;
|
|
|
+ await this.download(
|
|
|
+ "pu/order/generate/export",
|
|
|
+ { ...prop, pageNum, pageSize },
|
|
|
+ `task_${new Date().getTime()}.xlsx`
|
|
|
+ );
|
|
|
+ await done();
|
|
|
+ } catch (err) {
|
|
|
+ // catch
|
|
|
+ console.error(err);
|
|
|
+ instance.confirmButtonText = "确认";
|
|
|
+ } finally {
|
|
|
+ // finally
|
|
|
+ instance.confirmButtonLoading = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then(() => {})
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
},
|
|
|
created() {},
|
|
@@ -57,35 +66,5 @@ export default {
|
|
|
<template>
|
|
|
<el-button v-bind="$attrs" v-on="$listeners" @click="open">
|
|
|
{{ title }}
|
|
|
- <el-dialog
|
|
|
- :title="title"
|
|
|
- :visible.sync="visible"
|
|
|
- width="25%"
|
|
|
- append-to-body
|
|
|
- @close="hide"
|
|
|
- >
|
|
|
- <div slot="footer">
|
|
|
- <el-button
|
|
|
- :size="$attrs.size"
|
|
|
- :loading="loading"
|
|
|
- @click="visible = false"
|
|
|
- >取 消</el-button
|
|
|
- >
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- :size="$attrs.size"
|
|
|
- :loading="loading"
|
|
|
- @click="submit(params, page)"
|
|
|
- >确 认</el-button
|
|
|
- >
|
|
|
- </div>
|
|
|
- <el-alert
|
|
|
- title="是否确认导出所有数据项?"
|
|
|
- type="info"
|
|
|
- show-icon
|
|
|
- :closable="false"
|
|
|
- >
|
|
|
- </el-alert>
|
|
|
- </el-dialog>
|
|
|
</el-button>
|
|
|
</template>
|