|
|
@@ -1,5 +1,5 @@
|
|
|
import { Button, Modal } from 'antd';
|
|
|
-import { createForm, Field, registerValidateRules } from '@formily/core';
|
|
|
+import { createForm, Field, onFieldValueChange, registerValidateRules } from '@formily/core';
|
|
|
import { createSchemaField } from '@formily/react';
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
import * as ICONS from '@ant-design/icons';
|
|
|
@@ -54,6 +54,18 @@ export default (props: Props) => {
|
|
|
const form = createForm({
|
|
|
validateFirst: true,
|
|
|
initialValues: data || {},
|
|
|
+ effects: () => {
|
|
|
+ onFieldValueChange('configuration.function', (field, f) => {
|
|
|
+ const value = (field as Field).value;
|
|
|
+ // console.log(value)
|
|
|
+ if (value === 'InputRegisters') {
|
|
|
+ f.setFieldState('configuration.codec.provider', (state) => {
|
|
|
+ console.log(state.dataSource);
|
|
|
+ state.dataSource = state.dataSource?.filter((item) => item.value !== 'bool');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
const SchemaField = createSchemaField({
|
|
|
@@ -174,7 +186,7 @@ export default (props: Props) => {
|
|
|
enum: [
|
|
|
{ label: '01线圈寄存器', value: 'Coils' },
|
|
|
{ label: '03保存寄存器', value: 'HoldingRegisters' },
|
|
|
- { label: '04输入寄存器', value: 'DiscreteInputs' },
|
|
|
+ { label: '04输入寄存器', value: 'InputRegisters' },
|
|
|
],
|
|
|
'x-validator': [
|
|
|
{
|
|
|
@@ -290,7 +302,7 @@ export default (props: Props) => {
|
|
|
dependencies: ['..function', 'configuration.parameter.quantity'],
|
|
|
fulfill: {
|
|
|
state: {
|
|
|
- visible: '{{$deps[0] === "HoldingRegisters"}}',
|
|
|
+ visible: '{{$deps[0] === "HoldingRegisters" || $deps[0] === "InputRegisters"}}',
|
|
|
selfErrors:
|
|
|
'{{$deps[1] && $self.value && {"int8:": 1, "int16": 2, "int32": 4, "int64": 8, "ieee754_float": 4, "ieee754_double": 8, "hex": 1}[$self.value] > $deps[1] * 2 ? "数据类型长度需 <= 寄存器数量 * 2" : ""}}',
|
|
|
},
|