refactor: 修改性能测试上传文件数量的限制判断

This commit is contained in:
Captain.B 2020-09-18 16:32:58 +08:00
parent fed9519fce
commit cfe8393fee
1 changed files with 22 additions and 4 deletions

View File

@ -4,7 +4,7 @@
accept=".jmx,.csv" accept=".jmx,.csv"
drag drag
action="" action=""
:limit="5" :limit="fileNumLimit"
multiple multiple
:show-file-list="false" :show-file-list="false"
:before-upload="beforeUpload" :before-upload="beforeUpload"
@ -77,6 +77,7 @@ export default {
fileList: [], fileList: [],
tableData: [], tableData: [],
uploadList: [], uploadList: [],
fileNumLimit: 5,
}; };
}, },
created() { created() {
@ -196,12 +197,29 @@ export default {
return this.fileList;// return this.fileList;//
}, },
validConfig() { validConfig() {
let newJmxNum = 0, oldJmxNum = 0; let newJmxNum = 0, oldJmxNum = 0, newCsvNum = 0, oldCsvNum = 0;
if (this.uploadList.length > 0) { if (this.uploadList.length > 0) {
newJmxNum = this.uploadList.filter(f => f.name.toLowerCase().endsWith(".jmx")).length; this.uploadList.forEach(f => {
if (f.name.toLowerCase().endsWith(".jmx")) {
newJmxNum++;
}
if (f.name.toLowerCase().endsWith(".csv")) {
newCsvNum++;
}
});
} }
if (this.fileList.length > 0) { if (this.fileList.length > 0) {
oldJmxNum = this.fileList.filter(f => f.name.toLowerCase().endsWith(".jmx")).length; this.fileList.forEach(f => {
if (f.name.toLowerCase().endsWith(".jmx")) {
oldJmxNum++;
}
if (f.name.toLowerCase().endsWith(".csv")) {
oldCsvNum++;
}
});
}
if (newCsvNum + oldCsvNum > this.fileNumLimit - 1) {
this.handleExceed();
} }
if (newJmxNum + oldJmxNum !== 1) { if (newJmxNum + oldJmxNum !== 1) {
this.$error(this.$t('load_test.jmx_is_null')); this.$error(this.$t('load_test.jmx_is_null'));