feat(工单管理): 添加工单成品数显示与计算逻辑

- 在工单列表和详情弹窗中添加成品数字段
- 修改出货、入库逻辑使用成品数进行计算
- 优化请求错误处理和默认操作员设置
- 调整axios配置缩进格式
- 移除冗余的catch块,使用统一错误处理
This commit is contained in:
2026-02-10 15:07:43 +08:00
parent ab79da8d3b
commit fcd5ce1f3e
6 changed files with 212 additions and 203 deletions

View File

@@ -103,7 +103,7 @@ service.interceptors.response.use(
message = '系统接口' + message.substr(message.length - 3) + '异常,请联系管理员' message = '系统接口' + message.substr(message.length - 3) + '异常,请联系管理员'
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
message = 'Oops,后端出错了,你不会连错误日志都不会看吧' message = '服务器正在重启中'
duration = 0 duration = 0
} }
} }

View File

@@ -50,6 +50,12 @@
<el-form-item label="计划数量"> <el-form-item label="计划数量">
<el-input :disabled="!isEditing" v-model="workorderInfo.planNum" /> <el-input :disabled="!isEditing" v-model="workorderInfo.planNum" />
</el-form-item> </el-form-item>
<el-form-item label="不良数量">
<el-input :disabled="!isEditing" v-model="workorderInfo.defectNum" />
</el-form-item>
<el-form-item label="成品数量">
<el-input :disabled="!isEditing" v-model="workorderInfo.productNum" />
</el-form-item>
<el-form-item label="出货数量"> <el-form-item label="出货数量">
<el-input :disabled="!isEditing" v-model="workorderInfo.shipmentNum" /> <el-input :disabled="!isEditing" v-model="workorderInfo.shipmentNum" />
</el-form-item> </el-form-item>

View File

