Commit 897143e439753184487844002ec285fd678e8ccd
1 parent
93d021a9
fix: repeat fetch in visual board bind dataSource modal happend echo data
Showing
3 changed files
with
13 additions
and
4 deletions
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | return decode((ROUTE.params as DataComponentRouteParams).boardId as string); |
34 | 34 | }); |
35 | 35 | |
36 | - const frontId = ref(FrontComponent.TEXT_COMPONENT_1); | |
36 | + const frontId = ref(); | |
37 | 37 | |
38 | 38 | const isEdit = ref(false); |
39 | 39 | |
... | ... | @@ -48,6 +48,7 @@ |
48 | 48 | const [register, { closeModal, changeOkLoading }] = useModalInner( |
49 | 49 | (data: { isEdit: boolean; record?: DataBoardLayoutInfo }) => { |
50 | 50 | componentRecord.value = data.record || ({} as unknown as DataBoardLayoutInfo); |
51 | + if (!unref(isEdit)) frontId.value = FrontComponent.TEXT_COMPONENT_1; | |
51 | 52 | frontId.value = |
52 | 53 | (data.record?.record?.frontId as FrontComponent) || FrontComponent.TEXT_COMPONENT_1; |
53 | 54 | isEdit.value = data.isEdit || false; | ... | ... |
1 | 1 | <script lang="ts" setup> |
2 | - import { ref, onMounted, unref } from 'vue'; | |
2 | + import { ref, onMounted, unref, computed } from 'vue'; | |
3 | 3 | import { FrontComponent } from '../../../const/const'; |
4 | 4 | import { DataSourceField, dataSourceSchema } from '../../config/basicConfiguration'; |
5 | 5 | import { DeviceTypeEnum } from '/@/api/device/model/deviceModel'; |
... | ... | @@ -7,12 +7,18 @@ |
7 | 7 | import BasicForm from '/@/components/Form/src/BasicForm.vue'; |
8 | 8 | const formEl = ref<Nullable<FormActionType>>(null); |
9 | 9 | |
10 | - defineProps<{ | |
10 | + const props = defineProps<{ | |
11 | 11 | frontId?: FrontComponent; |
12 | 12 | }>(); |
13 | 13 | |
14 | 14 | defineExpose({ formActionType: formEl }); |
15 | 15 | |
16 | + const getDataSchema = computed(() => { | |
17 | + const { frontId } = props; | |
18 | + if (!frontId) return []; | |
19 | + return dataSourceSchema(frontId); | |
20 | + }); | |
21 | + | |
16 | 22 | onMounted(() => { |
17 | 23 | unref(formEl)?.setFieldsValue({ [DataSourceField.DEVICE_TYPE]: DeviceTypeEnum.SENSOR }); |
18 | 24 | }); |
... | ... | @@ -21,7 +27,7 @@ |
21 | 27 | <template> |
22 | 28 | <BasicForm |
23 | 29 | ref="formEl" |
24 | - :schemas="dataSourceSchema($props.frontId)" | |
30 | + :schemas="getDataSchema" | |
25 | 31 | class="w-full flex-1 data-source-form" |
26 | 32 | :show-action-button-group="false" |
27 | 33 | :row-props="{ | ... | ... |
... | ... | @@ -149,6 +149,7 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => { |
149 | 149 | const { setFieldsValue } = formActionType; |
150 | 150 | const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID]; |
151 | 151 | const deviceType = formModel[DataSourceField.DEVICE_TYPE]; |
152 | + if (![deviceType, deviceProfileId].every(Boolean)) return {}; | |
152 | 153 | return { |
153 | 154 | api: async () => { |
154 | 155 | if (!deviceType) return []; |
... | ... | @@ -253,6 +254,7 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => { |
253 | 254 | componentProps({ formModel }) { |
254 | 255 | const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID]; |
255 | 256 | const transportType = formModel[DataSourceField.TRANSPORT_TYPE]; |
257 | + if (![deviceProfileId, transportType].every(Boolean)) return {}; | |
256 | 258 | return { |
257 | 259 | api: async () => { |
258 | 260 | try { | ... | ... |