data.ts 1.95 KB
import { FormSchema } from '/@/components/Form';
import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi';
import { findDictItemByCode } from '/@/api/system/dict';

export const step1Schemas: FormSchema[] = [
  {
    field: 'name',
    label: '上传图片',
    component: 'Input',
    slot: 'imageSelect',
  },
  {
    field: 'name',
    label: '配置名称',
    required: true,
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入配置名称',
    },
  },
  {
    field: 'defaultRuleChainId',
    label: '规则链',
    component: 'ApiSelect',
    componentProps: {
      api: async () => {
        const data = await deviceConfigGetRuleChain();
        const returnData = data.map((m) => {
          return {
            getValueField: m.name,
            getKeyField: m.id.id,
          };
        });
        return returnData;
      },
      labelField: 'getValueField',
      valueField: 'getKeyField',
      immediate: true,
    },
  },
  {
    field: 'defaultQueueName',
    label: '处理队列',
    component: 'ApiSelect',
    componentProps: {
      api: findDictItemByCode,
      params: {
        dictCode: 'queen_execute_sequence',
      },
      labelField: 'itemText',
      valueField: 'itemValue',
      resultField: 'items',
    },
  },

  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入描述',
    },
  },
];

export const step2Schemas: FormSchema[] = [
  {
    field: 'transportType',
    component: 'Select',
    label: '传输方式',
    defaultValue: 'DEFAULT',
    componentProps() {
      return {
        options: [
          { label: '默认', value: 'DEFAULT' },
          { label: 'MQTT', value: 'MQTT' },
          { label: 'CoAP', value: 'COAP' },
          // { label: 'LWM2M', value: 'LWM2M' },
        ],
        onChange(e) {},
      };
    },
    colProps: { span: 11 },
  },
];