Commit b0bca8c8fcf1b642606383b11a391145a9232b28

Authored by xp.Huang
1 parent 12333e9e

Merge branch 'ft' into 'main_dev'

pref:修改测试接口,切换为http,websocket的值还存在问题

See merge request yunteng/thingskit-front!528

(cherry picked from commit 038cdbb3)

3038f469 fix:DEFECT-1082 首页字体变小了
9a61a2a6 feat:测试接口,post新增json,xml测试
... ... @@ -76,7 +76,7 @@
76 76 style: {
77 77 fill: '#1a1a1a',
78 78 text: value + '个',
79   - font: '1.25vh Microsoft YaHei',
  79 + font: '0.85rem Microsoft YaHei',
80 80 },
81 81 },
82 82 ],
... ...
... ... @@ -52,6 +52,8 @@
52 52 },
53 53 });
54 54
  55 + const emits = defineEmits(['resetValue']);
  56 +
55 57 const { pushObj } = useUtils();
56 58
57 59 const bodyCellFormDataTableRef = ref<InstanceType<typeof BodyTable>>();
... ... @@ -63,6 +65,7 @@
63 65 const handleChange = ({ target }) => {
64 66 const { value } = target;
65 67 getRequestBody.content.requestParamsBodyType = value;
  68 + emits('resetValue', value);
66 69 };
67 70
68 71 //获取数据
... ...
... ... @@ -17,8 +17,9 @@
17 17 key="Body"
18 18 tab="Body"
19 19 >
20   - <Body ref="bodyRef" />
  20 + <Body ref="bodyRef" @resetValue="handleResetValue" />
21 21 <BodyTest
  22 + v-if="bodyType !== 'none'"
22 23 @testBodyInterface="handleTestBodyInterface"
23 24 ref="testBodyRequestRef"
24 25 :data="dataMap.mapBodyObj"
... ... @@ -70,6 +71,8 @@
70 71
71 72 const excuteData = ref({});
72 73
  74 + const bodyType = ref('');
  75 +
73 76 const paramsCellTableRef = ref<InstanceType<typeof ParamsTable>>();
74 77
75 78 const editHeaderCellTableRef = ref<InstanceType<typeof ParamsTable>>();
... ... @@ -90,15 +93,18 @@
90 93 mapHeaderObj: {},
91 94 });
92 95
93   - const handleChange = () => {
94   - excuteTestRef.value?.resetValue();
  96 + const handleChange = () => excuteTestRef.value?.resetValue(false);
  97 +
  98 + const handleResetValue = (v) => {
  99 + bodyType.value = v;
  100 + handleClickReset();
95 101 };
96 102
97 103 const handleClickReset = () => {
98 104 testParamsRequestRef.value?.setValue();
99 105 testHeaderRequestRef.value?.setValue();
100 106 testBodyRequestRef.value?.setValue();
101   - excuteTestRef.value?.resetValue();
  107 + excuteTestRef.value?.resetValue(true);
102 108 };
103 109
104 110 //if-else-if-else分支优化
... ... @@ -160,14 +166,14 @@
160 166 };
161 167
162 168 const handleTestBodyInterface = () => {
163   - excuteTestRef.value?.showTest();
164 169 let value = getValue(false) as any;
165 170 const type = value?.Body?.requestParamsBodyType;
166   - //取出对应的类型的值
  171 + excuteTestRef.value?.showTest();
167 172 let values = [];
168 173 for (let i in value?.Body) if (i === type) values = value?.Body[i];
169 174 dataMap.mapBodyObj = {
170 175 list: values,
  176 + type,
171 177 ...getCompose(),
172 178 };
173 179 };
... ...
... ... @@ -8,7 +8,15 @@
8 8 <a-row type="flex" justify="center">
9 9 <a-col :span="3"> 参数设置 </a-col>
10 10 <a-col :span="21">
11   - <TestBodyCellTable ref="testEditCellTableRef" />
  11 + <div v-if="data?.type === 'x-www-form-urlencoded' || data?.type === 'form-data'">
  12 + <TestBodyCellTable ref="testEditCellTableRef" />
  13 + </div>
  14 + <div style="width: 30vw" v-else-if="data?.type === 'json'">
  15 + <JsonEditor ref="jsonEditorRef" />
  16 + </div>
  17 + <div style="width: 30vw" v-else-if="data?.type === 'xml'">
  18 + <a-textarea v-model:value="xmlContent" placeholder="请输入xml" :rows="6" />
  19 + </div>
12 20 </a-col>
13 21 </a-row>
14 22 </div>
... ... @@ -22,6 +30,7 @@
22 30 import TestBodyCellTable from './testEditBodyCellTable.vue';
23 31 import moment from 'moment';
24 32 import { useUtils } from '../../../hooks/useUtils';
  33 + import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue';
