fix(接口测试): 修复文件导入后再次被修改保存报错问题
--bug=1024222 --user=赵勇 [接口测试]github#22498场景内上传csv文件,保存后,再修改本地的csv文件表头,再保存场景,报 Network Error错误 https://www.tapd.cn/55049933/s/1348935 Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
7579c2a433
commit
d7bba96d6f
|
@ -75,8 +75,26 @@ function getScenarioFiles(obj) {
|
|||
}
|
||||
return scenarioFiles;
|
||||
}
|
||||
|
||||
export function saveScenario(url, scenario, scenarioDefinition, _this, success) {
|
||||
async function checkFile(scenarioFiles) {
|
||||
return new Promise((resolve, reject) => {
|
||||
scenarioFiles.forEach((item) => {
|
||||
let func = item
|
||||
.slice(0, 1)
|
||||
.arrayBuffer()
|
||||
.then(() => {
|
||||
resolve(false);
|
||||
})
|
||||
.catch(() => {
|
||||
resolve(true);
|
||||
});
|
||||
return func;
|
||||
});
|
||||
if (!scenarioFiles || scenarioFiles.length == 0) {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
export async function saveScenario(url, scenario, scenarioDefinition, _this, success) {
|
||||
let bodyFiles = getBodyUploadFiles(scenario, scenarioDefinition);
|
||||
if (store.pluginFiles && store.pluginFiles.length > 0) {
|
||||
store.pluginFiles.forEach((fileItem) => {
|
||||
|
@ -86,7 +104,15 @@ export function saveScenario(url, scenario, scenarioDefinition, _this, success)
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
let scenarioFiles = getScenarioFiles(scenario);
|
||||
let isUpdated = await checkFile(scenarioFiles);
|
||||
if (isUpdated) {
|
||||
_this.$error(_this.$t('automation.document_validity_msg'));
|
||||
_this.isPreventReClick = false;
|
||||
_this.errorRefresh();
|
||||
return;
|
||||
}
|
||||
let formData = new FormData();
|
||||
if (bodyFiles) {
|
||||
bodyFiles.forEach((f) => {
|
||||
|
|
|
@ -66,6 +66,9 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
errorRefresh() {
|
||||
this.$emit('errorRefresh');
|
||||
},
|
||||
run() {
|
||||
let testPlan = createComponent('TestPlan');
|
||||
testPlan.clazzName = TYPE_TO_C.get(testPlan.type);
|
||||
|
|
|
@ -1885,7 +1885,7 @@ export default {
|
|||
}
|
||||
}
|
||||
this.isPreventReClick = true;
|
||||
saveScenario(this.path, this.currentScenario, this.scenarioDefinition, this, (response) => {
|
||||
await saveScenario(this.path, this.currentScenario, this.scenarioDefinition, this, (response) => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.isPreventReClick = false;
|
||||
this.path = '/api/automation/update';
|
||||
|
|
|
@ -121,6 +121,7 @@ const message = {
|
|||
},
|
||||
automation: {
|
||||
project_no_permission: 'The current person does not have the operation permission for this step',
|
||||
document_validity_msg: 'The file has been modified, please re-upload',
|
||||
},
|
||||
};
|
||||
export default {
|
||||
|
|
|
@ -117,6 +117,7 @@ const message = {
|
|||
},
|
||||
automation: {
|
||||
project_no_permission: '当前操作人无此步骤的操作权限',
|
||||
document_validity_msg: '文件已经被修改,请重新上传',
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ const message = {
|
|||
},
|
||||
automation: {
|
||||
project_no_permission: '當前人操作無此步驟的操作權限',
|
||||
document_validity_msg: '文件已經被修改,請重新上傳',
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue