车间能级提升-智能设备管理系统
baoshiwei
2025-07-02 2f0009c750de4d47a18cce4a5a403fa83ba0c209
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
86
87
88
89
90
91
92
93
<script setup lang="ts">
import { onMounted, ref, toRaw, computed } from 'vue';
 
import { Page, type VbenFormProps } from '@vben/common-ui';
 
import { Space } from 'ant-design-vue';
 
import { useVbenVxeGrid, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table';
import { getEquEfficiency } from '#/api/eims/report';
 
import { columns, querySchema } from './data';
 
const selYear = ref('');
 
const formOptions: VbenFormProps = {
  commonConfig: {
    labelWidth: 80,
    componentProps: {
      allowClear: true
    }
  },
  schema: querySchema(),
  wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
  handleReset: async () => {
    const { formApi, reload } = tableApi;
    await formApi.resetForm();
    const formValues = formApi.form.values;
    formApi.setLatestSubmissionValues(formValues);
    await reload(formValues);
  }
};
 
const gridOptions: VxeGridProps = {
  border: true,
  size: 'mini',
  columns: columns.value,
  height: 'auto',
  keepSource: true,
  proxyConfig: {
    ajax: {
      query: async (_ctx, formValues = {}) => {
        const params = toRaw(formValues);
        return await getEquEfficiency(params);
      }
    }
  },
  rowConfig: {
    isHover: true,
    keyField: 'item'
  },
  id: 'equ-efficency-index'
};
 
const [BasicTable, tableApi] = useVbenVxeGrid({
  formOptions,
  gridOptions,
  gridEvents: {
    sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams)
  }
});
 
onMounted(() => {
  tableApi.formApi.updateSchema([
    {
      component: 'DatePicker',
      componentProps: {
        onChange: (sYear: string) => {
          selYear.value = sYear;
        }
      },
      fieldName: 'selectYear'
    }
  ]);
  // 初始化年份
  selYear.value = tableApi.formApi.form.values.selectYear;
});
 
const tableTitle = computed(() => `${selYear.value || new Date().getFullYear()}年生产设备正常运转率`);
</script>
 
<template>
  <Page :auto-content-height="true">
    <div class="flex h-full gap-[8px]">
      <BasicTable class="flex-1 overflow-hidden" :table-title="tableTitle">
        <template #toolbar-tools>
          <Space>
            <span class="ml-4 mr-2">稼动率 = (总运行时间-停机时间) ÷ 总运行时间 × 100%</span>
          </Space>
        </template>
      </BasicTable>
    </div>
  </Page>
</template>