This commit is contained in:
zlwu committed 2026-07-16 11:45:34 +08:00
1 parent f6efca8fdf
commit 93a83d260f
45 files changed
+1211 -393

No files matched your search

@@ -0,0 +1,354 @@
<!-- 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.urls?.length">
<div v-for="(u, ui) in row.urls" :key="ui" class="oa-print-url">{{ u }}</div>
</template>
<template v-else>
<span class="oa-print-text">{{ row.text || '-' }}</span>
</template>
</td>
</tr>
<tr class="oa-print-flow">
<th>审批流程</th>
<td>
<div v-if="!model.flowItems.length" class="oa-print-text">-</div>
<div
v-for="(f, fi) in model.flowItems"
:key="`f-${fi}`"
class="oa-print-flow__item"
>
<div class="oa-print-flow__row">
<div class="oa-print-flow__left">{{ f.left }}</div>
<div class="oa-print-flow__right">{{ f.right }}</div>
</div>
<div v-if="f.comment" class="oa-print-flow__comment">意见:{{ f.comment }}</div>
</div>
</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'
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;
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;
}
.oa-print-table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
font-size: 13px;
}
.oa-print-table th,
.oa-print-table td {
border: 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 {
color: #3370ff;
word-break: break-all;
}
.oa-print-text {
white-space: pre-wrap;
}
.oa-print-flow th,
.oa-print-flow td {
vertical-align: top;
}
.oa-print-flow__item {
padding: 3px 0;
}
.oa-print-flow__row {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
}
.oa-print-flow__left {
flex: 1;
min-width: 0;
}
.oa-print-flow__right {
flex-shrink: 0;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.oa-print-flow__comment {
margin-top: 2px;
font-size: 12px;
color: #646a73;
}
.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>
@@ -1,266 +0,0 @@
<!-- OA 附件字段:值=逗号分隔 URL;卡片布局对齐协议附件 -->
<template>
<div class="oa-attach" :class="{ 'is-disabled': disabled }">
<div class="attachment-list">
<el-upload
v-if="!disabled && !reachedMax"
:auto-upload="false"
:show-file-list="false"
:multiple="true"
:disabled="disabled || uploading"
accept="image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.zip,.rar"
@change="onFileChange"
>
<div class="upload-card">
<el-icon :size="28" color="#047857"><Plus /></el-icon>
<span class="upload-card-text">上传附件</span>
</div>
</el-upload>
<div v-for="(item, index) in items" :key="item.url + index" class="attachment-item">
<div class="attachment-preview" @click="preview(item)">
<img v-if="isImage(item.url)" :src="item.url" :alt="item.name" />
<div v-else class="attachment-preview__icon">
<el-icon :size="28"><Document /></el-icon>
</div>
</div>
<div class="attachment-footer">
<span class="attachment-name" :title="item.name">{{ item.name }}</span>
<div class="attachment-actions">
<el-icon class="action-btn" title="下载" @click="download(item)"
><Download
/></el-icon>
<el-icon
v-if="!disabled"
class="action-btn action-btn--danger"
title="删除"
@click="removeAt(index)"
><Delete
/></el-icon>
</div>
</div>
</div>
</div>
<span v-if="!disabled" class="upload-hint">
{{ hintText }}
</span>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { Plus, Document, Download, Delete } from '@element-plus/icons-vue'
import { fetchAttachmentDownloadUrl, fetchUploadAttachment } from '@/api/business'
defineOptions({ name: 'OaAttachmentField' })
const props = withDefaults(
defineProps<{
modelValue?: string
disabled?: boolean
maxCount?: number
maxSizeMb?: number
}>(),
{
modelValue: '',
disabled: false,
maxCount: 9,
maxSizeMb: 20
}
)
const emit = defineEmits<{
'update:modelValue': [value: string]
change: [value: string]
}>()
const uploading = ref(false)
const items = computed(() => {
const urls = String(props.modelValue || '')
.split(',')
.map((s) => s.trim())
.filter(Boolean)
return urls.map((url) => ({
url,
name: decodeURIComponent(url.split('/').pop() || '附件')
}))
})
const reachedMax = computed(() => items.value.length >= props.maxCount)
const hintText = computed(
() => `支持图片、PDF、Office 等,最多 ${props.maxCount} 个,单文件不超过 ${props.maxSizeMb}MB`
)
function setValue(urls: string[]) {
const v = urls.filter(Boolean).join(',')
emit('update:modelValue', v)
emit('change', v)
}
function isImage(url: string) {
return /\.(png|jpe?g|gif|webp|bmp|svg)(\?|$)/i.test(url)
}
async function onFileChange(uploadFile: any) {
const raw: File | undefined = uploadFile?.raw
if (!raw) return
if (reachedMax.value) {
ElMessage.warning(`最多上传 ${props.maxCount} 个附件`)
return
}
if (raw.size > props.maxSizeMb * 1024 * 1024) {
ElMessage.warning(`单文件不能超过 ${props.maxSizeMb}MB`)
return
}
uploading.value = true
try {
const fd = new FormData()
fd.append('file', raw)
const res: any = await fetchUploadAttachment(fd)
const url = res?.fileUrl || res?.data?.fileUrl
if (!url) {
ElMessage.error('上传失败:未返回文件地址')
return
}
setValue([...items.value.map((x) => x.url), url])
} finally {
uploading.value = false
}
}
function removeAt(index: number) {
const next = items.value.map((x) => x.url)
next.splice(index, 1)
setValue(next)
}
function preview(item: { url: string }) {
if (isImage(item.url)) {
window.open(item.url, '_blank')
} else {
download(item)
}
}
async function download(item: { url: string; name: string }) {
try {
const res: any = await fetchAttachmentDownloadUrl({
fileUrl: item.url,
fileName: item.name
})
const href = res?.downloadUrl || item.url
window.open(href, '_blank')
} catch {
window.open(item.url, '_blank')
}
}
</script>
<style scoped lang="scss">
.attachment-list {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.upload-card {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 140px;
height: 96px;
cursor: pointer;
background: #fff;
border: 1px dashed #a7f3d0;
border-radius: 8px;
&:hover {
background: var(--primary-bg, #ecfdf5);
}
}
.upload-card-text {
margin-top: 6px;
color: #047857;
font-size: 13px;
}
.attachment-item {
width: 140px;
overflow: hidden;
background: #fff;
border: 1px solid var(--mint-border, #e2e8f0);
border-radius: 8px;
}
.attachment-preview {
display: flex;
align-items: center;
justify-content: center;
height: 72px;
cursor: pointer;
background: #f8fafc;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.attachment-preview__icon {
color: #94a3b8;
}
.attachment-footer {
display: flex;
gap: 4px;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
}
.attachment-name {
overflow: hidden;
color: var(--mint-text, #334155);
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.attachment-actions {
display: flex;
gap: 4px;
}
.action-btn {
color: #64748b;
cursor: pointer;
&:hover {
color: var(--primary, #10b981);
}
&--danger:hover {
color: #dc2626;
}
}
.upload-hint {
display: block;
margin-top: 8px;
color: var(--mint-text-muted, #94a3b8);
font-size: 12px;
}
.is-disabled {
.upload-card {
cursor: not-allowed;
opacity: 0.6;
}
}
</style>
@@ -1,103 +0,0 @@
/**
* OA FormCreate 自定义控件注册(运行时 + 设计器)
*/
import type { App } from 'vue'
import OaAttachmentField from './OaAttachmentField.vue'
/** V1 允许发布的控件 type(与 Spec §4.5 / 后端 oa_publish 对齐) */
export const OA_ALLOWED_CONTROL_TYPES = [
'input',
'textarea',
'inputNumber',
'number',
'radio',
'checkbox',
'select',
'switch',
'datePicker',
'date',
'dateRange',
'timePicker',
'time',
'phone',
'image',
'upload',
'attachment',
'oaAttachment',
'money',
'dept',
'region',
'formula',
'relatedApproval',
'rate',
'slider',
'cascader',
'fcRow',
'col',
'column',
'html',
'divider',
'card',
'space',
'group',
'object'
] as const
export function registerOaFormCreateComponents(formCreate: any) {
if (!formCreate?.component) return
formCreate.component('oaAttachment', OaAttachmentField)
formCreate.component('attachment', OaAttachmentField)
}
/** 将附件控件挂到设计器菜单 */
export function registerOaDesignerAttachment(designer: any) {
if (!designer) return
const addComponent = designer.addComponent || designer?.proxy?.addComponent
const addMenu = designer.addMenu || designer?.proxy?.addMenu
const ruleFactory = () => ({
type: 'oaAttachment',
field: `attach_${Date.now().toString(36)}`,
title: '附件',
info: '',
$required: false,
props: {
maxCount: 9,
maxSizeMb: 20
}
})
if (typeof addComponent === 'function') {
addComponent({
icon: 'icon-upload',
label: '附件',
name: 'oaAttachment',
rule: ruleFactory,
props() {
return [
{ type: 'inputNumber', field: 'maxCount', title: '最大个数', value: 9 },
{ type: 'inputNumber', field: 'maxSizeMb', title: '单文件上限(MB)', value: 20 }
]
}
})
}
if (typeof addMenu === 'function') {
addMenu({
name: 'oaBiz',
title: 'OA控件',
list: [
{
icon: 'icon-upload',
label: '附件',
name: 'oaAttachment',
rule: ruleFactory
}
]
})
}
}
export function installOaFormComponents(app: App, formCreate: any) {
app.component('OaAttachmentField', OaAttachmentField)
registerOaFormCreateComponents(formCreate)
}