feat: 新增质检模块功能并优化界面交互

refactor: 重构质检任务和历史记录页面布局
feat: 添加Greeting组件并集成到首页
feat: 实现质检项选择和详情展示功能
feat: 新增实验室和工段质检页面
style: 优化表格样式和交互体验
This commit is contained in:
砂糖
2025-10-17 14:40:28 +08:00
parent cb5f83e124
commit 28881d787c
10 changed files with 2267 additions and 463 deletions

View File

@@ -5,6 +5,7 @@
filterable
placeholder="请选择检查项"
@change="handleChange"
size="mini"
style="width: 100%;"
>
<el-option

View File

@@ -0,0 +1,74 @@
<template>
<div class="user-greeting-row">
<img :src="avatar" class="user-avatar" alt="头像" />
<div class="greeting-text">
<div class="greeting-title">{{ greeting }}{{ name }}</div>
<div class="greeting-desc">愿你天黑有灯下雨有伞</div>
</div>
</div>
</template>
<script>
export default {
name: 'Greeting',
data() {
return {
avatar: '',
name: '',
greeting: ''
}
},
mounted() {
this.avatar = this.$store.getters.avatar
this.name = this.$store.getters.name
this.greeting = this.getGreeting()
},
methods: {
getGreeting() {
const hour = new Date().getHours()
if (hour < 6) return '凌晨好'
if (hour < 9) return '早上好'
if (hour < 12) return '上午好'
if (hour < 14) return '中午好'
if (hour < 18) return '下午好'
if (hour < 21) return '晚上好'
return '夜深了'
}
}
}
</script>
<style scoped>
.user-greeting-row {
display: flex;
align-items: center;
gap: 24px;
margin-bottom: 24px;
}
.user-avatar {
width: 80px;
height: 80px;
border-radius: 50%;
object-fit: cover;
border: 2px solid #e0e0e0;
}
.greeting-text {
display: flex;
flex-direction: column;
justify-content: center;
}
.greeting-title {
font-size: 28px;
font-weight: 600;
color: #888;
}
.greeting-desc {
font-size: 16px;
color: #888;
margin-top: 4px;
}
</style>

View File

@@ -3,13 +3,7 @@
<template>
<div class="dashboard-root">
<!-- 第一行头像+欢迎语 -->
<div class="user-greeting-row">
<img :src="avatar" class="user-avatar" alt="头像" />
<div class="greeting-text">
<div class="greeting-title">{{ greeting }}{{ name }}</div>
<div class="greeting-desc">愿你天黑有灯下雨有伞</div>
</div>
</div>
<Greeting />
<!-- 全部应用 -->
<el-row>
@@ -36,36 +30,14 @@
import AllApplications from '@/views/components/AllApplications.vue';
import OrderDashboard from '@/views/components/OrderDashboard.vue';
import FlowTable from '@/views/components/FlowTable.vue';
import Greeting from '@/views/components/Greeting.vue';
export default {
components: {
AllApplications,
OrderDashboard,
FlowTable
},
data() {
return {
avatar: '',
name: '',
greeting: '',
};
},
mounted() {
this.avatar = this.$store.getters.avatar;
this.name = this.$store.getters.name;
this.greeting = this.getGreeting();
},
methods: {
getGreeting() {
const hour = new Date().getHours();
if (hour < 6) return '凌晨好';
if (hour < 9) return '早上好';
if (hour < 12) return '上午好';
if (hour < 14) return '中午好';
if (hour < 18) return '下午好';
if (hour < 21) return '晚上好';
return '夜深了';
},
FlowTable,
Greeting
}
};
</script>
@@ -75,254 +47,4 @@ export default {
min-height: 100vh;
padding: 32px;
}
.data-overview {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 24px;
margin-bottom: 32px;
}
.data-card {
padding: 24px;
border-radius: 16px;
backdrop-filter: blur(4px);
box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.06);
border: 1px solid rgba(255, 255, 255, 0.2);
transition: transform 0.2s;
}
.data-card:hover {
transform: scale(1.02);
}
.data-card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 16px;
}
.data-card-title {
color: #6b7280;
font-size: 14px;
margin-bottom: 4px;
}
.data-card-value {
font-size: 24px;
font-weight: 600;
}
.data-card-icon {
font-size: 24px;
}
.icon-blue {
color: #3b82f6;
}
.icon-green {
color: #22c55e;
}
.icon-yellow {
color: #eab308;
}
.icon-purple {
color: #a855f7;
}
.data-card-chart {
height: 48px;
width: 100%;
}
.chart-inner {
width: 100%;
height: 100%;
}
.business-modules {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 24px;
margin-bottom: 32px;
}
.business-module {
display: flex;
align-items: center;
padding: 16px;
border-radius: 12px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
transition: all 0.2s;
cursor: pointer;
}
.business-module:hover {
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
transform: translateY(-2px);
}
.business-module-icon {
width: 40px;
height: 40px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-right: 12px;
}
.business-module-icon i {
font-size: 20px;
}
.bg-blue {
background: #3b82f6;
}
.bg-green {
background: #22c55e;
}
.bg-yellow {
background: #eab308;
}
.bg-purple {
background: #a855f7;
}
.bg-red {
background: #ef4444;
}
.bg-indigo {
background: #6366f1;
}
.bg-teal {
background: #14b8a6;
}
.business-module-title {
font-size: 16px;
font-weight: 500;
color: #303133;
}
.monitor-panel {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 24px;
}
.monitor-resource,
.monitor-records {
padding: 24px;
border-radius: 16px;
box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.06);
}
.monitor-title {
font-size: 18px;
font-weight: 500;
margin-bottom: 24px;
}
.monitor-resource-charts {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16px;
}
.monitor-resource-chart {
height: 160px;
}
.monitor-records-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.monitor-record-item {
display: flex;
align-items: center;
padding: 12px;
border-radius: 12px;
transition: background 0.2s;
}
.monitor-record-item:hover {
background: #f9fafb;
}
.monitor-record-icon {
width: 32px;
height: 32px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16px;
}
.monitor-record-icon-inner {
font-size: 14px;
}
.monitor-record-action {
font-size: 14px;
font-weight: 500;
}
.monitor-record-time {
font-size: 12px;
color: #6b7280;
}
.user-greeting-row {
display: flex;
align-items: center;
gap: 24px;
margin-bottom: 24px;
}
.user-avatar {
width: 80px;
height: 80px;
border-radius: 50%;
object-fit: cover;
border: 2px solid #e0e0e0;
}
.greeting-text {
display: flex;
flex-direction: column;
justify-content: center;
}
.greeting-title {
font-size: 28px;
font-weight: 600;
color: #888;
}
.greeting-desc {
font-size: 16px;
color: #888;
margin-top: 4px;
}
</style>
<style>
.business-module-header,
.business-module-icon-inner,
.business-module-desc {
display: none;
}
</style>
</style>

