|
|
@ -44,6 +44,7 @@ export default { |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
excelImport: Boolean, |
|
|
|
excelImport: Boolean, |
|
|
|
loading: Boolean, |
|
|
|
loading: Boolean, |
|
|
|
|
|
|
|
importToProject: Boolean, |
|
|
|
templateData: [Array, Object], |
|
|
|
templateData: [Array, Object], |
|
|
|
importData: [Array, Object], |
|
|
|
importData: [Array, Object], |
|
|
|
valid: { |
|
|
|
valid: { |
|
|
@ -107,30 +108,56 @@ export default { |
|
|
|
this.$store.commit('loader/MutMessage', this.loaderMessages[this.loaderMessagesIndex]) |
|
|
|
this.$store.commit('loader/MutMessage', this.loaderMessages[this.loaderMessagesIndex]) |
|
|
|
}, 1000) |
|
|
|
}, 1000) |
|
|
|
|
|
|
|
|
|
|
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectCreateByWebWithXCDB', { |
|
|
|
let projectId, prefix |
|
|
|
title: this.templateData.title, |
|
|
|
|
|
|
|
projectType, |
|
|
|
|
|
|
|
template: this.templateData, |
|
|
|
|
|
|
|
excelImport: this.excelImport |
|
|
|
|
|
|
|
}]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.$store.dispatch('project/ActLoadProjectInfo') |
|
|
|
if (this.importToProject) { |
|
|
|
|
|
|
|
this.$store.commit('loader/MutMessage', 'Importing excel template') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ |
|
|
|
|
|
|
|
// todo: extract based on active |
|
|
|
|
|
|
|
dbAlias: 'db', // this.nodes.dbAlias, |
|
|
|
|
|
|
|
env: '_noco' |
|
|
|
|
|
|
|
}, 'xcModelsCreateFromTemplate', { |
|
|
|
|
|
|
|
template: this.templateData |
|
|
|
|
|
|
|
}]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (res && res.tables && res.tables.length) { |
|
|
|
|
|
|
|
this.$toast.success(`Imported ${res.tables.length} tables successfully`).goAway(3000) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.$toast.success('Template imported successfully').goAway(3000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
projectId = this.$route.params.project_id |
|
|
|
|
|
|
|
prefix = this.$store.getters['project/GtrProjectPrefix'] |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectCreateByWebWithXCDB', { |
|
|
|
|
|
|
|
title: this.templateData.title, |
|
|
|
|
|
|
|
projectType, |
|
|
|
|
|
|
|
template: this.templateData, |
|
|
|
|
|
|
|
excelImport: this.excelImport |
|
|
|
|
|
|
|
}]) |
|
|
|
|
|
|
|
projectId = result.id |
|
|
|
|
|
|
|
prefix = result.prefix |
|
|
|
|
|
|
|
await this.$store.dispatch('project/ActLoadProjectInfo') |
|
|
|
|
|
|
|
} |
|
|
|
clearInterval(interv) |
|
|
|
clearInterval(interv) |
|
|
|
if (this.importData) { |
|
|
|
if (this.importData) { |
|
|
|
this.$store.commit('loader/MutMessage', 'Importing excel data to project') |
|
|
|
this.$store.commit('loader/MutMessage', 'Importing excel data to project') |
|
|
|
await this.importDataToProject({ projectId: result.id, projectType, prefix: result.prefix }) |
|
|
|
await this.importDataToProject({ projectId, projectType, prefix }) |
|
|
|
} |
|
|
|
} |
|
|
|
this.$store.commit('loader/MutMessage', null) |
|
|
|
this.$store.commit('loader/MutMessage', null) |
|
|
|
|
|
|
|
|
|
|
|
this.projectReloading = false |
|
|
|
this.projectReloading = false |
|
|
|
|
|
|
|
if (!this.importToProject) { |
|
|
|
|
|
|
|
await this.$router.push({ |
|
|
|
|
|
|
|
path: `/nc/${projectId}`, |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
new: 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.$router.push({ |
|
|
|
this.$emit('success') |
|
|
|
path: `/nc/${result.id}`, |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
new: 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
this.$toast.error(e.message).goAway(3000) |
|
|
|
this.$toast.error(e.message).goAway(3000) |
|
|
|