提交
This commit is contained in:
1 parent
c9711d0dce
commit
28e59a2262
218 files changed
+20698
-7413
No files matched your search
@@ -0,0 +1,266 @@
|
||||
<!-- 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>
|
||||
@@ -0,0 +1,269 @@
|
||||
<!-- 发起审批 · 表单底部审批流预览(对齐 docs/mockups/oa-approval-start-flow-preview-demo.html) -->
|
||||
<template>
|
||||
<div class="oa-flow-preview">
|
||||
<div class="oa-flow-preview__title">
|
||||
<span>审批流程</span>
|
||||
<span v-if="hint" class="oa-flow-preview__hint">{{ hint }}</span>
|
||||
</div>
|
||||
<div v-loading="loading" class="oa-flow-preview__chain">
|
||||
<div v-if="!loading && !steps.length" class="oa-flow-preview__empty">暂无流程配置</div>
|
||||
<div v-for="(s, idx) in steps" :key="s.id || idx" class="oa-flow-step">
|
||||
<div class="oa-flow-rail">
|
||||
<div class="oa-flow-dot" :class="{ end: s.type === 'end' }" />
|
||||
<div v-if="idx < steps.length - 1" class="oa-flow-line" />
|
||||
</div>
|
||||
<div class="oa-flow-card">
|
||||
<div class="oa-flow-card__row">
|
||||
<span class="oa-flow-card__name">{{ s.name || '-' }}</span>
|
||||
<span v-if="signBadge(s)" class="oa-flow-badge" :class="signBadge(s)">
|
||||
{{ signBadgeText(s) }}
|
||||
</span>
|
||||
<template v-if="s.meta">
|
||||
<span class="oa-flow-card__sep">·</span>
|
||||
<span class="oa-flow-card__meta" :title="s.meta">{{ s.meta }}</span>
|
||||
</template>
|
||||
<span v-if="s.resolveError" class="oa-flow-card__err" :title="s.resolveError">
|
||||
{{ s.resolveError }}
|
||||
</span>
|
||||
<span v-if="(s.people || []).length" class="oa-flow-card__people">
|
||||
<span v-for="p in s.people" :key="p.id" class="oa-person-chip">
|
||||
<span class="oa-person-chip__dot">{{ avatarChar(p.nickName) }}</span>
|
||||
{{ p.nickName || p.id }}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { OaFlowPreviewStep } from '@/api/oaApproval'
|
||||
|
||||
defineOptions({ name: 'OaFlowPreview' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
steps?: OaFlowPreviewStep[]
|
||||
loading?: boolean
|
||||
hint?: string
|
||||
}>(),
|
||||
{
|
||||
steps: () => [],
|
||||
loading: false,
|
||||
hint: '按当前发起人解析审批人'
|
||||
}
|
||||
)
|
||||
|
||||
const steps = computed(() => props.steps || [])
|
||||
|
||||
function signBadge(s: OaFlowPreviewStep) {
|
||||
if (s.type === 'cc' || s.signMode === 'cc') return 'cc'
|
||||
if (s.signMode === 'and') return 'and'
|
||||
if (s.signMode === 'or') return 'or'
|
||||
return ''
|
||||
}
|
||||
|
||||
function signBadgeText(s: OaFlowPreviewStep) {
|
||||
const k = signBadge(s)
|
||||
if (k === 'cc') return '抄送'
|
||||
if (k === 'and') return '会签'
|
||||
if (k === 'or') return '或签'
|
||||
return ''
|
||||
}
|
||||
|
||||
function avatarChar(name: string) {
|
||||
const n = (name || '').trim()
|
||||
return n ? n.slice(0, 1) : '?'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.oa-flow-preview {
|
||||
margin: 8px 0 12px;
|
||||
padding: 12px 12px 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid var(--mint-border, #e2e8f0);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.oa-flow-preview__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.oa-flow-preview__hint {
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.oa-flow-preview__empty {
|
||||
padding: 8px 0;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.oa-flow-preview__chain {
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
.oa-flow-step {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.oa-flow-rail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.oa-flow-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-top: 12px;
|
||||
background: #94a3b8;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 3px #e2e8f0;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.end {
|
||||
background: #cbd5e1;
|
||||
box-shadow: 0 0 0 3px #f1f5f9;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-flow-line {
|
||||
width: 2px;
|
||||
flex: 1;
|
||||
min-height: 10px;
|
||||
margin: 4px 0;
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.oa-flow-card {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-bottom: 6px;
|
||||
padding: 9px 12px;
|
||||
background: #fff;
|
||||
border: 1px solid var(--mint-border, #e2e8f0);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.oa-flow-card__row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 8px;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.oa-flow-card__name {
|
||||
flex-shrink: 0;
|
||||
color: var(--mint-text-strong, #0f172a);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.oa-flow-card__meta {
|
||||
flex-shrink: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.oa-flow-card__sep {
|
||||
flex-shrink: 0;
|
||||
color: #cbd5e1;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.oa-flow-card__err {
|
||||
flex-shrink: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: #d97706;
|
||||
font-size: 11px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.oa-flow-card__people {
|
||||
display: inline-flex;
|
||||
flex: 1 1 140px;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.oa-person-chip {
|
||||
display: inline-flex;
|
||||
gap: 3px;
|
||||
align-items: center;
|
||||
padding: 1px 6px 1px 2px;
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
background: #f1f5f9;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.oa-person-chip__dot {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
background: var(--primary, #10b981);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.oa-flow-badge {
|
||||
flex-shrink: 0;
|
||||
padding: 0 5px;
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
line-height: 16px;
|
||||
white-space: nowrap;
|
||||
border-radius: 4px;
|
||||
|
||||
&.or {
|
||||
color: #d97706;
|
||||
background: #fff7ed;
|
||||
}
|
||||
|
||||
&.and {
|
||||
color: #2563eb;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
&.cc {
|
||||
color: #0891b2;
|
||||
background: #ecfeff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,171 @@
|
||||
<!-- OA 表单设计:iframe 隔离 FormCreate,避免主应用 Tailwind 打乱三栏 -->
|
||||
<template>
|
||||
<div class="oa-form-designer-embed">
|
||||
<p class="oa-form-designer-embed__hint">
|
||||
拖拽左侧控件到中间画布;顶部可切换 PC / 手机预览。选中控件后在右侧配置属性。
|
||||
</p>
|
||||
<iframe
|
||||
ref="frameRef"
|
||||
class="oa-form-designer-embed__frame"
|
||||
title="表单设计器"
|
||||
:src="hostSrc"
|
||||
@load="onFrameLoad"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, toRaw, watch } from 'vue'
|
||||
|
||||
defineOptions({ name: 'OaFormDesignerEmbed' })
|
||||
|
||||
const props = defineProps<{
|
||||
/** { rule, option } */
|
||||
modelValue?: { rule?: unknown; option?: unknown } | null
|
||||
}>()
|
||||
|
||||
const frameRef = ref<HTMLIFrameElement | null>(null)
|
||||
const frameReady = ref(false)
|
||||
let reqSeq = 0
|
||||
const pending = new Map<
|
||||
number,
|
||||
{ resolve: (v: { rule: unknown; option: unknown }) => void; reject: (e: Error) => void }
|
||||
>()
|
||||
|
||||
const MSG = {
|
||||
READY: 'oa-fc:ready',
|
||||
SET: 'oa-fc:set-schema',
|
||||
GET: 'oa-fc:get-schema',
|
||||
SCHEMA: 'oa-fc:schema'
|
||||
} as const
|
||||
|
||||
const hostSrc = computed(() => {
|
||||
const base = import.meta.env.BASE_URL || '/'
|
||||
const normalized = base.endsWith('/') ? base : `${base}/`
|
||||
return `${normalized}oa-fc-host.html`
|
||||
})
|
||||
|
||||
/** postMessage 无法可靠克隆 Vue Proxy,必须先变成纯 JSON */
|
||||
function toPlainSchema(schema: unknown): { rule: unknown; option: unknown } {
|
||||
const raw = toRaw(schema as any) || {}
|
||||
try {
|
||||
const cloned = JSON.parse(JSON.stringify(raw))
|
||||
return {
|
||||
rule: Array.isArray(cloned?.rule) ? cloned.rule : Array.isArray(cloned) ? cloned : [],
|
||||
option: cloned?.option && typeof cloned.option === 'object' ? cloned.option : {}
|
||||
}
|
||||
} catch {
|
||||
return { rule: [], option: {} }
|
||||
}
|
||||
}
|
||||
|
||||
function postToFrame(payload: Record<string, unknown>) {
|
||||
try {
|
||||
frameRef.value?.contentWindow?.postMessage(payload, '*')
|
||||
} catch (e) {
|
||||
console.warn('[OaFormDesignerEmbed] postMessage failed', e)
|
||||
}
|
||||
}
|
||||
|
||||
function pushSchemaToFrame() {
|
||||
if (!frameReady.value) return
|
||||
postToFrame({
|
||||
type: MSG.SET,
|
||||
schema: toPlainSchema(props.modelValue)
|
||||
})
|
||||
}
|
||||
|
||||
function onFrameLoad() {
|
||||
if (frameReady.value) pushSchemaToFrame()
|
||||
}
|
||||
|
||||
function onMessage(ev: MessageEvent) {
|
||||
const data = ev.data
|
||||
if (!data || typeof data !== 'object') return
|
||||
if (data.type === MSG.READY) {
|
||||
frameReady.value = true
|
||||
pushSchemaToFrame()
|
||||
// 宿主刚就绪时再补推一次,避免 setRule 早于内部 dragForm 初始化
|
||||
window.setTimeout(() => pushSchemaToFrame(), 50)
|
||||
window.setTimeout(() => pushSchemaToFrame(), 200)
|
||||
return
|
||||
}
|
||||
if (data.type === MSG.SCHEMA && typeof data.requestId === 'number') {
|
||||
const wait = pending.get(data.requestId)
|
||||
if (!wait) return
|
||||
pending.delete(data.requestId)
|
||||
const schema = toPlainSchema(data.schema)
|
||||
wait.resolve(schema)
|
||||
}
|
||||
}
|
||||
|
||||
/** 供父页保存草稿 / 发布前拉取最新 schema */
|
||||
function fetchSchema(timeoutMs = 3000): Promise<{ rule: unknown; option: unknown }> {
|
||||
if (!frameReady.value) {
|
||||
return Promise.resolve(toPlainSchema(props.modelValue))
|
||||
}
|
||||
const requestId = ++reqSeq
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = window.setTimeout(() => {
|
||||
pending.delete(requestId)
|
||||
reject(new Error('表单设计器响应超时'))
|
||||
}, timeoutMs)
|
||||
pending.set(requestId, {
|
||||
resolve: (v) => {
|
||||
window.clearTimeout(timer)
|
||||
resolve(v)
|
||||
},
|
||||
reject
|
||||
})
|
||||
postToFrame({ type: MSG.GET, requestId })
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => {
|
||||
pushSchemaToFrame()
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('message', onMessage)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('message', onMessage)
|
||||
pending.forEach((p) => p.reject(new Error('表单设计器已卸载')))
|
||||
pending.clear()
|
||||
})
|
||||
|
||||
defineExpose({ fetchSchema })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.oa-form-designer-embed {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: calc(100vh - 200px);
|
||||
min-height: 520px;
|
||||
}
|
||||
|
||||
.oa-form-designer-embed__hint {
|
||||
flex-shrink: 0;
|
||||
margin: 0 0 10px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.oa-form-designer-embed__frame {
|
||||
display: block;
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
border: 1px solid var(--mint-border, #cbd5e1);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 8px rgb(15 23 42 / 8%);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,326 @@
|
||||
<!-- 审批详情 · 审批进度(视觉对齐 OaFlowPreview / 发起审批弹窗底部) -->
|
||||
<template>
|
||||
<div class="oa-flow-preview">
|
||||
<div class="oa-flow-preview__title">
|
||||
<span>审批进度</span>
|
||||
</div>
|
||||
<div class="oa-flow-preview__chain">
|
||||
<div v-if="!items.length" class="oa-flow-preview__empty">暂无任务记录</div>
|
||||
<div v-for="(item, idx) in items" :key="item.key" class="oa-flow-step">
|
||||
<div class="oa-flow-rail">
|
||||
<div
|
||||
class="oa-flow-dot"
|
||||
:class="dotClass(item)"
|
||||
/>
|
||||
<div v-if="idx < items.length - 1" class="oa-flow-line" />
|
||||
</div>
|
||||
<div class="oa-flow-card">
|
||||
<div class="oa-flow-card__row">
|
||||
<span class="oa-flow-card__name">{{ item.title }}</span>
|
||||
<span v-if="statusBadge(item)" class="oa-flow-badge" :class="statusBadge(item)">
|
||||
{{ statusText(item.status) }}
|
||||
</span>
|
||||
<span v-if="item.taskType === 'cc'" class="oa-flow-badge cc">抄送</span>
|
||||
<template v-if="item.timestamp">
|
||||
<span class="oa-flow-card__sep">·</span>
|
||||
<span class="oa-flow-card__meta" :title="item.timestamp">{{ item.timestamp }}</span>
|
||||
</template>
|
||||
<template v-if="item.resolveSource && item.kind === 'task'">
|
||||
<span class="oa-flow-card__sep">·</span>
|
||||
<span class="oa-flow-card__meta" :title="resolveSourceText(item.resolveSource)">
|
||||
{{ resolveSourceText(item.resolveSource) }}
|
||||
</span>
|
||||
</template>
|
||||
<span
|
||||
v-if="item.assignee && item.kind !== 'pending_node' && item.kind !== 'terminal'"
|
||||
class="oa-flow-card__people"
|
||||
>
|
||||
<span class="oa-person-chip">
|
||||
<span class="oa-person-chip__dot">{{ avatarChar(item.assignee) }}</span>
|
||||
{{ item.assignee }}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="item.commentText" class="oa-flow-card__comment">
|
||||
意见:{{ item.commentText }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: 'OaProgressChain' })
|
||||
|
||||
export type OaProgressChainItem = {
|
||||
key: string
|
||||
title: string
|
||||
status: string
|
||||
timestamp?: string
|
||||
assignee?: string
|
||||
resolveSource?: string
|
||||
commentText?: string
|
||||
taskType?: string
|
||||
kind?: string
|
||||
}
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
items?: OaProgressChainItem[]
|
||||
}>(),
|
||||
{
|
||||
items: () => []
|
||||
}
|
||||
)
|
||||
|
||||
function statusText(s: string) {
|
||||
const map: Record<string, string> = {
|
||||
pending: '待处理',
|
||||
running: '进行中',
|
||||
approved: '已同意',
|
||||
rejected: '已拒绝',
|
||||
completed: '已完成',
|
||||
cancelled: '已撤销',
|
||||
done: '已结束',
|
||||
submitted: '已提交',
|
||||
not_reached: '未到达',
|
||||
returned: '已打回'
|
||||
}
|
||||
return map[s] || s
|
||||
}
|
||||
|
||||
/** 徽章色:与 Fresh Mint 语义一致 */
|
||||
function statusBadge(item: OaProgressChainItem) {
|
||||
const s = item.status || ''
|
||||
if (s === 'approved' || s === 'completed' || s === 'done' || s === 'submitted') return 'ok'
|
||||
if (s === 'pending' || s === 'running') return 'or'
|
||||
if (s === 'rejected' || s === 'cancelled' || s === 'returned') return 'danger'
|
||||
if (s === 'not_reached') return 'mute'
|
||||
return ''
|
||||
}
|
||||
|
||||
function dotClass(item: OaProgressChainItem) {
|
||||
const s = item.status || ''
|
||||
if (s === 'approved' || s === 'completed' || s === 'done' || s === 'submitted') return 'ok'
|
||||
if (s === 'pending' || s === 'running') return 'pending'
|
||||
if (s === 'rejected' || s === 'cancelled' || s === 'returned') return 'danger'
|
||||
return ''
|
||||
}
|
||||
|
||||
function resolveSourceText(src: string) {
|
||||
const map: Record<string, string> = {
|
||||
users: '指定成员',
|
||||
oa_roles: '工作流角色',
|
||||
dept_leader: '部门负责人',
|
||||
direct_supervisor: '直属主管',
|
||||
supervisor_fallback_dept_leader: '部门负责人(主管回退)',
|
||||
initiator_select: '发起人自选'
|
||||
}
|
||||
return map[src] || src
|
||||
}
|
||||
|
||||
function avatarChar(name: string) {
|
||||
const n = (name || '').trim()
|
||||
return n ? n.slice(0, 1) : '?'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.oa-flow-preview {
|
||||
margin: 0;
|
||||
padding: 12px 12px 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid var(--mint-border, #e2e8f0);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.oa-flow-preview__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.oa-flow-preview__empty {
|
||||
padding: 8px 0;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.oa-flow-preview__chain {
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
.oa-flow-step {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.oa-flow-rail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.oa-flow-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-top: 12px;
|
||||
background: #94a3b8;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 3px #e2e8f0;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.ok {
|
||||
background: var(--primary, #10b981);
|
||||
box-shadow: 0 0 0 3px var(--primary-bg, #ecfdf5);
|
||||
}
|
||||
|
||||
&.pending {
|
||||
background: #d97706;
|
||||
box-shadow: 0 0 0 3px #fff7ed;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
background: #ef4444;
|
||||
box-shadow: 0 0 0 3px #fef2f2;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-flow-line {
|
||||
width: 2px;
|
||||
flex: 1;
|
||||
min-height: 10px;
|
||||
margin: 4px 0;
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.oa-flow-card {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-bottom: 6px;
|
||||
padding: 9px 12px;
|
||||
background: #fff;
|
||||
border: 1px solid var(--mint-border, #e2e8f0);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.oa-flow-card__row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 8px;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.oa-flow-card__name {
|
||||
flex-shrink: 0;
|
||||
color: var(--mint-text-strong, #0f172a);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.oa-flow-card__meta {
|
||||
flex-shrink: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.oa-flow-card__sep {
|
||||
flex-shrink: 0;
|
||||
color: #cbd5e1;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.oa-flow-card__people {
|
||||
display: inline-flex;
|
||||
flex: 1 1 140px;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.oa-flow-card__comment {
|
||||
margin-top: 6px;
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.oa-person-chip {
|
||||
display: inline-flex;
|
||||
gap: 3px;
|
||||
align-items: center;
|
||||
padding: 1px 6px 1px 2px;
|
||||
color: var(--mint-text, #334155);
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
background: #f1f5f9;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.oa-person-chip__dot {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
background: var(--primary, #10b981);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.oa-flow-badge {
|
||||
flex-shrink: 0;
|
||||
padding: 0 5px;
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
line-height: 16px;
|
||||
white-space: nowrap;
|
||||
border-radius: 4px;
|
||||
|
||||
&.ok {
|
||||
color: #059669;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
|
||||
&.or {
|
||||
color: #d97706;
|
||||
background: #fff7ed;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
color: #dc2626;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
&.mute {
|
||||
color: #64748b;
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
&.cc {
|
||||
color: #0891b2;
|
||||
background: #ecfeff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,250 @@
|
||||
<!-- 递归渲染线性分支:节点 → + → 下一节点 -->
|
||||
<template>
|
||||
<div class="flow-branch">
|
||||
<template v-if="node.type === 'end'">
|
||||
<div class="flow-end">流程结束</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div
|
||||
class="flow-node"
|
||||
:class="node.type"
|
||||
@click="emit('edit', node)"
|
||||
>
|
||||
<div class="hd">
|
||||
<span>{{ node.name || typeLabel(node.type) }}</span>
|
||||
<el-button
|
||||
v-if="node.type !== 'start'"
|
||||
class="flow-node__del"
|
||||
text
|
||||
type="danger"
|
||||
@click.stop="emit('remove', node.id)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="bd">{{ nodeSummary(node) }} ›</div>
|
||||
</div>
|
||||
|
||||
<template v-if="node.type === 'condition'">
|
||||
<div class="flow-cond-wrap">
|
||||
<div
|
||||
v-for="(g, idx) in node.conditionGroups || []"
|
||||
:key="`${node.id}_g_${idx}`"
|
||||
class="flow-cond-col"
|
||||
>
|
||||
<div class="flow-cond-col__title" @click.stop="emit('edit', node)">
|
||||
{{ g.name || (g.isDefault ? '默认' : `条件${idx + 1}`) }}
|
||||
<span v-if="g.when" class="muted">{{ g.when }}</span>
|
||||
</div>
|
||||
<FlowBranch
|
||||
v-if="g.child"
|
||||
:node="g.child"
|
||||
:depth="depth + 1"
|
||||
@edit="(n) => emit('edit', n)"
|
||||
@remove="(id) => emit('remove', id)"
|
||||
@add="(payload) => emit('add', payload)"
|
||||
/>
|
||||
<div v-else class="flow-end">流程结束</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<el-dropdown trigger="click" @command="(cmd: string) => onAdd(cmd)">
|
||||
<button type="button" class="flow-plus" title="添加节点">+</button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="approval">审批人</el-dropdown-item>
|
||||
<el-dropdown-item command="cc">抄送人</el-dropdown-item>
|
||||
<el-dropdown-item command="condition">条件分支</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
<FlowBranch
|
||||
v-if="node.child"
|
||||
:node="node.child"
|
||||
:depth="depth"
|
||||
@edit="(n) => emit('edit', n)"
|
||||
@remove="(id) => emit('remove', id)"
|
||||
@add="(payload) => emit('add', payload)"
|
||||
/>
|
||||
<div v-else class="flow-end">流程结束</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Delete } from '@element-plus/icons-vue'
|
||||
import type { FlowNode } from './types'
|
||||
import { summarizeApprover } from './types'
|
||||
// 递归自引用
|
||||
import FlowBranch from './FlowBranch.vue'
|
||||
|
||||
defineOptions({ name: 'OaFlowBranch' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
node: FlowNode
|
||||
depth?: number
|
||||
}>(),
|
||||
{ depth: 0 }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [node: FlowNode]
|
||||
remove: [nodeId: string]
|
||||
add: [payload: { parentId: string; type: 'approval' | 'cc' | 'condition' }]
|
||||
}>()
|
||||
|
||||
function typeLabel(t: string) {
|
||||
if (t === 'start') return '发起人'
|
||||
if (t === 'approval') return '审批人'
|
||||
if (t === 'cc') return '抄送人'
|
||||
if (t === 'condition') return '条件分支'
|
||||
return t
|
||||
}
|
||||
|
||||
function nodeSummary(n: FlowNode) {
|
||||
if (n.type === 'start') return '谁可以发起本审批'
|
||||
if (n.type === 'condition') {
|
||||
const g = n.conditionGroups?.length || 0
|
||||
return `${g} 个分支`
|
||||
}
|
||||
return summarizeApprover(n.approverConfig)
|
||||
}
|
||||
|
||||
function onAdd(cmd: string) {
|
||||
if (cmd === 'approval' || cmd === 'cc' || cmd === 'condition') {
|
||||
emit('add', { parentId: props.node.id, type: cmd })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.flow-branch {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flow-node {
|
||||
width: 220px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
background: #fff;
|
||||
border: 1px solid var(--mint-border, #e2e8f0);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary, #10b981);
|
||||
box-shadow: 0 0 0 3px var(--primary-bg, #ecfdf5);
|
||||
}
|
||||
|
||||
.hd {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 12px;
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.bd {
|
||||
padding: 10px 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&.start .hd {
|
||||
background: #0f766e;
|
||||
}
|
||||
|
||||
&.approval .hd {
|
||||
background: #d97706;
|
||||
}
|
||||
|
||||
&.cc .hd {
|
||||
background: #0891b2;
|
||||
}
|
||||
|
||||
&.condition .hd {
|
||||
background: #7c3aed;
|
||||
}
|
||||
}
|
||||
|
||||
.flow-node__del {
|
||||
padding: 0;
|
||||
color: #fff !important;
|
||||
opacity: 0.85;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.flow-plus {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: 8px 0;
|
||||
color: var(--primary, #10b981);
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
background: #fff;
|
||||
border: 1px solid var(--primary, #10b981);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.flow-end {
|
||||
margin-top: 8px;
|
||||
padding: 6px 16px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 12px;
|
||||
background: #e2e8f0;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.flow-cond-wrap {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: flex-start;
|
||||
width: max-content;
|
||||
margin-top: 8px;
|
||||
padding: 12px;
|
||||
background: #f1f5f9;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.flow-cond-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-width: 240px;
|
||||
}
|
||||
|
||||
.flow-cond-col__title {
|
||||
margin-bottom: 8px;
|
||||
padding: 4px 10px;
|
||||
color: #5b21b6;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
background: #ede9fe;
|
||||
border-radius: 6px;
|
||||
|
||||
.muted {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,186 @@
|
||||
export type FlowNodeType = 'start' | 'approval' | 'cc' | 'condition' | 'end'
|
||||
|
||||
export type AssigneeType =
|
||||
| 'users'
|
||||
| 'oa_roles'
|
||||
| 'dept_leader'
|
||||
| 'direct_supervisor'
|
||||
| 'initiator_select'
|
||||
|
||||
export interface ApproverConfig {
|
||||
assigneeType: AssigneeType
|
||||
userIds?: string[]
|
||||
oaRoleIds?: string[]
|
||||
oaRoleCodes?: string[]
|
||||
signMode?: 'or' | 'and'
|
||||
}
|
||||
|
||||
export interface ConditionGroup {
|
||||
name: string
|
||||
when?: string
|
||||
rules?: unknown[]
|
||||
isDefault?: boolean
|
||||
child: FlowNode | null
|
||||
}
|
||||
|
||||
export interface FlowNode {
|
||||
id: string
|
||||
type: FlowNodeType
|
||||
name: string
|
||||
approverConfig?: ApproverConfig
|
||||
conditionGroups?: ConditionGroup[]
|
||||
child?: FlowNode | null
|
||||
}
|
||||
|
||||
export function newId(prefix = 'n'): string {
|
||||
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`
|
||||
}
|
||||
|
||||
export function createEndNode(): FlowNode {
|
||||
return { id: newId('end'), type: 'end', name: '结束' }
|
||||
}
|
||||
|
||||
export function createDefaultFlow(): FlowNode {
|
||||
return {
|
||||
id: newId('start'),
|
||||
type: 'start',
|
||||
name: '发起人',
|
||||
child: {
|
||||
id: newId('approval'),
|
||||
type: 'approval',
|
||||
name: '审批人',
|
||||
approverConfig: { assigneeType: 'dept_leader', signMode: 'or' },
|
||||
child: createEndNode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createNode(type: 'approval' | 'cc' | 'condition'): FlowNode {
|
||||
if (type === 'approval') {
|
||||
return {
|
||||
id: newId('approval'),
|
||||
type: 'approval',
|
||||
name: '审批人',
|
||||
approverConfig: { assigneeType: 'dept_leader', signMode: 'or' },
|
||||
child: null
|
||||
}
|
||||
}
|
||||
if (type === 'cc') {
|
||||
return {
|
||||
id: newId('cc'),
|
||||
type: 'cc',
|
||||
name: '抄送人',
|
||||
approverConfig: { assigneeType: 'initiator_select' },
|
||||
child: null
|
||||
}
|
||||
}
|
||||
const endA = createEndNode()
|
||||
const endB = createEndNode()
|
||||
return {
|
||||
id: newId('cond'),
|
||||
type: 'condition',
|
||||
name: '条件分支',
|
||||
conditionGroups: [
|
||||
{
|
||||
name: '条件1',
|
||||
when: '',
|
||||
rules: [],
|
||||
isDefault: false,
|
||||
child: endA
|
||||
},
|
||||
{
|
||||
name: '默认',
|
||||
when: '',
|
||||
rules: [],
|
||||
isDefault: true,
|
||||
child: endB
|
||||
}
|
||||
],
|
||||
child: null
|
||||
}
|
||||
}
|
||||
|
||||
export function ensureFlowRoot(raw: unknown): FlowNode {
|
||||
if (raw && typeof raw === 'object' && (raw as FlowNode).type === 'start') {
|
||||
return raw as FlowNode
|
||||
}
|
||||
if (raw && typeof raw === 'object' && (raw as any).root?.type === 'start') {
|
||||
return (raw as any).root as FlowNode
|
||||
}
|
||||
return createDefaultFlow()
|
||||
}
|
||||
|
||||
const ASSIGNEE_LABEL: Record<AssigneeType, string> = {
|
||||
users: '指定成员',
|
||||
oa_roles: '工作流角色',
|
||||
dept_leader: '发起人部门负责人',
|
||||
direct_supervisor: '发起人的主管',
|
||||
initiator_select: '发起人自选'
|
||||
}
|
||||
|
||||
export function summarizeApprover(cfg?: ApproverConfig): string {
|
||||
if (!cfg?.assigneeType) return '未配置审批人'
|
||||
const base = ASSIGNEE_LABEL[cfg.assigneeType] || cfg.assigneeType
|
||||
if (cfg.assigneeType === 'users') {
|
||||
const n = cfg.userIds?.length || 0
|
||||
return n ? `${base}(${n}人)` : `${base}(未选)`
|
||||
}
|
||||
if (cfg.assigneeType === 'oa_roles') {
|
||||
const n = (cfg.oaRoleIds?.length || 0) + (cfg.oaRoleCodes?.length || 0)
|
||||
return n ? `${base}(已选${n})` : `${base}(未选)`
|
||||
}
|
||||
const sign =
|
||||
cfg.signMode === 'and' ? '会签' : cfg.assigneeType === 'initiator_select' ? '' : '或签'
|
||||
return sign ? `${base} · ${sign}` : base
|
||||
}
|
||||
|
||||
/** 在 parent 与其 child 之间插入 newNode */
|
||||
export function insertBetween(parent: FlowNode, newNode: FlowNode): void {
|
||||
const oldChild = parent.child || null
|
||||
newNode.child = oldChild
|
||||
parent.child = newNode
|
||||
}
|
||||
|
||||
/** 删除线性子链上的节点(condition 不可用此简化删除其内部) */
|
||||
export function removeChildNode(parent: FlowNode, nodeId: string): boolean {
|
||||
if (!parent.child) return false
|
||||
if (parent.child.id === nodeId) {
|
||||
parent.child = parent.child.child || null
|
||||
return true
|
||||
}
|
||||
if (parent.child.type === 'condition') {
|
||||
for (const g of parent.child.conditionGroups || []) {
|
||||
if (g.child && removeFromSubtree(g, nodeId)) return true
|
||||
}
|
||||
}
|
||||
return removeChildNode(parent.child, nodeId)
|
||||
}
|
||||
|
||||
function removeFromSubtree(group: ConditionGroup, nodeId: string): boolean {
|
||||
if (!group.child) return false
|
||||
if (group.child.id === nodeId) {
|
||||
if (group.child.type === 'end') return false
|
||||
group.child = group.child.child || createEndNode()
|
||||
return true
|
||||
}
|
||||
return removeChildNode(group.child, nodeId)
|
||||
}
|
||||
|
||||
export function findParent(
|
||||
root: FlowNode,
|
||||
nodeId: string,
|
||||
parent: FlowNode | null = null
|
||||
): FlowNode | null {
|
||||
if (root.id === nodeId) return parent
|
||||
if (root.child) {
|
||||
const p = findParent(root.child, nodeId, root)
|
||||
if (p) return p
|
||||
}
|
||||
for (const g of root.conditionGroups || []) {
|
||||
if (g.child) {
|
||||
const p = findParent(g.child, nodeId, root)
|
||||
if (p) return p
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* 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)
|
||||
}
|
||||
Reference in new issue
Block a user