diff --git a/src/api/qualityManagement/IPQC/qcscraprecords.js b/src/api/qualityManagement/IPQC/qcscraprecords.js
index f9fa4d8..0e85956 100644
--- a/src/api/qualityManagement/IPQC/qcscraprecords.js
+++ b/src/api/qualityManagement/IPQC/qcscraprecords.js
@@ -140,6 +140,18 @@ export function createTransferOrderByWorkorder(data) {
})
}
+/**
+ * 根据工单号填写不良品单
+ * @param {不良品单数据} data
+ */
+export function createDefectOrderByWorkorder(data) {
+ return request({
+ url: 'mes/qualityManagement/IPQC/QcScrapRecords/defectOrder/byWorkorder',
+ method: 'post',
+ data: data
+ })
+}
+
/**
* 根据不良品记录ID撤销不良品记录
* @param {不良品记录ID} id
diff --git a/src/views/productManagement/ProWorkorder/components/WorkorderDefectDialog.vue b/src/views/productManagement/ProWorkorder/components/WorkorderDefectDialog.vue
index 2496f5e..6566093 100644
--- a/src/views/productManagement/ProWorkorder/components/WorkorderDefectDialog.vue
+++ b/src/views/productManagement/ProWorkorder/components/WorkorderDefectDialog.vue
@@ -4,14 +4,13 @@
:lock-scroll="false"
:model-value="dialogVisible"
@update:model-value="(val) => emit('update:dialogVisible', val)"
- width="70%"
+ width="80%"
draggable
append-to-body
:close-on-click-modal="false">
- 报废单
- 转用单
+ 不良品单
@@ -23,165 +22,88 @@
-
-
-
+
+ {{ scope.row.status }}
+ {{ scope.row.status }}
+ {{ scope.row.status }}
+ {{ scope.row.status }}
+
+
+
+
+
+
+
+
+ 审批
撤销
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
+
+
- {{ $t('btn.cancel') }}
- {{ $t('btn.submit') }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ $t('btn.cancel') }}
- {{ $t('btn.submit') }}
+ {{ $t('btn.cancel') }}
+ {{ $t('btn.submit') }}
@@ -193,6 +115,36 @@
{{ $t('btn.submit') }}
+
+
+
+
+
+
+
+
+ 批准
+ 拒绝
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('btn.cancel') }}
+ {{ $t('btn.submit') }}
+
+
@@ -200,9 +152,9 @@
import { ref, reactive, toRefs, watch, getCurrentInstance } from 'vue'
import {
getQcScrapRecordsByWorkorder,
- createScrapOrderByWorkorder,
- createTransferOrderByWorkorder,
- revokeScrapRecordById
+ createDefectOrderByWorkorder,
+ revokeScrapRecordById,
+ approveScrapRecord
} from '@/api/qualityManagement/IPQC/qcscraprecords.js'
import { listUser } from '@/api/system/user.js'
@@ -230,38 +182,26 @@ const defectList = ref([])
const userOptions = ref([])
// 弹窗状态
-const scrapOrderOpen = ref(false)
-const transferOrderOpen = ref(false)
+const defectOrderOpen = ref(false)
const revokeConfirmOpen = ref(false)
+const approveOpen = ref(false)
// 选中的记录
const selectedRevokeId = ref(null)
+const selectedApproveId = ref(null)
// 表单引用
-const scrapOrderFormRef = ref()
-const transferOrderFormRef = ref()
+const defectOrderFormRef = ref()
+const approveFormRef = ref()
// 表单数据
const state = reactive({
- scrapOrderForm: {
- materialCode: null,
- materialName: null,
- batchNo: null,
- scrapQuantity: null,
- scrapType: '报废',
- scrapReason: null,
- disposalMethod: null,
- operator: null,
- qualityInspector: null,
- scrapDate: null,
- remark: null
- },
- transferOrderForm: {
+ defectOrderForm: {
materialCode: null,
materialName: null,
workorder: null,
scrapQuantity: null,
- scrapType: '转用',
+ scrapType: '不良品',
scrapReason: null,
disposalMethod: null,
operator: null,
@@ -269,16 +209,7 @@ const state = reactive({
scrapDate: null,
remark: null
},
- scrapOrderRules: {
- materialCode: [{ required: true, message: '主体型号不能为空', trigger: 'blur' }],
- scrapReason: [{ required: true, message: '不良品原因不能为空', trigger: 'blur' }],
- scrapQuantity: [{ required: true, message: '不良品数量不能为空', trigger: 'blur' }],
- // disposalMethod: [{ required: true, message: '处置方式不能为空', trigger: 'blur' }],
- operator: [{ required: true, message: '操作员不能为空', trigger: 'change' }],
- qualityInspector: [{ required: true, message: '质检员不能为空', trigger: 'change' }],
- scrapDate: [{ required: true, message: '报废日期不能为空', trigger: 'blur' }]
- },
- transferOrderRules: {
+ defectOrderRules: {
materialCode: [{ required: true, message: '主体型号不能为空', trigger: 'blur' }],
workorder: [{ required: true, message: '工单号不能为空', trigger: 'blur' }],
scrapReason: [{ required: true, message: '不良品原因不能为空', trigger: 'blur' }],
@@ -286,11 +217,20 @@ const state = reactive({
// disposalMethod: [{ required: true, message: '处置方式不能为空', trigger: 'blur' }],
operator: [{ required: true, message: '操作员不能为空', trigger: 'change' }],
qualityInspector: [{ required: true, message: '质检员不能为空', trigger: 'change' }],
- scrapDate: [{ required: true, message: '转用日期不能为空', trigger: 'blur' }]
+ scrapDate: [{ required: true, message: '不良品日期不能为空', trigger: 'blur' }]
+ },
+ approveForm: {
+ isApproved: true,
+ approver: '',
+ remark: null
+ },
+ approveRules: {
+ isApproved: [{ required: true, message: '请选择是否批准', trigger: 'change' }],
+ approver: [{ required: true, message: '审批人不能为空', trigger: 'blur' }]
}
})
-const { scrapOrderForm, transferOrderForm, scrapOrderRules, transferOrderRules } = toRefs(state)
+const { defectOrderForm, defectOrderRules, approveForm, approveRules } = toRefs(state)
// 监听弹窗显示,加载不良品记录
watch(
@@ -345,37 +285,37 @@ function getUserList() {
}
}
-// 打开创建报废单对话框
-function handleCreateScrapOrder() {
- resetScrapOrderForm()
+// 打开创建不良品单对话框
+function handleCreateDefectOrder() {
+ resetDefectOrderForm()
// 从工单信息带入数据
- scrapOrderForm.value.workorder = props.workorderInfo.workorder
+ defectOrderForm.value.workorder = props.workorderInfo.workorder
// 自动带入主体型号和主体品名
if (props.workorderInfo.productionCode) {
- scrapOrderForm.value.materialCode = props.workorderInfo.productionCode
+ defectOrderForm.value.materialCode = props.workorderInfo.productionCode
}
if (props.workorderInfo.productionName) {
- scrapOrderForm.value.materialName = props.workorderInfo.productionName
+ defectOrderForm.value.materialName = props.workorderInfo.productionName
}
// 设置默认日期
- scrapOrderForm.value.scrapDate = new Date().toISOString().slice(0, 19).replace('T', ' ')
- scrapOrderOpen.value = true
+ defectOrderForm.value.scrapDate = new Date().toISOString().slice(0, 19).replace('T', ' ')
+ defectOrderOpen.value = true
}
-// 关闭创建报废单对话框
-function cancelScrapOrder() {
- scrapOrderOpen.value = false
- resetScrapOrderForm()
+// 关闭创建不良品单对话框
+function cancelDefectOrder() {
+ defectOrderOpen.value = false
+ resetDefectOrderForm()
}
-// 重置报废单表单
-function resetScrapOrderForm() {
- state.scrapOrderForm = {
+// 重置不良品单表单
+function resetDefectOrderForm() {
+ state.defectOrderForm = {
materialCode: null,
materialName: null,
- batchNo: null,
+ workorder: null,
scrapQuantity: null,
- scrapType: '报废',
+ scrapType: '不良品',
scrapReason: null,
disposalMethod: null,
operator: null,
@@ -383,90 +323,78 @@ function resetScrapOrderForm() {
scrapDate: null,
remark: null
}
- proxy.resetForm('scrapOrderFormRef')
+ proxy.resetForm('defectOrderFormRef')
}
-// 提交报废单
-function submitScrapOrder() {
- proxy.$refs['scrapOrderFormRef'].validate((valid) => {
+// 提交不良品单
+function submitDefectOrder() {
+ proxy.$refs['defectOrderFormRef'].validate((valid) => {
if (valid) {
const formData = {
- ...scrapOrderForm.value,
+ ...defectOrderForm.value,
workorder: props.workorderInfo.workorder
}
- createScrapOrderByWorkorder(formData)
+ // 使用创建不良品单的API
+ createDefectOrderByWorkorder(formData)
.then((res) => {
if (res.code === 200) {
- proxy.$modal.msgSuccess('创建报废单成功')
- scrapOrderOpen.value = false
+ proxy.$modal.msgSuccess('创建不良品单成功')
+ defectOrderOpen.value = false
getDefectList()
- emit('submit', { type: 'scrap', data: formData })
+ emit('submit', { type: 'defect', data: formData })
}
})
.catch(() => {
- proxy.$modal.msgError('创建报废单失败')
+ proxy.$modal.msgError('创建不良品单失败')
})
}
})
}
-// 打开创建转用单对话框
-function handleCreateTransferOrder() {
- resetTransferOrderForm()
- // 从工单信息带入数据
- transferOrderForm.value.workorder = props.workorderInfo.workorder
- // 自动带入主体型号和主体品名
- if (props.workorderInfo.productionCode) {
- transferOrderForm.value.materialCode = props.workorderInfo.productionCode
- }
- if (props.workorderInfo.productionName) {
- transferOrderForm.value.materialName = props.workorderInfo.productionName
- }
- // 设置默认日期
- transferOrderForm.value.scrapDate = new Date().toISOString().slice(0, 19).replace('T', ' ')
- transferOrderOpen.value = true
+// 打开审批不良品记录对话框
+function handleApprove(row) {
+ selectedApproveId.value = row.id
+ resetApproveForm()
+ approveOpen.value = true
}
-// 关闭创建转用单对话框
-function cancelTransferOrder() {
- transferOrderOpen.value = false
- resetTransferOrderForm()
+// 关闭审批不良品记录对话框
+function cancelApprove() {
+ approveOpen.value = false
+ resetApproveForm()
+ selectedApproveId.value = null
}
-// 重置转用单表单
-function resetTransferOrderForm() {
- state.transferOrderForm = {
- materialCode: null,
- materialName: null,
- workorder: null,
- scrapQuantity: null,
- scrapType: '转用',
- scrapReason: null,
- disposalMethod: null,
- operator: null,
- qualityInspector: null,
- scrapDate: null,
+// 重置审批表单
+function resetApproveForm() {
+ state.approveForm = {
+ isApproved: true,
+ approver: '',
remark: null
}
- proxy.resetForm('transferOrderFormRef')
+ proxy.resetForm('approveFormRef')
}
-// 提交转用单
-function submitTransferOrder() {
- proxy.$refs['transferOrderFormRef'].validate((valid) => {
+// 提交审批
+function submitApprove() {
+ proxy.$refs['approveFormRef'].validate((valid) => {
if (valid) {
- createTransferOrderByWorkorder(transferOrderForm.value)
+ // 使用审批API
+ approveScrapRecord(selectedApproveId.value, approveForm.value)
.then((res) => {
if (res.code === 200) {
- proxy.$modal.msgSuccess('创建转用单成功')
- transferOrderOpen.value = false
+ proxy.$modal.msgSuccess('审批成功')
+ approveOpen.value = false
getDefectList()
- emit('submit', { type: 'transfer', data: transferOrderForm.value })
+ emit('submit', { type: 'approve', data: { id: selectedApproveId.value, ...approveForm.value } })
}
})
.catch(() => {
- proxy.$modal.msgError('创建转用单失败')
+ proxy.$modal.msgError('审批失败')
+ })
+ .finally(() => {
+ selectedApproveId.value = null
})
}
})