|
1
|
+import { StructJSON } from '/@/api/device/model/modelOfMatterModel';
|
1
|
2
|
import { FormSchema } from '/@/components/Form';
|
|
3
|
+import { validateTCPCustomCommand } from '/@/components/Form/src/externalCompns/components/ThingsModelForm';
|
|
4
|
+import { DataTypeEnum } from '/@/enums/objectModelEnum';
|
2
|
5
|
|
3
|
6
|
const InsertString = (t, c, n) => {
|
4
|
7
|
const r: string | number[] = [];
|
...
|
...
|
@@ -127,21 +130,33 @@ const SingleToHexBatch = (t) => { |
127
|
130
|
return r.join('\r\n');
|
128
|
131
|
};
|
129
|
132
|
|
130
|
|
-const formSchemasConfig = (schemas, actionType): FormSchema[] => {
|
131
|
|
- const { identifier, functionName } = schemas;
|
|
133
|
+const formSchemasConfig = (schemas: StructJSON, actionType: string): FormSchema[] => {
|
|
134
|
+ const { identifier, functionName, dataType } = schemas;
|
|
135
|
+
|
|
136
|
+ if (dataType?.type === DataTypeEnum.STRING) {
|
|
137
|
+ return [
|
|
138
|
+ {
|
|
139
|
+ field: identifier,
|
|
140
|
+ label: functionName!,
|
|
141
|
+ component: 'Input',
|
|
142
|
+ rules: [{ required: true, validator: validateTCPCustomCommand }],
|
|
143
|
+ componentProps: {
|
|
144
|
+ placeholder: `请输入${functionName}`,
|
|
145
|
+ },
|
|
146
|
+ },
|
|
147
|
+ ];
|
|
148
|
+ }
|
|
149
|
+
|
132
|
150
|
if (actionType == '06') {
|
133
|
151
|
return [
|
134
|
152
|
{
|
135
|
153
|
field: identifier,
|
136
|
|
- label: functionName,
|
|
154
|
+ label: functionName!,
|
137
|
155
|
component: 'InputNumber',
|
138
|
156
|
rules: [{ required: true, message: '请输入正数' }],
|
139
|
157
|
componentProps: {
|
140
|
158
|
min: 0,
|
141
|
|
- formatter: (e) => {
|
142
|
|
- const value = `${e}`.replace('-', '').replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
|
143
|
|
- return value;
|
144
|
|
- },
|
|
159
|
+ precision: 2,
|
145
|
160
|
placeholder: `请输入正数`,
|
146
|
161
|
},
|
147
|
162
|
},
|
...
|
...
|
@@ -150,7 +165,7 @@ const formSchemasConfig = (schemas, actionType): FormSchema[] => { |
150
|
165
|
return [
|
151
|
166
|
{
|
152
|
167
|
field: identifier,
|
153
|
|
- label: functionName,
|
|
168
|
+ label: functionName!,
|
154
|
169
|
component: 'InputNumber',
|
155
|
170
|
rules: [{ required: true, message: '请输入值' }],
|
156
|
171
|
componentProps: {
|
...
|
...
|
@@ -165,13 +180,12 @@ const formSchemasConfig = (schemas, actionType): FormSchema[] => { |
165
|
180
|
return [
|
166
|
181
|
{
|
167
|
182
|
field: identifier,
|
168
|
|
- label: functionName,
|
|
183
|
+ label: functionName!,
|
169
|
184
|
component: 'InputNumber',
|
170
|
185
|
rules: [{ required: true, message: '请输入值' }],
|
171
|
186
|
componentProps: {
|
172
|
187
|
placeholder: `请输入数字`,
|
173
|
|
- formatter: (e) =>
|
174
|
|
- `${e}`.replace(/\B(?=(\d{3})+(?!\d))/g, '').replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3'),
|
|
188
|
+ precision: 2,
|
175
|
189
|
},
|
176
|
190
|
},
|
177
|
191
|
];
|
...
|
...
|
|