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