refactor: 如果文件未选中,就选中第一个

This commit is contained in:
马琦钧 2021-08-08 17:15:30 +08:00
parent 245acea3ab
commit a929294bc9
1 changed files with 19 additions and 22 deletions

View File

@ -228,30 +228,33 @@ export default {
} }
}, },
methods: { methods: {
//
getFiles () {
const that = this
get(`/v1/files/query?projectName=${that.projectName}&pageNumber=${that.pageNumber}&pageSize=${that.pageSize}`, function (info) {
that.$set(that, 'files', info.map((item) => {
if (typeof item === 'string') return item
that.isAnnoDic[`${that.projectName}_${item.fileName}`] = item.isAnno
return item.fileName
}))
//
if (that.files[0] && that.nowFile !== that.files[0]) {
that.setNowText(that.files[0])
}
})
},
lastPage () { lastPage () {
const that = this const that = this
if (that.pageNumber > 1) { if (that.pageNumber > 1) {
that.pageNumber = that.pageNumber - 1 that.pageNumber = that.pageNumber - 1
get(`/v1/files/query?projectName=${that.projectName}&pageNumber=${that.pageNumber}&pageSize=${that.pageSize}`, function (info) { that.getFiles()
that.$set(that, 'files', info.map((item) => {
if (typeof item === 'string') return item
that.isAnnoDic[`${that.projectName}_${item.fileName}`] = item.isAnno
return item.fileName
}))
})
} }
}, },
nextPage () { nextPage () {
const that = this const that = this
if (that.files.length === that.pageSize) { if (that.files.length === that.pageSize) {
that.pageNumber = that.pageNumber + 1 that.pageNumber = that.pageNumber + 1
get(`/v1/files/query?projectName=${that.projectName}&pageNumber=${that.pageNumber}&pageSize=${that.pageSize}`, function (info) { that.getFiles()
that.$set(that, 'files', info.map((item) => {
if (typeof item === 'string') return item
that.isAnnoDic[`${that.projectName}_${item.fileName}`] = item.isAnno
return item.fileName
}))
})
} }
}, },
goHome: function () { goHome: function () {
@ -503,7 +506,7 @@ export default {
event.preventDefault() event.preventDefault()
// //
var data = event.dataTransfer var data = event.dataTransfer
var files = data.files var files = data.files || []
// //
this.processFiles(files) this.processFiles(files)
}, },
@ -631,13 +634,7 @@ export default {
that.types = types that.types = types
// //
if (that.typeList && that.typeList[0] && projectType === '命名实体识别') that.nowType = that.typeList[0] if (that.typeList && that.typeList[0] && projectType === '命名实体识别') that.nowType = that.typeList[0]
get(`/v1/files/query?projectName=${projectName}&pageNumber=${that.pageNumber}&pageSize=${that.pageSize}`, function (info) { that.getFiles()
that.$set(that, 'files', info.map((item) => {
if (typeof item === 'string') return item
that.isAnnoDic[`${that.projectName}_${item.fileName}`] = item.isAnno
return item.fileName
}))
})
} }
function calcColumnWordCount () { function calcColumnWordCount () {
const nerBox = document.getElementById('ner-box') const nerBox = document.getElementById('ner-box')