riku
2024-08-12 65124213af664a68ad88ce7f6dcb133116d7702f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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: 下拉框选项)
 * @param {Boolean} _required 是否为必填项
 * @param {Array} _options 当输入类型为picker时,提供可选项
 */
function baseInputItem(_label, _name, _required, _type = 'text', _options = []) {
  return {
    required: _required,
    label: _label,
    placeholder: '请输入' + _label,
    name: _name,
    value: _type == 'switch' ? false : null,
    status: 'success',
    tips: _label + '不能为空',
    inputType: _type,
    options: _options,
  };
}
 
/**
 * 监测设备表单
 */
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'),
  ];
}