✨ feat(mes): 添加报工审批功能,优化状态管理
新增报工审批功能,包括审批通过和驳回的逻辑,优化了状态枚举和表单交互,提升用户体验。pull/871/MERGE
parent
424f3d04c1
commit
434d68ac11
|
|
@ -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 = {
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -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 安灯处置状态枚举 */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue