xiaoyi
4 天以前 5c243d9d05da668a32b1bc9a4f543ea081488d11
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<script lang="ts" setup>
import type { WorkResultSummary } from '#/api/mes/pro/feedback';
 
import { onMounted, reactive, ref } from 'vue';
 
import { Page } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
 
import {
  Button,
  Card,
  Col,
  DatePicker,
  Row,
  Select,
  Space,
  Table,
  Tag,
} from 'ant-design-vue';
 
import { getFeedbackSummary } from '#/api/mes/pro/feedback';
 
defineOptions({ name: 'MesWorkResultSummary' });
 
const loading = ref(false);
const summary = ref<WorkResultSummary>({});
 
const queryForm = reactive<{
  beginDate?: string;
  endDate?: string;
  workOrderType?: number;
}>({});
 
const workOrderTypeOptions = getDictOptions(
  DICT_TYPE.MES_PRO_WORK_ORDER_TYPE,
  'number',
).map((option) => ({ label: option.label, value: option.value as number }));
 
async function loadSummary() {
  loading.value = true;
  try {
    summary.value = await getFeedbackSummary({
      beginDate: queryForm.beginDate,
      endDate: queryForm.endDate,
      workOrderType: queryForm.workOrderType,
    });
  } finally {
    loading.value = false;
  }
}
 
function handleRangeChange(_: unknown, dateStrings: string[]) {
  queryForm.beginDate = dateStrings[0] || undefined;
  queryForm.endDate = dateStrings[1] || undefined;
}
 
function resetQuery() {
  queryForm.beginDate = undefined;
  queryForm.endDate = undefined;
  queryForm.workOrderType = undefined;
  loadSummary();
}
 
onMounted(loadSummary);
</script>
 
<template>
  <Page>
    <Card class="mb-4">
      <Space wrap>
        <DatePicker.RangePicker
          :placeholder="['开始日期', '结束日期']"
          value-format="YYYY-MM-DD"
          @change="handleRangeChange"
        />
        <Select
          v-model:value="queryForm.workOrderType"
          allow-clear
          :options="workOrderTypeOptions"
          placeholder="工单类型"
          style="width: 160px"
        />
        <Button type="primary" :loading="loading" @click="loadSummary">
          查询
        </Button>
        <Button @click="resetQuery">重置</Button>
      </Space>
    </Card>
 
    <Row :gutter="16" class="mb-4">
      <Col :span="8">
        <Card>
          <div class="text-sm text-gray-500">累计报工数量</div>
          <div class="mt-2 text-2xl font-bold">
            {{ summary.totalFeedbackQuantity ?? 0 }}
          </div>
        </Card>
      </Col>
      <Col :span="8">
        <Card>
          <div class="text-sm text-gray-500">累计合格数量</div>
          <div class="mt-2 text-2xl font-bold text-green-600">
            {{ summary.totalQualifiedQuantity ?? 0 }}
          </div>
        </Card>
      </Col>
      <Col :span="8">
        <Card>
          <div class="text-sm text-gray-500">累计报工单数</div>
          <div class="mt-2 text-2xl font-bold text-blue-600">
            {{ summary.totalFeedbackCount ?? 0 }}
          </div>
        </Card>
      </Col>
    </Row>
 
    <Card class="mb-4" title="按工单类型汇总">
      <Table
        row-key="workOrderType"
        :data-source="summary.byType ?? []"
        :loading="loading"
        :pagination="false"
        size="middle"
      >
        <Table.Column title="工单类型" data-index="workOrderTypeName">
          <template #default="{ record }">
            <Tag color="blue">{{ record.workOrderTypeName }}</Tag>
          </template>
        </Table.Column>
        <Table.Column
          title="报工数量"
          data-index="feedbackQuantity"
          align="right"
        />
        <Table.Column
          title="合格数量"
          data-index="qualifiedQuantity"
          align="right"
        />
        <Table.Column title="报工单数" data-index="feedbackCount" align="right" />
      </Table>
    </Card>
 
    <Card title="按日期汇总">
      <Table
        row-key="date"
        :data-source="summary.byDate ?? []"
        :loading="loading"
        :pagination="false"
        size="middle"
      >
        <Table.Column title="日期" data-index="date" />
        <Table.Column
          title="报工数量"
          data-index="feedbackQuantity"
          align="right"
        />
        <Table.Column
          title="合格数量"
          data-index="qualifiedQuantity"
          align="right"
        />
        <Table.Column title="报工单数" data-index="feedbackCount" align="right" />
      </Table>
    </Card>
  </Page>
</template>