Files
klp-oa/klp-ui/src/views/mes/qc/history/index.vue
砂糖 e8373fe560 feat(mes/qc/history): 在检验历史列表中添加钢卷号列并完善数据映射
添加钢卷号列以显示当前钢卷信息,同时修改数据映射逻辑以解析verifyTarget字段并补充钢卷相关数据
2026-02-03 11:12:14 +08:00

230 lines
7.8 KiB
Vue

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="60px">
<el-form-item label="任务名称" prop="taskName">
<el-input
v-model="queryParams.taskName"
placeholder="请输入任务名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 上方任务列表表格 -->
<div class="mb10">
<div class="table-title">检验历史列表</div>
<KLPTable ref="historyTable" height="300px" highlight-current-row v-loading="loading" :data="checkTaskList" @row-click="handleRowClick" row-class-name="tableRowClassName">
<el-table-column label="任务名称" align="center" prop="taskName" />
<el-table-column label="钢卷号" align="center" prop="currentCoilNo" />
<el-table-column label="工段" align="center" prop="workshopSection" />
<el-table-column label="工序" align="center" prop="process" />
<el-table-column label="机组" align="center" prop="unitGroup" />
<el-table-column label="检验结果" align="center" prop="inspectionResult">
<template slot-scope="scope">
<span>
<span v-if="scope.row.inspectionResult == 0" style="color: grey;">未检验</span>
<span v-else-if="scope.row.inspectionResult == 1" style="color: #67C23A;">合格</span>
<span v-else-if="scope.row.inspectionResult == 2" style="color: #FF4949;">不合格</span>
<span v-else style="color: grey;">未知</span>
</span>
</template>
</el-table-column>
<el-table-column label="检验类型" align="center" prop="inspectionType" />
<el-table-column label="备注" align="center" prop="remark" />
</KLPTable>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 下方检测详情表格 -->
<div class="detail-section">
<div class="table-title">检测详情</div>
<div v-if="selectedTask && detailData.itemList && detailData.itemList.length > 0">
<KLPTable v-loading="loading" :data="detailData.itemList" style="margin-top: 10px;">
<el-table-column label="检查项" align="center" prop="itemName">
<template slot-scope="scope">
<el-tag type="info">{{ scope.row.itemName }}</el-tag>
</template>
</el-table-column>
<el-table-column label="定性定量" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.qualitativeQuantitative !== undefined" :type="scope.row.qualitativeQuantitative === 0 ? 'primary' : 'warning'">
{{ scope.row.qualitativeQuantitative === 0 ? '定性' : '定量' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="标准目标" align="center">
<template slot-scope="scope">
{{ scope.row.standardTarget }} {{ scope.row.unit || '' }}
</template>
</el-table-column>
<el-table-column label="目标上限" align="center">
<template slot-scope="scope">
{{ scope.row.targetUpper }} {{ scope.row.unit || '' }}
</template>
</el-table-column>
<el-table-column label="目标下限" align="center">
<template slot-scope="scope">
{{ scope.row.targetLower }} {{ scope.row.unit || '' }}
</template>
</el-table-column>
<el-table-column label="实测值" align="center">
<template slot-scope="scope">
{{ scope.row.actualMeasure }} {{ scope.row.unit || '' }}
</template>
</el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<span>
<span v-if="scope.row.status == 0" style="color: gray;">未检测</span>
<span v-else-if="scope.row.status == 1" style="color: #67C23A;">通过</span>
<span v-else-if="scope.row.status == 2" style="color: #FF4949;">不通过</span>
<span v-else style="color: gray;">未知</span>
</span>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个检验历史任务查看详情"></el-empty>
</div>
</div>
</div>
</template>
<script>
import { listHistoryCheckTask, getCheckTask } from '@/api/mes/qc/checkTask'
export default {
name: 'CheckTaskHistory',
data() {
return {
loading: true,
showSearch: true,
total: 0,
checkTaskList: [],
queryParams: {
pageNum: 1,
pageSize: 20,
taskName: undefined,
},
detailData: {},
// 当前选中的任务(单选)
selectedTask: null,
}
},
mounted() {
this.getList()
},
methods: {
getList() {
this.loading = true
listHistoryCheckTask(this.queryParams).then(response => {
this.checkTaskList = response.rows.map(item => ({
...item,
verifyTarget: JSON.parse(item.verifyTarget),
entryCoilNo: item.coilList?.[0]?.entryCoilNo || '',
currentCoilNo: item.coilList?.[0]?.currentCoilNo || '',
weight: item.coilList?.[0]?.netWeight || 0,
}))
this.total = response.total
this.loading = false
})
},
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.resetForm('queryForm')
this.handleQuery()
},
// 点击行选中任务
handleRowClick(row) {
if (this.selectedTask && this.selectedTask.taskId === row.taskId) {
// 点击当前选中行,取消选中
this.selectedTask = null
this.detailData = {}
} else {
// 选中新行
this.selectedTask = row
this.loadTaskDetail(row.taskId)
}
},
// 表格行样式
tableRowClassName({row, rowIndex}) {
return this.selectedTask && this.selectedTask.taskId === row.taskId ? 'current-row' : ''
},
// 加载任务详情
loadTaskDetail(taskId) {
this.loading = true
getCheckTask(taskId).then(response => {
this.detailData = response.data
}).finally(() => {
this.loading = false
})
},
handleExport() {
this.download('qc/checkTask/export', {
...this.queryParams
}, `checkTask_${new Date().getTime()}.xlsx`)
}
},
// 添加样式
computed: {
styles() {
return {
mb10: { marginBottom: '10px' },
detailSection: {
marginTop: '20px',
border: '1px solid #e6e6e6',
borderRadius: '4px',
padding: '10px'
},
tableTitle: {
fontSize: '16px',
fontWeight: 'bold',
marginBottom: '10px',
color: '#333'
},
emptyTip: {
textAlign: 'center',
padding: '40px 0',
backgroundColor: '#fafafa',
borderRadius: '4px'
}
}
}
}
}
</script>