<!-- 核查记录管理列表页 --> <script lang="ts" setup name="CheckRecordDetail"> import { ElMessage, ElMessageBox } from 'element-plus' import type { Ref } from 'vue' import type { FormInstance, FormRules, UploadUserFile } from 'element-plus' import type { IForm } from './checkRecord-interface' import checkRecordBasic from './components/basic.vue' import checkRecordChangeRecord from './components/changeRecord.vue' import checkRecordApprovalRecord from './components/approvalRecord.vue' import useUserStore from '@/store/modules/user' import { cancelApproval, refuseApproval, } from '@/api/equipment/standard/checkRecords' import { download } from '@/utils/download' 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 approvalStatusName = ref('') // 审批状态名称 const processId = ref('') // 流程实例id const taskId = ref('') // 任务id,用于同意、驳回、拒绝审批 const showApprovalButton = ref(true) // 是否展示审批按钮 const approvalDialog = ref() // 审批对话ref // -------------------------------------标签-------------------------------------------------- const radioMenus = ref([ // 标签内容 { name: '基本信息', value: 'checkRecord-basic' }, { name: '核查数据修改记录', value: 'checkRecord-change-record' }, { name: '审批详情', value: 'approval-record' }, ]) const current = ref('checkRecord-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 } } console.log('页面类型', pageType.value, 'infoId', infoId.value) // --------------------------------------------按钮---------------------------------------------- // 点击核查记录下载 const downloadCheckRecord = () => { ElMessage.info('敬请期待') } // 点击提交 const submitForm = () => { ElMessage.info('敬请期待') } // 点击保存 const saveForm = (formEl: FormInstance | undefined) => { } // 点击关闭 const close = () => { $router.back() } // -------------------------------------------审批---------------------------------------- // 审批结束回调 const approvalSuccess = () => { showApprovalButton.value = false } // 审批 const handleApprove = (val: string) => { if (val === '取消') { const params = { processInstanceId: processId.value!, comments: '', id: infoId.value, } ElMessageBox.confirm( '确认取消该审批吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ) .then(() => { cancelApproval(params).then((res) => { ElMessage({ type: 'success', message: '已取消', }) showApprovalButton.value = false }) }) } else if (val === '同意') { approvalDialog.value.initDialog('agree', taskId.value) } else if (val === '拒绝') { approvalDialog.value.initDialog('refuse', taskId.value, infoId.value) } } // 拒绝 const refuse = (comments: string, taskId: string, id: string) => { const params = { id, taskId, // 任务id comments, // 拒绝原因 } refuseApproval(params).then((res) => { ElMessage({ type: 'success', message: '已拒绝', }) showApprovalButton.value = false }) } // -----------------------------------------------钩子----------------------------- watch(() => approvalStatusName.value, (val) => { if (val === '全部' || val === '草稿箱' || pageType.value === 'add') { // 全部草稿箱把审批详情删了 if (radioMenus.value[radioMenus.value.length - 1].value === 'approval-record') { radioMenus.value.pop() } console.log(radioMenus.value) } else { // 非全部和草稿箱把审批详情加上 if (radioMenus.value[radioMenus.value.length - 1].value !== 'approval-record') { radioMenus.value.push({ name: '审批详情', value: 'approval-record' }) } } }) // ---------------------------------------------------------------------------------------------- onMounted(() => { approvalStatusName.value = $route.query.approvalStatusName as string // 审批名称 }) </script> <template> <app-container> <detail-page :title="`核查记录管理(${textMap[pageType]})`"> <template #btns> <el-button v-if="pageType === 'detail'" type="primary" @click="downloadCheckRecord"> 核查记录下载 </el-button> <el-button v-if="pageType === 'add'" type="primary" @click="submitForm"> 提交 </el-button> <el-button v-if="pageType !== 'detail'" type="primary" @click="saveForm(ruleFormRef)"> 保存 </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> <!-- 基本信息 --> <check-record-basic v-if="current === 'checkRecord-basic'" :page-type="pageType" /> <!-- 修改记录 --> <check-record-change-record v-if="current === 'checkRecord-change-record'" :page-type="pageType" /> <!-- 审批详情 --> <approval-record-table v-if="current === 'approval-record'" :process-id="processId" /> <!-- 审批弹窗 --> <approval-dialog ref="approvalDialog" @on-success="approvalSuccess" @refuse="refuse" /> </app-container> </template>