QualityList.vue
5.58 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
<div class="quality-list-container">
<el-card>
<template #header>
<div class="card-header">
<span>质检信息列表</span>
</div>
</template>
<div class="filter-section">
<el-row :gutter="20" style="margin-bottom: 20px;">
<el-col :span="5" style="margin-right: 20px;">
<el-date-picker
v-model="filterForm.uploadTime"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 100%;"
>
</el-date-picker>
</el-col>
<el-col :span="4">
<el-select
v-model="filterForm.batchStatus"
placeholder="批次状态"
clearable
multiple
style="width: 100%"
>
<el-option v-for="status in pagination.list" :key="status.value" :label="status.label" :value="status.value"></el-option>
</el-select>
</el-col>
<el-col :span="8">
<el-button type="primary" @click="handleFilter">查询</el-button>
<el-button @click="resetFilter">重置</el-button>
</el-col>
</el-row>
</div>
<el-table :data="tableData" :height="tableForm.height" border style="width: 100%">
<el-table-column prop="batchId" label="质检批次ID" width="220"></el-table-column>
<el-table-column prop="orderCount" label="工单数量" width="100"></el-table-column>
<el-table-column prop="userAccountCount" label="用户账号数量" width="120"></el-table-column>
<el-table-column prop="staffCount" label="工维人员数量" width="120"></el-table-column>
<el-table-column prop="createTime" label="上传时间" width="180"></el-table-column>
<el-table-column prop="batchStatus" label="批次状态" width="120">
<template #default="scope">
<el-tag
:type="getTagType(scope.row.batchStatus)"
>
{{ getStatusText(scope.row.batchStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作">
<template #default="scope">
<el-button
size="small"
type="primary"
@click="viewDetail(scope.row)"
>
查看详情
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination-container" style="margin-top: 20px; text-align: right;">
<el-pagination
:current-page="pagination.currentPage"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="pagination.pageSizes"
@sizeChange="handleSizeChange"
layout="total, prev, pager, next, jumper,sizes"
@current-change="handlePageChange"
>
</el-pagination>
</div>
</el-card>
</div>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { getQualityBatches , commonListEnum} from '../utils/api'
const router = useRouter()
const filterForm = reactive({
uploadTime: '',
batchStatus: []
})
const pagination = reactive({
currentPage: 1,
pageSize: 20,
pageSizes: [20, 50, 100],
total: 0,
list: []
})
const tableForm = reactive({
height: window.top.document.body.offsetHeight - 346
})
const handleSizeChange = (newSize) => {
pagination.pageSize = newSize;
pagination.currentPage = 1; // 重置到第一页
handleFilter();
};
const tableData = ref([])
const handleFilter = async () => {
try {
const params = {
pageNum: pagination.currentPage,
pageSize: pagination.pageSize,
batchStatusList: filterForm.batchStatus
};
if (filterForm.uploadTime && filterForm.uploadTime.length === 2) {
params.uploadStartTime = filterForm.uploadTime[0];
params.uploadEndTime = filterForm.uploadTime[1];
}
const response = await getQualityBatches(params);
if (response.code === 200) {
tableData.value = response.data.records || [];
pagination.total = response.data.total;
ElMessage.success('查询成功');
} else {
ElMessage.error(response.msg || '查询失败');
}
} catch (error) {
ElMessage.error('查询失败: ' + error.message);
}
}
const resetFilter = () => {
filterForm.uploadTime = '';
filterForm.batchStatus = [];
handleFilter();
}
const getStatusText = (status) => {
let ret = '未知'
pagination.list.forEach(item => {
if(item.value === status) {
ret = item.label
}
})
return ret
}
const getTagType = (status) => {
const typeMap = {
0: 'info',
1: 'warning',
2: 'success'
}
return typeMap[status] || 'info'
}
const viewDetail = (row) => {
sessionStorage.setItem('selectedBatch', JSON.stringify(row))
router.push(`/quality-detail`)
}
const handlePageChange = (page) => {
pagination.currentPage = page;
handleFilter();
}
const queryStatus = async () => {
try {
const response = await commonListEnum({ type: 4});
if (response.code === 200) {
pagination.list = response.data || []
}
} catch (error) {
}
}
onMounted(() => {
// 初始化数据
handleFilter();
queryStatus()
})
</script>
<style scoped>
.quality-list-container {
padding: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
</style>