From 58dcdddcec6e94311da7eb8d60e0fd534b44efe3 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 4 May 2022 16:57:41 +0800 Subject: [PATCH] fix: import excel by url logic --- packages/nc-gui/components/import/excelImport.vue | 2 +- .../templateParsers/ExcelUrlTemplateAdapter.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/import/excelImport.vue b/packages/nc-gui/components/import/excelImport.vue index 9a4921b311..dda21b2fa3 100644 --- a/packages/nc-gui/components/import/excelImport.vue +++ b/packages/nc-gui/components/import/excelImport.vue @@ -266,7 +266,7 @@ export default { templateGenerator = new ExcelTemplateAdapter(name, val, this.parserConfig) break case 'url': - templateGenerator = new ExcelUrlTemplateAdapter(val, this.$store, this.parserConfig) + templateGenerator = new ExcelUrlTemplateAdapter(val, this.$store, this.parserConfig, this.$api) break } await templateGenerator.init() diff --git a/packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js b/packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js index 6c8e774f76..baf8133455 100644 --- a/packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js +++ b/packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js @@ -1,20 +1,22 @@ import ExcelTemplateAdapter from '~/components/import/templateParsers/ExcelTemplateAdapter' export default class ExcelUrlTemplateAdapter extends ExcelTemplateAdapter { - constructor(url, $store, parserConfig) { + constructor(url, $store, parserConfig, $api) { const name = url.split('/').pop() super(name, null, parserConfig) this.url = url + this.$api = $api this.$store = $store } async init() { - const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'handleAxiosCall', - [{ + const data = await this.$api.utils.axiosRequestMake({ + apiMeta: { url: this.url, responseType: 'arraybuffer' - }]]) - this.excelData = res.data - await super.init() + } + }) + this.excelData = data.data + await super.init() } }