feat(不良品管理): 重构不良品记录相关功能

- 新增根据工单号查询不良品记录、创建报废单和转用单的API
- 优化WorkorderDefectDialog组件,移除批量撤销功能并更新API调用
- 调整QcScrapRecords页面布局,隐藏部分列和功能按钮
- 统一原料相关字段命名,从"物料"改为"原料"
This commit is contained in:
2026-02-10 19:01:09 +08:00
parent fcd5ce1f3e
commit 3ad2d3accb
3 changed files with 73 additions and 43 deletions

View File

@@ -103,3 +103,50 @@ export function revokeScrapRecord(id) {
method: 'put' method: 'put'
}) })
} }
/**
* 根据工单号查询不良品记录
* @param {工单号} workorder
*/
export function getQcScrapRecordsByWorkorder(workorder) {
return request({
url: 'mes/qualityManagement/IPQC/QcScrapRecords/byWorkorder',
method: 'get',
params: { workorder }
})
}
/**
* 根据工单号填写报废单
* @param {报废单数据} data
*/
export function createScrapOrderByWorkorder(data) {
return request({
url: 'mes/qualityManagement/IPQC/QcScrapRecords/scrapOrder/byWorkorder',
method: 'post',
data: data
})
}
/**
* 根据工单号填写转用单
* @param {转用单数据} data
*/
export function createTransferOrderByWorkorder(data) {
return request({
url: 'mes/qualityManagement/IPQC/QcScrapRecords/transferOrder/byWorkorder',
method: 'post',
data: data
})
}
/**
* 根据不良品记录ID撤销不良品记录
* @param {不良品记录ID} id
*/
export function revokeScrapRecordById(id) {
return request({
url: 'mes/qualityManagement/IPQC/QcScrapRecords/revokeById/' + id,
method: 'put'
})
}

View File