@@ -485,8 +485,7 @@ function handleCancel(row) {
type: 'warning' type: 'warning'
}) })
.then(() => { .then(() => {
cancelMmInventory({ id: row.id, type: 2 }) cancelMmInventory({ id: row.id, type: 2 }).then((response) => {
.then((response) => {
if (response.code === 200) { if (response.code === 200) {
proxy.$message.success('撤销成功') proxy.$message.success('撤销成功')
loadPickRecords() loadPickRecords()
@@ -495,9 +494,6 @@ function handleCancel(row) {
proxy.$message.error('撤销失败: ' + (response.msg || '未知错误')) proxy.$message.error('撤销失败: ' + (response.msg || '未知错误'))
} }
}) })
.catch((error) => {
proxy.$message.error('撤销失败: ' + error.message)
})
}) })
.catch(() => { .catch(() => {
// 取消操作 // 取消操作
@@ -532,13 +528,12 @@ function submitForm() {
// 刷新数据 // 刷新数据
loadPickRecords() loadPickRecords()
loadInventoryList() loadInventoryList()
// 触发外部工单列表更新
emit('submit', { type: 'materialPick', data: requestData })
} else { } else {
proxy.$message.error('领料失败: ' + (response.msg || '未知错误')) proxy.$message.error('领料失败: ' + (response.msg || '未知错误'))
} }
}) })
.catch((error) => {
proxy.$message.error('领料失败: ' + error.message)
})
.finally(() => { .finally(() => {
// 关闭加载状态 // 关闭加载状态
proxy.$modal.closeLoading() proxy.$modal.closeLoading()

View File

@@ -313,7 +313,13 @@ function handleStorageMaterial() {
if (props.workorderInfo) { if (props.workorderInfo) {
formData.productionCode = props.workorderInfo.productionCode || '' formData.productionCode = props.workorderInfo.productionCode || ''
formData.productionName = props.workorderInfo.productionName || '' formData.productionName = props.workorderInfo.productionName || ''
formData.storageQuantity = props.workorderInfo.planNum || 1 // 重新计算入库数量,使用最新的工单数据
// 计划数量减去已入库数量
formData.storageQuantity = (props.workorderInfo.planNum || 0) - (props.workorderInfo.productNum || 0)
// 确保入库数量至少为1
if (formData.storageQuantity < 1) {
formData.storageQuantity = 1
}
} }
// 显示入库单据弹窗 // 显示入库单据弹窗
showStorageForm.value = true showStorageForm.value = true
@@ -328,8 +334,7 @@ function handleCancel(row) {
type: 'warning' type: 'warning'
}) })
.then(() => { .then(() => {
cancelMmInventory({ id: row.id, type: 1 }) cancelMmInventory({ id: row.id, type: 1 }).then((response) => {
.then((response) => {
if (response.code === 200) { if (response.code === 200) {
proxy.$message.success('撤销成功') proxy.$message.success('撤销成功')
loadStorageRecords() loadStorageRecords()
@@ -338,9 +343,6 @@ function handleCancel(row) {
proxy.$message.error('撤销失败: ' + (response.msg || '未知错误')) proxy.$message.error('撤销失败: ' + (response.msg || '未知错误'))
} }
}) })
.catch((error) => {
proxy.$message.error('撤销失败: ' + error.message)
})
}) })
.catch(() => { .catch(() => {
// 取消操作 // 取消操作
@@ -372,13 +374,12 @@ function submitForm() {
// 刷新数据 // 刷新数据
loadStorageRecords() loadStorageRecords()
loadInventoryList() loadInventoryList()
// 触发外部工单列表更新
emit('submit', { type: 'productStorage', data: requestData })
} else { } else {
proxy.$message.error('入库失败: ' + (response.msg || '未知错误')) proxy.$message.error('入库失败: ' + (response.msg || '未知错误'))
} }
}) })
.catch((error) => {
proxy.$message.error('入库失败: ' + error.message)
})
.finally(() => { .finally(() => {
// 关闭加载状态 // 关闭加载状态
proxy.$modal.closeLoading() proxy.$modal.closeLoading()

View File

@@ -285,8 +285,8 @@ function resetForm() {
// 重置表单数据 // 重置表单数据
Object.assign(formData, { Object.assign(formData, {
selectedOrderNo: '', selectedOrderNo: '',
shipmentQuantity: props.workorderInfo?.planNum - props.workorderInfo?.defectNum || 1, shipmentQuantity: 1,
operator: '', operator: '解建雄',
orderId: '' orderId: ''
}) })
// 如果有工单信息,保持工单相关数据 // 如果有工单信息,保持工单相关数据
@@ -315,7 +315,13 @@ function handleShipmentMaterial(product) {
formData.productionName = product.materialName formData.productionName = product.materialName
formData.selectedOrderNo = product.orderNoMes formData.selectedOrderNo = product.orderNoMes
formData.orderId = product.id formData.orderId = product.id
formData.shipmentQuantity = props.workorderInfo?.planNum || 1 // 重新计算出货数量,使用最新的工单数据
// 已入库数量减去已出货数量
formData.shipmentQuantity = (props.workorderInfo.productNum || 0) - (props.workorderInfo.shipmentNum || 0)
// 确保出货数量至少为1
if (formData.shipmentQuantity < 1) {
formData.shipmentQuantity = 1
}
// 显示出货单据弹窗 // 显示出货单据弹窗
showShipmentForm.value = true showShipmentForm.value = true
} }
@@ -374,13 +380,13 @@ function submitForm() {
// 刷新数据 // 刷新数据
loadShipmentRecords() loadShipmentRecords()
loadInventoryList() loadInventoryList()
// 触发外部工单列表更新
emit('submit', { type: 'shipment', data: requestData })
} else { } else {
console.log('response1', response)
proxy.$message.error('出货失败: ' + (response.msg || '未知错误')) proxy.$message.error('出货失败: ' + (response.msg || '未知错误'))
} }
}) })
.catch((error) => {
proxy.$message.error('出货失败: ' + error.message)
})
.finally(() => { .finally(() => {
// 关闭加载状态 // 关闭加载状态
proxy.$modal.closeLoading() proxy.$modal.closeLoading()

View File

@@ -105,6 +105,7 @@
<el-table-column prop="stoveCode" label="炉号" width="100" /> <el-table-column prop="stoveCode" label="炉号" width="100" />
<el-table-column prop="planNum" align="center" label="计划数" width="60" /> <el-table-column prop="planNum" align="center" label="计划数" width="60" />
<el-table-column prop="defectNum" align="center" label="不良数" width="60" /> <el-table-column prop="defectNum" align="center" label="不良数" width="60" />
<el-table-column prop="productNum" align="center" label="成品数" width="60" />
<el-table-column prop="shipmentNum" align="center" label="出货数" width="60" /> <el-table-column prop="shipmentNum" align="center" label="出货数" width="60" />
<el-table-column prop="feedOrder" label="原料批次号" width="120" /> <el-table-column prop="feedOrder" label="原料批次号" width="120" />
<el-table-column prop="customerOrder" label="订单号" width="120" /> <el-table-column prop="customerOrder" label="订单号" width="120" />