Commit 910c1d3093eedca9ac1b60dcff011255c4fd0fa2

Authored by loveumiko
1 parent 32a616b5

fix: 修复数据流转编辑不需要校验未填项也可以点击返回上一步

@@ -39,11 +39,13 @@ @@ -39,11 +39,13 @@
39 privateKeyFileName: undefined, 39 privateKeyFileName: undefined,
40 }); 40 });
41 41
42 - const [register, { validateFields, setFieldsValue, resetFields, setProps, updateSchema }] =  
43 - useForm({  
44 - schemas: modeApiForm,  
45 - ...modelFormPublicConfig,  
46 - }); 42 + const [
  43 + register,
  44 + { validateFields, setFieldsValue, resetFields, setProps, updateSchema, getFieldsValue },
  45 + ] = useForm({
  46 + schemas: modeApiForm,
  47 + ...modelFormPublicConfig,
  48 + });
47 49
48 const handleFileUrlEmitH = (fileUrl) => (credentialsFile.caCertFileName = fileUrl); 50 const handleFileUrlEmitH = (fileUrl) => (credentialsFile.caCertFileName = fileUrl);
49 51
@@ -52,7 +54,7 @@ @@ -52,7 +54,7 @@
52 const handleFileUrlEmitB = (fileUrl) => (credentialsFile.privateKeyFileName = fileUrl); 54 const handleFileUrlEmitB = (fileUrl) => (credentialsFile.privateKeyFileName = fileUrl);
53 55
54 const getValue = async () => { 56 const getValue = async () => {
55 - const values = await validateFields(); 57 + const values = await getFieldsValue();
56 if (!values) return; 58 if (!values) return;
57 // if (values.type == 'anonymous' || values.type == 'basic') { 59 // if (values.type == 'anonymous' || values.type == 'basic') {
58 // credentialsFile.caCertFileName = undefined; 60 // credentialsFile.caCertFileName = undefined;
@@ -70,6 +72,12 @@ @@ -70,6 +72,12 @@
70 return mergeValues; 72 return mergeValues;
71 }; 73 };
72 74
  75 + const validateValue = async () => {
  76 + const values = await validateFields();
  77 + if (!values) return;
  78 + return values;
  79 + };
  80 +
73 const setValue = (value) => { 81 const setValue = (value) => {
74 const { credentials } = value; 82 const { credentials } = value;
75 if (credentials) { 83 if (credentials) {
@@ -100,6 +108,7 @@ @@ -100,6 +108,7 @@
100 resetValue, 108 resetValue,
101 setDisabledProps, 109 setDisabledProps,
102 setCancelDisabled, 110 setCancelDisabled,
  111 + validateValue,
103 }); 112 });
104 </script> 113 </script>
105 114
@@ -8,13 +8,22 @@ @@ -8,13 +8,22 @@
8 import { modelKafkaForm } from './config'; 8 import { modelKafkaForm } from './config';
9 import { modelFormPublicConfig } from '../../../dataflowmodal/config'; 9 import { modelFormPublicConfig } from '../../../dataflowmodal/config';
10 10
11 - const [register, { validate, setFieldsValue, resetFields, setProps, updateSchema }] = useForm({ 11 + const [
  12 + register,
  13 + { validateFields, setFieldsValue, resetFields, setProps, updateSchema, getFieldsValue },
  14 + ] = useForm({
12 schemas: modelKafkaForm, 15 schemas: modelKafkaForm,
13 ...modelFormPublicConfig, 16 ...modelFormPublicConfig,
14 }); 17 });
15 18
16 const getValue = async () => { 19 const getValue = async () => {
17 - const values = await validate(); 20 + const values = await getFieldsValue();
  21 + if (!values) return;
  22 + return values;
  23 + };
  24 +
  25 + const validateValue = async () => {
  26 + const values = await validateFields();
18 if (!values) return; 27 if (!values) return;
19 return values; 28 return values;
20 }; 29 };
@@ -41,6 +50,7 @@ @@ -41,6 +50,7 @@
41 resetValue, 50 resetValue,
42 setDisabledProps, 51 setDisabledProps,
43 setCancelDisabled, 52 setCancelDisabled,
  53 + validateValue,
44 }); 54 });
45 </script> 55 </script>
46 56
@@ -40,10 +40,11 @@ @@ -40,10 +40,11 @@
40 privateKeyFileName: undefined, 40 privateKeyFileName: undefined,
41 }); 41 });
42 42
43 - const [register, { validateFields, setFieldsValue, resetFields, setProps }] = useForm({  
44 - schemas: modeMqttForm,  
45 - ...modelFormPublicConfig,  
46 - }); 43 + const [register, { validateFields, setFieldsValue, resetFields, setProps, getFieldsValue }] =
  44 + useForm({
  45 + schemas: modeMqttForm,
  46 + ...modelFormPublicConfig,
  47 + });
