Commit 7c2ad0ef2d4809731cc2cf0c8d8f9755054753e4

Authored by ww
1 parent 4331f4fc

fix: DEFECT-1261 修复看板管理编辑切换前端组件需要重新选择属性

@@ -294,8 +294,9 @@ @@ -294,8 +294,9 @@
294 watch( 294 watch(
295 () => props.frontId, 295 () => props.frontId,
296 async (target, oldTarget) => { 296 async (target, oldTarget) => {
297 - if (isControlComponent(oldTarget!) && isControlComponent(target!)) return;  
298 - await resetFormFields(); 297 + if ([isControlComponent(oldTarget!), isControlComponent(target!)].some(Boolean)) {
  298 + await resetFormFields();
  299 + }
299 } 300 }
300 ); 301 );
301 302
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 import { useCalcGridLayout } from '../../hook/useCalcGridLayout'; 14 import { useCalcGridLayout } from '../../hook/useCalcGridLayout';
15 import { FrontComponent } from '../../const/const'; 15 import { FrontComponent } from '../../const/const';
16 import { frontComponentMap } from '../../components/help'; 16 import { frontComponentMap } from '../../components/help';
  17 + import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
17 18
18 interface DataComponentRouteParams extends RouteParams { 19 interface DataComponentRouteParams extends RouteParams {
19 id: string; 20 id: string;
@@ -75,7 +76,14 @@ @@ -75,7 +76,14 @@
75 unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value); 76 unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value);
76 resetForm(); 77 resetForm();
77 } catch (error: unknown) { 78 } catch (error: unknown) {
78 - window.console.error(error); 79 + if (
  80 + ((error || {}) as ValidateErrorEntity).errorFields &&
  81 + ((error || {}) as ValidateErrorEntity).errorFields.length
  82 + ) {
  83 + const tooltip = ((error || {}) as ValidateErrorEntity).errorFields[0];
  84 + createMessage.warning(tooltip.errors[0]);
  85 + }
  86 + throw error;
79 } 87 }
80 }; 88 };
81 89
@@ -97,7 +105,7 @@ @@ -97,7 +105,7 @@
97 closeModal(); 105 closeModal();
98 emit('create'); 106 emit('create');
99 } catch (error) { 107 } catch (error) {
100 - console.log(error); 108 + throw error;
101 // createMessage.error('创建失败'); 109 // createMessage.error('创建失败');
102 } finally { 110 } finally {
103 changeOkLoading(false); 111 changeOkLoading(false);
@@ -289,6 +289,7 @@ export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): For @@ -289,6 +289,7 @@ export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): For
289 component: 'ApiSelect', 289 component: 'ApiSelect',
290 label: '命令类型', 290 label: '命令类型',
291 defaultValue: CommandTypeEnum.CUSTOM.toString(), 291 defaultValue: CommandTypeEnum.CUSTOM.toString(),
  292 + rules: [{ required: true, message: '请选择命令类型' }],
292 colProps: { span: 8 }, 293 colProps: { span: 8 },
293 ifShow: ({ model }) => 294 ifShow: ({ model }) =>
294 isControlComponent(frontId!) && isTcpProfile(model[DataSourceField.TRANSPORT_TYPE]), 295 isControlComponent(frontId!) && isTcpProfile(model[DataSourceField.TRANSPORT_TYPE]),
@@ -347,6 +348,7 @@ export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): For @@ -347,6 +348,7 @@ export const dataSourceSchema = (isEdit: boolean, frontId?: FrontComponent): For
347 component: 'Input', 348 component: 'Input',
348 label: '命令', 349 label: '命令',
349 colProps: { span: 8 }, 350 colProps: { span: 8 },
  351 + rules: [{ required: true, message: '请输入下发命令' }],
350 // 是控制组件 && 自定义命令 && 传输协议为TCP 352 // 是控制组件 && 自定义命令 && 传输协议为TCP
351 ifShow: ({ model }) => 353 ifShow: ({ model }) =>
352 isControlComponent(frontId!) && 354 isControlComponent(frontId!) &&