Browse Source

fix: import excel by url logic

pull/1931/head
Wing-Kam Wong 3 years ago
parent
commit
58dcdddcec
  1. 2
      packages/nc-gui/components/import/excelImport.vue
  2. 12
      packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js

2
packages/nc-gui/components/import/excelImport.vue

@ -266,7 +266,7 @@ export default {
templateGenerator = new ExcelTemplateAdapter(name, val, this.parserConfig) templateGenerator = new ExcelTemplateAdapter(name, val, this.parserConfig)
break break
case 'url': case 'url':
templateGenerator = new ExcelUrlTemplateAdapter(val, this.$store, this.parserConfig) templateGenerator = new ExcelUrlTemplateAdapter(val, this.$store, this.parserConfig, this.$api)
break break
} }
await templateGenerator.init() await templateGenerator.init()

12
packages/nc-gui/components/import/templateParsers/ExcelUrlTemplateAdapter.js

@ -1,20 +1,22 @@
import ExcelTemplateAdapter from '~/components/import/templateParsers/ExcelTemplateAdapter' import ExcelTemplateAdapter from '~/components/import/templateParsers/ExcelTemplateAdapter'
export default class ExcelUrlTemplateAdapter extends ExcelTemplateAdapter { export default class ExcelUrlTemplateAdapter extends ExcelTemplateAdapter {
constructor(url, $store, parserConfig) { constructor(url, $store, parserConfig, $api) {
const name = url.split('/').pop() const name = url.split('/').pop()
super(name, null, parserConfig) super(name, null, parserConfig)
this.url = url this.url = url
this.$api = $api
this.$store = $store this.$store = $store
} }
async init() { async init() {
const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'handleAxiosCall', const data = await this.$api.utils.axiosRequestMake({
[{ apiMeta: {
url: this.url, url: this.url,
responseType: 'arraybuffer' responseType: 'arraybuffer'
}]]) }
this.excelData = res.data })
this.excelData = data.data
await super.init() await super.init()
} }
} }

Loading…
Cancel
Save