Commit 3ba23b64468be295faa87a750e32d907634297a3

Authored by ww
1 parent a244ab46

feat: tcp产品物模型新增字段

  1 +import { FormSchema } from '/@/components/Table';
  2 +
  3 +export enum FormFieldsEnum {
  4 + REGISTER_ADDRESS = 'registerAddress',
  5 + DATA_TYPE = 'dataType',
  6 + ACTION_TYPE = 'actionType',
  7 +}
  8 +
  9 +export const formSchemas: FormSchema[] = [
  10 + {
  11 + field: FormFieldsEnum.REGISTER_ADDRESS,
  12 + component: 'InputNumber',
  13 + label: '寄存器地址',
  14 + rules: [{ message: '请输入寄存器地址', required: true }],
  15 + componentProps: {
  16 + max: parseInt('ffff', 16),
  17 + placeholder: '请输入寄存器地址',
  18 + },
  19 + },
  20 + // {
  21 + // field: FormFieldsEnum.DATA_TYPE,
  22 + // component: 'ApiSelect',
  23 + // label: '数据格式',
  24 + // rules: [{ message: '请选择数据格式', required: true }],
  25 + // componentProps: {
  26 + // api: findDictItemByCode,
  27 + // params: {
  28 + // dictCode: DictEnum.REGISTER_DATA_FORMAT,
  29 + // },
  30 + // labelField: 'itemText',
  31 + // valueField: 'itemValue',
  32 + // placeholder: '请选择数据格式',
  33 + // },
  34 + // },
  35 + {
  36 + field: FormFieldsEnum.ACTION_TYPE,
  37 + component: 'Select',
  38 + label: '操作类型',
  39 + rules: [{ message: '请选择操作类型', required: true }],
  40 + componentProps: {
  41 + options: [
  42 + { label: '05 写入单个线圈寄存器', value: '05' },
  43 + { label: '06 写入单个保持寄存器', value: '06' },
  44 + { label: '0F 写入多个线圈状态', value: '0F' },
  45 + { label: '10 写入多个保持寄存器', value: '10' },
  46 + ],
  47 + placeholder: '请选择操作类型',
  48 + getPopupContainer: () => document.body,
  49 + },
  50 + },
  51 +];
... ...
1 1 <script lang="ts" setup>
2 2 import { Button } from 'ant-design-vue';
3 3 import { nextTick, ref, watch } from 'vue';
4   - import { findDictItemByCode } from '/@/api/system/dict';
5 4 import { BasicForm, useForm } from '/@/components/Form';
6 5 import { BasicModal } from '/@/components/Modal';
7   - import { DictEnum } from '/@/enums/dictEnum';
8 6 import { PlusCircleOutlined } from '@ant-design/icons-vue';
  7 + import { formSchemas } from './config';
9 8 const show = ref(false);
10 9
11 10 const props = withDefaults(
... ... @@ -22,33 +21,7 @@
22 21
23 22 const [registerForm, { setFieldsValue, getFieldsValue, setProps, validate, resetFields }] =
24 23 useForm({
25   - schemas: [
26   - {
27   - field: 'registerAddress',
28   - component: 'InputNumber',
29   - label: '寄存器地址',
30   - rules: [{ message: '请输入寄存器地址', required: true }],
31   - componentProps: {
32   - max: parseInt('ffff', 16),
33   - placeholder: '请输入寄存器地址',
34   - },
35   - },
36   - {
37   - field: 'dataType',
38   - component: 'ApiSelect',
39   - label: '数据格式',
40   - rules: [{ message: '请选择数据格式', required: true }],
41   - componentProps: {
42   - api: findDictItemByCode,
43   - params: {
44   - dictCode: DictEnum.REGISTER_DATA_FORMAT,
45   - },
46   - labelField: 'itemText',
47   - valueField: 'itemValue',
48   - placeholder: '请选择数据格式',
49   - },
50   - },
51   - ],
  24 + schemas: formSchemas,
52 25 showActionButtonGroup: false,
53 26 });
54 27
... ...
... ... @@ -281,17 +281,6 @@ export const formSchemas = (hasStructForm: boolean, isTcp = false): FormSchema[]
281 281 label: '扩展描述',
282 282 valueField: 'value',
283 283 changeEvent: 'update:value',
284   - rules: [
285   - {
286   - message: '请输入扩展描述',
287   - required: true,
288   - validator(_rule, value, _callback) {
289   - if (isNullOrUnDef(value?.['registerAddress']))
290   - return Promise.reject('请输入寄存器地址');
291   - return Promise.resolve();
292   - },
293   - },
294   - ],
295 284 ifShow: isTcp,
296 285 colProps: {
297 286 span: 16,
... ...