feat(质量报表): 实现合格率报表功能并优化表格展示

- 新增合格率报表API文件及接口调用
- 替换原有模拟数据为真实接口调用
- 调整表格列展示,增加一次合格率统计
- 优化数据获取逻辑和错误处理
This commit is contained in:
2025-10-17 17:13:40 +08:00
parent 401cf32a13
commit c8038484cf
4 changed files with 104 additions and 92 deletions

View File

@@ -0,0 +1,20 @@
import request from '@/utils/request'
import { downFile } from '@/utils/request'
// 分页获取合格率报表数据
export function GetQualificationRateReport(data) {
return request({
url: '/mes/qc/FQC/QualificationRateReport/GetQualificationRateReport',
method: 'post',
data: data,
})
}
// 获取合格率Echarts数据
export function GetQualificationRateEcharts(data) {
return request({
url: '/mes/qc/FQC/QualificationRateEcharts/GetQualificationRateEcharts',
method: 'post',
data: data,
})
}

View File

@@ -0,0 +1,20 @@
import request from '@/utils/request'
import { downFile } from '@/utils/request'
// 分页获取合格率报表数据
export function GetQualificationRateReport(data) {
return request({
url: '/mes/qc/FQC/QualificationRateReport/GetQualificationRateReport',
method: 'post',
data: data,
})
}
// 获取合格率Echarts数据
export function GetQualificationRateEcharts(data) {
return request({
url: '/mes/qc/FQC/QualificationRateEcharts/GetQualificationRateEcharts',
method: 'post',
data: data,
})
}

View File

