<script name="QualityInternalWorkDetail" lang="ts" setup> import { ElMessage } from 'element-plus' import edit from './edit.vue' import { exportFile, printContent } from '@/utils/exportUtils' import { getFiles } from '@/utils/download' import pdfFile from '@/views/quality/supervise/record/components/pdfFile.vue' import { getInternalAuditPlanFile, noticePerson } from '@/api/quality/internal/internalPlan' import useUserStore from '@/store/modules/user' const $router = useRouter() const $route = useRoute() const user = useUserStore() // 用户信息 // 编辑 const updateRow = () => { $router.push({ path: '/internalplan/update', query: { id: $route.query.id as string, }, }) } const file = ref() const getFile = (fun: any) => { getInternalAuditPlanFile({ id: $route.query.id, pdf: true, }).then((res) => { if (res.data.type.includes('json')) { ElMessage.error('文件获取失败') fun() return } file.value = res.data fun(res) }).catch(() => { fun() ElMessage.error('文件获取失败') }) } // 打印 const printFile = () => { if (file.value) { printContent(getFiles(file.value, 'application/pdf;chartset=UTF-8')) } else { ElMessage.warning('打印失败') } } // 下载 const downloadFile = () => { if (file.value) { const data = JSON.parse($route.query.data as string) exportFile(file.value, `${data.fileName}.pdf`) } else { ElMessage.warning('下载失败') } } // 保存提交后自动通知 // 通知内审组成员 const notice = () => { noticePerson({id: $route.query.id}).then(res => { console.log(res.data) ElMessage.success('通知成功') }) // ElMessage.warning('敬请期待') } const detail = JSON.parse($route.query.data as string) console.log(detail, 'detail') </script> <template> <app-container style="overflow: hidden;"> <detail-page title="内部审核计划"> <template #btns> <el-button v-if="detail.commanderId === user.id" type="primary" @click="notice"> 通知内审组成员 </el-button> <el-button type="primary" @click="downloadFile"> 下载 </el-button> <el-button type="primary" @click="printFile"> 打印 </el-button> <!-- <el-button type="primary" @click="updateRow"> 编辑 </el-button> --> <el-button type="info" @click="() => $router.go(-1)"> 关闭 </el-button> </template> </detail-page> <div class="base-info-report"> <edit :show-base="false" /> <pdf-file @get-file="getFile" /> </div> </app-container> </template> <style lang="scss" scoped> .base-info-report { ::v-deep(.app-container) { padding: 0 !important; .info-header { display: none; } .info-body { display: none; } .base-info { display: none; } } } </style>