Browse Source

fix: import excel by url logic

pull/1931/head
Wing-Kam Wong 2 years ago
parent
commit
58dcdddcec
  1. 2
      packages/nc-gui/components/import/excelImport.vue
  2. 14
      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)
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()

14
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()
}
}

Loading…
Cancel
Save