CN-1313 fix: 知识库上传文件大小限制为100M
This commit is contained in:
@@ -202,10 +202,12 @@
|
|||||||
<script>
|
<script>
|
||||||
import table from '@/mixins/table'
|
import table from '@/mixins/table'
|
||||||
import Loading from '@/components/common/Loading'
|
import Loading from '@/components/common/Loading'
|
||||||
import { knowledgeCategoryValue, storageKey, builtInKnowledgeBaseBasicInfo } from '@/utils/constants'
|
import { knowledgeCategoryValue, unitTypes, storageKey, builtInKnowledgeBaseBasicInfo } from '@/utils/constants'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { api } from '@/utils/api'
|
import { api } from '@/utils/api'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import unitConvert from '@/utils/unit-convert'
|
||||||
export default {
|
export default {
|
||||||
name: 'knowledgeBaseTableForCard',
|
name: 'knowledgeBaseTableForCard',
|
||||||
mixins: [table],
|
mixins: [table],
|
||||||
@@ -249,12 +251,24 @@ export default {
|
|||||||
},
|
},
|
||||||
uploadErrorTip,
|
uploadErrorTip,
|
||||||
fileTypeLimit: '.csv',
|
fileTypeLimit: '.csv',
|
||||||
fileList: ref([])
|
fileList: ref([]),
|
||||||
|
uploadFileSizeLimit: 100 * 1024 * 1024
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fileChange (files, fileList) {
|
fileChange (file, fileList) {
|
||||||
this.fileList = fileList.slice(-1)
|
console.info(!_.endsWith(file.name, '.csv'))
|
||||||
|
console.info(file.size > this.uploadFileSizeLimit)
|
||||||
|
// 判断后缀,仅支持.csv
|
||||||
|
if (!_.endsWith(file.name, '.csv')) {
|
||||||
|
this.fileList = []
|
||||||
|
this.$message.error(this.$t('validate.fileTypeLimit', { types: this.fileTypeLimit }))
|
||||||
|
} else if (file.size > this.uploadFileSizeLimit) { // 判断文件大小
|
||||||
|
this.$message.error(this.$t('validate.fileSizeLimit', { size: unitConvert(this.uploadFileSizeLimit, unitTypes.byte).join('') }))
|
||||||
|
this.fileList = []
|
||||||
|
} else {
|
||||||
|
this.fileList = fileList.slice(-1)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
uploadError (error) {
|
uploadError (error) {
|
||||||
let errorMsg
|
let errorMsg
|
||||||
|
|||||||
Reference in New Issue
Block a user