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
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesDvStatisticsApi } from '#/api/mes/dv/statistics';
 
import { DICT_TYPE } from '@vben/constants';
 
import { getDateRangePickerDefaultProps } from '#/utils';
 
/** 统计的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'dateRange',
      label: '统计区间',
      component: 'RangePicker',
      componentProps: {
        ...getDateRangePickerDefaultProps(),
        allowClear: true,
      },
      help: '默认统计近 30 天',
    },
  ];
}
 
/** 统计表格列 */
export function useGridColumns(): VxeTableGridOptions<MesDvStatisticsApi.MachineryStatistics>['columns'] {
  return [
    { field: 'machineryCode', title: '设备编码', minWidth: 130 },
    { field: 'machineryName', title: '设备名称', minWidth: 140 },
    { field: 'machineryTypeName', title: '设备类型', minWidth: 120 },
    { field: 'workshopName', title: '所属车间', minWidth: 120 },
    { field: 'processName', title: '所属工序', minWidth: 120 },
    {
      field: 'status',
      title: '设备状态',
      width: 110,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.MES_DV_MACHINERY_STATUS },
      },
    },
    { field: 'checkCount', title: '点检次数', width: 100 },
    { field: 'maintenCount', title: '保养次数', width: 100 },
    { field: 'repairCount', title: '故障次数', width: 100 },
    { field: 'borrowCount', title: '借用次数', width: 100 },
    { field: 'repairHours', title: '维修耗时(h)', width: 120 },
    { field: 'downHours', title: '停机时长(h)', width: 120 },
    {
      field: 'usageRate',
      title: '使用率(%)',
      width: 120,
      formatter: ({ cellValue }) =>
        cellValue === null || cellValue === undefined ? '' : `${cellValue}%`,
    },
    {
      field: 'lastRepairTime',
      title: '最近报修时间',
      width: 180,
      formatter: 'formatDate',
    },
  ];
}