<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>
|