fix: 测试计划报告配置项保存后国际化不生效

This commit is contained in:
chenjianxing 2022-04-27 14:46:34 +08:00 committed by 刘瑞斌
parent 28e03af5a4
commit 7b94ca4179
1 changed files with 18 additions and 20 deletions

View File

@ -152,30 +152,14 @@ export default {
} }
}, },
getDefaultConfig(report) { getDefaultConfig(report) {
if (report && report.config && report.config!== "") { let dbConfig = null;
if (report && report.config) {
let configStr = report.config; let configStr = report.config;
if (configStr) { if (configStr) {
let configObj = JSON.parse(configStr); dbConfig = JSON.parse(configStr);
if(configObj.api && configObj.api.children){
if(!configObj.api.children.errorReport){
let obj = {
enable: true,
name: this.$t('error_report_library.option.name'),
};
configObj.api.children.errorReport = obj;
}
if(!configObj.api.children.unExecute){
let obj = {
enable: true,
name: this.$t('api_test.home_page.detail_card.unexecute'),
};
configObj.api.children.unExecute = obj;
}
}
return configObj;
} }
} }
return { let config = {
overview: { overview: {
enable: true, enable: true,
name: this.$t('test_track.report.overview') name: this.$t('test_track.report.overview')
@ -251,6 +235,20 @@ export default {
} }
} }
}; };
if (dbConfig) {
this.mergeConfig(config, dbConfig);
}
return config;
},
mergeConfig(config, dbConfig) {
for (let key of Object.keys(config)) {
if (dbConfig[key]) {
config[key].enable = dbConfig[key].enable;
if (config[key].children && dbConfig[key].children) {
this.mergeConfig(config[key].children, dbConfig[key].children);
}
}
}
} }
} }
} }