Commit 3ca746d2e1d46d18626cb53c3420b315be542b8f

Authored by xp.Huang
2 parents 02bcfcf6 43b6c208

Merge branch 'local_dev_branch_by_ft' into 'main_dev'

fix: DEFECT-1758 首先点击新增公共接口,选择websocket请求,然后点击管理页回到界面,再新增公共接口,此时普通请求没有请求类型了

See merge request yunteng/thingskit-front!1012
@@ -4,77 +4,102 @@ @@ -4,77 +4,102 @@
4 <!-- 待完善封装InputGroup --> 4 <!-- 待完善封装InputGroup -->
5 <InputGroup compact> 5 <InputGroup compact>
6 <Select 6 <Select
7 - v-if="type !== '2'" 7 + v-if="type !== RequestMethodTypeEnum.WEBSOCKET"
8 placeholder="请求类型" 8 placeholder="请求类型"
9 - :style="{ width: type !== '2' ? 15 + '%' : 0 + '%' }"  
10 - v-model:value="valueObj.requestHttpType" 9 + :style="{ width: type !== RequestMethodTypeEnum.WEBSOCKET ? 15 + '%' : 0 + '%' }"
  10 + v-model:value="requestTypeUrlValue.requestHttpType"
11 :options="selectOptions" 11 :options="selectOptions"
12 allowClear 12 allowClear
13 @change="emitChange" 13 @change="emitChange"
14 /> 14 />
15 <Input 15 <Input
16 - @change="emitChange"  
17 placeholder="请输入接口地址" 16 placeholder="请输入接口地址"
18 - v-model:value="valueObj.requestUrl"  
19 - :style="{ width: type !== '2' ? 85 + '%' : 100 + '%' }" 17 + v-model:value="requestTypeUrlValue.requestUrl"
  18 + :style="{ width: type !== RequestMethodTypeEnum.WEBSOCKET ? 85 + '%' : 100 + '%' }"
  19 + @change="emitChange"
20 /> 20 />
21 </InputGroup> 21 </InputGroup>
22 </div> 22 </div>
23 </template> 23 </template>
24 <script lang="ts" setup> 24 <script lang="ts" setup>
25 - import { reactive, ref, watchEffect } from 'vue'; 25 + import { reactive, ref, PropType, watch } from 'vue';
26 import { InputGroup, Select, Input } from 'ant-design-vue'; 26 import { InputGroup, Select, Input } from 'ant-design-vue';
27 - import type { SelectValue } from 'ant-design-vue/lib/select';  
28 import { findDictItemByCode } from '/@/api/system/dict'; 27 import { findDictItemByCode } from '/@/api/system/dict';
29 - import { propTypes } from '/@/utils/propTypes'; 28 + import { RequestMethodTypeEnum } from '/@/views/dataview/publicApi/config/enum';
30 29
31 - type TypeInputGroup = {  
32 - requestHttpType: SelectValue | undefined; 30 + interface requestTypeUrlConfig {
  31 + requestHttpType: undefined;
33 requestUrl?: string; 32 requestUrl?: string;
34 disabled?: boolean; 33 disabled?: boolean;
35 - }; 34 + }
36 35
37 - type selectType = { label: string; value: string; disabled?: boolean }; 36 + type selectType = {
  37 + label: string;
  38 + value: string;
  39 + };
38 40
39 const props = defineProps({ 41 const props = defineProps({
40 type: { 42 type: {
41 type: String, 43 type: String,
  44 + default: RequestMethodTypeEnum.COMMOM,
42 }, 45 },
43 - value: propTypes.object.def({}), 46 + value: Object as PropType<requestTypeUrlConfig>,
44 }); 47 });
45 48
46 const emits = defineEmits(['change', 'update:value']); 49 const emits = defineEmits(['change', 'update:value']);
47 50
48 const selectOptions = ref<selectType[]>([]); 51 const selectOptions = ref<selectType[]>([]);
49 52
50 - const getOptions = async (e) => {  
51 - const res = await findDictItemByCode({  
52 - dictCode: e === '1' ? 'dataview_select_sql_request' : 'dataview_select_request', 53 + const getOptions = async (requestType) => {
  54 + // 暂且排除SQL和WEBSOCKET
  55 + const resItem = await findDictItemByCode({
  56 + dictCode: 'dataview_select_request',
53 }); 57 });
54 - if (e === '1' || e === '0') {  
55 - selectOptions.value = res.map((m) => ({ label: m.itemText, value: m.itemValue })); 58 + if (requestType === RequestMethodTypeEnum.COMMOM) {
  59 + selectOptions.value = resItem.map((m) => ({ label: m.itemText, value: m.itemValue }));
56 } else { 60 } else {
57 selectOptions.value = []; 61 selectOptions.value = [];
58 } 62 }
59 }; 63 };
60 64
61 - const valueObj = reactive<TypeInputGroup>({ 65 + const requestTypeUrlValue = reactive<requestTypeUrlConfig>({
62 requestHttpType: undefined, 66 requestHttpType: undefined,
63 requestUrl: '', 67 requestUrl: '',
64 }); 68 });
65 69
66 - watchEffect(() => {  
67 - initVal();  
68 - }); 70 + watch(
  71 + () => props.type,
  72 + () => {
  73 + initOption();
  74 + },
  75 + {
  76 + immediate: true,
  77 + }
  78 + );
  79 +
  80 + watch(
  81 + () => props.value,
  82 + () => {
  83 + initConfig();
  84 + },
  85 + {
  86 + immediate: true,
  87 + }
  88 + );
  89 +
  90 + function initOption() {
  91 + if (props.type) {
  92 + getOptions(props.type);
  93 + }
  94 + }
