feat(qc): 新增检化验申请单相关API,优化检验项模板接口并清理冗余页面

1. 将检验项模板查询接口从POST改为GET请求
2. 新增检化验申请单的增删改查、批量保存检验数据API
3. 删除多个冗余的质检历史、检验项、检验任务页面
This commit is contained in:
砂糖
2026-07-08 16:49:22 +08:00
parent d630920c06
commit 212b79be56
14 changed files with 1685 additions and 4278 deletions

View File

@@ -99,7 +99,7 @@ public class WmsInspectionItemTemplateController extends BaseController {
}
// 根据待检项查询详细信息
@PostMapping("/getInfoByInspectionItem")
@GetMapping("/getInfoByInspectionItem")
public R<List<WmsCheckItemVo>> getInfoByInspectionItem(@RequestParam String inspectionItemIds) {
return R.ok(iWmsInspectionItemTemplateService.getInfoByInspectionItem(inspectionItemIds));
}

View File

@@ -0,0 +1,64 @@
import request from '@/utils/request'
// 查询检化验申请单列表
export function listInspectionApplication(query) {
return request({
url: '/wms/inspectionApplication/list',
method: 'get',
params: query
})
}
// 查询检化验申请单详细
export function getInspectionApplication(applicationId) {
return request({
url: '/wms/inspectionApplication/' + applicationId,
method: 'get'
})
}
// 新增检化验申请单
export function addInspectionApplication(data) {
return request({
url: '/wms/inspectionApplication',
method: 'post',
data: data
})
}
// 修改检化验申请单
export function updateInspectionApplication(data) {
return request({
url: '/wms/inspectionApplication',
method: 'put',
data: data
})
}
// 删除检化验申请单
export function delInspectionApplication(applicationIds) {
return request({
url: '/wms/inspectionApplication/' + applicationIds,
method: 'delete'
})
}
// ====== 批量保存检验数据(审批通过后填写) ======
// 批量保存物理检验数据
export function batchSavePhysicalData(data) {
return request({
url: '/wms/inspectionApplication/batchSavePhysical',
method: 'post',
data: data
})
}
// 批量保存化学检验数据
export function batchSaveChemicalData(data) {
return request({
url: '/wms/inspectionApplication/batchSaveChemical',
method: 'post',
data: data
})
}

View File

