Files
zkxw/web-admin/src/components/oa-approval/OaApprovalPrintSheet.vue
T
zlwu a511004812 fix(oa): include discussion comments and attachment links in approval PDFs
Merge discussion comments into the existing printed approval flow on Web and mobile OA, preserving detail timeline order and hiding revoked content. Include mentions and absolute attachment URLs, and add PDF link annotations so rasterized exports retain usable links. Add regression tests for ordering, attachments, mentions and revoked comments. Related to Gitea issue #30.
2026-11-05 10:27:39 +08:00

425 lines
10 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- OA 审批单打印页(钉钉风格 · 印章第 4 版) -->
<template>
<div class="oa-print-page">
<div class="oa-print-wm" aria-hidden="true">
<span
v-for="n in 48"
:key="n"
class="oa-print-wm__item"
:style="wmStyle(n)"
>
{{ model.watermarkName }} {{ model.watermarkName }} {{ model.watermarkName }}
</span>
</div>
<div class="oa-print-inner">
<h1 class="oa-print-title">{{ model.title }}</h1>
<div class="oa-print-meta">
<span>{{ model.companyName }}</span>
<span>创建时间:{{ model.createDate }}</span>
</div>
<div class="oa-print-table-wrap">
<div
class="oa-stamp"
:class="[model.stampClass, { 'is-chars3': model.stampText.length >= 3 }]"
:aria-label="model.stampText"
>
<div class="outer" />
<div class="arc-top" />
<div class="arc-bottom" />
<div class="label-top">OA审批</div>
<div class="main" :class="{ 'chars-3': model.stampText.length >= 3 }">
{{ model.stampText }}
</div>
<div class="label-bottom">approval</div>
</div>
<table class="oa-print-table">
<tbody>
<tr v-for="(row, idx) in model.rows" :key="`r-${idx}`">
<th>{{ row.label }}</th>
<td>
<template v-if="row.blocks?.length">
<OaPrintRelatedTree :blocks="row.blocks" />
</template>
<template v-else-if="row.urls?.length">
<div v-for="(u, ui) in row.urls" :key="ui" class="oa-print-url">
{{ formatOaPrintAttachmentText(u) }}
</div>
</template>
<template v-else>
<span class="oa-print-text">{{
formatOaPrintAttachmentText(row.text || '-')
}}</span>
</template>
</td>
</tr>
<!-- 审批流程:左列 rowspan,每个节点独立一行(含表格线,对齐钉钉导出) -->
<template v-if="model.flowItems.length">
<tr
v-for="(f, fi) in model.flowItems"
:key="`f-${fi}`"
class="oa-print-flow"
>
<th
v-if="fi === 0"
class="oa-print-flow__label"
:rowspan="model.flowItems.length"
>
审批流程
</th>
<td class="oa-print-flow__cell">
<div class="oa-print-flow__row">
<div class="oa-print-flow__left">{{ f.left }}</div>
<div v-if="f.right" class="oa-print-flow__right">{{ f.right }}</div>
</div>
<div v-if="f.personLines?.length" class="oa-print-flow__person-lines">
<div
v-for="(line, li) in f.personLines"
:key="li"
class="oa-print-flow__row oa-print-flow__person-line"
>
<div class="oa-print-flow__left">{{ line.left }}</div>
<div v-if="line.right" class="oa-print-flow__right">{{ line.right }}</div>
</div>
</div>
<div v-else-if="f.comment" class="oa-print-flow__comment">
意见:{{ f.comment }}
</div>
<div v-for="url in f.attachmentLinks" :key="url" class="oa-print-url">
<a :href="url" data-oa-print-link>{{ url }}</a>
</div>
</td>
</tr>
</template>
<tr v-else class="oa-print-flow">
<th class="oa-print-flow__label">审批流程</th>
<td class="oa-print-flow__cell">
<span class="oa-print-text">-</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="oa-print-footer">
<span>打印时间:{{ model.printTime }}</span>
<span>打印人:{{ model.printerName }}</span>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import type { OaPrintModel } from '@/utils/oa-approval-print'
import OaPrintRelatedTree from '@/components/oa-approval/OaPrintRelatedTree.vue'
import { formatOaPrintAttachmentText } from '@/utils/oa-upload-file-type'
defineOptions({ name: 'OaApprovalPrintSheet' })
defineProps<{
model: OaPrintModel
}>()
function wmStyle(n: number) {
const row = Math.floor((n - 1) / 4)
const col = (n - 1) % 4
const top = 28 + row * 88
const left = -30 + col * 210 + (row % 2) * 50
return { top: `${top}px`, left: `${left}px` }
}
</script>
<style scoped lang="scss">
.oa-print-page {
position: relative;
width: 794px;
/* 至少一页 A4 高,水印铺满;分页用 EPS 容差,避免略超 297mm 多出空白第二页 */
min-height: 1123px;
padding: 48px 56px 56px;
box-sizing: border-box;
background: #fff;
color: #1f2329;
font-family:
'PingFang SC',
'Microsoft YaHei',
'Helvetica Neue',
Arial,
sans-serif;
overflow: hidden;
}
.oa-print-wm {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 0;
overflow: hidden;
}
.oa-print-wm__item {
position: absolute;
font-size: 14px;
color: rgba(0, 0, 0, 0.045);
white-space: nowrap;
transform: rotate(-30deg);
letter-spacing: 2px;
}
.oa-print-inner {
position: relative;
z-index: 1;
}
.oa-print-title {
margin: 0 0 14px;
text-align: center;
font-size: 28px;
font-weight: 700;
letter-spacing: 2px;
line-height: 1.3;
}
.oa-print-meta {
display: flex;
gap: 48px;
margin-bottom: 12px;
font-size: 12px;
line-height: 1.5;
}
.oa-print-table-wrap {
position: relative;
}
/*
* 边框用 separate + 只画右/下边,避免 collapse 下相邻 1px 叠成粗细不一
*(html2canvas 导出时尤其明显);外框由 table 上/左 + 末行下/末列右拼成。
*/
.oa-print-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
table-layout: fixed;
font-size: 13px;
border-top: 1px solid #1f2329;
border-left: 1px solid #1f2329;
}
.oa-print-table th,
.oa-print-table td {
border: none;
border-right: 1px solid #1f2329;
border-bottom: 1px solid #1f2329;
padding: 9px 12px;
vertical-align: middle;
line-height: 1.5;
word-break: break-all;
}
.oa-print-table th {
width: 118px;
font-weight: 400;
text-align: left;
background: #fff;
}
.oa-print-url a {
color: inherit;
}
.oa-print-url {
color: #3370ff;
word-break: break-all;
}
.oa-print-text {
white-space: pre-wrap;
}
.oa-print-flow__label {
vertical-align: middle;
}
.oa-print-flow__cell {
vertical-align: middle;
padding: 8px 12px;
}
.oa-print-flow__row {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
width: 100%;
}
.oa-print-flow__left {
white-space: pre-wrap;
overflow-wrap: anywhere;
flex: 1 1 auto;
min-width: 0;
}
.oa-print-flow__right {
flex: 0 0 auto;
margin-left: auto;
text-align: right;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.oa-print-flow__comment {
margin-top: 2px;
font-size: 12px;
color: #646a73;
}
.oa-print-flow__person-lines {
margin-top: 6px;
display: grid;
gap: 3px;
}
.oa-print-flow__person-line {
line-height: 1.55;
}
.oa-print-flow__person-line .oa-print-flow__left {
word-break: break-word;
white-space: pre-wrap;
}
.oa-print-footer {
display: flex;
gap: 28px;
margin-top: 14px;
font-size: 12px;
}
/* ===== 印章 v4(钉钉风格) ===== */
.oa-stamp {
--stamp: #3ec9a8;
position: absolute;
top: -10px;
right: 18px;
width: 118px;
height: 118px;
z-index: 5;
pointer-events: none;
transform: rotate(-18deg);
opacity: 0.88;
color: var(--stamp);
}
.oa-stamp.ok {
--stamp: #3ec9a8;
}
.oa-stamp.run {
--stamp: #f0a020;
}
.oa-stamp.rej {
--stamp: #e85d5d;
}
.oa-stamp.ret {
--stamp: #e07070;
}
.oa-stamp.can {
--stamp: #9aa0a6;
}
.oa-stamp .outer {
position: absolute;
inset: 0;
border-radius: 50%;
border: 5px solid currentColor;
box-sizing: border-box;
}
.oa-stamp .arc-top,
.oa-stamp .arc-bottom {
position: absolute;
left: 14px;
right: 14px;
border: 2px solid currentColor;
opacity: 0.95;
pointer-events: none;
}
.oa-stamp .arc-top {
top: 11px;
height: 36px;
border-bottom: none;
border-left-color: transparent;
border-right-color: transparent;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.oa-stamp .arc-bottom {
bottom: 11px;
height: 36px;
border-top: none;
border-left-color: transparent;
border-right-color: transparent;
border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.oa-stamp .label-top {
position: absolute;
top: 22px;
left: 0;
right: 0;
text-align: center;
font-size: 10px;
font-weight: 500;
letter-spacing: 2px;
line-height: 1;
color: currentColor;
opacity: 0.95;
}
.oa-stamp .label-bottom {
position: absolute;
bottom: 20px;
left: 0;
right: 0;
text-align: center;
font-size: 9px;
font-weight: 500;
letter-spacing: 0.5px;
line-height: 1;
color: currentColor;
opacity: 0.9;
font-family: Arial, 'Helvetica Neue', sans-serif;
}
.oa-stamp .main {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
font-weight: 800;
letter-spacing: 2px;
line-height: 1;
color: currentColor;
font-family:
'PingFang SC',
'Microsoft YaHei',
'Helvetica Neue',
Arial,
sans-serif;
-webkit-text-stroke: 0.3px currentColor;
}
.oa-stamp .main.chars-3 {
font-size: 28px;
letter-spacing: 1px;
}
</style>