<!-- 证书管理详情 --> <script name="certificateDetail" lang="ts" setup> import { ElMessage, ElMessageBox } from 'element-plus' import certificatePrintRecord from './components/printRecord.vue' import certificateBasic from './components/basic.vue' import certificatePreview from './components/preview.vue' import useUserStore from '@/store/modules/user' import { printPdf } from '@/utils/printUtils' import { getPhotoUrl } from '@/api/system/tool' import ApprovalDialog from '@/components/Approval/ApprovalDialog.vue' import { approvalDelete, createMeasureCert, refuseCert, rejectApproval } from '@/api/business/certManage/cert' const textMap: { [key: string]: string } = { edit: '编辑', add: '新建', detail: '详情', }// 页面类型字典 const user = useUserStore() // 用户信息 const pageType = ref('add') // 页面类型: add, edit, detail const infoId = ref('') // id const ruleFormRef = ref() // 表单ref const $router = useRouter() const printFileName = ref('') // 证书打印文件名称 const printStatusName = ref('') // 证书打印状态 const approvalStatusName = ref('') // 审批状态名称 const processId = ref('') // 流程实例id const taskId = ref('') // taskId const decisionItem = ref('') const showApprovalButton = ref(true) const showSubmitButton = ref(false) // 显示提交按钮 const certificateBasicRef = ref() // 基本信息组件ref const deptName = ref('') // 实验室 // -------------------------------------标签-------------------------------------------------- const radioMenus = ref([ // 标签内容 { name: '基本信息', value: 'certificate-basic' }, { name: '审批详情', value: 'certificate-approval-record' }, ]) const current = ref('certificate-basic') // 选择的tab 默认基本信息 // -----------------------------------------路由参数---------------------------------------- // 从路由中获取页面类型参数 const $route = useRoute() if ($route.params && $route.params.type) { pageType.value = $route.params.type as string if ($route.params.id) { infoId.value = $route.params.id as string } } // --------------------------------------------按钮---------------------------------------------- // 点击关闭 const close = () => { $router.back() } // 点击提交 const handleSubmit = () => { certificateBasicRef.value.submitForm(processId.value, infoId.value) } // 点击保存 const saveForm = () => { certificateBasicRef.value.saveForm() } // 新建保存成功 const addSuccess = (id: string) => { infoId.value = id pageType.value = 'detail' // 详情模式-不可编辑 approvalStatusName.value = '草稿箱' showSubmitButton.value = true // 保存成功显示提交按钮 } // 提交成功 const submitSuccess = () => { pageType.value = 'detail' // 详情模式-不可编辑 showSubmitButton.value = false // 隐藏提交按钮 } // 点击删除--已取消 const del = () => { ElMessageBox.confirm( '确认删除吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then(() => { approvalDelete({ id: infoId.value }).then(() => { ElMessage.success('已删除') close() }) }) } // 点击编辑 const handleEdit = () => { pageType.value = 'edit' // 编辑模式 } // --------------------------------------------审批------------------------------------------ const approvalDialog = ref() // 审批组件ref // 审批 const handleApprove = (status: string) => { if (status === '同意') { approvalDialog.value.initDialog('agree', taskId.value) } else if (status === '拒绝') { approvalDialog.value.initDialog('refuse', taskId.value, infoId.value) } else if (status === '驳回') { approvalDialog.value.initDialog('reject', taskId.value, infoId.value) } } // 拒绝 const refuse = (comments: string, taskId: string, id: string) => { const params = { id, taskId, // 任务id comments, // 拒绝原因 } refuseCert(params).then((res) => { ElMessage({ type: 'success', message: '已拒绝', }) showApprovalButton.value = false }) } // 驳回 const reject = (comments: string, taskId: string, id: string) => { const params = { id, taskId, // 任务id comments, // 拒绝原因 } rejectApproval(params).then((res) => { ElMessage({ type: 'success', message: '已驳回', }) showApprovalButton.value = false }) } // 审批结束回调 const approvalSuccess = () => { showApprovalButton.value = false const params = { deptName: deptName.value, id: infoId.value, taskId: taskId.value, } createMeasureCert(params).then(() => { }) } // ---------------------------------------------------------------------------------------------- watch(() => approvalStatusName.value, (val) => { console.log('审批状态名称', val) if (val !== '待审批' && val !== '审批中' && val !== '已通过' && val !== '未通过') { // 全部草稿箱把审批详情删了 if (radioMenus.value[radioMenus.value.length - 1].value === 'certificate-approval-record') { radioMenus.value.pop() } console.log(radioMenus.value) } else { // 非全部和草稿箱把审批详情加上 if (radioMenus.value[radioMenus.value.length - 1].value !== 'certificate-approval-record') { radioMenus.value.push({ name: '审批详情', value: 'certificate-approval-record' }) } } }, { immediate: true }) onMounted(() => { printFileName.value = $route.query.printFileName as string // 打印文件路径 printStatusName.value = $route.query.printStatusName as string // 打印状态名称 approvalStatusName.value = $route.query.approvalStatusName as string // 审批状态名称 processId.value = $route.query.processId as string // 流程实例id taskId.value = $route.query.taskId as string decisionItem.value = $route.query.decisionItem as string }) </script> <template> <app-container> <detail-page :title="`证书管理(${textMap[pageType]})`"> <template #btns> <el-button v-if="pageType === 'detail' && approvalStatusName === '待审批' && showApprovalButton" type="primary" @click="handleApprove('同意')"> 同意 </el-button> <el-button v-if="(`${decisionItem}` === '1' || `${decisionItem}` === '2') && pageType === 'detail' && approvalStatusName === '待审批' && showApprovalButton" type="warning" @click="handleApprove('驳回')"> 驳回 </el-button> <el-button v-if="(`${decisionItem}` === '1' || `${decisionItem}` === '3') && pageType === 'detail' && approvalStatusName === '待审批' && showApprovalButton" type="danger" @click="handleApprove('拒绝')"> 拒绝 </el-button> <el-button v-if="pageType === 'detail' && approvalStatusName === '草稿箱'" type="primary" :disabled="!infoId" @click="handleSubmit" > 提交 </el-button> <el-button v-if="approvalStatusName !== '已审批' && pageType === 'detail' && (approvalStatusName === '未通过' || approvalStatusName === '已取消' || approvalStatusName === '草稿箱')" type="primary" @click="handleEdit"> 编辑 </el-button> <el-button v-if="pageType !== 'detail'" type="primary" @click="saveForm"> 保存 </el-button> <el-button v-if="approvalStatusName === '已取消'" type="danger" @click="del"> 删除 </el-button> <el-button type="info" @click="close"> 关闭 </el-button> </template> <el-radio-group v-model="current"> <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value"> {{ item.name }} </el-radio-button> </el-radio-group> </detail-page> <!-- 基本信息 --> <certificate-basic v-if="current === 'certificate-basic'" ref="certificateBasicRef" :page-type="pageType" :print-file-name="printFileName" @addSuccess="addSuccess" @submitSuccess="submitSuccess" /> <!-- 审批详情 --> <approval-record-table v-if="current === 'certificate-approval-record'" :process-id="processId" /> <!-- 审批弹窗 --> <approval-dialog ref="approvalDialog" @on-success="approvalSuccess" @refuse="refuse" @reject="reject" /> </app-container> </template>