25 34
26 35 const emits = defineEmits(['testBodyInterface']);
27 36
... ... @@ -35,8 +44,12 @@
35 44
36 45 const excuteData = ref({});
37 46
  47 + const xmlContent = ref('');
  48 +
38 49 const testEditCellTableRef = ref<InstanceType<typeof TestBodyCellTable>>();
39 50
  51 + const jsonEditorRef = ref<InstanceType<typeof JsonEditor>>();
  52 +
40 53 const testResult = ref('');
41 54
42 55 const { getMultipleKeys } = useUtils();
... ... @@ -50,14 +63,20 @@
50 63 const getValue = async () => {
51 64 await nextTick();
52 65 await nextTick(() => {
53   - //拆分"xx,xx,xx"多个
54   - const getSingleKey = props.data?.list;
55   - const getMuteKey = props.data?.list?.filter((it: any) => it.key.split(',').length > 1);
56   - const getMuteKeys = getMultipleKeys(getMuteKey);
57   - const mergeKeys = [...getSingleKey, ...getMuteKeys]?.filter(
58   - (it: any) => it.key.split(',').length === 1
59   - );
60   - testEditCellTableRef.value?.setTableArray(mergeKeys);
  66 + console.log(props.data?.list);
  67 + if (props.data?.type === 'x-www-form-urlencoded' || props.data?.type === 'form-data') {
  68 + const getSingleKey = props.data?.list;
  69 + const getMuteKey = props.data?.list?.filter((it: any) => it.key.split(',').length > 1);
  70 + const getMuteKeys = getMultipleKeys(getMuteKey);
  71 + const mergeKeys = [...getSingleKey, ...getMuteKeys]?.filter(
  72 + (it: any) => it.key.split(',').length === 1
  73 + );
  74 + testEditCellTableRef.value?.setTableArray(mergeKeys);
  75 + } else if (props.data?.type === 'json') {
  76 + jsonEditorRef.value?.setJsonValue(props.data?.list);
  77 + } else if (props.data?.type === 'xml') {
  78 + xmlContent.value = props.data?.list;
  79 + }
61 80 });
62 81 };
63 82
... ... @@ -98,27 +117,20 @@
98 117
99 118 //获取数据
100 119 const getTestValue = () => {
101   - const getTable = getTestTableKeyValue();
102   - //源地址
103   - let apiGetUrl = '';
104   - if (props.data?.originUrlType === 'server_url') {
105   - const pathUrl = window.location.host;
106   - const protocol = window.location.protocol;
107   - apiGetUrl = `${protocol}//${pathUrl}`;
108   - } else {
109   - apiGetUrl = `${props.data?.requestOriginUrl}${props.data?.requestTypeAndUrl?.requestUrl}`;
  120 + let params: any = {};
  121 + if (props.data?.type === 'x-www-form-urlencoded' || props.data?.type === 'form-data') {
  122 + const getTable = getTestTableKeyValue();
  123 + getTable?.map((it) => (params[it.key!] = it.value!));
  124 + } else if (props.data?.type === 'json') {
  125 + params = jsonEditorRef.value?.getJsonValue();
  126 + } else if (props.data?.type === 'xml') {
  127 + params = xmlContent.value;
  128 + }
  129 + if (params['keys']) {
  130 + Reflect.set(params, 'keys', params['keys'].join(','));
110 131 }
111   - //请求类型
112   - const apiType = props.data?.requestTypeAndUrl?.requestHttpType;
113   - //替换key value
114   - const params: any = {};
115   - getTable?.map((it) => (params[it.key!] = it.value!));
116 132 excuteData.value = {
117   - method: props.data?.method,
118   - apiGetUrl,
119   - apiType,
120 133 params,
121   - activeKey: props.data?.activeKey,
122 134 };
123 135 return excuteData.value;
124 136 };
... ...
... ... @@ -45,6 +45,7 @@
45 45 placeholder="请选择"
46 46 notFoundContent="请选择"
47 47 :options="attributeOptions"
  48 + mode="multiple"
48 49 allowClear
49 50 />
50 51 <div v-else-if="item.key === 'date_range'">
... ... @@ -149,6 +150,9 @@
149 150 //设置数据
150 151 const setTableArray = (data) => {
151 152 const list = cloneDeep(data);
  153 + list?.forEach((it) => {
  154 + if (it.key === 'keys') it.value = [];
  155 + });
152 156 if (Array.isArray(list)) (tableTestArray.content = list) && getApi(list);
153 157 if (list.hasOwnProperty('form-data') && Array.isArray(list['form-data']))
154 158 (tableTestArray.content = list['form-data']) && getApi(list['form-data']);
... ... @@ -202,7 +206,7 @@
202 206 if (e.key === 'deviceProfileId') {
203 207 tableTestArray.content.forEach((f: any) => {
204 208 if (f.key === 'keys') {
205   - f.value = null;
  209 + f.value = [];
206 210 }
207 211 if (f.key === 'organizationId') organizationId = f.value;
208 212 if (f.key === 'entityId') f.value = null;
... ...
... ... @@ -183,8 +183,10 @@
183 183 }
184 184 };
185 185
186   - const resetValue = () => {
187   - showTestFlag.value = false;
  186 + const resetValue = (flag) => {
  187 + if (flag) {
  188 + showTestFlag.value = false;
  189 + }
188 190 httpResult.value = '测试结果为:';
189 191 testResult.value = '测试结果为:';
190 192 ifWebSocket.value = '0';
... ...
... ... @@ -59,26 +59,10 @@
59 59 //获取数据
60 60 const getTestValue = () => {
61 61 const getTable = getTestTableKeyValue();
62   - //源地址
63   - let apiGetUrl = '';
64   - if (props.data?.originUrlType === 'server_url') {
65   - const pathUrl = window.location.host;
66   - const protocol = window.location.protocol;
67   - apiGetUrl = `${protocol}//${pathUrl}`;
68   - } else {
69   - apiGetUrl = `${props.data?.requestOriginUrl}${props.data?.requestTypeAndUrl?.requestUrl}`;
70   - }
71   - //请求类型
72   - const apiType = props.data?.requestTypeAndUrl?.requestHttpType;
73   - //替换key value
74 62 const params: any = {};
75 63 getTable?.map((it: any) => (params[it.key!] = it.value!));
76 64 excuteData.value = {
77   - method: props.data?.method,
78   - apiGetUrl,
79   - apiType,
80 65 params,
81   - activeKey: props.data?.activeKey,
82 66 };
83 67 return excuteData.value;
84 68 };
... ...
... ... @@ -99,26 +99,13 @@
99 99 //获取数据
100 100 const getTestValue = () => {
101 101 const getTable = getTestTableKeyValue();
102   - //源地址
103   - let apiGetUrl = '';
104   - if (props.data?.originUrlType === 'server_url') {
105   - const pathUrl = window.location.host;
106   - const protocol = window.location.protocol;
107   - apiGetUrl = `${protocol}//${pathUrl}`;
108   - } else {
109   - apiGetUrl = `${props.data?.requestOriginUrl}${props.data?.requestTypeAndUrl?.requestUrl}`;
110   - }
111   - //请求类型
112   - const apiType = props.data?.requestTypeAndUrl?.requestHttpType;
113   - //替换key value
114 102 const params: any = {};
115 103 getTable?.map((it) => (params[it.key!] = it.value!));
  104 + if (params['keys']) {
  105 + Reflect.set(params, 'keys', params['keys'].join(','));
  106 + }
116 107 excuteData.value = {
117   - method: props.data?.method,
118   - apiGetUrl,
119   - apiType,
120 108 params,
121   - activeKey: props.data?.activeKey,
122 109 };
123 110 return excuteData.value;
124 111 };
... ...
... ... @@ -45,6 +45,7 @@
45 45 placeholder="请选择"
46 46 notFoundContent="请选择"
47 47 :options="attributeOptions"
  48 + mode="multiple"
48 49 allowClear
49 50 />
50 51 <div v-else-if="item.key === 'date_range'">
... ... @@ -149,15 +150,10 @@
149 150 //设置数据
150 151 const setTableArray = (data) => {
151 152 const list = cloneDeep(data);
  153 + list?.forEach((it) => {
  154 + if (it.key === 'keys') it.value = [];
  155 + });
152 156 if (Array.isArray(list)) (tableTestArray.content = list) && getApi(list);
153   - if (list.hasOwnProperty('form-data') && Array.isArray(list['form-data']))
154   - (tableTestArray.content = list['form-data']) && getApi(list['form-data']);
155   - if (
156   - list.hasOwnProperty('x-www-form-urlencoded') &&
157   - Array.isArray(list['x-www-form-urlencoded'])
158   - )
159   - (tableTestArray.content = list['x-www-form-urlencoded']) &&
160   - getApi(list['x-www-form-urlencoded']);
161 157 };
162 158
163 159 const getApi = (list) => {
... ... @@ -202,7 +198,7 @@
202 198 if (e.key === 'deviceProfileId') {
203 199 tableTestArray.content.forEach((f: any) => {
204 200 if (f.key === 'keys') {
205   - f.value = null;
  201 + f.value = [];
206 202 }
207 203 if (f.key === 'organizationId') organizationId = f.value;
208 204 if (f.key === 'entityId') f.value = null;
... ...
... ... @@ -10,7 +10,7 @@ export type selectType = { label: string; value: string; disabled?: boolean };
10 10 */
11 11 export type tableItems = {
12 12 key: SelectValue | undefined;
13   - value: string | SelectValue | undefined;
  13 + value: string | SelectValue | undefined | [string];
14 14 fixed_date_value?: string;
15 15 editDisabled?: boolean;
16 16 required?: boolean;
... ...