View File

@@ -28,22 +28,26 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<KLPTable v-loading="loading" :data="checkTaskList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="taskId" v-if="true"/>
<!-- 上方任务列表表格 -->
<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="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<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">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleDetail(scope.row)"
>详情</el-button>
<el-tag :type="scope.row.inspectionResult === 1 ? 'success' : (scope.row.inspectionResult === 2 ? 'danger' : 'info')">
{{ scope.row.inspectionResult === 0 ? '未检验' : (scope.row.inspectionResult === 1 ? '合格' : (scope.row.inspectionResult === 2 ? '不合格' : '')) }}
</el-tag>
</template>
</el-table-column>
</KLPTable>
<el-table-column label="检验类型" align="center" prop="inspectionType" />
<el-table-column label="备注" align="center" prop="remark" />
</KLPTable>
</div>
<pagination
v-show="total>0"
@@ -53,33 +57,61 @@
@pagination="getList"
/>
<!-- 检查任务详情弹窗可复用task页面的实现 -->
<!-- ...如需详情弹窗可参考task/index.vue... -->
<el-dialog :title="'检查任务详情'" :visible.sync="detailOpen" width="600px" append-to-body>
<el-descriptions :column="1" border>
<el-descriptions-item label="任务名称">{{ detailData.taskName }}</el-descriptions-item>
<el-descriptions-item label="备注">{{ detailData.remark }}</el-descriptions-item>
<el-descriptions-item label="检查项">
<div v-for="item in detailData.itemList" :key="item.itemId" style="margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;">
<div style="display: flex; align-items: center;">
<el-tag type="info" style="margin-right: 12px;">{{ item.itemName }}</el-tag>
<!-- 下方检测详情表格 -->
<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">
<el-tag
:type="item.status == 1 ? 'success' : (item.status == 2 ? 'danger' : 'info')"
style="margin-right: 16px; min-width: 60px; text-align: center;"
:type="scope.row.status == 1 ? 'success' : (scope.row.status == 2 ? 'danger' : 'info')"
>
<span v-if="item.status == 0">未检测</span>
<span v-else-if="item.status == 1">通过</span>
<span v-else-if="item.status == 2">不通过</span>
<span v-if="scope.row.status == 0">未检测</span>
<span v-else-if="scope.row.status == 1">通过</span>
<span v-else-if="scope.row.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</div>
</div>
</el-descriptions-item>
</el-descriptions>
<span slot="footer" class="dialog-footer">
<el-button @click="handleDetailClose"> </el-button>
</span>
</el-dialog>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个检验历史任务查看详情"></el-empty>
</div>
</div>
</div>
</template>
@@ -91,9 +123,6 @@ export default {
data() {
return {
loading: true,
ids: [],
single: true,
multiple: true,
showSearch: true,
total: 0,
checkTaskList: [],
@@ -102,11 +131,12 @@ export default {
pageSize: 20,
taskName: undefined,
},
detailOpen: false,
detailData: {},
// 当前选中的任务(单选)
selectedTask: null,
}
},
created() {
mounted() {
this.getList()
},
methods: {
@@ -126,28 +156,65 @@ export default {
this.resetForm('queryForm')
this.handleQuery()
},
handleSelectionChange(selection) {
this.ids = selection.map(item => item.taskId)
this.single = selection.length!==1
this.multiple = !selection.length
// 点击行选中任务
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`)
},
handleDetail(row) {
this.loading = true
getCheckTask(row.taskId).then(response => {
this.detailData = response.data
this.detailOpen = true
}).finally(() => {
this.loading = false
})
},
handleDetailClose() {
this.detailOpen = false
this.getList()
}
},
// 添加样式
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'
}
}
}
}
}

View File

@@ -61,6 +61,15 @@
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="itemId" v-if="true"/>
<el-table-column label="检查项名称" align="center" prop="itemName" />
<el-table-column label="标准目标" align="center" prop="standardTarget" />
<el-table-column label="目标上限" align="center" prop="targetUpper" />
<el-table-column label="目标下限" align="center" prop="targetLower" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="定性定量" align="center" prop="qualitativeQuantitative">
<template slot-scope="scope">
{{ scope.row.qualitativeQuantitative === 0 ? '定性' : '定量' }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
@@ -94,6 +103,24 @@
<el-form-item label="检查项名称" prop="itemName">
<el-input v-model="form.itemName" placeholder="请输入检查项名称" />
</el-form-item>
<el-form-item label="标准目标" prop="standardTarget">
<el-input v-model.number="form.standardTarget" type="number" step="0.01" placeholder="请输入标准目标" />
</el-form-item>
<el-form-item label="目标上限" prop="targetUpper">
<el-input v-model.number="form.targetUpper" type="number" step="0.01" placeholder="请输入目标上限" />
</el-form-item>
<el-form-item label="目标下限" prop="targetLower">
<el-input v-model.number="form.targetLower" type="number" step="0.01" placeholder="请输入目标下限" />
</el-form-item>
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入单位" />
</el-form-item>
<el-form-item label="定性定量" prop="qualitativeQuantitative">
<el-radio-group v-model="form.qualitativeQuantitative">
<el-radio :label="0">定性</el-radio>
<el-radio :label="1">定量</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
@@ -138,6 +165,11 @@ export default {
pageNum: 1,
pageSize: 20,
itemName: undefined,
standardTarget: undefined,
targetUpper: undefined,
targetLower: undefined,
unit: undefined,
qualitativeQuantitative: 0,
},
// 表单参数
form: {},
@@ -169,6 +201,11 @@ export default {
this.form = {
itemId: undefined,
itemName: undefined,
standardTarget: undefined,
targetUpper: undefined,
targetLower: undefined,
unit: undefined,
qualitativeQuantitative: 0,
createBy: undefined,
createTime: undefined,
updateBy: undefined,

View File

@@ -2,12 +2,7 @@
<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-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>
@@ -17,76 +12,118 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!selectedTask"
@click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="!selectedTask"
@click="handleDelete">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
<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>
<KLPTable v-loading="loading" :data="checkTaskList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="taskId" v-if="true"/>
<el-table-column label="任务名称" align="center" prop="taskName" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleDetail(scope.row)"
>详情</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</KLPTable>
<!-- 上方任务列表表格 -->
<div class="mb10">
<div class="table-title">待检任务列表</div>
<KLPTable ref="checkTaskTable" height="300px" highlight-current-row v-loading="loading" :data="checkTaskList" @row-click="handleRowClick">
<el-table-column label="任务名称" align="center" prop="taskName" />
<el-table-column label="校验目标" align="center" prop="verifyTarget" />
<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">
<template slot-scope="scope">
<el-tag
:type="scope.row.inspectionResult == 1 ? 'success' : (scope.row.inspectionResult == 2 ? 'danger' : 'info')">
<span v-if="scope.row.inspectionResult == 0">未检验</span>
<span v-else-if="scope.row.inspectionResult == 1">合格</span>
<span v-else-if="scope.row.inspectionResult == 2">不合格</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="检验类型" align="center" prop="inspectionType" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</KLPTable>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</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="detailLoading" :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">
<el-tag :type="scope.row.status == 1 ? 'success' : (scope.row.status == 2 ? 'danger' : 'info')">
<span v-if="scope.row.status == 0">未检测</span>
<span v-else-if="scope.row.status == 1">通过</span>
<span v-else-if="scope.row.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.status == 0" size="mini" type="success"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="danger" style="margin-left: 8px;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 2)">不通过</el-button>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个待检任务查看详情"></el-empty>
</div>
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -100,43 +137,34 @@
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="校验目标" prop="verifyTarget">
<el-input v-model="form.verifyTarget" type="textarea" placeholder="请输入校验目标(JSON格式)" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="form.workshopSection" placeholder="请输入工段" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="form.process" placeholder="请输入工序" />
</el-form-item>
<el-form-item label="机组" prop="unitGroup">
<el-input v-model="form.unitGroup" placeholder="请输入机组" />
</el-form-item>
<el-form-item label="检验结果" prop="inspectionResult">
<el-select v-model="form.inspectionResult" placeholder="请选择检验结果">
<el-option label="未检验" :value="0" />
<el-option label="合格" :value="1" />
<el-option label="不合格" :value="2" />
</el-select>
</el-form-item>
<el-form-item label="检验类型" prop="inspectionType">
<el-input v-model="form.inspectionType" placeholder="请输入检验类型" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 检查任务详情弹窗 -->
<el-dialog :title="'检查任务详情'" :visible.sync="detailOpen" width="600px" append-to-body>
<el-descriptions :column="1" border>
<el-descriptions-item label="任务名称">{{ detailData.taskName }}</el-descriptions-item>
<el-descriptions-item label="备注">{{ detailData.remark }}</el-descriptions-item>
<el-descriptions-item label="检查项">
<div v-for="item in detailData.itemList" :key="item.itemId" style="margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;">
<div style="display: flex; align-items: center;">
<el-tag type="info" style="margin-right: 12px;">{{ item.itemName }}</el-tag>
<el-tag
:type="item.status == 1 ? 'success' : (item.status == 2 ? 'danger' : 'info')"
style="margin-right: 16px; min-width: 60px; text-align: center;"
>
<span v-if="item.status == 0">未检测</span>
<span v-else-if="item.status == 1">通过</span>
<span v-else-if="item.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</div>
<div>
<el-button v-if="item.status == 0" size="mini" type="success" style="margin-right: 8px;" @click="changeItemStatus(detailData.taskId, item.itemId, 1)">通过</el-button>
<el-button v-if="item.status == 0" size="mini" type="danger" @click="changeItemStatus(detailData.taskId, item.itemId, 2)">不通过</el-button>
</div>
</div>
</el-descriptions-item>
</el-descriptions>
<span slot="footer" class="dialog-footer">
<el-button @click="handleDetailClose"> </el-button>
</span>
</el-dialog>
</div>
</template>
@@ -154,12 +182,6 @@ export default {
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
@@ -177,15 +199,24 @@ export default {
taskName: undefined,
},
// 表单参数
form: {},
form: {
verifyTarget: undefined,
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: undefined
},
// 表单校验
rules: {
},
detailOpen: false,
detailData: {}
detailData: {},
// 选中的任务(当前选择的行)
selectedTask: null
};
},
mounted() {
created() {
console.log(this.$refs.checkTaskTable, '初始化表格数据')
this.getList();
},
components: {
@@ -217,7 +248,13 @@ export default {
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined
remark: undefined,
verifyTarget: undefined,
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: undefined
};
this.resetForm("form");
},
@@ -231,11 +268,22 @@ export default {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.taskId)
this.single = selection.length!==1
this.multiple = !selection.length
/** 点击行选中任务 */
handleRowClick(row) {
// 否则选中当前行
this.selectedTask = row
this.loadTaskDetail(row.taskId)
},
// 加载任务详情
loadTaskDetail(taskId) {
this.detailLoading = true
console.log(taskId, '加载任务详情')
getCheckTask(taskId)
.then(response => {
this.detailData = response.data
this.detailLoading = false
})
},
/** 新增按钮操作 */
handleAdd() {
@@ -244,11 +292,10 @@ export default {
this.title = "添加检查任务";
},
/** 修改按钮操作 */
handleUpdate(row) {
handleUpdate() {
this.loading = true;
this.reset();
const taskId = row.taskId || this.ids
getCheckTask(taskId).then(response => {
getCheckTask(this.selectedTask.taskId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
@@ -260,7 +307,6 @@ export default {
this.loading = true
getCheckTask(row.taskId).then(response => {
this.detailData = response.data
this.detailOpen = true
}).finally(() => {
this.loading = false
})
@@ -292,13 +338,16 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const taskIds = row.taskId || this.ids;
this.$modal.confirm('是否确认删除检查任务编号为"' + taskIds + '"的数据项?').then(() => {
const taskId = row ? row.taskId : this.selectedTask.taskId;
this.$modal.confirm('是否确认删除检查任务编号为"' + taskId + '"的数据项?').then(() => {
this.loading = true;
return delCheckTask(taskIds);
return delCheckTask(taskId);
}).then(() => {
this.loading = false;
this.getList();
// 重置选中状态和详情数据
this.selectedTask = null;
this.detailData = {};
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
@@ -324,10 +373,33 @@ export default {
})
})
},
handleDetailClose() {
this.detailOpen = false
this.getList()
},
// 添加样式
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>

View File

@@ -0,0 +1,468 @@
<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 label="机组" prop="unitGroup">
<el-input v-model="queryParams.unitGroup" placeholder="请输入机组" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="queryParams.workshopSection" placeholder="请输入工段" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="queryParams.process" 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="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!selectedTask"
@click="handleUpdate">修改</el-button>
</el-col>
<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">
<KLPTable ref="checkTaskTable" height="300px" highlight-current-row v-loading="loading" :data="checkTaskList"
@row-click="handleRowClick">
<el-table-column label="任务名称" align="center" prop="taskName" />
<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="verifyTarget.sampleId" />
<el-table-column label="物料编码" align="center" prop="verifyTarget.materialId" />
<el-table-column label="物料名称" align="center" prop="verifyTarget.materialName" />
<el-table-column label="供应商" align="center" prop="verifyTarget.vendor" />
<el-table-column label="规格型号" align="center" prop="verifyTarget.specificationModel" />
<el-table-column label="检验结果" align="center">
<template slot-scope="scope">
<el-tag
:type="scope.row.inspectionResult == 1 ? 'success' : (scope.row.inspectionResult == 2 ? 'danger' : 'info')">
<span v-if="scope.row.inspectionResult == 0">未检验</span>
<span v-else-if="scope.row.inspectionResult == 1">合格</span>
<span v-else-if="scope.row.inspectionResult == 2">不合格</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleAccept(scope.row)">合格</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleReject(scope.row)">不合格</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</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="detailLoading" :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" prop="standardTarget"></el-table-column>
<el-table-column label="目标上限" align="center" prop="targetUpper"></el-table-column>
<el-table-column label="目标下限" align="center" prop="targetLower"></el-table-column>
<el-table-column label="实测值" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.actualMeasure" placeholder="请输入实测值" clearable
@blur="handleBlur(scope.row)" />
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit"></el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : (scope.row.status == 2 ? 'danger' : 'info')">
<span v-if="scope.row.status == 0">未检测</span>
<span v-else-if="scope.row.status == 1">通过</span>
<span v-else-if="scope.row.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.status == 0" size="mini" type="success"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="danger" style="margin-left: 8px;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 2)">不通过</el-button>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个待检任务查看详情"></el-empty>
</div>
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
</el-form-item>
<el-form-item label="检查项" prop="itemId" v-if="!form.taskId">
<CheckItemSelect v-model="form.itemId" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="样品编号" prop="verifyTarget.sampleId">
<el-input v-model="form.verifyTarget.sampleId" placeholder="请输入样品编号" />
</el-form-item>
<el-form-item label="物料编码" prop="verifyTarget.materialId">
<el-input v-model="form.verifyTarget.materialId" placeholder="请输入物料编码" />
</el-form-item>
<el-form-item label="物料名称" prop="verifyTarget.materialName">
<el-input v-model="form.verifyTarget.materialName" placeholder="请输入物料名称" />
</el-form-item>
<el-form-item label="供应商" prop="verifyTarget.vendor">
<el-input v-model="form.verifyTarget.vendor" placeholder="请输入供应商" />
</el-form-item>
<el-form-item label="规格型号" prop="verifyTarget.specificationModel">
<el-input v-model="form.verifyTarget.specificationModel" placeholder="请输入规格型号" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="form.workshopSection" placeholder="请输入工段" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="form.process" placeholder="请输入工序" />
</el-form-item>
<el-form-item label="机组" prop="unitGroup">
<el-input v-model="form.unitGroup" placeholder="请输入机组" />
</el-form-item>
<el-form-item label="检验结果" prop="inspectionResult">
<el-select v-model="form.inspectionResult" placeholder="请选择检验结果">
<el-option label="未检验" :value="0" />
<el-option label="合格" :value="1" />
<el-option label="不合格" :value="2" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCheckTask, getCheckTask, delCheckTask, addCheckTask, updateCheckTask } from '@/api/mes/qc/checkTask'
import { updateCheckTaskItemStatus, updateCheckTaskItem } from '@/api/mes/qc/checkTaskItem'
import CheckItemSelect from '@/components/KLPService/CheckItemSelect/index'
export default {
name: 'CheckTask',
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 检查任务表格数据
checkTaskList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
taskName: undefined,
unitGroup: undefined,
workshopSection: undefined,
process: undefined,
inspectionType: 'auxiliary'
},
// 表单参数
form: {
verifyTarget: {
sampleId: undefined,
materialId: undefined,
materialName: undefined,
vendor: undefined,
specificationModel: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'auxiliary'
},
// 表单校验
rules: {
},
detailData: {},
// 选中的任务(当前选择的行)
selectedTask: null
};
},
created() {
console.log(this.$refs.checkTaskTable, '初始化表格数据')
this.getList();
},
components: {
CheckItemSelect
},
methods: {
/** 查询检查任务列表 */
getList() {
this.loading = true;
listCheckTask(this.queryParams).then(response => {
this.checkTaskList = response.rows.map(item => ({
...item,
verifyTarget: JSON.parse(item.verifyTarget)
}));
this.total = response.total;
this.loading = false;
});
},
handleBlur(row) {
updateCheckTaskItem({...row, itemId: row.checkTaskItemId}).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
})
},
handleAccept(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 1 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
handleReject(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 2 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
taskId: undefined,
taskName: undefined,
itemId: [],
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined,
verifyTarget: {
sampleId: undefined,
materialId: undefined,
materialName: undefined,
vendor: undefined,
specificationModel: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'auxiliary',
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 点击行选中任务 */
handleRowClick(row) {
// 否则选中当前行
this.selectedTask = row
this.loadTaskDetail(row.taskId)
},
// 加载任务详情
loadTaskDetail(taskId) {
this.detailLoading = true
console.log(taskId, '加载任务详情')
getCheckTask(taskId)
.then(response => {
this.detailData = response.data
this.detailLoading = false
})
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加检查任务";
},
/** 修改按钮操作 */
handleUpdate() {
this.loading = true;
this.reset();
getCheckTask(this.selectedTask.taskId).then(response => {
this.loading = false;
this.form = {
...response.data,
verifyTarget: JSON.parse(response.data.verifyTarget)
};
this.open = true;
this.title = "修改检查任务";
});
},
/** 详情按钮操作 */
handleDetail(row) {
this.loading = true
getCheckTask(row.taskId).then(response => {
this.detailData = response.data
}).finally(() => {
this.loading = false
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
// 对象转json
const payload = {
...this.form,
verifyTarget: JSON.stringify(this.form.verifyTarget)
}
if (this.form.taskId != null) {
updateCheckTask(payload).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addCheckTask(payload).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const taskId = row ? row.taskId : this.selectedTask.taskId;
this.$modal.confirm('是否确认删除检查任务编号为"' + taskId + '"的数据项?').then(() => {
this.loading = true;
return delCheckTask(taskId);
}).then(() => {
this.loading = false;
this.getList();
// 重置选中状态和详情数据
this.selectedTask = null;
this.detailData = {};
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/checkTask/export', {
...this.queryParams
}, `checkTask_${new Date().getTime()}.xlsx`)
},
/** 修改检查项状态 */
changeItemStatus(checkTaskId, checkItemId, status) {
this.$modal.confirm('确定要将该检查项状态修改为' + (status === 1 ? '通过' : '不通过') + '吗?').then(() => {
// 调用新接口
return updateCheckTaskItemStatus({ checkTaskId, checkItemId, status })
}).then(() => {
this.$modal.msgSuccess('状态修改成功')
// 重新拉取详情
getCheckTask(this.detailData.taskId).then(response => {
this.detailData = response.data
})
})
},
},
// 添加样式
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>

View File

@@ -0,0 +1,444 @@
<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 label="机组" prop="unitGroup">
<el-input v-model="queryParams.unitGroup" placeholder="请输入机组" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="queryParams.workshopSection" placeholder="请输入工段" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="queryParams.process" 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="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!selectedTask"
@click="handleUpdate">修改</el-button>
</el-col>
<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">
<KLPTable ref="checkTaskTable" height="300px" highlight-current-row v-loading="loading" :data="checkTaskList"
@row-click="handleRowClick">
<el-table-column label="任务名称" align="center" prop="taskName" />
<el-table-column label="样品编号" align="center" prop="verifyTarget.sampleId" />
<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">
<template slot-scope="scope">
<el-tag
:type="scope.row.inspectionResult == 1 ? 'success' : (scope.row.inspectionResult == 2 ? 'danger' : 'info')">
<span v-if="scope.row.inspectionResult == 0">未检验</span>
<span v-else-if="scope.row.inspectionResult == 1">合格</span>
<span v-else-if="scope.row.inspectionResult == 2">不合格</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleAccept(scope.row)">合格</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleReject(scope.row)">不合格</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</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="detailLoading" :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" prop="standardTarget"></el-table-column>
<el-table-column label="目标上限" align="center" prop="targetUpper"></el-table-column>
<el-table-column label="目标下限" align="center" prop="targetLower"></el-table-column>
<el-table-column label="实测值" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.actualMeasure" placeholder="请输入实测值" clearable
@blur="handleBlur(scope.row)" />
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit"></el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : (scope.row.status == 2 ? 'danger' : 'info')">
<span v-if="scope.row.status == 0">未检测</span>
<span v-else-if="scope.row.status == 1">通过</span>
<span v-else-if="scope.row.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.status == 0" size="mini" type="success"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="danger" style="margin-left: 8px;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 2)">不通过</el-button>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个待检任务查看详情"></el-empty>
</div>
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
</el-form-item>
<el-form-item label="检查项" prop="itemId" v-if="!form.taskId">
<CheckItemSelect v-model="form.itemId" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="样品编号">
<el-input v-model="form.verifyTarget.sampleId" placeholder="请输入样品编号" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="form.workshopSection" placeholder="请输入工段" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="form.process" placeholder="请输入工序" />
</el-form-item>
<el-form-item label="机组" prop="unitGroup">
<el-input v-model="form.unitGroup" placeholder="请输入机组" />
</el-form-item>
<el-form-item label="检验结果" prop="inspectionResult">
<el-select v-model="form.inspectionResult" placeholder="请选择检验结果">
<el-option label="未检验" :value="0" />
<el-option label="合格" :value="1" />
<el-option label="不合格" :value="2" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCheckTask, getCheckTask, delCheckTask, addCheckTask, updateCheckTask } from '@/api/mes/qc/checkTask'
import { updateCheckTaskItemStatus, updateCheckTaskItem } from '@/api/mes/qc/checkTaskItem'
import CheckItemSelect from '@/components/KLPService/CheckItemSelect/index'
export default {
name: 'CheckTask',
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 检查任务表格数据
checkTaskList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
taskName: undefined,
unitGroup: undefined,
workshopSection: undefined,
process: undefined,
inspectionType: 'lab'
},
// 表单参数
form: {
verifyTarget: {
sampleId: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'lab'
},
// 表单校验
rules: {
},
detailData: {},
// 选中的任务(当前选择的行)
selectedTask: null
};
},
created() {
console.log(this.$refs.checkTaskTable, '初始化表格数据')
this.getList();
},
components: {
CheckItemSelect
},
methods: {
/** 查询检查任务列表 */
getList() {
this.loading = true;
listCheckTask(this.queryParams).then(response => {
this.checkTaskList = response.rows.map(item => ({
...item,
verifyTarget: JSON.parse(item.verifyTarget)
}));
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
handleBlur(row) {
updateCheckTaskItem({...row, itemId: row.checkTaskItemId}).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
})
},
handleAccept(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 1 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
handleReject(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 2 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
// 表单重置
reset() {
this.form = {
taskId: undefined,
taskName: undefined,
itemId: [],
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined,
verifyTarget: {
sampleId: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'lab',
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 点击行选中任务 */
handleRowClick(row) {
// 否则选中当前行
this.selectedTask = row
this.loadTaskDetail(row.taskId)
},
// 加载任务详情
loadTaskDetail(taskId) {
this.detailLoading = true
console.log(taskId, '加载任务详情')
getCheckTask(taskId)
.then(response => {
this.detailData = response.data
this.detailLoading = false
})
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加检查任务";
},
/** 修改按钮操作 */
handleUpdate() {
this.loading = true;
this.reset();
getCheckTask(this.selectedTask.taskId).then(response => {
this.loading = false;
this.form = {
...response.data,
verifyTarget: JSON.parse(response.data.verifyTarget)
};
this.open = true;
this.title = "修改检查任务";
});
},
/** 详情按钮操作 */
handleDetail(row) {
this.loading = true
getCheckTask(row.taskId).then(response => {
this.detailData = response.data
}).finally(() => {
this.loading = false
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
// 对象转json
const payload = {
...this.form,
verifyTarget: JSON.stringify(this.form.verifyTarget)
}
if (this.form.taskId != null) {
updateCheckTask(payload).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addCheckTask(payload).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const taskId = row ? row.taskId : this.selectedTask.taskId;
this.$modal.confirm('是否确认删除检查任务编号为"' + taskId + '"的数据项?').then(() => {
this.loading = true;
return delCheckTask(taskId);
}).then(() => {
this.loading = false;
this.getList();
// 重置选中状态和详情数据
this.selectedTask = null;
this.detailData = {};
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/checkTask/export', {
...this.queryParams
}, `checkTask_${new Date().getTime()}.xlsx`)
},
/** 修改检查项状态 */
changeItemStatus(checkTaskId, checkItemId, status) {
this.$modal.confirm('确定要将该检查项状态修改为' + (status === 1 ? '通过' : '不通过') + '吗?').then(() => {
// 调用新接口
return updateCheckTaskItemStatus({ checkTaskId, checkItemId, status })
}).then(() => {
this.$modal.msgSuccess('状态修改成功')
// 重新拉取详情
getCheckTask(this.detailData.taskId).then(response => {
this.detailData = response.data
})
})
},
},
// 添加样式
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>

View File

@@ -0,0 +1,475 @@
<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 label="机组" prop="unitGroup">
<el-input v-model="queryParams.unitGroup" placeholder="请输入机组" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="queryParams.workshopSection" placeholder="请输入工段" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="queryParams.process" 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="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!selectedTask"
@click="handleUpdate">修改</el-button>
</el-col>
<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">
<KLPTable ref="checkTaskTable" height="300px" highlight-current-row v-loading="loading" :data="checkTaskList"
@row-click="handleRowClick">
<el-table-column label="任务名称" align="center" prop="taskName" />
<el-table-column label="钢卷号" align="center" prop="verifyTarget.coilId" />
<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="verifyTarget.coilId" />
<el-table-column label="原料卷号" align="center" prop="verifyTarget.rawCoilId" />
<el-table-column label="厂家" align="center" prop="verifyTarget.vendor" />
<el-table-column label="宽度" align="center" prop="verifyTarget.width" />
<el-table-column label="厚度" align="center" prop="verifyTarget.thickness" />
<el-table-column label="重量" align="center" prop="verifyTarget.weight" />
<el-table-column label="检验结果" align="center">
<template slot-scope="scope">
<el-tag
:type="scope.row.inspectionResult == 1 ? 'success' : (scope.row.inspectionResult == 2 ? 'danger' : 'info')">
<span v-if="scope.row.inspectionResult == 0">未检验</span>
<span v-else-if="scope.row.inspectionResult == 1">合格</span>
<span v-else-if="scope.row.inspectionResult == 2">不合格</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleAccept(scope.row)">合格</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleReject(scope.row)">不合格</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</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="detailLoading" :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" prop="standardTarget"></el-table-column>
<el-table-column label="目标上限" align="center" prop="targetUpper"></el-table-column>
<el-table-column label="目标下限" align="center" prop="targetLower"></el-table-column>
<el-table-column label="实测值" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.actualMeasure" placeholder="请输入实测值" clearable
@blur="handleBlur(scope.row)" />
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit"></el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : (scope.row.status == 2 ? 'danger' : 'info')">
<span v-if="scope.row.status == 0">未检测</span>
<span v-else-if="scope.row.status == 1">通过</span>
<span v-else-if="scope.row.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.status == 0" size="mini" type="success"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="danger" style="margin-left: 8px;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 2)">不通过</el-button>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个待检任务查看详情"></el-empty>
</div>
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
</el-form-item>
<el-form-item label="检查项" prop="itemId" v-if="!form.taskId">
<CheckItemSelect v-model="form.itemId" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="钢卷号">
<el-input v-model="form.verifyTarget.coilId" placeholder="请输入钢卷号" />
</el-form-item>
<el-form-item label="原料卷号">
<el-input v-model="form.verifyTarget.rawCoilId" placeholder="请输入原料卷号" />
</el-form-item>
<el-form-item label="厂家">
<el-input v-model="form.verifyTarget.factory" placeholder="请输入厂家" />
</el-form-item>
<el-form-item label="厚度">
<el-input v-model="form.verifyTarget.thickness" placeholder="请输入厚度" />
</el-form-item>
<el-form-item label="宽度">
<el-input v-model="form.verifyTarget.width" placeholder="请输入宽度" />
</el-form-item>
<el-form-item label="重量">
<el-input v-model="form.verifyTarget.weight" placeholder="请输入重量" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="form.workshopSection" placeholder="请输入工段" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="form.process" placeholder="请输入工序" />
</el-form-item>
<el-form-item label="机组" prop="unitGroup">
<el-input v-model="form.unitGroup" placeholder="请输入机组" />
</el-form-item>
<el-form-item label="检验结果" prop="inspectionResult">
<el-select v-model="form.inspectionResult" placeholder="请选择检验结果">
<el-option label="未检验" :value="0" />
<el-option label="合格" :value="1" />
<el-option label="不合格" :value="2" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCheckTask, getCheckTask, delCheckTask, addCheckTask, updateCheckTask } from '@/api/mes/qc/checkTask'
import { updateCheckTaskItemStatus, updateCheckTaskItem } from '@/api/mes/qc/checkTaskItem'
import CheckItemSelect from '@/components/KLPService/CheckItemSelect/index'
export default {
name: 'CheckTask',
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 检查任务表格数据
checkTaskList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
taskName: undefined,
unitGroup: undefined,
workshopSection: undefined,
process: undefined,
inspectionType: 'raw'
},
// 表单参数
form: {
verifyTarget: {
coilId: undefined,
rawCoilId: undefined,
factory: undefined,
thickness: undefined,
width: undefined,
weight: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'raw'
},
// 表单校验
rules: {
},
detailData: {},
// 选中的任务(当前选择的行)
selectedTask: null
};
},
created() {
console.log(this.$refs.checkTaskTable, '初始化表格数据')
this.getList();
},
components: {
CheckItemSelect
},
methods: {
/** 查询检查任务列表 */
getList() {
this.loading = true;
listCheckTask(this.queryParams).then(response => {
this.checkTaskList = response.rows.map(item => ({
...item,
verifyTarget: JSON.parse(item.verifyTarget)
}));
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
handleBlur(row) {
updateCheckTaskItem({...row, itemId: row.checkTaskItemId}).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
})
},
handleAccept(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 1 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
handleReject(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 2 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
// 表单重置
reset() {
this.form = {
taskId: undefined,
taskName: undefined,
itemId: [],
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined,
verifyTarget: {
coilId: undefined,
rawCoilId: undefined,
factory: undefined,
thickness: undefined,
width: undefined,
weight: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'raw',
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 点击行选中任务 */
handleRowClick(row) {
// 否则选中当前行
this.selectedTask = row
this.loadTaskDetail(row.taskId)
},
// 加载任务详情
loadTaskDetail(taskId) {
this.detailLoading = true
console.log(taskId, '加载任务详情')
getCheckTask(taskId)
.then(response => {
this.detailData = response.data
this.detailLoading = false
})
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加检查任务";
},
/** 修改按钮操作 */
handleUpdate() {
this.loading = true;
this.reset();
getCheckTask(this.selectedTask.taskId).then(response => {
this.loading = false;
this.form = {
...response.data,
verifyTarget: JSON.parse(response.data.verifyTarget)
};
this.open = true;
this.title = "修改检查任务";
});
},
/** 详情按钮操作 */
handleDetail(row) {
this.loading = true
getCheckTask(row.taskId).then(response => {
this.detailData = response.data
}).finally(() => {
this.loading = false
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
// 对象转json
const payload = {
...this.form,
verifyTarget: JSON.stringify(this.form.verifyTarget)
}
if (this.form.taskId != null) {
updateCheckTask(payload).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addCheckTask(payload).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const taskId = row ? row.taskId : this.selectedTask.taskId;
this.$modal.confirm('是否确认删除检查任务编号为"' + taskId + '"的数据项?').then(() => {
this.loading = true;
return delCheckTask(taskId);
}).then(() => {
this.loading = false;
this.getList();
// 重置选中状态和详情数据
this.selectedTask = null;
this.detailData = {};
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/checkTask/export', {
...this.queryParams
}, `checkTask_${new Date().getTime()}.xlsx`)
},
/** 修改检查项状态 */
changeItemStatus(checkTaskId, checkItemId, status) {
this.$modal.confirm('确定要将该检查项状态修改为' + (status === 1 ? '通过' : '不通过') + '吗?').then(() => {
// 调用新接口
return updateCheckTaskItemStatus({ checkTaskId, checkItemId, status })
}).then(() => {
this.$modal.msgSuccess('状态修改成功')
// 重新拉取详情
getCheckTask(this.detailData.taskId).then(response => {
this.detailData = response.data
})
})
},
},
// 添加样式
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>

View File

@@ -0,0 +1,444 @@
<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 label="机组" prop="unitGroup">
<el-input v-model="queryParams.unitGroup" placeholder="请输入机组" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="queryParams.workshopSection" placeholder="请输入工段" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="queryParams.process" 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="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!selectedTask"
@click="handleUpdate">修改</el-button>
</el-col>
<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">
<KLPTable ref="checkTaskTable" height="300px" highlight-current-row v-loading="loading" :data="checkTaskList"
@row-click="handleRowClick">
<el-table-column label="任务名称" align="center" prop="taskName" />
<el-table-column label="钢卷号" align="center" prop="verifyTarget.coilId" />
<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">
<template slot-scope="scope">
<el-tag
:type="scope.row.inspectionResult == 1 ? 'success' : (scope.row.inspectionResult == 2 ? 'danger' : 'info')">
<span v-if="scope.row.inspectionResult == 0">未检验</span>
<span v-else-if="scope.row.inspectionResult == 1">合格</span>
<span v-else-if="scope.row.inspectionResult == 2">不合格</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleAccept(scope.row)">合格</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleReject(scope.row)">不合格</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</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="detailLoading" :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" prop="standardTarget"></el-table-column>
<el-table-column label="目标上限" align="center" prop="targetUpper"></el-table-column>
<el-table-column label="目标下限" align="center" prop="targetLower"></el-table-column>
<el-table-column label="实测值" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.actualMeasure" placeholder="请输入实测值" clearable
@blur="handleBlur(scope.row)" />
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit"></el-table-column>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : (scope.row.status == 2 ? 'danger' : 'info')">
<span v-if="scope.row.status == 0">未检测</span>
<span v-else-if="scope.row.status == 1">通过</span>
<span v-else-if="scope.row.status == 2">不通过</span>
<span v-else>未知</span>
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.status == 0" size="mini" type="success"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="danger" style="margin-left: 8px;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 2)">不通过</el-button>
</template>
</el-table-column>
</KLPTable>
</div>
<div v-else class="empty-tip">
<el-empty description="请选择一个待检任务查看详情"></el-empty>
</div>
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />
</el-form-item>
<el-form-item label="检查项" prop="itemId" v-if="!form.taskId">
<CheckItemSelect v-model="form.itemId" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="钢卷号">
<el-input v-model="form.verifyTarget.coilId" placeholder="请输入钢卷号" />
</el-form-item>
<el-form-item label="工段" prop="workshopSection">
<el-input v-model="form.workshopSection" placeholder="请输入工段" />
</el-form-item>
<el-form-item label="工序" prop="process">
<el-input v-model="form.process" placeholder="请输入工序" />
</el-form-item>
<el-form-item label="机组" prop="unitGroup">
<el-input v-model="form.unitGroup" placeholder="请输入机组" />
</el-form-item>
<el-form-item label="检验结果" prop="inspectionResult">
<el-select v-model="form.inspectionResult" placeholder="请选择检验结果">
<el-option label="未检验" :value="0" />
<el-option label="合格" :value="1" />
<el-option label="不合格" :value="2" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCheckTask, getCheckTask, delCheckTask, addCheckTask, updateCheckTask } from '@/api/mes/qc/checkTask'
import { updateCheckTaskItemStatus, updateCheckTaskItem } from '@/api/mes/qc/checkTaskItem'
import CheckItemSelect from '@/components/KLPService/CheckItemSelect/index'
export default {
name: 'CheckTask',
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 检查任务表格数据
checkTaskList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
taskName: undefined,
unitGroup: undefined,
workshopSection: undefined,
process: undefined,
inspectionType: 'section'
},
// 表单参数
form: {
verifyTarget: {
coilId: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'section'
},
// 表单校验
rules: {
},
detailData: {},
// 选中的任务(当前选择的行)
selectedTask: null
};
},
created() {
console.log(this.$refs.checkTaskTable, '初始化表格数据')
this.getList();
},
components: {
CheckItemSelect
},
methods: {
/** 查询检查任务列表 */
getList() {
this.loading = true;
listCheckTask(this.queryParams).then(response => {
this.checkTaskList = response.rows.map(item => ({
...item,
verifyTarget: JSON.parse(item.verifyTarget)
}));
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
handleBlur(row) {
updateCheckTaskItem({...row, itemId: row.checkTaskItemId}).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
})
},
handleAccept(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 1 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
handleReject(row) {
updateCheckTask({ taskId: row.taskId, inspectionResult: 2 }).then(response => {
this.$message({
message: '更新成功',
type: 'success'
})
this.getList()
})
},
// 表单重置
reset() {
this.form = {
taskId: undefined,
taskName: undefined,
itemId: [],
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined,
verifyTarget: {
coilId: undefined
},
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: 'section',
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 点击行选中任务 */
handleRowClick(row) {
// 否则选中当前行
this.selectedTask = row
this.loadTaskDetail(row.taskId)
},
// 加载任务详情
loadTaskDetail(taskId) {
this.detailLoading = true
console.log(taskId, '加载任务详情')
getCheckTask(taskId)
.then(response => {
this.detailData = response.data
this.detailLoading = false
})
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加检查任务";
},
/** 修改按钮操作 */
handleUpdate() {
this.loading = true;
this.reset();
getCheckTask(this.selectedTask.taskId).then(response => {
this.loading = false;
this.form = {
...response.data,
verifyTarget: JSON.parse(response.data.verifyTarget)
};
this.open = true;
this.title = "修改检查任务";
});
},
/** 详情按钮操作 */
handleDetail(row) {
this.loading = true
getCheckTask(row.taskId).then(response => {
this.detailData = response.data
}).finally(() => {
this.loading = false
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
// 对象转json
const payload = {
...this.form,
verifyTarget: JSON.stringify(this.form.verifyTarget)
}
if (this.form.taskId != null) {
updateCheckTask(payload).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addCheckTask(payload).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const taskId = row ? row.taskId : this.selectedTask.taskId;
this.$modal.confirm('是否确认删除检查任务编号为"' + taskId + '"的数据项?').then(() => {
this.loading = true;
return delCheckTask(taskId);
}).then(() => {
this.loading = false;
this.getList();
// 重置选中状态和详情数据
this.selectedTask = null;
this.detailData = {};
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/checkTask/export', {
...this.queryParams
}, `checkTask_${new Date().getTime()}.xlsx`)
},
/** 修改检查项状态 */
changeItemStatus(checkTaskId, checkItemId, status) {
this.$modal.confirm('确定要将该检查项状态修改为' + (status === 1 ? '通过' : '不通过') + '吗?').then(() => {
// 调用新接口
return updateCheckTaskItemStatus({ checkTaskId, checkItemId, status })
}).then(() => {
this.$modal.msgSuccess('状态修改成功')
// 重新拉取详情
getCheckTask(this.detailData.taskId).then(response => {
this.detailData = response.data
})
})
},
},
// 添加样式
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>