fix(接口测试): 修复case不显示请求内容的缺陷

--bug=1028054 --user=王孝刚 【接口测试】接口定义-编辑接口-CASE页面添加case-页面不显示请求内容信息
https://www.tapd.cn/55049933/s/1396066
This commit is contained in:
wxg0103 2023-07-21 10:55:23 +08:00 committed by fit2-zhao
parent 08b3f4c241
commit dd381da0a0
1 changed files with 44 additions and 1 deletions

View File

@ -268,7 +268,12 @@ import { relationGet, updateRuleRelation } from '@/api/xpack';
import { getUUID } from 'metersphere-frontend/src/utils';
import { getCurrentProjectID, getCurrentUser } from 'metersphere-frontend/src/utils/token';
import { hasLicense, hasPermissions } from 'metersphere-frontend/src/utils/permission';
import { _getBodyUploadFiles, mergeRequestDocumentData } from '@/business/definition/api-definition';
import {
_getBodyUploadFiles,
hisDataProcessing,
mergeRequestDocumentData,
stepCompute
} from '@/business/definition/api-definition';
import { API_METHOD_COLOUR, API_STATUS, PRIORITY } from '../../model/JsonData';
import MsTag from 'metersphere-frontend/src/components/MsTag';
import MsTipButton from 'metersphere-frontend/src/components/MsTipButton';
@ -288,6 +293,7 @@ import { TYPE_TO_C } from '@/business/automation/scenario/Setting';
import ApiCaseHeader from './ApiCaseHeader';
import { deepClone } from 'metersphere-frontend/src/utils/tableUtils';
import { useApiStore } from '@/store';
import {Body, KeyValue} from "@/business/definition/model/ApiTestModel";
const store = useApiStore();
export default {
@ -397,6 +403,7 @@ export default {
this.$EventBus.$off('showXpackCaseSet');
},
created() {
this.init();
window.addEventListener('resize', this.resizeTable, false);
store.scenarioEnvMap = undefined;
if (this.apiCase.request && this.apiCase.request.hashTree && this.apiCase.request.hashTree.length > 0) {
@ -955,6 +962,42 @@ export default {
}
});
},
initStepSize(array) {
stepCompute(array, this.apiCase.request);
},
historicalDataProcessing(array) {
hisDataProcessing(array, this.apiCase.request);
},
init() {
if (
Object.prototype.toString
.call(this.apiCase.request)
.match(/\[object (\w+)\]/)[1]
.toLowerCase() !== 'object'
) {
this.apiCase.request = JSON.parse(this.apiCase.request);
}
if (!this.apiCase.request.body) {
this.apiCase.request.body = new Body();
}
if (!this.apiCase.request.body.kvs) {
this.apiCase.request.body.kvs = [];
}
if (!this.apiCase.request.rest) {
this.apiCase.request.rest = [];
}
if (!this.apiCase.request.arguments) {
this.apiCase.request.arguments = [];
}
if (!this.apiCase.request.headers) {
this.apiCase.request.headers = [];
this.apiCase.request.headers.push(new KeyValue({ enable: true, name: '', value: '' }));
}
if (this.apiCase.request.hashTree) {
this.initStepSize(this.apiCase.request.hashTree);
this.historicalDataProcessing(this.apiCase.request.hashTree);
}
},
},
};
</script>