@@ -47,7 +47,7 @@ export function delInspectionItemTemplate(templateId) {
export function getInfoByInspectionItem(inspectionItemIds) {
return request({
url: '/qc/inspectionItemTemplate/getInfoByInspectionItem',
method: 'post',
method: 'get',
params: {
inspectionItemIds
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,229 +0,0 @@
<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>

View File

@@ -1,402 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="检验项目名称" prop="itemName">
<el-input
v-model="queryParams.itemName"
placeholder="请输入检验项目名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="标准值" prop="standardValue">
<el-input
v-model="queryParams.standardValue"
placeholder="请输入标准值"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="上限" prop="upperLimit">
<el-input
v-model="queryParams.upperLimit"
placeholder="请输入上限"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="下限" prop="lowerLimit">
<el-input
v-model="queryParams.lowerLimit"
placeholder="请输入下限"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="单位" prop="unit">
<el-input
v-model="queryParams.unit"
placeholder="请输入单位"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="检验值" prop="inspectValue">
<el-input
v-model="queryParams.inspectValue"
placeholder="请输入检验值"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="是否合格" prop="isQualified">
<el-input
v-model="queryParams.isQualified"
placeholder="请输入是否合格"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="判定结果" prop="judgeResult">
<el-input
v-model="queryParams.judgeResult"
placeholder="请输入判定结果"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="检验人" prop="inspectUser">
<el-input
v-model="queryParams.inspectUser"
placeholder="请输入检验人"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="检验时间" prop="inspectTime">
<el-date-picker clearable
v-model="queryParams.inspectTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择检验时间">
</el-date-picker>
</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="single"
@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-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>
<el-table v-loading="loading" :data="inspectionItemList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="明细ID" align="center" prop="itemId" v-if="false"/>
<el-table-column label="检验项目名称" align="center" prop="itemName" />
<el-table-column label="标准值" align="center" prop="standardValue" />
<el-table-column label="上限" align="center" prop="upperLimit" />
<el-table-column label="下限" align="center" prop="lowerLimit" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="定性/定量" align="center" prop="itemType" />
<el-table-column label="检验值" align="center" prop="inspectValue" />
<el-table-column label="是否合格" align="center" prop="isQualified" />
<el-table-column label="判定结果" align="center" prop="judgeResult" />
<el-table-column label="检验人" align="center" prop="inspectUser" />
<el-table-column label="检验时间" align="center" prop="inspectTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.inspectTime, '{y}-{m}-{d}') }}</span>
</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="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改检验任务项目+结果对话框 -->
<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="itemName">
<el-input v-model="form.itemName" placeholder="请输入检验项目名称" />
</el-form-item>
<el-form-item label="标准值" prop="standardValue">
<el-input v-model="form.standardValue" placeholder="请输入标准值" />
</el-form-item>
<el-form-item label="上限" prop="upperLimit">
<el-input v-model="form.upperLimit" placeholder="请输入上限" />
</el-form-item>
<el-form-item label="下限" prop="lowerLimit">
<el-input v-model="form.lowerLimit" 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="inspectValue">
<el-input v-model="form.inspectValue" placeholder="请输入检验值" />
</el-form-item>
<el-form-item label="是否合格" prop="isQualified">
<el-input v-model="form.isQualified" placeholder="请输入是否合格" />
</el-form-item>
<el-form-item label="判定结果" prop="judgeResult">
<el-input v-model="form.judgeResult" placeholder="请输入判定结果" />
</el-form-item>
<el-form-item label="检验人" prop="inspectUser">
<el-input v-model="form.inspectUser" placeholder="请输入检验人" />
</el-form-item>
<el-form-item label="检验时间" prop="inspectTime">
<el-date-picker clearable
v-model="form.inspectTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择检验时间">
</el-date-picker>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" 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>
</div>
</template>
<script>
import { listInspectionItem, getInspectionItem, delInspectionItem, addInspectionItem, updateInspectionItem } from "@/api/mes/qc/inspectionItem";
export default {
name: "InspectionItem",
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 检验任务项目+结果表格数据
inspectionItemList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
itemName: undefined,
standardValue: undefined,
upperLimit: undefined,
lowerLimit: undefined,
unit: undefined,
itemType: undefined,
inspectValue: undefined,
isQualified: undefined,
judgeResult: undefined,
inspectUser: undefined,
inspectTime: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询检验任务项目+结果列表 */
getList() {
this.loading = true;
listInspectionItem(this.queryParams).then(response => {
this.inspectionItemList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
itemId: undefined,
taskId: undefined,
itemName: undefined,
standardValue: undefined,
upperLimit: undefined,
lowerLimit: undefined,
unit: undefined,
itemType: undefined,
inspectValue: undefined,
isQualified: undefined,
judgeResult: undefined,
inspectUser: undefined,
inspectTime: undefined,
remark: undefined,
delFlag: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.itemId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加检验任务项目+结果";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const itemId = row.itemId || this.ids
getInspectionItem(itemId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改检验任务项目+结果";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.itemId != null) {
updateInspectionItem(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addInspectionItem(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const itemIds = row.itemId || this.ids;
this.$modal.confirm('是否确认删除检验任务项目+结果编号为"' + itemIds + '"的数据项?').then(() => {
this.loading = true;
return delInspectionItem(itemIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/inspectionItem/export', {
...this.queryParams
}, `inspectionItem_${new Date().getTime()}.xlsx`)
}
}
};
</script>

File diff suppressed because it is too large Load Diff

View File

@@ -3,14 +3,14 @@
<div v-loading="filterLoading" style="margin-bottom: 16px; min-height: 50px;">
<div style="display: flex; align-items: center; margin-bottom: 6px;">
<span style="font-size: 13px; color: #909399; white-space: nowrap; margin-right: 12px; width: 68px; text-align: right;">所属单位</span>
<el-radio-group v-model="selectedCompany" size="small" @change="handleCompanyChange">
<el-radio-group v-model="selectedCompany" size="small" :disabled="mainLoading" @change="handleCompanyChange">
<el-radio-button label="">全部</el-radio-button>
<el-radio-button v-for="company in companyOptions" :key="company" :label="company">{{ company }}</el-radio-button>
</el-radio-group>
</div>
<div style="display: flex; align-items: center; margin-bottom: 6px;">
<span style="font-size: 13px; color: #909399; white-space: nowrap; margin-right: 12px; width: 68px; text-align: right;">方案名称</span>
<el-radio-group v-model="selectedScheme" size="small" @change="handleSchemeChange">
<el-radio-group v-model="selectedScheme" size="small" :disabled="mainLoading" @change="handleSchemeChange">
<el-radio-button label="">全部</el-radio-button>
<el-radio-button v-for="scheme in schemeOptions" :key="scheme" :label="scheme">{{ scheme }}</el-radio-button>
</el-radio-group>
@@ -42,6 +42,9 @@
<el-table v-loading="mainLoading" :data="mainList" border stripe class="dynamic-table" fit max-height="calc(100vh - 260px)">
<el-table-column label="日期" align="center" width="150" fixed="left">
<template slot="header">
<span class="required-mark">日期</span>
</template>
<template slot-scope="scope">
<el-date-picker
v-model="scope.row.inspectionDate"
@@ -113,30 +116,6 @@
/>
</div>
<el-empty v-else description="请先选择所属单位和检验方案" />
<el-dialog :title="'新增检验记录'" :visible.sync="addMainDialogVisible" width="600px" append-to-body>
<el-form ref="addMainForm" :model="addMainFormData" label-width="100px">
<el-form-item label="样品名称" prop="sampleName">
<el-input v-model="addMainFormData.sampleName" placeholder="请输入样品名称" />
</el-form-item>
<el-form-item label="样品编号" prop="sampleNo">
<el-input v-model="addMainFormData.sampleNo" placeholder="请输入样品编号" />
</el-form-item>
<el-form-item label="来样编号" prop="batchNo">
<el-input v-model="addMainFormData.batchNo" placeholder="请输入来样编号" />
</el-form-item>
<el-form-item label="检验日期" prop="inspectionDate">
<el-date-picker v-model="addMainFormData.inspectionDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择检验日期" style="width:100%" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="addMainFormData.remark" type="textarea" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="addMainDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitAddMain">确定</el-button>
</div>
</el-dialog>
</div>
</template>
@@ -151,7 +130,6 @@ export default {
return {
filterLoading: false,
mainLoading: false,
addMainDialogVisible: false,
templateList: [],
cascadeData: {},
companyOptions: [],
@@ -166,14 +144,7 @@ export default {
pageNum: 1,
pageSize: 1000
},
dateRange: [],
addMainFormData: {
sampleName: '',
sampleNo: '',
batchNo: '',
inspectionDate: '',
remark: ''
}
dateRange: []
}
},
created() {
@@ -247,6 +218,7 @@ export default {
},
handleCompanyChange() {
if (this.mainLoading) return
this.selectedScheme = ''
if (this.selectedCompany) {
this.schemeOptions = this.cascadeData[this.selectedCompany] || []
@@ -262,6 +234,7 @@ export default {
},
handleSchemeChange() {
if (this.mainLoading) return
if (!this.selectedScheme) {
this.currentTemplate = null
this.mainList = []
@@ -365,31 +338,39 @@ export default {
},
handleAddMain() {
this.addMainFormData = {
const itemMap = {}
if (this.checkItems.length > 0) {
this.checkItems.forEach(item => {
itemMap[item.itemName] = {
detailId: undefined,
mainId: undefined,
itemName: item.itemName,
itemValue: '',
itemUnit: item.unit,
upperLimit: item.targetUpper,
lowerLimit: item.targetLower,
rangeDesc: ''
}
})
}
const newRow = {
_isNew: true,
_items: itemMap,
_originalItems: JSON.parse(JSON.stringify(itemMap)),
inspectionDate: '',
sampleName: '',
sampleNo: '',
batchNo: '',
inspectionDate: '',
remark: ''
}
this.addMainDialogVisible = true
},
submitAddMain() {
const data = {
...this.addMainFormData,
templateId: this.currentTemplate.templateId
}
addInspectionMain(data).then(() => {
this.$message.success('新增成功')
this.addMainDialogVisible = false
this.getMainList()
}).catch(() => {
this.$message.error('新增失败')
})
this.mainList.unshift(newRow)
},
handleSaveMain(row) {
if (!row.inspectionDate) {
this.$message.warning('请选择检验日期')
return
}
row._saving = true
const detailList = this.checkItems.map(checkItem => {
const itemData = row._items[checkItem.itemName]
@@ -405,38 +386,20 @@ export default {
rangeDesc: itemData.rangeDesc || ''
}
}).filter(Boolean)
updateInspectionMain({
mainId: row.mainId,
const requestData = {
sampleName: row.sampleName,
sampleNo: row.sampleNo,
batchNo: row.batchNo,
inspectionDate: row.inspectionDate,
remark: row.remark,
templateId: this.currentTemplate.templateId,
detailList: detailList
}).then(() => {
}
const isNew = row._isNew || !row.mainId
const apiCall = isNew ? addInspectionMain(requestData) : updateInspectionMain({ ...requestData, mainId: row.mainId })
apiCall.then(() => {
this.$message.success('保存成功')
return listInspectionDetail({ mainId: row.mainId, pageNum: 1, pageSize: 9999 })
}).then(response => {
const details = response.rows || []
if (this.checkItems.length > 0) {
this.checkItems.forEach(item => {
const found = details.find(d => d.itemName === item.itemName)
if (found) {
row._items[item.itemName] = {
detailId: found.detailId,
mainId: found.mainId,
itemName: found.itemName,
itemValue: found.itemValue || '',
itemUnit: found.itemUnit || item.unit,
upperLimit: found.upperLimit,
lowerLimit: found.lowerLimit,
rangeDesc: found.rangeDesc
}
}
})
}
row._originalItems = JSON.parse(JSON.stringify(row._items))
row._saving = false
this.getMainList()
}).catch(() => {
this.$message.error('保存失败')
row._saving = false
@@ -515,4 +478,10 @@ export default {
::v-deep .dynamic-table .el-table__body-wrapper {
overflow-x: auto;
}
.required-mark::before {
content: '*';
color: #f56c6c;
margin-right: 4px;
}
</style>

View File

@@ -1,299 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="检查项名称" prop="itemName">
<el-input
v-model="queryParams.itemName"
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="single"
@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-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>
<KLPTable v-loading="loading" :data="checkItemList" @selection-change="handleSelectionChange">
<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">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(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>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改检查项对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<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>
</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 { listCheckItem, getCheckItem, delCheckItem, addCheckItem, updateCheckItem } from "@/api/mes/qc/checkItem";
export default {
name: "CheckItem",
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 检查项表格数据
checkItemList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
itemName: undefined,
standardTarget: undefined,
targetUpper: undefined,
targetLower: undefined,
unit: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询检查项列表 */
getList() {
this.loading = true;
listCheckItem(this.queryParams).then(response => {
this.checkItemList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
itemId: undefined,
itemName: undefined,
standardTarget: undefined,
targetUpper: undefined,
targetLower: undefined,
unit: undefined,
qualitativeQuantitative: 0,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.itemId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加检查项";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const itemId = row.itemId || this.ids
getCheckItem(itemId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改检查项";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.itemId != null) {
updateCheckItem(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addCheckItem(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const itemIds = row.itemId || this.ids;
this.$modal.confirm('是否确认删除检查项编号为"' + itemIds + '"的数据项?').then(() => {
this.loading = true;
return delCheckItem(itemIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/checkItem/export', {
...this.queryParams
}, `checkItem_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -1,405 +0,0 @@
<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="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="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-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 上方任务列表表格 -->
<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>
</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>
<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">
<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">
<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>
</div>
</template>
<script>
import { listCheckTask, getCheckTask, delCheckTask, addCheckTask, updateCheckTask } from '@/api/mes/qc/checkTask'
import { updateCheckTaskItemStatus } 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,
},
// 表单参数
form: {
verifyTarget: undefined,
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: undefined
},
// 表单校验
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;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
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: undefined,
workshopSection: undefined,
process: undefined,
unitGroup: undefined,
inspectionResult: 0,
inspectionType: undefined
};
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;
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;
if (this.form.taskId != null) {
updateCheckTask(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addCheckTask(this.form).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

@@ -1,467 +0,0 @@
<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">
<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="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">
<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>
<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="text" style="color: #67C23A;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="text" style="margin-left: 8px; color: #FF4949;"
@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="700px" 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

@@ -1,443 +0,0 @@
<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">
<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="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">
<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>
<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="text" style="color: #67C23A;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="text" style="margin-left: 8px; color: #FF4949;"
@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="700px" 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

@@ -1,493 +0,0 @@
<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="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="verifyTarget.coilId" /> -->
<el-table-column label="原料卷号" align="center" prop="entryCoilNo" />
<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="weight" />
<el-table-column label="检验结果" align="center">
<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="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">
<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>
<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="text" style="color: #67C23A;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="text" style="margin-left: 8px; color: #FF4949;"
@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="700px" 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="钢卷号">
<coil-selector v-model="form.coilIds" @select="handleCoilChange" :filters="{ selectType: 'raw_material', itemType: 'raw_material' }"></coil-selector>
<!-- <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="remark">
<el-input v-model="form.remark" 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'
import CoilSelector from '@/components/CoilSelector/index.vue'
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,
CoilSelector
},
methods: {
/** 查询检查任务列表 */
getList() {
this.loading = true;
listCheckTask(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;
});
},
handleCoilChange(coil) {
const [thickness, width] = coil.specification?.split('*') || []
console.log(thickness, width, coil.netWeight)
this.form.verifyTarget = {
coilId: coil.coilId,
rawCoilId: coil.rawCoilId,
factory: coil.manufacturer,
thickness: thickness,
width: width,
weight: coil.netWeight,
}
},
// 取消按钮
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,
itemId: this.form.itemId.split(','),
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

@@ -1,451 +0,0 @@
<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="coilList[0].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">
<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="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">
<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>
<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="text" style="color: #67C23A;"
@click="changeItemStatus(detailData.taskId, scope.row.itemId, 1)">通过</el-button>
<el-button v-if="scope.row.status == 0" size="mini" type="text" style="margin-left: 8px; color: #FF4949;"
@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="700px" 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="钢卷号">
<!-- <el-input v-model="form.verifyTarget.coilId" placeholder="请输入钢卷号" /> -->
<coil-selector v-model="form.coilIds" @select="handleCoilChange"></coil-selector>
</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="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="remark">
<el-input v-model="form.remark" 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'
import CoilSelector from '@/components/CoilSelector/index.vue'
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,
CoilSelector
},
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;
});
},
handleCoilChange(coil) {
this.form.verifyTarget.coilId = coil.coilId
},
// 取消按钮
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,
itemId: this.form.itemId.split(','),
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>