@@ -27,15 +27,10 @@
<el-table-column prop="scrapDate" label="不良品日期" align="center" /> <el-table-column prop="scrapDate" label="不良品日期" align="center" />
<el-table-column label="操作" align="center" width="120"> <el-table-column label="操作" align="center" width="120">
<template #default="scope"> <template #default="scope">
<el-button type="info" size="small" icon="undo" v-if="scope.row.status === '已批准'" @click="handleRevoke(scope.row)"> 撤销 </el-button> <el-button type="info" size="small" v-if="scope.row.status === '已批准'" @click="handleRevoke(scope.row)"> 撤销 </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 列表下方的撤销按钮 -->
<div class="list-actions mt10" v-if="defectList.length > 0">
<el-button type="info" icon="undo" @click="handleBatchRevoke" :disabled="!canBatchRevoke"> 批量撤销 </el-button>
</div>
</div> </div>
<!-- 创建报废单对话框 --> <!-- 创建报废单对话框 -->
@@ -203,7 +198,12 @@
<script setup name="WorkorderDefectDialog"> <script setup name="WorkorderDefectDialog">
import { ref, reactive, toRefs, watch, getCurrentInstance } from 'vue' import { ref, reactive, toRefs, watch, getCurrentInstance } from 'vue'
import { listQcScrapRecords, createScrapOrder, createTransferOrder, revokeScrapRecord } from '@/api/qualityManagement/IPQC/qcscraprecords.js' import {
getQcScrapRecordsByWorkorder,
createScrapOrderByWorkorder,
createTransferOrderByWorkorder,
revokeScrapRecordById
} from '@/api/qualityManagement/IPQC/qcscraprecords.js'
import { listUser } from '@/api/system/user.js' import { listUser } from '@/api/system/user.js'
// 获取组件实例 // 获取组件实例
@@ -292,9 +292,6 @@ const state = reactive({
const { scrapOrderForm, transferOrderForm, scrapOrderRules, transferOrderRules } = toRefs(state) const { scrapOrderForm, transferOrderForm, scrapOrderRules, transferOrderRules } = toRefs(state)
// 计算属性
const canBatchRevoke = ref(false)
// 监听弹窗显示,加载不良品记录 // 监听弹窗显示,加载不良品记录
watch( watch(
() => props.dialogVisible, () => props.dialogVisible,
@@ -305,20 +302,13 @@ watch(
} }
} }
) )
// 获取不良品记录列表 // 获取不良品记录列表
function getDefectList() { function getDefectList() {
loading.value = true loading.value = true
listQcScrapRecords({ getQcScrapRecordsByWorkorder(props.workorderInfo.workorder)
pageNum: 1,
pageSize: 100,
workorder: props.workorderInfo.workorder
})
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
defectList.value = res.data.result defectList.value = res.data.result
// 检查是否有可批量撤销的记录
canBatchRevoke.value = defectList.value.some((item) => item.status === '已批准')
} }
}) })
.catch(() => { .catch(() => {
@@ -405,7 +395,7 @@ function submitScrapOrder() {
workorder: props.workorderInfo.workorder workorder: props.workorderInfo.workorder
} }
createScrapOrder(formData) createScrapOrderByWorkorder(formData)
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
proxy.$modal.msgSuccess('创建报废单成功') proxy.$modal.msgSuccess('创建报废单成功')
@@ -466,7 +456,7 @@ function resetTransferOrderForm() {
function submitTransferOrder() { function submitTransferOrder() {
proxy.$refs['transferOrderFormRef'].validate((valid) => { proxy.$refs['transferOrderFormRef'].validate((valid) => {
if (valid) { if (valid) {
createTransferOrder(transferOrderForm.value) createTransferOrderByWorkorder(transferOrderForm.value)
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
proxy.$modal.msgSuccess('创建转用单成功') proxy.$modal.msgSuccess('创建转用单成功')
@@ -488,20 +478,11 @@ function handleRevoke(row) {
revokeConfirmOpen.value = true revokeConfirmOpen.value = true
} }
// 处理批量撤销
function handleBatchRevoke() {
const approvedItems = defectList.value.filter((item) => item.status === '已批准')
if (approvedItems.length > 0) {
selectedRevokeId.value = approvedItems[0].id
revokeConfirmOpen.value = true
}
}
// 提交撤销 // 提交撤销
function submitRevoke() { function submitRevoke() {
if (!selectedRevokeId.value) return if (!selectedRevokeId.value) return
revokeScrapRecord(selectedRevokeId.value) revokeScrapRecordById(selectedRevokeId.value)
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
proxy.$modal.msgSuccess('撤销成功') proxy.$modal.msgSuccess('撤销成功')

View File

@@ -46,7 +46,7 @@
</el-form> </el-form>
<!-- 工具区域 --> <!-- 工具区域 -->
<el-row :gutter="15" class="mb10"> <el-row :gutter="15" class="mb10">
<el-col :span="3"> <!-- <el-col :span="3">
<el-button type="success" plain icon="document" @click="handleCreateScrapOrder"> 填写原材料报废单 </el-button> <el-button type="success" plain icon="document" @click="handleCreateScrapOrder"> 填写原材料报废单 </el-button>
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
@@ -57,7 +57,7 @@
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
<el-button type="success" plain icon="document" @click="handleCreateTransferOrder"> 填写工单转用单 </el-button> <el-button type="success" plain icon="document" @click="handleCreateTransferOrder"> 填写工单转用单 </el-button>
</el-col> </el-col> -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
@@ -69,12 +69,14 @@
header-cell-class-name="el-table-header-cell" header-cell-class-name="el-table-header-cell"
highlight-current-row highlight-current-row
@sort-change="sortChange"> @sort-change="sortChange">
<el-table-column prop="scrapOrderNo" label="不良品单号" align="center" v-if="columns.showColumn('scrapOrderNo')" /> <el-table-column prop="scrapOrderNo" label="不良品单号" width="180" align="center" v-if="columns.showColumn('scrapOrderNo')" />
<el-table-column prop="workorder" label="工单号" align="center" v-if="columns.showColumn('workorder')" /> <el-table-column prop="workorder" label="工单号" width="180" align="center" v-if="columns.showColumn('workorder')" />
<el-table-column prop="materialCode" label="物料编码" align="center" v-if="columns.showColumn('materialCode')" /> <el-table-column prop="productCode" label="产品编号" width="180" align="center" v-if="columns.showColumn('productCode')" />
<el-table-column prop="materialName" label="物料名称" align="center" v-if="columns.showColumn('materialName')" /> <el-table-column prop="productName" label="产品名称" width="180" align="center" v-if="columns.showColumn('productName')" />
<el-table-column prop="productCode" label="产品编号" align="center" v-if="columns.showColumn('productCode')" />
<el-table-column prop="productName" label="产品名称" align="center" v-if="columns.showColumn('productName')" /> <el-table-column prop="materialCode" label="原料编码" width="180" align="center" v-if="columns.showColumn('materialCode')" />
<el-table-column prop="materialName" label="原料名称" width="180" align="center" v-if="columns.showColumn('materialName')" />
<el-table-column prop="batchNo" label="原材料批次号" align="center" v-if="columns.showColumn('batchNo')" /> <el-table-column prop="batchNo" label="原材料批次号" align="center" v-if="columns.showColumn('batchNo')" />
<el-table-column prop="scrapType" label="不良品类型" align="center" v-if="columns.showColumn('scrapType')"> <el-table-column prop="scrapType" label="不良品类型" align="center" v-if="columns.showColumn('scrapType')">
<template #default="scope"> <template #default="scope">
@@ -586,18 +588,18 @@ const selectedTransferMaterial = ref(null)
const columns = ref([ const columns = ref([
{ visible: true, align: 'center', type: '', prop: 'scrapOrderNo', label: '不良品单号', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'scrapOrderNo', label: '不良品单号', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'workorder', label: '工单号', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'workorder', label: '工单号', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'materialCode', label: '料编码', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'materialCode', label: '料编码', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'materialName', label: '料名称', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'materialName', label: '料名称', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'productCode', label: '产品编号', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'productCode', label: '产品编号', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'productName', label: '产品名称', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'productName', label: '产品名称', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'batchNo', label: '原材料批次号', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'batchNo', label: '原材料批次号', showOverflowTooltip: true },
{ visible: true, align: 'center', type: 'dict', prop: 'scrapType', label: '不良品类型', showOverflowTooltip: true }, { visible: true, align: 'center', type: 'dict', prop: 'scrapType', label: '不良品类型', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'scrapReason', label: '不良品原因', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'scrapReason', label: '不良品原因', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'scrapQuantity', label: '不良品数量' }, { visible: true, align: 'center', type: '', prop: 'scrapQuantity', label: '不良品数量' },
{ visible: true, align: 'center', type: '', prop: 'unit', label: '单位', showOverflowTooltip: true }, { visible: false, align: 'center', type: '', prop: 'unit', label: '单位', showOverflowTooltip: true },
{ visible: true, align: 'center', type: 'dict', prop: 'status', label: '状态', showOverflowTooltip: true }, { visible: true, align: 'center', type: 'dict', prop: 'status', label: '状态', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'lineCode', label: '线别', showOverflowTooltip: true }, { visible: false, align: 'center', type: '', prop: 'lineCode', label: '线别', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'workStation', label: '工位', showOverflowTooltip: true }, { visible: false, align: 'center', type: '', prop: 'workStation', label: '工位', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'operator', label: '操作员', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'operator', label: '操作员', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'qualityInspector', label: '质检员', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'qualityInspector', label: '质检员', showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'supervisorName', label: '审核人', showOverflowTooltip: true }, { visible: true, align: 'center', type: '', prop: 'supervisorName', label: '审核人', showOverflowTooltip: true },