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"
drag
action=""
:limit="5"
:limit="fileNumLimit"
multiple
:show-file-list="false"
:before-upload="beforeUpload"
@ -77,6 +77,7 @@ export default {
fileList: [],
tableData: [],
uploadList: [],
fileNumLimit: 5,
};
},
created() {
@ -196,12 +197,29 @@ export default {
return this.fileList;//
},
validConfig() {
let newJmxNum = 0, oldJmxNum = 0;
let newJmxNum = 0, oldJmxNum = 0, newCsvNum = 0, oldCsvNum = 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) {
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) {
this.$error(this.$t('load_test.jmx_is_null'));