Commit 93106bcf08c3b2c8649cf873c426510bc142eacc

Authored by ww
1 parent d325344d

fix: DEFECT-1001 visual board create panel product select not found data

... ... @@ -30,6 +30,7 @@
30 30
31 31 const props = defineProps<{
32 32 record: DataBoardLayoutInfo;
  33 + isEdit: boolean;
33 34 frontId?: FrontComponent;
34 35 defaultConfig?: Partial<ComponentInfo>;
35 36 componentCategory?: FrontComponentCategory;
... ... @@ -296,6 +297,7 @@
296 297 <div class="pl-2 flex-auto">
297 298 <component
298 299 :frontId="$props.frontId"
  300 + :isEdit="isEdit"
299 301 :is="dataSourceComponent"
300 302 :ref="(el) => setFormEl(el, item.id)"
301 303 />
... ...
... ... @@ -62,7 +62,7 @@
62 62
63 63 const resetForm = () => {
64 64 isEdit.value = false;
65   - frontId.value = FrontComponent.TEXT_COMPONENT_1;
  65 + frontId.value = undefined;
66 66 componentRecord.value = {} as unknown as DataBoardLayoutInfo;
67 67 componentDefaultConfig.value = {};
68 68 };
... ... @@ -153,6 +153,7 @@
153 153 <BasicConfiguration
154 154 ref="basicConfigurationEl"
155 155 :front-id="frontId"
  156 + :isEdit="isEdit"
156 157 :record="componentRecord"
157 158 :defaultConfig="componentDefaultConfig"
158 159 :componentCategory="getComponentCategory"
... ...
... ... @@ -9,14 +9,16 @@
9 9
10 10 const props = defineProps<{
11 11 frontId?: FrontComponent;
  12 + isEdit: boolean;
12 13 }>();
13 14
14 15 defineExpose({ formActionType: formEl });
15 16
16 17 const getDataSchema = computed(() => {
17   - const { frontId } = props;
  18 + const { frontId, isEdit } = props;
  19 + console.log({ frontId });
18 20 if (!frontId) return [];
19   - return dataSourceSchema(frontId);
  21 + return dataSourceSchema(isEdit, frontId);
20 22 });
21 23
22 24 onMounted(() => {
... ...
... ... @@ -5,6 +5,7 @@
5 5 import { FrontComponent } from '../../../const/const';
6 6
7 7 defineProps<{
  8 + isEdit: boolean;
8 9 frontId?: FrontComponent;
9 10 }>();
10 11
... ... @@ -38,7 +39,7 @@
38 39 <div class="w-full flex-1">
39 40 <BasicForm
40 41 :ref="(el) => setFormEl(el)"
41   - :schemas="dataSourceSchema($props.frontId)"
  42 + :schemas="dataSourceSchema($props.isEdit, $props.frontId)"
42 43 class="w-full flex-1 data-source-form"
43 44 :show-action-button-group="false"
44 45 :row-props="{
... ...
... ... @@ -92,7 +92,7 @@ export const basicSchema: FormSchema[] = [
92 92 },
93 93 ];
94 94
95   -export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
  95 +export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): FormSchema[] => {
96 96 return [
97 97 {
98 98 field: DataSourceField.IS_GATEWAY_DEVICE,
... ... @@ -117,6 +117,7 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
117 117 component: 'ApiSelect',
118 118 label: '设备类型',
119 119 colProps: { span: 8 },
  120 + // defaultValue: DeviceTypeEnum.SENSOR,
120 121 componentProps: ({ formActionType }) => {
121 122 const { setFieldsValue } = formActionType;
122 123 return {
... ... @@ -147,14 +148,13 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
147 148 rules: [{ required: true, message: '产品为必填项' }],
148 149 componentProps: ({ formActionType, formModel }) => {
149 150 const { setFieldsValue } = formActionType;
150   - const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID];
151 151 const deviceType = formModel[DataSourceField.DEVICE_TYPE];
152   - if (![deviceType, deviceProfileId].every(Boolean)) return {};
153 152 return {
154 153 api: async () => {
155 154 if (!deviceType) return [];
156 155 const list = await getDeviceProfile(deviceType);
157   - if (deviceProfileId) {
  156 + if (isEdit) {
  157 + const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID];
158 158 const record = list.find((item) => item.id === deviceProfileId);
159 159 setFieldsValue({ [DataSourceField.TRANSPORT_TYPE]: record?.transportType });
160 160 }
... ... @@ -254,7 +254,7 @@ export const dataSourceSchema = (frontId?: FrontComponent): FormSchema[] => {
254 254 componentProps({ formModel }) {
255 255 const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID];
256 256 const transportType = formModel[DataSourceField.TRANSPORT_TYPE];
257   - if (![deviceProfileId, transportType].every(Boolean)) return {};
  257 + if (isEdit && ![deviceProfileId, transportType].every(Boolean)) return {};
258 258 return {
259 259 api: async () => {
260 260 try {
... ...