69 95
70 - async function initVal() {  
71 - if (props?.type) await getOptions(props?.type);  
72 - if (props?.value) for (let i in props.value) Reflect.set(valueObj, i, props.value[i]); 96 + function initConfig() {
  97 + if (props?.value)
  98 + for (let i in props.value) Reflect.set(requestTypeUrlValue, i, props.value[i]);
73 } 99 }
74 100
75 function emitChange() { 101 function emitChange() {
76 - emits('change', valueObj);  
77 - emits('update:value', valueObj); 102 + emits('change', requestTypeUrlValue);
  103 + emits('update:value', requestTypeUrlValue);
78 } 104 }
79 </script> 105 </script>
80 -<style scoped></style>  
1 export const createPickerSearch = (searchValue = false) => { 1 export const createPickerSearch = (searchValue = false) => {
2 return { 2 return {
3 showSearch: true, 3 showSearch: true,
  4 + getPopupContainer: (triggerNode) => triggerNode.parentNode,
4 filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => { 5 filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => {
5 let { label, value } = option; 6 let { label, value } = option;
6 label = label.toLowerCase(); 7 label = label.toLowerCase();
@@ -232,12 +232,6 @@ export const schemas = (): FormSchema[] => { @@ -232,12 +232,6 @@ export const schemas = (): FormSchema[] => {
232 component: 'InputGroup', 232 component: 'InputGroup',
233 required: true, 233 required: true,
234 colProps: { span: 24 }, 234 colProps: { span: 24 },
235 - componentProps: ({ formActionType }) => {  
236 - const { getFieldsValue } = formActionType;  
237 - return {  
238 - type: getFieldsValue().requestContentType,  
239 - };  
240 - },  
241 }, 235 },
242 { 236 {
243 field: 'fillAddress', 237 field: 'fillAddress',
@@ -127,6 +127,15 @@ @@ -127,6 +127,15 @@
127 showActionButtonGroup: false, 127 showActionButtonGroup: false,
128 }); 128 });
129 129
  130 + const updatePartFormScheme = (requestType: string) => {
  131 + updateSchema({
  132 + field: 'requestHttpTypeAndUrl',
  133 + componentProps: {
  134 + type: requestType,
  135 + },
  136 + });
  137 + };
  138 +
130 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { 139 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
131 await resetFields(); 140 await resetFields();
132 await nextTick(); 141 await nextTick();
@@ -152,13 +161,12 @@ @@ -152,13 +161,12 @@
152 requestUrl: data.record?.requestUrl, 161 requestUrl: data.record?.requestUrl,
153 }, 162 },
154 }); 163 });
155 - await nextTick(() => simpleRequestRef.value?.setValue(data.record, false, []));  
156 - updateSchema({  
157 - field: 'requestHttpTypeAndUrl',  
158 - componentProps: {  
159 - type: String(data.record?.requestContentType),  
160 - }, 164 + await nextTick(() => {
  165 + simpleRequestRef.value?.setValue(data.record, false, []);
  166 + updatePartFormScheme(String(data.record?.requestContentType));
161 }); 167 });
  168 + } else {
  169 + await updatePartFormScheme(RequestMethodTypeEnum.COMMOM);
162 } 170 }
163 }); 171 });
164 172
@@ -184,10 +184,12 @@ @@ -184,10 +184,12 @@
184 businessText.value === BusinessReportConfigTextEnum.BUSINESS_ADD_TEXT 184 businessText.value === BusinessReportConfigTextEnum.BUSINESS_ADD_TEXT
185 ? await createOrEditReportManage(data) 185 ? await createOrEditReportManage(data)
186 : putReportConfigManage({ ...restData.data, ...data }); 186 : putReportConfigManage({ ...restData.data, ...data });
187 - emits('success');  
188 createMessage.success(`${businessText.value}成功`); 187 createMessage.success(`${businessText.value}成功`);
189 closeDrawer(); 188 closeDrawer();
190 handleClose(); 189 handleClose();
  190 + setTimeout(() => {
  191 + emits('success');
  192 + }, 500);
191 } finally { 193 } finally {
192 setDrawerProps({ confirmLoading: false }); 194 setDrawerProps({ confirmLoading: false });
193 } 195 }
@@ -166,6 +166,8 @@ export const useHooks = () => { @@ -166,6 +166,8 @@ export const useHooks = () => {
166 dataRange: [value?.startTs, value?.endTs], 166 dataRange: [value?.startTs, value?.endTs],
167 dateGroupGap: value?.interval, 167 dateGroupGap: value?.interval,
168 }; 168 };
  169 + Reflect.deleteProperty(value, 'startTs');
  170 + Reflect.deleteProperty(value, 'interval');
169 } 171 }
170 const spanDisance = executeContent?.split(' '); 172 const spanDisance = executeContent?.split(' ');
171 const cronTime = 173 const cronTime =