✨ feat(mes): 重构「完成」操作逻辑,优化表单处理
更新了多个表单的完成操作逻辑,确保在表单修改后先保存数据再完成检验单。此变更提升了用户体验,避免了数据丢失的风险。pull/871/MERGE
parent
0befdd32ad
commit
1993e46eb6
|
|
@ -275,6 +275,14 @@
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail">
|
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail">
|
||||||
保 存
|
保 存
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
@click="handleFinish"
|
||||||
|
type="success"
|
||||||
|
:disabled="formLoading"
|
||||||
|
v-if="formType === 'update' && formData.status === MesQcStatusEnum.DRAFT"
|
||||||
|
>
|
||||||
|
完 成
|
||||||
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
@ -290,7 +298,7 @@ import ProTaskSelect from '@/views/mes/pro/task/components/ProTaskSelect.vue'
|
||||||
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
||||||
import IpqcLineList from './IpqcLineList.vue'
|
import IpqcLineList from './IpqcLineList.vue'
|
||||||
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
||||||
import { MesQcTypeEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
import { MesQcTypeEnum, MesQcStatusEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'IpqcForm' })
|
defineOptions({ name: 'IpqcForm' })
|
||||||
|
|
||||||
|
|
@ -318,6 +326,7 @@ const formData = ref({
|
||||||
id: undefined as number | undefined,
|
id: undefined as number | undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined as number | undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
templateId: undefined,
|
templateId: undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
|
|
@ -363,6 +372,7 @@ const formRules = reactive({
|
||||||
inspectDate: [{ required: true, message: '检测日期不能为空', trigger: 'change' }]
|
inspectDate: [{ required: true, message: '检测日期不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const originalFormData = ref<string>('') // 原始表单数据快照,用于脏检查
|
||||||
|
|
||||||
/** 生成检验单编号 */
|
/** 生成检验单编号 */
|
||||||
const generateCode = async () => {
|
const generateCode = async () => {
|
||||||
|
|
@ -400,6 +410,8 @@ const open = async (type: string, id?: number, data?: QcIpqcVO) => {
|
||||||
// 预填模式:来自待检任务(pending inspect)
|
// 预填模式:来自待检任务(pending inspect)
|
||||||
Object.assign(formData.value, data)
|
Object.assign(formData.value, data)
|
||||||
}
|
}
|
||||||
|
// 保存原始数据快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
@ -429,12 +441,35 @@ const submitForm = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 完成操作:表单修改过则先保存,再完成 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.validate()
|
||||||
|
if (!valid) return
|
||||||
|
try {
|
||||||
|
await message.confirm('是否完成过程检验单编制?【完成后将不能更改】')
|
||||||
|
formLoading.value = true
|
||||||
|
if (JSON.stringify(formData.value) !== originalFormData.value) {
|
||||||
|
const data = formData.value as unknown as QcIpqcVO
|
||||||
|
await QcIpqcApi.updateIpqc(data)
|
||||||
|
}
|
||||||
|
await QcIpqcApi.finishIpqc(formData.value.id!)
|
||||||
|
message.success('完成成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
templateId: undefined,
|
templateId: undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
|
|
|
||||||
|
|
@ -139,15 +139,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="success"
|
|
||||||
@click="handleFinish(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:qc-ipqc:finish']"
|
|
||||||
v-if="scope.row.status === MesQcStatusEnum.DRAFT"
|
|
||||||
>
|
|
||||||
完成
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -233,16 +224,6 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成操作 */
|
|
||||||
const handleFinish = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.confirm('是否完成过程检验单编制?【完成后将不能更改】')
|
|
||||||
await QcIpqcApi.finishIpqc(id)
|
|
||||||
message.success('完成成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,14 @@
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail">
|
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail">
|
||||||
保 存
|
保 存
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
@click="handleFinish"
|
||||||
|
type="success"
|
||||||
|
:disabled="formLoading"
|
||||||
|
v-if="formType === 'update' && formData.status === MesQcStatusEnum.DRAFT"
|
||||||
|
>
|
||||||
|
完 成
|
||||||
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
@ -240,7 +248,7 @@ import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
import IqcLineList from './IqcLineList.vue'
|
import IqcLineList from './IqcLineList.vue'
|
||||||
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
||||||
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
||||||
import { MesQcTypeEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
import { MesQcTypeEnum, MesQcStatusEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'IqcForm' })
|
defineOptions({ name: 'IqcForm' })
|
||||||
|
|
||||||
|
|
@ -269,6 +277,7 @@ const formData = ref({
|
||||||
id: undefined as number | undefined,
|
id: undefined as number | undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined as number | undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
sourceDocType: undefined,
|
sourceDocType: undefined,
|
||||||
sourceDocCode: undefined,
|
sourceDocCode: undefined,
|
||||||
|
|
@ -305,6 +314,7 @@ const formRules = reactive({
|
||||||
inspectDate: [{ required: true, message: '检测日期不能为空', trigger: 'change' }]
|
inspectDate: [{ required: true, message: '检测日期不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const originalFormData = ref<string>('') // 原始表单数据快照,用于脏检查
|
||||||
|
|
||||||
/** 生成检验单编号 */
|
/** 生成检验单编号 */
|
||||||
const generateCode = async () => {
|
const generateCode = async () => {
|
||||||
|
|
@ -329,6 +339,8 @@ const open = async (type: string, id?: number, data?: QcIqcVO) => {
|
||||||
// 预填模式:来自待检任务(pending inspect)
|
// 预填模式:来自待检任务(pending inspect)
|
||||||
Object.assign(formData.value, data)
|
Object.assign(formData.value, data)
|
||||||
}
|
}
|
||||||
|
// 保存原始数据快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
@ -358,12 +370,38 @@ const submitForm = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 完成操作:表单修改过则先保存,再完成 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
// 校验表单
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.validate()
|
||||||
|
if (!valid) return
|
||||||
|
try {
|
||||||
|
await message.confirm('是否完成来料检验单编制?【完成后将不能更改】')
|
||||||
|
formLoading.value = true
|
||||||
|
// 1. 表单有修改时,先保存
|
||||||
|
if (JSON.stringify(formData.value) !== originalFormData.value) {
|
||||||
|
const data = formData.value as unknown as QcIqcVO
|
||||||
|
await QcIqcApi.updateIqc(data)
|
||||||
|
}
|
||||||
|
// 2. 完成检验单
|
||||||
|
await QcIqcApi.finishIqc(formData.value.id!)
|
||||||
|
message.success('完成成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
sourceDocType: undefined,
|
sourceDocType: undefined,
|
||||||
sourceDocCode: undefined,
|
sourceDocCode: undefined,
|
||||||
|
|
|
||||||
|
|
@ -166,15 +166,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="success"
|
|
||||||
@click="handleComplete(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:qc-iqc:update']"
|
|
||||||
v-if="scope.row.status === MesQcStatusEnum.DRAFT"
|
|
||||||
>
|
|
||||||
完成
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -265,16 +256,6 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成操作 */
|
|
||||||
const handleComplete = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.confirm('是否完成来料检验单编制?【完成后将不能更改】')
|
|
||||||
await QcIqcApi.finishIqc(id)
|
|
||||||
message.success('完成成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,14 @@
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail"> 保 存 </el-button>
|
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail"> 保 存 </el-button>
|
||||||
|
<el-button
|
||||||
|
@click="handleFinish"
|
||||||
|
type="success"
|
||||||
|
:disabled="formLoading"
|
||||||
|
v-if="formType === 'update' && formData.status === MesQcStatusEnum.DRAFT"
|
||||||
|
>
|
||||||
|
完 成
|
||||||
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
@ -248,7 +256,7 @@ import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
||||||
import OqcLineList from './OqcLineList.vue'
|
import OqcLineList from './OqcLineList.vue'
|
||||||
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
||||||
import { MesQcTypeEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
import { MesQcTypeEnum, MesQcStatusEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'OqcForm' })
|
defineOptions({ name: 'OqcForm' })
|
||||||
|
|
||||||
|
|
@ -275,6 +283,7 @@ const formData = ref({
|
||||||
id: undefined as number | undefined,
|
id: undefined as number | undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined as number | undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
sourceDocType: undefined,
|
sourceDocType: undefined,
|
||||||
sourceDocCode: undefined,
|
sourceDocCode: undefined,
|
||||||
|
|
@ -313,6 +322,7 @@ const formRules = reactive({
|
||||||
inspectDate: [{ required: true, message: '检测日期不能为空', trigger: 'change' }]
|
inspectDate: [{ required: true, message: '检测日期不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const originalFormData = ref<string>('') // 原始表单数据快照,用于脏检查
|
||||||
const isDetail = computed(() => formType.value === 'detail') // 表单是否为详情模式(只读)
|
const isDetail = computed(() => formType.value === 'detail') // 表单是否为详情模式(只读)
|
||||||
|
|
||||||
/** 生成检验单编号 */
|
/** 生成检验单编号 */
|
||||||
|
|
@ -338,6 +348,8 @@ const open = async (type: string, id?: number, data?: QcOqcVO) => {
|
||||||
// 预填模式:来自待检任务(pending inspect)
|
// 预填模式:来自待检任务(pending inspect)
|
||||||
Object.assign(formData.value, data)
|
Object.assign(formData.value, data)
|
||||||
}
|
}
|
||||||
|
// 保存原始数据快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
@ -367,12 +379,35 @@ const submitForm = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 完成操作:表单修改过则先保存,再完成 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.validate()
|
||||||
|
if (!valid) return
|
||||||
|
try {
|
||||||
|
await message.confirm('是否完成出货检验单编制?【完成后将不能更改】')
|
||||||
|
formLoading.value = true
|
||||||
|
if (JSON.stringify(formData.value) !== originalFormData.value) {
|
||||||
|
const data = formData.value as unknown as QcOqcVO
|
||||||
|
await QcOqcApi.updateOqc(data)
|
||||||
|
}
|
||||||
|
await QcOqcApi.finishOqc(formData.value.id!)
|
||||||
|
message.success('完成成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
sourceDocType: undefined,
|
sourceDocType: undefined,
|
||||||
sourceDocCode: undefined,
|
sourceDocCode: undefined,
|
||||||
|
|
|
||||||
|
|
@ -138,15 +138,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="success"
|
|
||||||
@click="handleFinish(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:qc-oqc:finish']"
|
|
||||||
v-if="scope.row.status === MesQcStatusEnum.DRAFT"
|
|
||||||
>
|
|
||||||
完成
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -232,16 +223,6 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成操作 */
|
|
||||||
const handleFinish = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.confirm('是否完成出货检验单编制?【完成后将不能更改】')
|
|
||||||
await QcOqcApi.finishOqc(id)
|
|
||||||
message.success('完成成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,14 @@
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail">
|
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!isDetail">
|
||||||
保 存
|
保 存
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
@click="handleFinish"
|
||||||
|
type="success"
|
||||||
|
:disabled="formLoading"
|
||||||
|
v-if="formType === 'update' && formData.status === MesQcStatusEnum.DRAFT"
|
||||||
|
>
|
||||||
|
完 成
|
||||||
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
@ -236,7 +244,7 @@ import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
||||||
import RqcLineList from './RqcLineList.vue'
|
import RqcLineList from './RqcLineList.vue'
|
||||||
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
import QcIndicatorResultList from '@/views/mes/qc/indicatorresult/components/QcIndicatorResultList.vue'
|
||||||
import { MesQcTypeEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
import { MesQcTypeEnum, MesQcStatusEnum, MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'RqcForm' })
|
defineOptions({ name: 'RqcForm' })
|
||||||
|
|
||||||
|
|
@ -264,6 +272,7 @@ const formData = ref({
|
||||||
id: undefined as number | undefined,
|
id: undefined as number | undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined as number | undefined,
|
||||||
templateId: undefined,
|
templateId: undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
sourceDocType: undefined,
|
sourceDocType: undefined,
|
||||||
|
|
@ -299,6 +308,7 @@ const formRules = reactive({
|
||||||
inspectorUserId: [{ required: true, message: '检测人员不能为空', trigger: 'change' }]
|
inspectorUserId: [{ required: true, message: '检测人员不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const originalFormData = ref<string>('') // 原始表单数据快照,用于脏检查
|
||||||
|
|
||||||
/** 生成检验单编号 */
|
/** 生成检验单编号 */
|
||||||
const generateCode = async () => {
|
const generateCode = async () => {
|
||||||
|
|
@ -323,6 +333,8 @@ const open = async (type: string, id?: number, data?: QcRqcVO) => {
|
||||||
// 预填模式:来自待检任务(pending inspect)
|
// 预填模式:来自待检任务(pending inspect)
|
||||||
Object.assign(formData.value, data)
|
Object.assign(formData.value, data)
|
||||||
}
|
}
|
||||||
|
// 保存原始数据快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
@ -354,12 +366,35 @@ const submitForm = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 完成操作:表单修改过则先保存,再完成 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.validate()
|
||||||
|
if (!valid) return
|
||||||
|
try {
|
||||||
|
await message.confirm('是否完成退货检验单编制?【完成后将不能更改】')
|
||||||
|
formLoading.value = true
|
||||||
|
if (JSON.stringify(formData.value) !== originalFormData.value) {
|
||||||
|
const data = formData.value as unknown as QcRqcVO
|
||||||
|
await QcRqcApi.updateRqc(data)
|
||||||
|
}
|
||||||
|
await QcRqcApi.finishRqc(formData.value.id!)
|
||||||
|
message.success('完成成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined,
|
||||||
templateId: undefined,
|
templateId: undefined,
|
||||||
sourceDocId: undefined,
|
sourceDocId: undefined,
|
||||||
sourceDocType: undefined,
|
sourceDocType: undefined,
|
||||||
|
|
|
||||||
|
|
@ -165,15 +165,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="success"
|
|
||||||
@click="handleFinish(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:qc-rqc:finish']"
|
|
||||||
v-if="scope.row.status === MesQcStatusEnum.DRAFT"
|
|
||||||
>
|
|
||||||
完成
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -261,16 +252,6 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成操作 */
|
|
||||||
const handleFinish = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.confirm('是否完成退货检验单编制?【完成后将不能更改】')
|
|
||||||
await QcRqcApi.finishRqc(id)
|
|
||||||
message.success('完成成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue