feat(mes): 添加报工审批功能,优化状态管理

新增报工审批功能,包括审批通过和驳回的逻辑,优化了状态枚举和表单交互,提升用户体验。
pull/871/MERGE
YunaiV 2026-03-19 13:09:37 +08:00
parent 424f3d04c1
commit 434d68ac11
3 changed files with 74 additions and 68 deletions

View File

@ -207,9 +207,16 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<template #footer v-if="!isDetail"> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <template v-if="formType === 'approve'">
<el-button @click="dialogVisible = false"> </el-button> <el-button type="success" @click="handleApprove" :disabled="formLoading">通过</el-button>
<el-button type="danger" @click="handleReject" :disabled="formLoading">不通过</el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
<template v-else-if="!isDetail">
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</template> </template>
</Dialog> </Dialog>
</template> </template>
@ -239,6 +246,9 @@ const dialogTitle = computed(() => {
if (formType.value === 'create') { if (formType.value === 'create') {
return '添加生产报工记录' return '添加生产报工记录'
} }
if (formType.value === 'approve') {
return '审批生产报工'
}
return '修改生产报工记录' return '修改生产报工记录'
}) })
const formData = ref<Record<string, any>>({ const formData = ref<Record<string, any>>({
@ -275,7 +285,7 @@ const formRules = reactive({
approveUserId: [{ required: true, message: '审核人不能为空', trigger: 'change' }] approveUserId: [{ required: true, message: '审核人不能为空', trigger: 'change' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const isDetail = computed(() => formType.value === 'detail') // const isDetail = computed(() => formType.value === 'detail' || formType.value === 'approve') // /
const checkFlag = ref(true) // true const checkFlag = ref(true) // true
// ==================== ==================== // ==================== ====================
@ -415,6 +425,36 @@ const submitForm = async () => {
} }
} }
/** 审批通过 */
const handleApprove = async () => {
formLoading.value = true
try {
const finished = await ProFeedbackApi.approveFeedback(formData.value.id!)
if (finished) {
message.success('报工单已审批完成')
} else {
message.success('报工成功,请等待质量检验完成!')
}
dialogVisible.value = false
emit('success')
} finally {
formLoading.value = false
}
}
/** 审批不通过(驳回) */
const handleReject = async () => {
formLoading.value = true
try {
await ProFeedbackApi.rejectFeedback(formData.value.id!)
message.success('报工单已驳回')
dialogVisible.value = false
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {

View File

@ -107,7 +107,6 @@
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
row-key="id" row-key="id"
> >
<!-- DONE @AI这里点击后跳转详情然后去掉下面的详情按钮 -->
<el-table-column label="报工单号" align="center" prop="code" width="160"> <el-table-column label="报工单号" align="center" prop="code" width="160">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="openForm('detail', scope.row.id)">{{ <el-button link type="primary" @click="openForm('detail', scope.row.id)">{{
@ -171,14 +170,11 @@
删除 删除
</el-button> </el-button>
</template> </template>
<!-- 审批中状态驳回执行取消 --> <template v-if="scope.row.status === MesProFeedbackStatusEnum.APPROVING && scope.row.approveUserId === currentUserId">
<!-- DONE @AI审批驳回融合点击后弹出一个界面里面通过/不通过 -->
<!-- TODO @AI弹出继续是 Form 组件参考 /Users/yunai/Java/yudao-all-in-one/yudao-ui-admin-vue3/src/views/mes/wm/returnvendor/ReturnVendorForm.vue -->
<template v-if="scope.row.status === MesProFeedbackStatusEnum.APPROVING">
<el-button <el-button
link link
type="primary" type="primary"
@click="openApproveDialog(scope.row.id)" @click="openForm('approve', scope.row.id)"
v-hasPermi="['mes:pro-feedback:approve']" v-hasPermi="['mes:pro-feedback:approve']"
> >
审批 审批
@ -198,17 +194,6 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<FeedbackForm ref="formRef" @success="getList" /> <FeedbackForm ref="formRef" @success="getList" />
<!-- 审批弹窗 -->
<Dialog title="审批报工" v-model="approveDialogVisible" width="400px">
<div style="text-align: center; padding: 20px 0">
<p style="margin-bottom: 20px; font-size: 14px">请确认审批结果</p>
<el-button type="success" size="large" @click="handleApprove"></el-button>
<el-button type="danger" size="large" @click="handleReject" style="margin-left: 24px"
>不通过</el-button
>
</div>
</Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -221,15 +206,17 @@ import UserSelect from '@/views/system/user/components/UserSelect.vue'
import FeedbackForm from './FeedbackForm.vue' import FeedbackForm from './FeedbackForm.vue'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { MesProFeedbackStatusEnum } from '@/views/mes/utils/constants' import { MesProFeedbackStatusEnum } from '@/views/mes/utils/constants'
import { useUserStore } from '@/store/modules/user'
defineOptions({ name: 'MesProFeedback' }) defineOptions({ name: 'MesProFeedback' })
const message = useMessage() const message = useMessage() //
const { t } = useI18n() const { t } = useI18n() //
const currentUserId = useUserStore().getUser.id // ID
const loading = ref(true) const loading = ref(true) //
const list = ref<ProFeedbackVO[]>([]) const list = ref<ProFeedbackVO[]>([]) //
const total = ref(0) const total = ref(0) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
@ -242,8 +229,8 @@ const queryParams = reactive({
status: undefined, status: undefined,
feedbackTime: undefined feedbackTime: undefined
}) })
const queryFormRef = ref() const queryFormRef = ref() //
const exportLoading = ref(false) const exportLoading = ref(false) //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
@ -257,75 +244,54 @@ const getList = async () => {
} }
} }
/** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.pageNo = 1 queryParams.pageNo = 1
getList() getList()
} }
/** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
handleQuery() handleQuery()
} }
/** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
//
await message.delConfirm() await message.delConfirm()
//
await ProFeedbackApi.deleteFeedback(id) await ProFeedbackApi.deleteFeedback(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
//
await getList() await getList()
} catch {} } catch {}
} }
/** 提交报工单 */
const handleSubmit = async (id: number) => { const handleSubmit = async (id: number) => {
try { try {
await message.confirm('确认要提交该报工单吗?') await message.confirm('确认要提交该报工单吗?')
await ProFeedbackApi.submitFeedback(id) await ProFeedbackApi.submitFeedback(id)
message.success('报工单已提交') message.success('报工单已提交')
//
await getList() await getList()
} catch {} } catch {}
} }
// ==================== ==================== /** 导出按钮操作 */
const approveDialogVisible = ref(false)
const approveTargetId = ref<number>()
const openApproveDialog = (id: number) => {
approveTargetId.value = id
approveDialogVisible.value = true
}
const handleApprove = async () => {
try {
const id = approveTargetId.value!
approveDialogVisible.value = false
const finished = await ProFeedbackApi.approveFeedback(id)
if (finished) {
message.success('报工单已审批完成')
} else {
message.success('报工成功,请等待质量检验完成!')
}
await getList()
} catch {}
}
const handleReject = async () => {
try {
const id = approveTargetId.value!
approveDialogVisible.value = false
await ProFeedbackApi.rejectFeedback(id)
message.success('报工单已驳回')
await getList()
} catch {}
}
const handleExport = async () => { const handleExport = async () => {
try { try {
//
await message.exportConfirm() await message.exportConfirm()
//
exportLoading.value = true exportLoading.value = true
const data = await ProFeedbackApi.exportFeedback(queryParams) const data = await ProFeedbackApi.exportFeedback(queryParams)
download.excel(data, '生产报工.xls') download.excel(data, '生产报工.xls')
@ -334,6 +300,7 @@ const handleExport = async () => {
} }
} }
/** 初始化 */
onMounted(async () => { onMounted(async () => {
await getList() await getList()
}) })

View File

@ -164,13 +164,12 @@ export const MesQcStatusEnum = {
} }
/** MES 生产报工状态枚举 */ /** MES 生产报工状态枚举 */
// TODO @芋艿:【晚点弄】需要对其 MesOrderStatusConstants
export const MesProFeedbackStatusEnum = { export const MesProFeedbackStatusEnum = {
PREPARE: 0, // 草稿 PREPARE: MesOrderStatusConstants.DRAFT, // 草稿
APPROVING: 1, // 审批中 APPROVING: MesOrderStatusConstants.APPROVING, // 审批中
UNCHECK: 2, // 待检验 UNCHECK: MesOrderStatusConstants.APPROVED, // 待检验
FINISHED: 3, // 已完成 FINISHED: MesOrderStatusConstants.FINISHED, // 已完成
CANCELED: 4 // 已取消 CANCELED: MesOrderStatusConstants.CANCELLED // 已取消
} }
/** MES 安灯处置状态枚举 */ /** MES 安灯处置状态枚举 */