Commit 4666799ae5dc784d5bf83c4eab3daec35026db41

Authored by xp.Huang
2 parents aab0390a b43522b9

Merge branch 'feat/tcp-product-thingsmodel-add-field' into 'main_dev'

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

See merge request yunteng/thingskit-front!745
  1 +import { findDictItemByCode } from '/@/api/system/dict';
  2 +import { FormSchema } from '/@/components/Table';
  3 +import { DictEnum } from '/@/enums/dictEnum';
  4 +
  5 +export enum FormFieldsEnum {
  6 + REGISTER_ADDRESS = 'registerAddress',
  7 + DATA_TYPE = 'dataType',
  8 + ACTION_TYPE = 'actionType',
  9 +}
  10 +
  11 +export const formSchemas: FormSchema[] = [
  12 + {
  13 + field: FormFieldsEnum.REGISTER_ADDRESS,
  14 + component: 'InputNumber',
  15 + label: '寄存器地址',
  16 + rules: [{ message: '请输入寄存器地址', required: true }],
  17 + componentProps: {
  18 + max: parseInt('ffff', 16),
  19 + placeholder: '请输入寄存器地址',
  20 + },
  21 + },
  22 + {
  23 + field: FormFieldsEnum.DATA_TYPE,
  24 + component: 'ApiSelect',
  25 + label: '数据格式',
  26 + rules: [{ message: '请选择数据格式', required: true }],
  27 + componentProps: {
  28 + api: findDictItemByCode,
  29 + params: {
  30 + dictCode: DictEnum.REGISTER_DATA_FORMAT,
  31 + },
  32 + labelField: 'itemText',
  33 + valueField: 'itemValue',
  34 + placeholder: '请选择数据格式',
  35 + getPopupContainer: () => document.body,
  36 + },
  37 + },
  38 + {
  39 + field: FormFieldsEnum.ACTION_TYPE,
  40 + component: 'Select',
  41 + label: '操作类型',
  42 + rules: [{ message: '请选择操作类型', required: true }],
  43 + componentProps: {
  44 + options: [
  45 + { label: '05 写入单个线圈寄存器', value: '05' },
  46 + { label: '06 写入单个保持寄存器', value: '06' },
  47 + // { label: '0F 写入多个线圈状态', value: '0F' },
  48 + { label: '16 写入多个保持寄存器', value: '16' },
  49 + ],
  50 + placeholder: '请选择操作类型',
  51 + getPopupContainer: () => document.body,
  52 + },
  53 + },
  54 +];
... ...
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,
... ...