47 48
48 const handleFileUrlEmitH = (fileUrl) => (credentialsFile.caCertFileName = fileUrl); 49 const handleFileUrlEmitH = (fileUrl) => (credentialsFile.caCertFileName = fileUrl);
49 50
@@ -52,7 +53,7 @@ @@ -52,7 +53,7 @@
52 const handleFileUrlEmitB = (fileUrl) => (credentialsFile.privateKeyFileName = fileUrl); 53 const handleFileUrlEmitB = (fileUrl) => (credentialsFile.privateKeyFileName = fileUrl);
53 54
54 const getValue = async () => { 55 const getValue = async () => {
55 - const values = await validateFields(); 56 + const values = await getFieldsValue();
56 if (!values) return; 57 if (!values) return;
57 if (values.type == 'anonymous' || values.type == 'basic') { 58 if (values.type == 'anonymous' || values.type == 'basic') {
58 credentialsFile.caCertFileName = undefined; 59 credentialsFile.caCertFileName = undefined;
@@ -71,6 +72,12 @@ @@ -71,6 +72,12 @@
71 return mergeValues; 72 return mergeValues;
72 }; 73 };
73 74
  75 + const validateValue = async () => {
  76 + const values = validateFields();
  77 + if (!values) return;
  78 + return values;
  79 + };
  80 +
74 const setValue = (value) => { 81 const setValue = (value) => {
75 const { credentials } = value; 82 const { credentials } = value;
76 if (credentials) { 83 if (credentials) {
@@ -96,6 +103,7 @@ @@ -96,6 +103,7 @@
96 setValue, 103 setValue,
97 resetValue, 104 resetValue,
98 setDisabledProps, 105 setDisabledProps,
  106 + validateValue,
99 }); 107 });
100 </script> 108 </script>
101 109
@@ -8,13 +8,20 @@ @@ -8,13 +8,20 @@
8 import { modeRabbitMqForm } from './config'; 8 import { modeRabbitMqForm } from './config';
9 import { modelFormPublicConfig } from '../../../dataflowmodal/config'; 9 import { modelFormPublicConfig } from '../../../dataflowmodal/config';
10 10
11 - const [register, { validateFields, setFieldsValue, resetFields, setProps, updateSchema }] =  
12 - useForm({  
13 - schemas: modeRabbitMqForm,  
14 - ...modelFormPublicConfig,  
15 - }); 11 + const [
  12 + register,
  13 + { validateFields, setFieldsValue, resetFields, setProps, updateSchema, getFieldsValue },
  14 + ] = useForm({
  15 + schemas: modeRabbitMqForm,
  16 + ...modelFormPublicConfig,
  17 + });
16 18
17 const getValue = async () => { 19 const getValue = async () => {
  20 + const values = await getFieldsValue();
  21 + return values;
  22 + };
  23 +
  24 + const validateValue = async () => {
18 const values = await validateFields(); 25 const values = await validateFields();
19 if (!values) return; 26 if (!values) return;
20 return values; 27 return values;
@@ -39,6 +46,7 @@ @@ -39,6 +46,7 @@
39 resetValue, 46 resetValue,
40 setDisabledProps, 47 setDisabledProps,
41 setCancelDisabled, 48 setCancelDisabled,
  49 + validateValue,
42 }); 50 });
43 </script> 51 </script>
44 <style lang="less" scoped></style> 52 <style lang="less" scoped></style>
@@ -100,6 +100,8 @@ @@ -100,6 +100,8 @@
100 if (closeModalAfterSuccess) { 100 if (closeModalAfterSuccess) {
101 closeModalAfterSuccess && setModalProps({ confirmLoading: true }); 101 closeModalAfterSuccess && setModalProps({ confirmLoading: true });
102 const getDataFlowMethod = await dataFlowMethodRef.value?.getValue(); 102 const getDataFlowMethod = await dataFlowMethodRef.value?.getValue();
  103 + const values = await dataFlowParamsRef.value?.validateValue();
  104 + if (!values) return;
103 const { name, description, ...getDataFlowParams } = 105 const { name, description, ...getDataFlowParams } =
104 await dataFlowParamsRef.value?.getValue(); 106 await dataFlowParamsRef.value?.getValue();
105 removeFieldByModeForm.forEach((item) => { 107 removeFieldByModeForm.forEach((item) => {
@@ -54,6 +54,7 @@ @@ -54,6 +54,7 @@
54 54
55 const currentDataFlowParamsHanlePrevStep = async () => { 55 const currentDataFlowParamsHanlePrevStep = async () => {
56 const values = await getValue(); 56 const values = await getValue();
  57 + console.log(values, 'values');
57 emit('currentDataFlowParamsEmitPrevStep', { currentStep: 0, values }); 58 emit('currentDataFlowParamsEmitPrevStep', { currentStep: 0, values });
58 }; 59 };
59 60
@@ -64,24 +65,28 @@ @@ -64,24 +65,28 @@
64 () => dataFlowMethodIsKafkaRef.value?.getValue(), 65 () => dataFlowMethodIsKafkaRef.value?.getValue(),
65 (value) => dataFlowMethodIsKafkaRef.value?.setValue(value), 66 (value) => dataFlowMethodIsKafkaRef.value?.setValue(value),
66 () => dataFlowMethodIsKafkaRef.value?.resetValue(), 67 () => dataFlowMethodIsKafkaRef.value?.resetValue(),
  68 + () => dataFlowMethodIsKafkaRef.value?.validateValue(),
67 ], 69 ],
68 [ 70 [
69 (dataFlowType) => dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_MQTT, 71 (dataFlowType) => dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_MQTT,
70 () => dataFlowMethodIsMqttRef.value?.getValue(), 72 () => dataFlowMethodIsMqttRef.value?.getValue(),
71 (value) => dataFlowMethodIsMqttRef.value?.setValue(value), 73 (value) => dataFlowMethodIsMqttRef.value?.setValue(value),
72 () => dataFlowMethodIsMqttRef.value?.resetValue(), 74 () => dataFlowMethodIsMqttRef.value?.resetValue(),
  75 + () => dataFlowMethodIsMqttRef.value?.validateValue(),
73 ], 76 ],
74 [ 77 [
75 (dataFlowType) => dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_RABBITMQ, 78 (dataFlowType) => dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_RABBITMQ,
76 () => dataFlowMethodIsRabbitMqRef.value?.getValue(), 79 () => dataFlowMethodIsRabbitMqRef.value?.getValue(),
77 (value) => dataFlowMethodIsRabbitMqRef.value?.setValue(value), 80 (value) => dataFlowMethodIsRabbitMqRef.value?.setValue(value),
78 () => dataFlowMethodIsRabbitMqRef.value?.resetValue(), 81 () => dataFlowMethodIsRabbitMqRef.value?.resetValue(),
  82 + () => dataFlowMethodIsRabbitMqRef.value?.validateValue(),
79 ], 83 ],
80 [ 84 [
81 (dataFlowType) => dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_REST_API, 85 (dataFlowType) => dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_REST_API,
82 () => dataFlowMethodIsApiRef.value?.getValue(), 86 () => dataFlowMethodIsApiRef.value?.getValue(),
83 (value) => dataFlowMethodIsApiRef.value?.setValue(value), 87 (value) => dataFlowMethodIsApiRef.value?.setValue(value),
84 () => dataFlowMethodIsApiRef.value?.resetValue(), 88 () => dataFlowMethodIsApiRef.value?.resetValue(),
  89 + () => dataFlowMethodIsApiRef.value?.validateValue(),
85 ], 90 ],
86 ]; 91 ];
87 92
@@ -105,6 +110,12 @@ @@ -105,6 +110,12 @@
105 findDateFlow[3](0); 110 findDateFlow[3](0);
106 }; 111 };
107 112
  113 + const validateValue = async () => {
  114 + const findDateFlow = dataFlowTypeGetForm.find((item) => item[0](props.dataFlowType));
  115 + if (!findDateFlow) return findDateFlow;
  116 + return findDateFlow[4](0);
  117 + };
  118 +
108 const setProps = async () => { 119 const setProps = async () => {
109 await nextTick(); 120 await nextTick();
110 props.dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_KAFKA && 121 props.dataFlowType === BusinessDataFlowMethodEnum.DATAFLOW_METHOD_KAFKA &&
@@ -133,6 +144,7 @@ @@ -133,6 +144,7 @@
133 resetValue, 144 resetValue,
134 setCancelDisabled, 145 setCancelDisabled,
135 setProps, 146 setProps,
  147 + validateValue,
136 }); 148 });
137 </script> 149 </script>
138 <style lang="less" scoped> 150 <style lang="less" scoped>