Merge pull request #215 from dataease/pr@dev@check-excel-columns

feat: 追加/更新 excel 数据集时,列名与原数据集保持一致
This commit is contained in:
taojinlong
2021-07-12 17:25:33 +08:00
committed by GitHub
6 changed files with 43 additions and 9 deletions

View File

@@ -28,6 +28,7 @@
:multiple="false"
:show-file-list="false"
:file-list="fileList"
:data="param"
accept=".xls,.xlsx,"
:before-upload="beforeUpload"
:on-success="uploadSuccess"
@@ -80,6 +81,7 @@
<script>
import { post } from '@/api/dataset/dataset'
import { getToken } from '@/utils/auth'
import i18n from "@/lang";
const token = getToken()
@@ -89,6 +91,10 @@ export default {
param: {
type: Object,
default: null
},
tableId: {
type: String,
default: null
}
},
data() {
@@ -100,7 +106,7 @@ export default {
mode: '1',
height: 600,
fileList: [],
headers: { Authorization: token },
headers: { Authorization: token , 'Accept-Language': i18n.locale.replace('_', '-')},
baseUrl: process.env.VUE_APP_BASE_API,
path: '',
uploading: false
@@ -115,6 +121,11 @@ export default {
}
this.calHeight()
},
created() {
if (!this.param.tableId) {
this.param.tableId = ""
}
},
methods: {
// initDataSource() {
// listDatasource().then(response => {
@@ -132,6 +143,10 @@ export default {
this.uploading = true
},
uploadFail(response, file, fileList) {
let myError=response.toString();
myError=myError.replace("Error: ","")
const errorMessage = JSON.parse(myError).message + ", " + this.$t('dataset.parse_error');
this.path = ''
this.fields = []
this.sheets = []
@@ -143,7 +158,7 @@ export default {
this.uploading = false
this.$message({
type: 'error',
message: this.$t('dataset.parse_error'),
message: errorMessage,
showClose: true
})
},
@@ -166,8 +181,6 @@ export default {
},
save() {
// console.log(this.checkTableList);
// console.log(this.scene);
if (!this.name || this.name === '') {
this.$message({
showClose: true,