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 4 <!-- 待完善封装InputGroup -->
5 5 <InputGroup compact>
6 6 <Select
7   - v-if="type !== '2'"
  7 + v-if="type !== RequestMethodTypeEnum.WEBSOCKET"
8 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 11 :options="selectOptions"
12 12 allowClear
13 13 @change="emitChange"
14 14 />
15 15 <Input
16   - @change="emitChange"
17 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 21 </InputGroup>
22 22 </div>
23 23 </template>
24 24 <script lang="ts" setup>
25   - import { reactive, ref, watchEffect } from 'vue';
  25 + import { reactive, ref, PropType, watch } from 'vue';
26 26 import { InputGroup, Select, Input } from 'ant-design-vue';
27   - import type { SelectValue } from 'ant-design-vue/lib/select';
28 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 32 requestUrl?: string;
34 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 41 const props = defineProps({
40 42 type: {
41 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 49 const emits = defineEmits(['change', 'update:value']);
47 50
48 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 60 } else {
57 61 selectOptions.value = [];
58 62 }
59 63 };
60 64
61   - const valueObj = reactive<TypeInputGroup>({
  65 + const requestTypeUrlValue = reactive<requestTypeUrlConfig>({
62 66 requestHttpType: undefined,
63 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 101 function emitChange() {
76   - emits('change', valueObj);
77   - emits('update:value', valueObj);
  102 + emits('change', requestTypeUrlValue);
  103 + emits('update:value', requestTypeUrlValue);
78 104 }
79 105 </script>
80   -<style scoped></style>
... ...
1 1 export const createPickerSearch = (searchValue = false) => {
2 2 return {
3 3 showSearch: true,
  4 + getPopupContainer: (triggerNode) => triggerNode.parentNode,
4 5 filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => {
5 6 let { label, value } = option;
6 7 label = label.toLowerCase();
... ...
... ... @@ -232,12 +232,6 @@ export const schemas = (): FormSchema[] => {
232 232 component: 'InputGroup',
233 233 required: true,
234 234 colProps: { span: 24 },
235   - componentProps: ({ formActionType }) => {
236   - const { getFieldsValue } = formActionType;
237   - return {
238   - type: getFieldsValue().requestContentType,
239   - };
240   - },
241 235 },
242 236 {
243 237 field: 'fillAddress',
... ...
... ... @@ -127,6 +127,15 @@
127 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 139 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
131 140 await resetFields();
132 141 await nextTick();
... ... @@ -152,13 +161,12 @@
152 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 184 businessText.value === BusinessReportConfigTextEnum.BUSINESS_ADD_TEXT
185 185 ? await createOrEditReportManage(data)
186 186 : putReportConfigManage({ ...restData.data, ...data });
187   - emits('success');
188 187 createMessage.success(`${businessText.value}成功`);
189 188 closeDrawer();
190 189 handleClose();
  190 + setTimeout(() => {
  191 + emits('success');
  192 + }, 500);
191 193 } finally {
192 194 setDrawerProps({ confirmLoading: false });
193 195 }
... ...
... ... @@ -166,6 +166,8 @@ export const useHooks = () => {
166 166 dataRange: [value?.startTs, value?.endTs],
167 167 dateGroupGap: value?.interval,
168 168 };
  169 + Reflect.deleteProperty(value, 'startTs');
  170 + Reflect.deleteProperty(value, 'interval');
169 171 }
170 172 const spanDisance = executeContent?.split(' ');
171 173 const cronTime =
... ...