Riku
2024-08-12 7c3c82d429f86358142adceb080e8922f6a18aa0
pages/inspection/scene/info/device-info-items.js
@@ -1,35 +1,87 @@
export const menuData = [
  {
    label: '站点名称',
    placeholder: '请输入站点名称',
    name: 'diName',
    value: '',
import { monitorDevices } from '../../../../common/dataMonitorDeviceType';
import { treatmentDevices } from '../../../../common/dataTreatmentDeviceType';
import { productionDevices } from '../../../../common/dataProductionDeviceType';
import { freq } from '../../../../common/dataMaintainFrequency';
import { status } from '../../../../common/dataRunningStatus';
import { ownership } from '../../../../common/dataOwnership';
/**
 * 生成一条表单条目
 * @param {String} _label 标签名称
 * @param {String} _name 字段名称
 * @param {String} _type 输入类型 (text: 输入框; switch: 切换按钮; picker: 下拉框选项; cascader: 级联选择)
 * @param {Boolean} _required 是否为必填项
 * @param {Array} _options 当输入类型为picker时,提供可选项
 */
function baseInputItem(_label, _name, _required, _type = 'text', _options = []) {
  return {
    required: _required,
    label: _label,
    placeholder: (_type == 'text' ? '请输入' : '请选择') + _label,
    name: _name,
    value: null,
    status: 'success',
    tips: '站点名称不能为空',
    onChange:(v)=>{
      this.value = v
    }
  },
  {
    label: 'MN编号',
    placeholder: '请输入MN编号',
    name: 'diMnCode',
    value: '',
    status: 'success',
    tips: 'MN编号不能为空',
    onChange:(v)=>{
      this.value = v
    }
  },
  {
    label: '设备类型',
    placeholder: '请输入设备类型',
    name: 'diType',
    value: '',
    status: 'success',
    tips: '设备类型不能为空',
    onChange:(v)=>{
      this.value = v
    }
  },
];
    tips: _label + '不能为空',
    inputType: _type,
    options: _options,
    cascaderTitles: ['1', '2'],
    visible: false,
  };
}
/**
 * 监测设备表单
 */
export function monitorDeviceForm(sceneType) {
  return [
    baseInputItem('站点名称', 'diName', true),
    baseInputItem('设备编号', 'diDeviceCode'),
    // 设备类型和设备子类合并用级联选择器展示
    baseInputItem('设备类型', '_type', true, 'cascader', monitorDevices(sceneType)),
    // baseInputItem('设备类型', 'diTypeId', true, 'picker'),
    // baseInputItem('设备子类', 'diSubtypeId', true, 'picker'),
    baseInputItem('供应商', 'diSupplier'),
    baseInputItem('运维商', 'diMaintainer'),
    baseInputItem('运维频次', 'diMaintainFrequency', true, 'picker', freq),
    baseInputItem('运维人员', 'diMaintainStaff'),
    baseInputItem('运维电话', 'diMaintainTel'),
    baseInputItem('运行状态', 'diRunningStatus', true, 'picker', status),
    baseInputItem('品牌型号', 'diBrandModel'),
    baseInputItem('设备参数', 'diDeviceParam'),
    baseInputItem('所有权', 'diOwnership', true, 'picker', ownership),
    // todo 2024/8/12: 后续要添加二维码的信息扫描录入
    // baseInputItem('标识二维码', 'DI_QR_Code'),
    // baseInputItem('其他第三方或设备自带二维码', 'DI_Other_QR_Code'),
  ];
}
/**
 * 治理设备表单
 */
export function treatmentDeviceForm(sceneType) {
  return [
    baseInputItem('站点名称', 'diName', true),
    baseInputItem('设备编号', 'diDeviceCode'),
    baseInputItem('设备类型', 'diType', true),
    baseInputItem('供应商', 'diSupplier'),
    baseInputItem('运维商', 'diMaintainer'),
    baseInputItem('是否上线', 'diRunningStatus', true, 'switch'),
    baseInputItem('是否拆除', 'diRemoved', true, 'switch'),
  ];
}
/**
 * 生产设备表单
 */
export function productionDeviceForm(sceneType) {
  return [
    baseInputItem('站点名称', 'diName', true),
    baseInputItem('设备编号', 'diDeviceCode'),
    baseInputItem('设备类型', 'diType', true),
    baseInputItem('供应商', 'diSupplier'),
    baseInputItem('运维商', 'diMaintainer'),
    baseInputItem('是否上线', 'diRunningStatus', true, 'switch'),
    baseInputItem('是否拆除', 'diRemoved', true, 'switch'),
  ];
}