@@ -86,7 +86,7 @@
<script>
import * as echarts from 'echarts'
import { GetProductAndPolishAndOneTimeFqcBoardData } from '@/api/qualityManagement/commonFQC.js'
import { GetQualificationRateEcharts } from '@/api/qualityManagement/qualificationRateReport/qualificationRateReport.js'
import { debounce } from '@/utils'
export default {
@@ -168,27 +168,26 @@ export default {
async getOverviewData() {
this.loading = true
try {
// 注释接口调用,直接使用测试数据
// const params = {
// startTime: this.timeRange.startTime,
// endTime: this.timeRange.endTime,
// ...this.queryParams
// }
const params = {
startTime: this.timeRange.startTime,
endTime: this.timeRange.endTime,
...this.queryParams
}
// // 调用API获取数据
// const res = await GetProductAndPolishAndOneTimeFqcBoardData(params)
// 调用API获取数据
const res = await GetQualificationRateEcharts(params)
// if (res.code === 200 && res.data) {
// this.updateStatData(res.data)
// this.updateTrendChart(res.data.trendData)
// this.updateDefectChart(res.data.defectData)
// } else {
// this.$message.error('获取数据失败')
// this.useMockData()
// }
// 打印返回值
console.log('接口返回数据:', res)
// 直接使用模拟数据
this.useMockData()
if (res.code === 200 && res.data) {
this.updateStatData(res.data)
this.updateTrendChart(res.data.trendData || { categories: [], series: [] })
this.updateDefectChart(res.data.defectData || [])
} else {
this.$message.error('获取数据失败')
this.useMockData()
}
} catch (error) {
this.$message.error('获取数据异常')
console.error('获取合格率概览数据异常:', error)

View File

@@ -10,43 +10,24 @@
</el-row>
<!-- 表格 -->
<el-table
v-loading="loading"
:data="dataList"
border
fit
highlight-current-row
style="width: 100%"
>
<el-table v-loading="loading" :data="dataList" border fit highlight-current-row style="width: 100%">
<el-table-column type="index" width="50" label="序号" />
<el-table-column prop="partNumber" label="物料号" width="120" />
<el-table-column prop="description" label="产品描述" min-width="150" />
<el-table-column prop="specification" label="规格" width="100" />
<el-table-column prop="color" label="颜色" width="80" />
<el-table-column prop="siteNo" label="站点" width="80" />
<el-table-column prop="team" label="班组" width="80" />
<el-table-column prop="requireNumber" label="投入数" width="80" align="right" />
<el-table-column prop="qualifiedNumber" label="合格数" width="80" align="right" />
<el-table-column prop="qualifiedRate" label="合格率" width="90" align="right">
<el-table-column prop="allRequireNumber" label="总投入数" width="80" align="right" />
<el-table-column prop="allQualifiedNumber" label="总合格数" width="80" align="right" />
<el-table-column prop="qualifiedRate" label="总合格率" width="90" align="right">
<template slot-scope="scope">
<span :class="getRateClass(scope.row.qualifiedRate)">{{ scope.row.qualifiedRate }}%</span>
</template>
</el-table-column>
<el-table-column prop="polishNumber" label="抛光数" width="80" align="right" />
<el-table-column prop="damoNumber" label="打磨数" width="80" align="right" />
<el-table-column prop="baofeiNumber" label="报废数" width="80" align="right" />
<el-table-column prop="isOnetime" label="一次合格" width="90" align="center">
<el-table-column prop="firstRequireNumber" label="一次投入数" width="80" align="right" />
<el-table-column prop="firstQualifiedNumber" label="一次合格数" width="80" align="right" />
<el-table-column prop="qualifiedRate" label="一次合格率" width="90" align="right">
<template slot-scope="scope">
<el-tag :type="scope.row.isOnetime === 1 ? 'success' : 'info'">
{{ scope.row.isOnetime === 1 ? '是' : '否' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="isBack" label="返工件" width="90" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.isBack === 1 ? 'warning' : 'info'">
{{ scope.row.isBack === 1 ? '是' : '否' }}
</el-tag>
<span :class="getRateClass(scope.row.qualifiedRate)">{{ scope.row.qualifiedRate }}%</span>
</template>
</el-table-column>
<el-table-column prop="startTime" label="开始时间" width="150" />
@@ -56,22 +37,15 @@
<!-- 分页 -->
<div class="pagination-container">
<el-pagination
background
:current-page="queryParams.pageNum"
:page-size="queryParams.pageSize"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
<el-pagination background :current-page="queryParams.pageNum" :page-size="queryParams.pageSize"
:page-sizes="[10, 20, 50, 100]" layout="total, sizes, prev, pager, next, jumper" :total="total"
@size-change="handleSizeChange" @current-change="handleCurrentChange" />
</div>
</div>
</template>
<script>
import { GetWorkOrderFqcTableData } from '@/api/qualityManagement/commonFQC.js'
import { GetQualificationRateReport } from '@/api/qualityManagement/qualificationRateReport/qualificationRateReport.js'
export default {
name: 'QualificationRateTable',
@@ -111,28 +85,27 @@ export default {
async getTableData() {
this.loading = true
try {
// 注释接口调用,直接使用测试数据
// const params = {
// startTime: this.timeRange.startTime,
// endTime: this.timeRange.endTime,
// ...this.queryParams,
// ...this.tableQueryParams
// }
const params = {
startTime: this.timeRange.startTime,
endTime: this.timeRange.endTime,
...this.queryParams,
...this.tableQueryParams
}
// // 调用API获取数据
// const res = await GetWorkOrderFqcTableData(params)
// 调用API获取数据
const res = await GetQualificationRateReport(params)
// if (res.code === 200 && res.data) {
// this.dataList = res.data.result || []
// this.total = res.data.totalNum || 0
// } else {
// this.$message.error('获取数据失败')
// // 使用模拟数据
// this.useMockData()
// }
// 打印返回值
console.log('接口返回数据:', res)
// 直接使用模拟数据
this.useMockData()
if (res.code === 200 && res.data) {
this.dataList = res.data.result || []
this.total = res.data.totalNum || 0
} else {
this.$message.error('获取数据失败')
// 使用模拟数据
this.useMockData()
}
} catch (error) {
this.$message.error('获取数据异常')
console.error('获取合格率报表数据异常:', error)