干燥机配套车间生产管理系统/云平台前端
baoshiwei
13 小时以前 a3e955e801044d8abc2ec575cdf74a6815b8d963
src/views/dry/dataDefine/DryHerbFormula.data.ts
@@ -1,4 +1,8 @@
import { BasicColumn, FormSchema } from '/@/components/Table'
import {render} from "/@/utils/common/renderUtils";
import {rules} from "/@/utils/helper/validator";
import {queryById} from "/@/views/dry/api/DryHerbInfo.api"
import { getFirstWordSpell } from "/@/utils/common/renderUtils";
//列表数据
export const columns: BasicColumn[] = [
   {
@@ -6,16 +10,48 @@
      align: 'center',
      dataIndex: 'herbId_dictText',
   },
   // {
   //    title: '药材名称',
   //    align: 'center',
   //    dataIndex: 'herbName',
   // },
   {
      title: '配方名称',
      align: 'center',
      dataIndex: 'name',
   },
   {
      title: '适用设备',
      align: 'center',
      dataIndex: 'eqpType_dictText',
   },
  {
    title: '缩写',
    align: 'center',
    dataIndex: 'abbr',
  },
  {
    title: '特种物料',
    align: 'center',
    dataIndex: 'special',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [
        { text: '是', value: 'true' },
        { text: '否', value: 'false' },
      ])
    },
  },
  {
    title: '轻质物料',
    align: 'center',
    dataIndex: 'light',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [
        { text: '是', value: 'true' },
        { text: '否', value: 'false' },
      ])
    },
  },
  {
    title: '初始含水率',
    align: 'center',
    dataIndex: 'initial',
  },
   {
      title: '目标含水率',
      align: 'center',
@@ -36,31 +72,30 @@
      align: 'center',
      dataIndex: 'windTemp',
   },
  {
    title: '风机初始频率',
    align: 'center',
    dataIndex: 'fanSpeed',
  },
   {
      title: '环境温度',
      title: '启用翻料策略',
      align: 'center',
      dataIndex: 'envTemp',
      dataIndex: 'strategy',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [
        { text: '是', value: 'true' },
        { text: '否', value: 'false' },
      ])
    },
   },
   {
      title: '环境湿度',
      align: 'center',
      dataIndex: 'envHum',
   },
   {
      title: '荡料延时ms',
      align: 'center',
      dataIndex: 'delay',
   },
   {
      title: '翻料次数',
      align: 'center',
      dataIndex: 'turn',
   },
   // {
   //    title: '租户id',
   //    align: 'center',
   //    dataIndex: 'tenantId',
   // },
  {
    title: '冷风时长',
    align: 'center',
    dataIndex: 'coolingDuration',
  },
]
//查询数据
export const searchFormSchema: FormSchema[] = [
@@ -69,7 +104,7 @@
      field: 'herbId',
      component: 'JSearchSelect',
      componentProps: {
         dict: 'dry_herb,name,id',
         dict: 'dry_herb_info,name,id',
      },
      colProps: { span: 6 },
   },
@@ -80,29 +115,94 @@
      label: '药材',
      field: 'herbId',
      component: 'JSearchSelect',
      componentProps: {
         dict: 'dry_herb,name,id',
      componentProps: ({formModel})=>{
      return {
        dict: 'dry_herb_info,name,id',
        onChange: e => {
          let param = {
            id: e,
          }
          queryById(param).then(res => {
            formModel.name = res.name
            if (res.name) {
              const abbr = getFirstWordSpell(res.name);
              formModel.abbr = abbr.toUpperCase();
            } else {
              formModel.abbr = '';
            }
          })
        },
      }
      },
      dynamicRules: ({ model, schema }) => {
         return [{ required: true, message: '请选择药材!' }]
      },
   },
   // {
   //    label: '药材名称',
   //    field: 'herbName',
   //    component: 'Input',
   // },
  {
    label: '配方名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入配方名称!' }, { ...rules.duplicateCheckRule('dry_herb_formula', 'name', model, schema)[0] }]
    },
    componentProps: ({ formModel }) => {
      return {
        onChange: (e) => {
          const value = e.target.value;
          // 生成拼音首字母并赋值给 abbr 字段
          if (value) {
            const abbr = getFirstWordSpell(value);
            formModel.abbr = abbr.toUpperCase();
          } else {
            formModel.abbr = '';
          }
        }
      };
    },
  },
   {
      label: '设备类型',
      field: 'eqpType',
      component: 'JSearchSelect',
      componentProps: {
         dict: 'dry_eqp_type,name,id',
         dict: 'dry_eqp_type,name,id'
      },
      dynamicRules: ({ model, schema }) => {
         return [{ required: true, message: '请设备设备类型!' }]
         return [{ required: true, message: '请选择设备类型!' }]
      },
    defaultValue: '1952566592372215810',
   },
  {
    label: '首字母缩写',
    field: 'abbr',
    component: 'Input'
  },
  {
    label: '特种物料',
    field: 'special',
    component: 'Switch',
    defaultValue: false
  },
  {
    label: '轻质物料',
    field: 'light',
    component: 'Switch',
    defaultValue: false
  },
  {
    label: '初始含水率',
    field: 'initial',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
    },
    renderComponentContent: () => {
      return {
        suffix: () => '%',
      }
    },
  },
   {
      label: '目标含水率',
      field: 'target',
@@ -155,58 +255,39 @@
         }
      },
   },
  {
    label: '风机初始频率',
    field: 'fanSpeed',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
    },
    renderComponentContent: () => {
      return {
        suffix: () => 'Hz',
      }
    },
  },
   {
      label: '环境温度',
      field: 'envTemp',
      component: 'Input',
      dynamicRules: ({ model, schema }) => {
         return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
      },
      renderComponentContent: () => {
         return {
            suffix: () => '℃',
         }
      },
      label: '启用翻料策略',
      field: 'strategy',
    component: 'Switch',
    defaultValue: false,
   },
   {
      label: '环境湿度',
      field: 'envHum',
      component: 'Input',
      dynamicRules: ({ model, schema }) => {
         return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
      },
      renderComponentContent: () => {
         return {
            suffix: () => 'rh',
         }
      },
   },
   {
      label: '荡料延时',
      field: 'delay',
      component: 'Input',
      dynamicRules: ({ model, schema }) => {
         return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
      },
      renderComponentContent: () => {
         return {
            suffix: () => 'ms',
         }
      },
   },
   {
      label: '翻料次数',
      field: 'turn',
      component: 'Input',
      dynamicRules: ({ model, schema }) => {
         return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
      },
      renderComponentContent: () => {
         return {
            suffix: () => '次',
         }
      },
   },
  {
    label: '冷风时长',
    field: 'coolingDuration',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: false }, { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' }]
    },
    renderComponentContent: () => {
      return {
        suffix: () => 'min',
      }
    },
  },
   // TODO 主键隐藏字段,目前写死为ID
   {
      label: '',