提交
This commit is contained in:
1 parent
80138c6388
commit
693e8a678e
682 files changed
+211375
-5306
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
export type CnHolidayDay = {
|
||||
dayDate: string
|
||||
dayType: number
|
||||
isRestDay: boolean
|
||||
dayName?: string
|
||||
}
|
||||
|
||||
export function fetchCnHolidayRange(start: string, end: string) {
|
||||
return request.get<{ days: CnHolidayDay[] }>({
|
||||
url: '/cn-holiday/range',
|
||||
params: { start, end }
|
||||
})
|
||||
}
|
||||
@@ -43,10 +43,14 @@
|
||||
<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">{{ u }}</div>
|
||||
<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">{{ row.text || '-' }}</span>
|
||||
<span class="oa-print-text">{{
|
||||
formatOaPrintAttachmentText(row.text || '-')
|
||||
}}</span>
|
||||
</template>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -67,15 +71,16 @@
|
||||
<td class="oa-print-flow__cell">
|
||||
<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 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__person-line"
|
||||
class="oa-print-flow__row oa-print-flow__person-line"
|
||||
>
|
||||
{{ 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">
|
||||
@@ -105,6 +110,7 @@
|
||||
<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' })
|
||||
|
||||
@@ -238,15 +244,18 @@
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.oa-print-flow__left {
|
||||
flex: 1;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.oa-print-flow__right {
|
||||
flex-shrink: 0;
|
||||
flex: 0 0 auto;
|
||||
margin-left: auto;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
@@ -265,6 +274,9 @@
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
<!-- 关联审批单 · 只读详情弹窗(盖在发起表单等弹窗之上) -->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="modelValue"
|
||||
width="920px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
append-to-body
|
||||
modal-class="protocol-dialog-mask"
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
@closed="onClosed"
|
||||
>
|
||||
<template #header>
|
||||
<div class="oa-detail-dlg__header">
|
||||
<span class="oa-detail-dlg__header-title">{{ dialogTitle }}</span>
|
||||
<el-tag v-if="detail?.status" size="small" :type="statusType(detail.status)">
|
||||
{{ statusText(detail.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<div v-loading="loading" class="oa-detail-dlg__body">
|
||||
<section class="oa-detail-dlg__section">
|
||||
<h3>表单内容</h3>
|
||||
<div class="oa-detail-dlg__form-wrap">
|
||||
<form-create
|
||||
v-if="viewRule.length"
|
||||
v-model="viewFormData"
|
||||
:rule="viewRule"
|
||||
:option="viewOption"
|
||||
/>
|
||||
<pre v-else-if="!loading" class="oa-detail-dlg__json">{{ prettyForm }}</pre>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oa-detail-dlg__section oa-detail-dlg__section--progress">
|
||||
<OaProgressChain :items="timelineItems" />
|
||||
</section>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="emit('update:modelValue', false)">
|
||||
<el-icon><Close /></el-icon>
|
||||
关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { Close } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { fetchOaInstanceDetail } from '@/api/oaApproval'
|
||||
import OaProgressChain from '@/components/oa-approval/OaProgressChain.vue'
|
||||
import {
|
||||
OA_FC_DEFAULT_GUTTER,
|
||||
ensureOaUploadRuleProps
|
||||
} from '@/utils/oa-form-create-upload'
|
||||
import { ensureLeaveKitRuleProps } from '@/utils/oa-leave-kit-runtime'
|
||||
import { ensureOvertimeKitRuleProps } from '@/utils/oa-overtime-kit-runtime'
|
||||
import { ensureConfirmationKitVisibility } from '@/utils/oa-confirmation-kit-runtime'
|
||||
import { ensureOwnerFieldRuleProps } from '@/utils/oa-owner-field-defaults'
|
||||
|
||||
defineOptions({ name: 'OaInstanceDetailDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
instanceId: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [boolean]
|
||||
}>()
|
||||
|
||||
const loading = ref(false)
|
||||
const detail = ref<any>(null)
|
||||
const viewFormData = ref<Record<string, any>>({})
|
||||
const viewRule = ref<any[]>([])
|
||||
const viewOption = ref({
|
||||
form: { disabled: true, labelPosition: 'top' },
|
||||
row: { gutter: OA_FC_DEFAULT_GUTTER },
|
||||
submitBtn: false,
|
||||
resetBtn: false
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => detail.value?.title || '审批详情')
|
||||
const prettyForm = computed(() => JSON.stringify(detail.value?.formDataJson || {}, null, 2))
|
||||
|
||||
const timelineItems = computed(() => {
|
||||
const list = detail.value?.progress
|
||||
if (!Array.isArray(list) || !list.length) return []
|
||||
return list
|
||||
.filter((p: any) => {
|
||||
const kind = String(p?.kind || '')
|
||||
const status = String(p?.status || '')
|
||||
const title = String(p?.title || '').trim()
|
||||
if (kind === 'terminal' && (status === 'returned' || title === '已打回')) return false
|
||||
return true
|
||||
})
|
||||
.map((p: any, idx: number) => ({
|
||||
key: `${p.kind}-${p.nodeKey || p.taskId || idx}-${p.roundNo || 1}`,
|
||||
title: p.title || '-',
|
||||
status: p.status || 'info',
|
||||
timestamp: p.timestamp || '',
|
||||
assignee: p.assigneeUserName || p.assigneeUserId || '',
|
||||
resolveSource: p.resolveSource || '',
|
||||
commentText: p.commentText || '',
|
||||
taskType: p.taskType || '',
|
||||
kind: p.kind || '',
|
||||
roundNo: p.roundNo || 1,
|
||||
signMode: p.signMode || '',
|
||||
people: Array.isArray(p.people)
|
||||
? p.people.map((x: any) => ({
|
||||
id: x.id || '',
|
||||
nickName: x.nickName || x.id || '',
|
||||
status: x.status || '',
|
||||
timestamp: x.timestamp || '',
|
||||
commentText: x.commentText || '',
|
||||
taskId: x.taskId || '',
|
||||
transferToUserId: x.transferToUserId || '',
|
||||
transferToUserName: x.transferToUserName || ''
|
||||
}))
|
||||
: []
|
||||
}))
|
||||
})
|
||||
|
||||
function statusType(s: string) {
|
||||
if (s === 'pending' || s === 'running') return 'warning'
|
||||
if (s === 'approved' || s === 'completed' || s === 'done' || s === 'submitted') return 'success'
|
||||
if (s === 'rejected' || s === 'cancelled' || s === 'returned') return 'danger'
|
||||
if (s === 'not_reached') return 'info'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
function statusText(s: string) {
|
||||
const map: Record<string, string> = {
|
||||
pending: '待处理',
|
||||
running: '进行中',
|
||||
approved: '已同意',
|
||||
rejected: '已拒绝',
|
||||
completed: '已完成',
|
||||
cancelled: '已撤销',
|
||||
done: '已结束',
|
||||
submitted: '已提交',
|
||||
not_reached: '未到达',
|
||||
returned: '已打回',
|
||||
transferred: '已转交'
|
||||
}
|
||||
return map[s] || s
|
||||
}
|
||||
|
||||
function applySchema(schema: any, data: any) {
|
||||
viewFormData.value = { ...(data || {}) }
|
||||
const rule = Array.isArray(schema?.rule) ? schema.rule : Array.isArray(schema) ? schema : []
|
||||
viewRule.value = ensureConfirmationKitVisibility(
|
||||
ensureOwnerFieldRuleProps(
|
||||
ensureOvertimeKitRuleProps(ensureLeaveKitRuleProps(ensureOaUploadRuleProps(rule)))
|
||||
)
|
||||
)
|
||||
const savedGutter = Number(schema?.option?.row?.gutter)
|
||||
viewOption.value = {
|
||||
...(schema?.option || {}),
|
||||
form: { ...(schema?.option?.form || {}), disabled: true, labelPosition: 'top' },
|
||||
row: {
|
||||
...(schema?.option?.row || {}),
|
||||
gutter: savedGutter > 0 ? savedGutter : OA_FC_DEFAULT_GUTTER
|
||||
},
|
||||
submitBtn: false,
|
||||
resetBtn: false
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const id = String(props.instanceId || '').trim()
|
||||
if (!id) return
|
||||
loading.value = true
|
||||
detail.value = null
|
||||
viewRule.value = []
|
||||
viewFormData.value = {}
|
||||
try {
|
||||
detail.value = await fetchOaInstanceDetail(id)
|
||||
applySchema(detail.value?.formSchemaJson, detail.value?.formDataJson)
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '加载审批详情失败')
|
||||
emit('update:modelValue', false)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onClosed() {
|
||||
detail.value = null
|
||||
viewRule.value = []
|
||||
viewFormData.value = {}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue, props.instanceId] as const,
|
||||
([visible, id]) => {
|
||||
if (visible && id) void load()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.oa-detail-dlg__header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding-right: 28px;
|
||||
}
|
||||
|
||||
.oa-detail-dlg__header-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--mint-text, #0f172a);
|
||||
}
|
||||
|
||||
.oa-detail-dlg__body {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
.oa-detail-dlg__section {
|
||||
h3 {
|
||||
margin: 8px 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--mint-text, #0f172a);
|
||||
}
|
||||
|
||||
&--progress {
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.oa-detail-dlg__form-wrap {
|
||||
box-sizing: border-box;
|
||||
padding: 4px 0 8px;
|
||||
}
|
||||
|
||||
.oa-detail-dlg__json {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: auto;
|
||||
font-size: 12px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,4 @@
|
||||
<!-- 加班套件:仅组合容器;时长手动填写,无自动计算 -->
|
||||
<!-- 加班套件:组合容器;时长可按起止自动计算,支持手改 -->
|
||||
<template>
|
||||
<div class="oa-overtime-kit" v-bind="$attrs">
|
||||
<slot />
|
||||
@@ -13,6 +13,10 @@
|
||||
startField?: string
|
||||
endField?: string
|
||||
durationField?: string
|
||||
workdayOvertimeStart?: string
|
||||
workdayOvertimeEnd?: string
|
||||
restBreakStart?: string
|
||||
restBreakEnd?: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class="oa-print-related__line"
|
||||
>
|
||||
<span class="oa-print-related__k">{{ line.label }}</span>
|
||||
<span class="oa-print-related__v">{{ line.value }}</span>
|
||||
<span class="oa-print-related__v">{{ formatOaPrintAttachmentText(line.value) }}</span>
|
||||
</div>
|
||||
<div v-if="b.children?.length" class="oa-print-related__children">
|
||||
<OaPrintRelatedTree :blocks="b.children" />
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { RelatedPrintBlock } from '@/utils/oa-approval-print-related'
|
||||
import { formatOaPrintAttachmentText } from '@/utils/oa-upload-file-type'
|
||||
|
||||
defineOptions({ name: 'OaPrintRelatedTree' })
|
||||
|
||||
|
||||
@@ -115,38 +115,94 @@
|
||||
@opened="loadCandidates"
|
||||
>
|
||||
<div class="oa-related-picker">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
clearable
|
||||
placeholder="搜索应用名 / 标题"
|
||||
@keyup.enter="loadCandidates"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="loadCandidates">
|
||||
<el-icon><Search /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-table
|
||||
v-loading="pickerLoading"
|
||||
class="list-table"
|
||||
:data="candidates"
|
||||
stripe
|
||||
max-height="360"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="48" :selectable="rowSelectable" />
|
||||
<el-table-column prop="appName" label="流程名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="title" label="标题" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="applyTime" label="申请时间" min-width="160" />
|
||||
</el-table>
|
||||
<el-empty
|
||||
v-if="!pickerLoading && !candidates.length"
|
||||
description="暂无已通过的申请"
|
||||
:image-size="64"
|
||||
/>
|
||||
<div v-if="pickerTotal > pageSize" class="oa-related-picker__pager">
|
||||
<div class="oa-related-picker__tabs" role="tablist">
|
||||
<button
|
||||
v-for="t in tabOptions"
|
||||
:key="t.value"
|
||||
type="button"
|
||||
class="oa-related-picker__tab"
|
||||
:class="{ 'is-active': activeTab === t.value }"
|
||||
role="tab"
|
||||
@click="onTabChange(t.value)"
|
||||
>
|
||||
{{ t.label }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="oa-related-picker__filters">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
clearable
|
||||
placeholder="搜索流程名 / 标题"
|
||||
@keyup.enter="onSearch"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="onSearch">
|
||||
<el-icon><Search /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<div v-loading="pickerLoading" class="oa-related-picker__list">
|
||||
<div
|
||||
v-for="row in candidates"
|
||||
:key="row.id"
|
||||
class="oa-related-picker__card"
|
||||
:class="{
|
||||
'is-selected': pendingIds.includes(row.id),
|
||||
'is-disabled': !rowSelectable(row)
|
||||
}"
|
||||
@click="togglePending(row)"
|
||||
>
|
||||
<el-checkbox
|
||||
:model-value="pendingIds.includes(row.id)"
|
||||
:disabled="!rowSelectable(row)"
|
||||
@click.stop
|
||||
@change="() => togglePending(row)"
|
||||
/>
|
||||
<div
|
||||
class="oa-related-picker__avatar"
|
||||
:style="{ background: avatarColor(row.initiatorUserName) }"
|
||||
>
|
||||
{{ shortName(row.initiatorUserName) }}
|
||||
</div>
|
||||
<div class="oa-related-picker__main">
|
||||
<div class="oa-related-picker__title">
|
||||
{{ row.displayTitle || row.appName || '审批单' }}
|
||||
</div>
|
||||
<div v-if="row.initiatorDeptName" class="oa-related-picker__meta">
|
||||
部门:{{ row.initiatorDeptName }}
|
||||
</div>
|
||||
<div
|
||||
v-for="(f, i) in (row.previewFields || []).slice(0, 2)"
|
||||
:key="i"
|
||||
class="oa-related-picker__meta"
|
||||
>
|
||||
{{ f.label }}:{{ f.value }}
|
||||
</div>
|
||||
<div class="oa-related-picker__time">{{ row.applyTime }}</div>
|
||||
</div>
|
||||
<div class="oa-related-picker__right" :class="statusClass(row.status)">
|
||||
<template v-if="row.status === 'running'">
|
||||
<div v-if="row.currentApproverNames">
|
||||
{{ row.currentApproverNames }}(审批人)
|
||||
</div>
|
||||
<div>{{ row.statusText || '处理中' }}</div>
|
||||
</template>
|
||||
<template v-else>{{ row.statusText || row.status }}</template>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty
|
||||
v-if="!pickerLoading && !candidates.length"
|
||||
description="暂无审批单"
|
||||
:image-size="64"
|
||||
/>
|
||||
</div>
|
||||
<div class="oa-related-picker__pager">
|
||||
<div class="oa-related-picker__selected">
|
||||
已选 <em>{{ pendingIds.length }}</em> 项
|
||||
</div>
|
||||
<el-pagination
|
||||
v-if="pickerTotal > pageSize"
|
||||
:current-page="page"
|
||||
:page-size="pageSize"
|
||||
layout="prev, pager, next"
|
||||
@@ -166,23 +222,30 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<OaInstanceDetailDialog
|
||||
v-model="detailVisible"
|
||||
:instance-id="detailInstanceId"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Check, Close, Plus, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
fetchOaRelatedCandidates,
|
||||
fetchOaRelatedSummaries,
|
||||
type OaRelatedCandidate,
|
||||
type OaRelatedSummary
|
||||
} from '@/api/oaApproval'
|
||||
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
||||
import OaInstanceDetailDialog from '@/components/oa-approval/OaInstanceDetailDialog.vue'
|
||||
|
||||
defineOptions({ name: 'relatedApproval' })
|
||||
|
||||
const COLLAPSE_FIELD_COUNT = 3
|
||||
const AVATAR_COLORS = ['#3b82f6', '#10b981', '#8b5cf6', '#f59e0b', '#06b6d4', '#ef4444']
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue?: string[] | string | null
|
||||
@@ -195,21 +258,28 @@
|
||||
(e: 'change', v: string[]): void
|
||||
}>()
|
||||
|
||||
const router = useRouter()
|
||||
const expanded = ref(new Set<string>())
|
||||
const summaries = ref<OaRelatedSummary[]>([])
|
||||
const isStack = ref(false)
|
||||
let mql: MediaQueryList | null = null
|
||||
|
||||
const detailVisible = ref(false)
|
||||
const detailInstanceId = ref('')
|
||||
|
||||
const pickerVisible = ref(false)
|
||||
const pickerLoading = ref(false)
|
||||
const keyword = ref('')
|
||||
const page = ref(1)
|
||||
const pageSize = 10
|
||||
const candidates = ref<any[]>([])
|
||||
const candidates = ref<OaRelatedCandidate[]>([])
|
||||
const pickerTotal = ref(0)
|
||||
const pendingIds = ref<string[]>([])
|
||||
|
||||
const activeTab = ref<'mine' | 'done' | 'cc'>('mine')
|
||||
const tabOptions = [
|
||||
{ value: 'mine' as const, label: '我发起的' },
|
||||
{ value: 'done' as const, label: '我审批的' },
|
||||
{ value: 'cc' as const, label: '抄送我的' }
|
||||
]
|
||||
const ids = computed(() => {
|
||||
const raw = props.modelValue
|
||||
if (Array.isArray(raw)) return raw.map((x) => String(x || '').trim()).filter(Boolean)
|
||||
@@ -261,9 +331,13 @@
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
if (!parts.length) return []
|
||||
const looksLikeUrl = parts.every(
|
||||
(p) => /^https?:\/\//i.test(p) || p.startsWith('/') || /\.[a-z0-9]{2,8}(\?|$)/i.test(p)
|
||||
)
|
||||
const looksLikeUrl = parts.every((p) => {
|
||||
if (/^https?:\/\//i.test(p) || p.startsWith('/')) return true
|
||||
// 纯数字/金额小数(如 100.00)不是附件 URL
|
||||
if (/^\d+(\.\d+)?$/.test(p)) return false
|
||||
// 扩展名须含字母,避免把 .00/.56 误判为文件后缀
|
||||
return /\.[a-z][a-z0-9]{0,7}(\?|$)/i.test(p)
|
||||
})
|
||||
return looksLikeUrl ? parts : []
|
||||
}
|
||||
|
||||
@@ -298,11 +372,8 @@
|
||||
|
||||
function goDetail(id: string) {
|
||||
if (!id) return
|
||||
try {
|
||||
router.push({ path: `/system-manage/oa-approval/instances/${id}` })
|
||||
} catch {
|
||||
/* designer iframe may lack router */
|
||||
}
|
||||
detailInstanceId.value = id
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
async function loadSummaries() {
|
||||
@@ -329,6 +400,7 @@
|
||||
|
||||
function openPicker() {
|
||||
if (props.disabled) return
|
||||
activeTab.value = 'mine'
|
||||
keyword.value = ''
|
||||
page.value = 1
|
||||
pendingIds.value = []
|
||||
@@ -339,6 +411,7 @@
|
||||
pickerLoading.value = true
|
||||
try {
|
||||
const res: any = await fetchOaRelatedCandidates({
|
||||
tab: activeTab.value,
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
page: page.value,
|
||||
pageSize
|
||||
@@ -353,12 +426,51 @@
|
||||
}
|
||||
}
|
||||
|
||||
function rowSelectable(row: any) {
|
||||
function onTabChange(tab: 'mine' | 'done' | 'cc') {
|
||||
if (activeTab.value === tab) return
|
||||
activeTab.value = tab
|
||||
page.value = 1
|
||||
pendingIds.value = []
|
||||
void loadCandidates()
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
page.value = 1
|
||||
void loadCandidates()
|
||||
}
|
||||
|
||||
function rowSelectable(row: OaRelatedCandidate) {
|
||||
return !ids.value.includes(String(row?.id || ''))
|
||||
}
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
pendingIds.value = (rows || []).map((r) => String(r.id || '')).filter(Boolean)
|
||||
function togglePending(row: OaRelatedCandidate) {
|
||||
if (!rowSelectable(row)) return
|
||||
const id = String(row.id || '')
|
||||
if (!id) return
|
||||
const idx = pendingIds.value.indexOf(id)
|
||||
if (idx >= 0) pendingIds.value = pendingIds.value.filter((x) => x !== id)
|
||||
else pendingIds.value = [...pendingIds.value, id]
|
||||
}
|
||||
|
||||
function shortName(name?: string) {
|
||||
const s = String(name || '').trim()
|
||||
if (!s) return '?'
|
||||
return s.length <= 2 ? s : s.slice(-2)
|
||||
}
|
||||
|
||||
function avatarColor(name?: string) {
|
||||
const s = String(name || '')
|
||||
let h = 0
|
||||
for (let i = 0; i < s.length; i++) h = (h + s.charCodeAt(i) * 17) % AVATAR_COLORS.length
|
||||
return AVATAR_COLORS[h]
|
||||
}
|
||||
|
||||
function statusClass(status?: string) {
|
||||
const s = String(status || '').trim()
|
||||
if (s === 'completed') return 'is-success'
|
||||
if (s === 'rejected') return 'is-danger'
|
||||
if (s === 'cancelled') return 'is-muted'
|
||||
return 'is-warning'
|
||||
}
|
||||
|
||||
function onPageChange(p: number) {
|
||||
@@ -551,11 +663,168 @@
|
||||
.oa-related-picker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.oa-related-picker__tabs {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
margin: 0 -4px 0;
|
||||
border-bottom: 1px solid var(--mint-border, #e2e8f0);
|
||||
}
|
||||
|
||||
.oa-related-picker__tab {
|
||||
position: relative;
|
||||
height: 40px;
|
||||
padding: 0 14px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.oa-related-picker__tab:hover {
|
||||
color: var(--mint-text, #1e293b);
|
||||
}
|
||||
|
||||
.oa-related-picker__tab.is-active {
|
||||
color: var(--primary-dark, #059669);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.oa-related-picker__tab.is-active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
bottom: 0;
|
||||
left: 10px;
|
||||
height: 2px;
|
||||
border-radius: 1px;
|
||||
background: var(--primary, #10b981);
|
||||
}
|
||||
|
||||
.oa-related-picker__filters {
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.oa-related-picker__list {
|
||||
max-height: 360px;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--mint-border, #e2e8f0);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.oa-related-picker__card {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
|
||||
.oa-related-picker__card:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.oa-related-picker__card:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.oa-related-picker__card.is-selected {
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
}
|
||||
|
||||
.oa-related-picker__card.is-disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.oa-related-picker__avatar {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-top: 2px;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.oa-related-picker__main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.oa-related-picker__title {
|
||||
margin: 0 0 4px;
|
||||
color: var(--mint-text, #1e293b);
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.oa-related-picker__meta {
|
||||
overflow: hidden;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 12.5px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.oa-related-picker__time {
|
||||
margin-top: 6px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.oa-related-picker__right {
|
||||
flex-shrink: 0;
|
||||
min-width: 96px;
|
||||
padding-top: 2px;
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
text-align: right;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.oa-related-picker__right.is-warning {
|
||||
color: #d97706;
|
||||
}
|
||||
|
||||
.oa-related-picker__right.is-success {
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
.oa-related-picker__right.is-danger {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.oa-related-picker__right.is-muted {
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.oa-related-picker__pager {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.oa-related-picker__selected {
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.oa-related-picker__selected em {
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
color: var(--primary-dark, #059669);
|
||||
}
|
||||
</style>
|
||||
@@ -25,6 +25,12 @@
|
||||
恢复转正日期自动计算
|
||||
</el-button>
|
||||
</p>
|
||||
<p v-if="overtimeDurationManualFields.length" class="oa-start__tip">
|
||||
<el-button link type="primary" @click="restoreOvertimeAuto">
|
||||
<el-icon><RefreshRight /></el-icon>
|
||||
恢复加班时长自动计算
|
||||
</el-button>
|
||||
</p>
|
||||
<p v-else-if="!formRule.length && !detailLoading" class="oa-start__tip">
|
||||
该模板暂无表单字段,仍可直接提交。
|
||||
</p>
|
||||
@@ -58,9 +64,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { Check, Close, Document } from '@element-plus/icons-vue'
|
||||
import { Check, Close, Document, RefreshRight } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { fetchUserList } from '@/api/admin'
|
||||
import { fetchCnHolidayRange } from '@/api/cnHoliday'
|
||||
import {
|
||||
fetchCreateOaInstanceDraft,
|
||||
fetchOaFlowPreview,
|
||||
@@ -84,7 +91,11 @@
|
||||
} from '@/utils/oa-leave-kit-runtime'
|
||||
import {
|
||||
applyOvertimeKitDefaults,
|
||||
ensureOvertimeKitRuleProps
|
||||
applyOvertimeKitDurationsToFormData,
|
||||
ensureOvertimeKitRuleProps,
|
||||
listOvertimeKitBindings,
|
||||
markOvertimeDurationManual,
|
||||
OVERTIME_MANUAL_PREFIX
|
||||
} from '@/utils/oa-overtime-kit-runtime'
|
||||
import { applyResignationKitDefaults } from '@/utils/oa-resignation-kit-runtime'
|
||||
import {
|
||||
@@ -146,11 +157,24 @@
|
||||
let tripKitPrevSnapshot: Record<string, unknown> = {}
|
||||
let confirmationKitSyncing = false
|
||||
let confirmationKitPrevSnapshot: Record<string, unknown> = {}
|
||||
let overtimeKitSyncing = false
|
||||
let overtimeKitPrevSnapshot: Record<string, unknown> = {}
|
||||
const overtimeRestMap: Record<string, boolean> = {}
|
||||
|
||||
const confirmationDateManualFields = computed(() =>
|
||||
listManualConfirmationDateFields({ rule: formRule.value }, formData.value)
|
||||
)
|
||||
|
||||
const overtimeDurationManualFields = computed(() => {
|
||||
const fields: string[] = []
|
||||
for (const kit of listOvertimeKitBindings({ rule: formRule.value })) {
|
||||
if (formData.value[OVERTIME_MANUAL_PREFIX + kit.durationField]) {
|
||||
fields.push(kit.durationField)
|
||||
}
|
||||
}
|
||||
return fields
|
||||
})
|
||||
|
||||
function flowNeedsInitiatorSelect(node: any): boolean {
|
||||
if (!node || typeof node !== 'object') return false
|
||||
const cfg = node.approverConfig || {}
|
||||
@@ -219,6 +243,7 @@
|
||||
leaveKitPrevSnapshot = {}
|
||||
tripKitPrevSnapshot = {}
|
||||
confirmationKitPrevSnapshot = {}
|
||||
overtimeKitPrevSnapshot = {}
|
||||
needInitiatorSelect.value = false
|
||||
initiatorSelectByNode.value = {}
|
||||
flowSteps.value = []
|
||||
@@ -274,6 +299,8 @@
|
||||
const linked = applyConfirmationKitDateLinkage({ rule: formRule.value }, data)
|
||||
formData.value = linked.data
|
||||
confirmationKitPrevSnapshot = { ...linked.data }
|
||||
overtimeKitPrevSnapshot = { ...linked.data }
|
||||
void syncOvertimeKitDurations()
|
||||
const flow = detail?.flowTreeJson || {}
|
||||
const root = flow.root || flow
|
||||
needInitiatorSelect.value = flowNeedsInitiatorSelect(root)
|
||||
@@ -338,6 +365,8 @@
|
||||
confirmationKitPrevSnapshot = { ...linked.data }
|
||||
leaveKitPrevSnapshot = { ...formData.value }
|
||||
tripKitPrevSnapshot = { ...formData.value }
|
||||
overtimeKitPrevSnapshot = { ...formData.value }
|
||||
void syncOvertimeKitDurations()
|
||||
const sel = detail?.initiatorSelectByNode
|
||||
initiatorSelectByNode.value =
|
||||
sel && typeof sel === 'object' && !Array.isArray(sel) ? { ...sel } : {}
|
||||
@@ -360,6 +389,8 @@
|
||||
formData.value,
|
||||
(userStore.info || userStore.getUserInfo) as any
|
||||
)
|
||||
overtimeKitPrevSnapshot = { ...formData.value }
|
||||
void syncOvertimeKitDurations()
|
||||
} catch {
|
||||
/* 预填失败仍可手工填 */
|
||||
}
|
||||
@@ -530,12 +561,137 @@
|
||||
})
|
||||
}
|
||||
|
||||
async function ensureOvertimeHolidayRange(startYmd: string, endYmd: string) {
|
||||
const start = String(startYmd || '').trim().slice(0, 10)
|
||||
const end = String(endYmd || '').trim().slice(0, 10)
|
||||
if (!start || !end) return
|
||||
let lo = start
|
||||
let hi = end
|
||||
if (lo > hi) {
|
||||
const t = lo
|
||||
lo = hi
|
||||
hi = t
|
||||
}
|
||||
const begin = new Date(lo + 'T00:00:00')
|
||||
const finish = new Date(hi + 'T00:00:00')
|
||||
if (Number.isNaN(begin.getTime()) || Number.isNaN(finish.getTime())) return
|
||||
|
||||
let allPresent = true
|
||||
for (let d = new Date(begin); d <= finish; d.setDate(d.getDate() + 1)) {
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
const key = `${y}-${m}-${day}`
|
||||
if (!(key in overtimeRestMap)) {
|
||||
allPresent = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (allPresent) return
|
||||
|
||||
try {
|
||||
const res = await fetchCnHolidayRange(lo, hi)
|
||||
const days = res?.days || []
|
||||
for (const day of days) {
|
||||
const key = String(day?.dayDate || '').trim().slice(0, 10)
|
||||
if (!key) continue
|
||||
overtimeRestMap[key] = !!day.isRestDay
|
||||
}
|
||||
} catch {
|
||||
/* 失败保留已有 map,计算回退周末规则 */
|
||||
}
|
||||
}
|
||||
|
||||
function isRestDayResolver(ymd: string): boolean {
|
||||
if (ymd in overtimeRestMap) return overtimeRestMap[ymd]
|
||||
const d = new Date(ymd + 'T00:00:00')
|
||||
const w = d.getDay()
|
||||
return w === 0 || w === 6
|
||||
}
|
||||
|
||||
async function syncOvertimeKitDurations() {
|
||||
if (overtimeKitSyncing) return
|
||||
if (!formRule.value.length) return
|
||||
const schema = { rule: formRule.value }
|
||||
const bindings = listOvertimeKitBindings(schema)
|
||||
if (!bindings.length) return
|
||||
|
||||
overtimeKitSyncing = true
|
||||
try {
|
||||
let minYmd = ''
|
||||
let maxYmd = ''
|
||||
for (const kit of bindings) {
|
||||
for (const field of [kit.startField, kit.endField]) {
|
||||
const ymd = String(formData.value[field] || '')
|
||||
.trim()
|
||||
.slice(0, 10)
|
||||
if (ymd.length < 10) continue
|
||||
if (!minYmd || ymd < minYmd) minYmd = ymd
|
||||
if (!maxYmd || ymd > maxYmd) maxYmd = ymd
|
||||
}
|
||||
}
|
||||
if (minYmd && maxYmd) {
|
||||
await ensureOvertimeHolidayRange(minYmd, maxYmd)
|
||||
}
|
||||
|
||||
const curr = { ...formData.value }
|
||||
for (const kit of bindings) {
|
||||
const prevDur = overtimeKitPrevSnapshot[kit.durationField]
|
||||
const currDur = curr[kit.durationField]
|
||||
const startChanged = overtimeKitPrevSnapshot[kit.startField] !== curr[kit.startField]
|
||||
const endChanged = overtimeKitPrevSnapshot[kit.endField] !== curr[kit.endField]
|
||||
const durChanged = prevDur !== currDur
|
||||
if (
|
||||
durChanged &&
|
||||
!startChanged &&
|
||||
!endChanged &&
|
||||
currDur !== undefined &&
|
||||
currDur !== ''
|
||||
) {
|
||||
Object.assign(curr, markOvertimeDurationManual(curr, kit.durationField, true))
|
||||
}
|
||||
}
|
||||
|
||||
const { data, changed } = applyOvertimeKitDurationsToFormData(
|
||||
schema,
|
||||
curr,
|
||||
isRestDayResolver
|
||||
)
|
||||
overtimeKitPrevSnapshot = { ...data }
|
||||
const manualKeysChanged = bindings.some(
|
||||
(k) =>
|
||||
!!data[OVERTIME_MANUAL_PREFIX + k.durationField] !==
|
||||
!!formData.value[OVERTIME_MANUAL_PREFIX + k.durationField]
|
||||
)
|
||||
const durationChanged = bindings.some(
|
||||
(k) => data[k.durationField] !== formData.value[k.durationField]
|
||||
)
|
||||
if (changed || manualKeysChanged || durationChanged) {
|
||||
formData.value = data
|
||||
}
|
||||
} finally {
|
||||
queueMicrotask(() => {
|
||||
overtimeKitSyncing = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function restoreOvertimeAuto() {
|
||||
let data = { ...formData.value }
|
||||
for (const kit of listOvertimeKitBindings({ rule: formRule.value })) {
|
||||
data = markOvertimeDurationManual(data, kit.durationField, false)
|
||||
}
|
||||
formData.value = data
|
||||
void syncOvertimeKitDurations()
|
||||
}
|
||||
|
||||
watch(
|
||||
formData,
|
||||
() => {
|
||||
syncLeaveKitDurations()
|
||||
syncTripKitDurations()
|
||||
syncConfirmationKitDates()
|
||||
void syncOvertimeKitDurations()
|
||||
scheduleFlowPreview()
|
||||
},
|
||||
{ deep: true }
|
||||
|
||||
@@ -299,7 +299,7 @@
|
||||
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check, UserFilled } from '@element-plus/icons-vue'
|
||||
import { fetchUserList, fetchPostList, fetchDeptTree } from '@/api/admin'
|
||||
import { fetchUserOptions, fetchPostList, fetchDeptTree } from '@/api/admin'
|
||||
import { MAX_ADMIN_LIST_PAGE_SIZE } from '@/utils/fetch-paged-list'
|
||||
import type {
|
||||
ConditionCandidate,
|
||||
@@ -561,22 +561,13 @@
|
||||
async function loadUsers() {
|
||||
userLoading.value = true
|
||||
try {
|
||||
const pageSize = MAX_ADMIN_LIST_PAGE_SIZE
|
||||
const raw: any[] = []
|
||||
let page = 1
|
||||
for (;;) {
|
||||
const res = await fetchUserList({ page, pageSize, status: '1' })
|
||||
const list = res?.list || []
|
||||
raw.push(...list)
|
||||
if (list.length < pageSize) break
|
||||
if (typeof res?.total === 'number' && raw.length >= res.total) break
|
||||
page += 1
|
||||
}
|
||||
userOptions.value = raw.map((u) => ({
|
||||
id: u.id,
|
||||
nickName: u.nickName || '',
|
||||
userNo: u.userNo || ''
|
||||
}))
|
||||
// 轻量 options 接口,避免 /users 列表 N+1 关联补全拖慢设计器
|
||||
const opts = (await fetchUserOptions()) || []
|
||||
userOptions.value = opts.map((o) => ({
|
||||
id: String(o.value || ''),
|
||||
nickName: String(o.label || ''),
|
||||
userNo: ''
|
||||
})).filter((u) => u.id)
|
||||
} finally {
|
||||
userLoading.value = false
|
||||
}
|
||||
|
||||
@@ -17,7 +17,12 @@ import { formatPersonDisplay } from '@/utils/oa-person-value'
|
||||
import { formatPostDisplay } from '@/utils/oa-post-value'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatReceiveAccountDisplay } from '@/utils/oa-receive-account-value'
|
||||
import {
|
||||
formatFormValueDisplay,
|
||||
formatRegionLikeDisplay
|
||||
} from '@/utils/oa-form-value-display'
|
||||
import { toRmbUpper } from '@/utils/rmb-upper'
|
||||
import { formatOaUploadPathsForPrint } from '@/utils/oa-upload-file-type'
|
||||
|
||||
export const OA_PRINT_COMPANY_NAME = '安徽中科兴皖医学研究有限公司'
|
||||
|
||||
@@ -29,19 +34,24 @@ export type OaPrintFieldRow = {
|
||||
label: string
|
||||
/** 普通文本(可含换行) */
|
||||
text?: string
|
||||
/** 附件 / 链接列表 */
|
||||
/** 附件文件名 / 链接列表(上传字段仅文件名) */
|
||||
urls?: string[]
|
||||
/** 关联审批单多行块(优先于 text) */
|
||||
blocks?: RelatedPrintBlock[]
|
||||
}
|
||||
|
||||
export type OaPrintPersonLine = {
|
||||
left: string
|
||||
right: string
|
||||
}
|
||||
|
||||
export type OaPrintFlowItem = {
|
||||
left: string
|
||||
right: string
|
||||
/** @deprecated 多人节点改用 personLines;单人/发起人可保留 */
|
||||
comment?: string
|
||||
/** 或签/会签按人纯文本行 */
|
||||
personLines?: string[]
|
||||
/** 或签/会签按人行:左侧文案 + 右侧时间(右对齐) */
|
||||
personLines?: OaPrintPersonLine[]
|
||||
}
|
||||
|
||||
export type OaPrintModel = {
|
||||
@@ -172,25 +182,7 @@ function extractUrls(value: unknown): string[] {
|
||||
}
|
||||
|
||||
function formatScalar(value: unknown, sep = '、'): string {
|
||||
if (value == null || value === '') return '-'
|
||||
if (typeof value === 'boolean') return value ? '是' : '否'
|
||||
if (typeof value === 'number') return String(value)
|
||||
if (typeof value === 'string') return value.trim() || '-'
|
||||
if (Array.isArray(value)) {
|
||||
if (!value.length) return '-'
|
||||
return value
|
||||
.map((v) => formatScalar(v))
|
||||
.filter((s) => s && s !== '-')
|
||||
.join(sep)
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
try {
|
||||
return JSON.stringify(value)
|
||||
} catch {
|
||||
return String(value)
|
||||
}
|
||||
}
|
||||
return String(value)
|
||||
return formatFormValueDisplay(value, sep)
|
||||
}
|
||||
|
||||
/** 日期/时间区间(FormCreate:日期区间、时间区间等)打印用 ~ 连接起止 */
|
||||
@@ -322,14 +314,26 @@ async function walkRules(
|
||||
continue
|
||||
}
|
||||
|
||||
if (type === 'region' || type === 'cascader') {
|
||||
const text = formatRegionLikeDisplay(value)
|
||||
out.push({ label, text: text || '-' })
|
||||
continue
|
||||
}
|
||||
|
||||
if (type === 'tripItinerary') {
|
||||
out.push({ label, text: formatTripItineraryForPrint(value) })
|
||||
continue
|
||||
}
|
||||
|
||||
if (UPLOAD_TYPES.has(type) || String(rule.name || '').toLowerCase().includes('upload')) {
|
||||
const urls = extractUrls(value)
|
||||
out.push({ label, urls: urls.length ? urls : [], text: urls.length ? undefined : '-' })
|
||||
const dragTag = String(rule._fc_drag_tag || '').trim()
|
||||
if (
|
||||
UPLOAD_TYPES.has(type) ||
|
||||
UPLOAD_TYPES.has(dragTag) ||
|
||||
String(rule.name || '').toLowerCase().includes('upload') ||
|
||||
dragTag.toLowerCase().includes('upload')
|
||||
) {
|
||||
const names = formatOaUploadPathsForPrint(value)
|
||||
out.push({ label, urls: names.length ? names : [], text: names.length ? undefined : '-' })
|
||||
continue
|
||||
}
|
||||
// 字符串里像 URL 列表的也拆开展示
|
||||
@@ -349,21 +353,40 @@ async function walkRules(
|
||||
}
|
||||
}
|
||||
|
||||
function ensurePlainObject(raw: unknown): Record<string, any> {
|
||||
if (raw == null) return {}
|
||||
if (typeof raw === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(raw)
|
||||
return parsed && typeof parsed === 'object' ? (parsed as Record<string, any>) : {}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
if (typeof raw === 'object') return raw as Record<string, any>
|
||||
return {}
|
||||
}
|
||||
|
||||
async function buildFormRows(detail: any): Promise<OaPrintFieldRow[]> {
|
||||
const schema = detail?.formSchemaJson
|
||||
const formData = (detail?.formDataJson || {}) as Record<string, any>
|
||||
const schema = ensurePlainObject(detail?.formSchemaJson)
|
||||
const formData = ensurePlainObject(detail?.formDataJson)
|
||||
const rule = Array.isArray(schema?.rule)
|
||||
? schema.rule
|
||||
: Array.isArray(schema)
|
||||
? schema
|
||||
: Array.isArray(detail?.formSchemaJson)
|
||||
? detail.formSchemaJson
|
||||
: []
|
||||
const out: OaPrintFieldRow[] = []
|
||||
await walkRules(rule, formData, out)
|
||||
if (out.length) return out
|
||||
// schema 缺失:兜底平铺 formData
|
||||
// schema 缺失:兜底平铺 formData(附件路径收成文件名)
|
||||
for (const [k, v] of Object.entries(formData)) {
|
||||
const names = formatOaUploadPathsForPrint(v)
|
||||
if (names.length && extractUrls(v).every((u) => /\/minio\//i.test(u) || /\.[a-z0-9]{2,5}(\?|$)/i.test(u))) {
|
||||
out.push({ label: k, urls: names })
|
||||
continue
|
||||
}
|
||||
const urls = extractUrls(v).filter(isHttpUrl)
|
||||
if (urls.length) out.push({ label: k, urls })
|
||||
if (urls.length) out.push({ label: k, urls: formatOaUploadPathsForPrint(urls) })
|
||||
else out.push({ label: k, text: formatScalar(v) })
|
||||
}
|
||||
return out
|
||||
@@ -380,10 +403,13 @@ function peopleDisplayNames(p: any): string[] {
|
||||
return name ? [name] : []
|
||||
}
|
||||
|
||||
function progressPersonLinesFromItem(p: any): string[] {
|
||||
function progressPersonLinesFromItem(p: any): OaPrintPersonLine[] {
|
||||
const people = Array.isArray(p?.people) ? p.people : []
|
||||
if (!people.length) return []
|
||||
return formatProgressPersonLines(people).map((x) => x.text)
|
||||
return formatProgressPersonLines(people).map((x) => ({
|
||||
left: x.body || x.text,
|
||||
right: x.timestamp || ''
|
||||
}))
|
||||
}
|
||||
|
||||
function isCcProgressItem(p: any): boolean {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
formatFormValueDisplay,
|
||||
formatRegionLikeDisplay,
|
||||
formatUnknownObjectDisplay
|
||||
} from './oa-form-value-display'
|
||||
|
||||
describe('oa-form-value-display', () => {
|
||||
it('formats region path array and object', () => {
|
||||
assert.equal(
|
||||
formatRegionLikeDisplay(['安徽省', '合肥市', '蜀山区']),
|
||||
'安徽省 / 合肥市 / 蜀山区'
|
||||
)
|
||||
assert.equal(
|
||||
formatRegionLikeDisplay({
|
||||
province: '安徽省',
|
||||
city: '合肥市',
|
||||
district: '蜀山区'
|
||||
}),
|
||||
'安徽省 / 合肥市 / 蜀山区'
|
||||
)
|
||||
})
|
||||
|
||||
it('never JSON.stringifies unknown objects', () => {
|
||||
const text = formatFormValueDisplay({
|
||||
foo: 1,
|
||||
bar: 'baz',
|
||||
id: 'hidden',
|
||||
durationManual: true
|
||||
})
|
||||
assert.equal(text.includes('{'), false)
|
||||
assert.equal(text.includes('hidden'), false)
|
||||
assert.ok(text.includes('baz'))
|
||||
})
|
||||
|
||||
it('formats trip-like object without dumping keys', () => {
|
||||
const text = formatUnknownObjectDisplay({
|
||||
transport: '汽车',
|
||||
fromCity: '合肥',
|
||||
toCity: '上海',
|
||||
durationManual: false
|
||||
})
|
||||
assert.ok(text.includes('合肥 → 上海'))
|
||||
assert.equal(text.includes('durationManual'), false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* OA 表单值可读化(打印 / 摘要兜底)
|
||||
* 禁止把对象直接 JSON.stringify 到界面。
|
||||
*/
|
||||
|
||||
export function formatRegionLikeDisplay(value: unknown): string {
|
||||
if (value == null || value === '') return ''
|
||||
if (typeof value === 'string') return value.trim()
|
||||
if (Array.isArray(value)) {
|
||||
const parts = value
|
||||
.map((x) => {
|
||||
if (x == null || x === '') return ''
|
||||
if (typeof x === 'object') {
|
||||
const o = x as Record<string, unknown>
|
||||
return String(o.label || o.name || o.text || o.value || '').trim()
|
||||
}
|
||||
return String(x).trim()
|
||||
})
|
||||
.filter(Boolean)
|
||||
return parts.join(' / ')
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
const o = value as Record<string, unknown>
|
||||
const path = [
|
||||
String(o.province || o.provinceName || o.province_name || '').trim(),
|
||||
String(o.city || o.cityName || o.city_name || '').trim(),
|
||||
String(
|
||||
o.district || o.districtName || o.area || o.areaName || o.district_name || ''
|
||||
).trim()
|
||||
].filter(Boolean)
|
||||
if (path.length) return path.join(' / ')
|
||||
return formatUnknownObjectDisplay(o)
|
||||
}
|
||||
return String(value).trim()
|
||||
}
|
||||
|
||||
export function formatUnknownObjectDisplay(raw: Record<string, unknown>): string {
|
||||
const named = String(raw.label || raw.name || raw.text || raw.value || '').trim()
|
||||
if (named) return named
|
||||
|
||||
if (raw.accountType || raw.accountNo || raw.accountName) {
|
||||
const parts = [
|
||||
String(raw.accountType || '').trim(),
|
||||
String(raw.accountName || '').trim(),
|
||||
String(raw.accountNo || '').trim()
|
||||
].filter(Boolean)
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
if (raw.fromCity || raw.toCity || raw.transport) {
|
||||
const fromCity = String(raw.fromCity || '').trim() || '-'
|
||||
const toCity = String(raw.toCity || '').trim() || '-'
|
||||
const transport = String(raw.transport || '').trim()
|
||||
const tripType = String(raw.tripType || '').trim()
|
||||
const bits = [
|
||||
transport,
|
||||
tripType,
|
||||
`${fromCity} → ${toCity}`
|
||||
].filter(Boolean)
|
||||
return bits.join(' · ')
|
||||
}
|
||||
|
||||
const skip = new Set(['id', 'uuid', 'key', 'durationManual', 'manual'])
|
||||
const parts: string[] = []
|
||||
for (const [k, v] of Object.entries(raw)) {
|
||||
if (skip.has(k) || k.startsWith('__') || /id$/i.test(k)) continue
|
||||
if (typeof v === 'boolean' || v == null || v === '') continue
|
||||
if (typeof v === 'string' || typeof v === 'number') {
|
||||
parts.push(String(v).trim())
|
||||
}
|
||||
}
|
||||
return parts.filter(Boolean).join('、')
|
||||
}
|
||||
|
||||
/** 标量/数组/对象统一可读化;对象绝不 JSON.stringify */
|
||||
export function formatFormValueDisplay(value: unknown, sep = '、'): string {
|
||||
if (value == null || value === '') return '-'
|
||||
if (typeof value === 'boolean') return value ? '是' : '否'
|
||||
if (typeof value === 'number') return String(value)
|
||||
if (typeof value === 'string') return value.trim() || '-'
|
||||
if (Array.isArray(value)) {
|
||||
if (!value.length) return '-'
|
||||
const parts = value
|
||||
.map((v) => formatFormValueDisplay(v, sep))
|
||||
.filter((s) => s && s !== '-')
|
||||
return parts.length ? parts.join(sep) : '-'
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
const text = formatUnknownObjectDisplay(value as Record<string, unknown>)
|
||||
return text || '-'
|
||||
}
|
||||
return String(value)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
calcOvertimeHours,
|
||||
DEFAULT_OVERTIME_WINDOWS,
|
||||
type RestDayResolver
|
||||
} from './oa-overtime-hours'
|
||||
|
||||
/** 固定:2026-08-07 周五工作日,08-08 周六休息日 */
|
||||
const restMap: Record<string, boolean> = {
|
||||
'2026-08-07': false,
|
||||
'2026-08-08': true,
|
||||
'2026-08-09': true
|
||||
}
|
||||
function isRestDay(ymd: string): boolean {
|
||||
if (ymd in restMap) return restMap[ymd]
|
||||
const d = new Date(ymd + 'T00:00:00')
|
||||
const w = d.getDay()
|
||||
return w === 0 || w === 6
|
||||
}
|
||||
|
||||
describe('calcOvertimeHours', () => {
|
||||
const w = DEFAULT_OVERTIME_WINDOWS
|
||||
|
||||
it('weekday 18:00-20:00 => 2.0', () => {
|
||||
assert.equal(
|
||||
calcOvertimeHours('2026-08-07 18:00', '2026-08-07 20:00', w, isRestDay),
|
||||
2.0
|
||||
)
|
||||
})
|
||||
|
||||
it('weekday 14:00-18:00 => 0.5', () => {
|
||||
assert.equal(
|
||||
calcOvertimeHours('2026-08-07 14:00', '2026-08-07 18:00', w, isRestDay),
|
||||
0.5
|
||||
)
|
||||
})
|
||||
|
||||
it('weekday 17:30 to next 08:30 => 15.0', () => {
|
||||
assert.equal(
|
||||
calcOvertimeHours('2026-08-07 17:30', '2026-08-08 08:30', w, isRestDay),
|
||||
15.0
|
||||
)
|
||||
})
|
||||
|
||||
it('Saturday 09:00-15:00 => 4.0', () => {
|
||||
assert.equal(
|
||||
calcOvertimeHours('2026-08-08 09:00', '2026-08-08 15:00', w, isRestDay),
|
||||
4.0
|
||||
)
|
||||
})
|
||||
|
||||
it('Fri 18:00 - Sat 12:00 => 17.5', () => {
|
||||
assert.equal(
|
||||
calcOvertimeHours('2026-08-07 18:00', '2026-08-08 12:00', w, isRestDay),
|
||||
17.5
|
||||
)
|
||||
})
|
||||
|
||||
it('end <= start => null', () => {
|
||||
assert.equal(
|
||||
calcOvertimeHours('2026-08-07 20:00', '2026-08-07 18:00', w, isRestDay),
|
||||
null
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,200 @@
|
||||
/** 加班套件:工作日/休息日窗口重叠小时数(与 backend oa_overtime_hours 对齐) */
|
||||
|
||||
export type OvertimeWindows = {
|
||||
workdayOvertimeStart: string
|
||||
workdayOvertimeEnd: string
|
||||
restBreakStart: string
|
||||
restBreakEnd: string
|
||||
}
|
||||
|
||||
export const DEFAULT_OVERTIME_WINDOWS: OvertimeWindows = {
|
||||
workdayOvertimeStart: '17:30',
|
||||
workdayOvertimeEnd: '08:30',
|
||||
restBreakStart: '11:30',
|
||||
restBreakEnd: '13:30'
|
||||
}
|
||||
|
||||
export type RestDayResolver = (ymd: string) => boolean
|
||||
|
||||
const DT_RE = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})$/
|
||||
|
||||
type Interval = [number, number]
|
||||
|
||||
function parseHm(hm: string): number | null {
|
||||
const m = String(hm || '')
|
||||
.trim()
|
||||
.match(/^(\d{1,2}):(\d{2})$/)
|
||||
if (!m) return null
|
||||
const h = Number(m[1])
|
||||
const min = Number(m[2])
|
||||
if (h < 0 || h > 23 || min < 0 || min > 59) return null
|
||||
return h * 60 + min
|
||||
}
|
||||
|
||||
function parseDt(s: string): Date | null {
|
||||
const m = String(s || '')
|
||||
.trim()
|
||||
.match(DT_RE)
|
||||
if (!m) return null
|
||||
const d = new Date(
|
||||
Number(m[1]),
|
||||
Number(m[2]) - 1,
|
||||
Number(m[3]),
|
||||
Number(m[4]),
|
||||
Number(m[5]),
|
||||
0,
|
||||
0
|
||||
)
|
||||
return Number.isNaN(d.getTime()) ? null : d
|
||||
}
|
||||
|
||||
function formatYmd(d: Date): string {
|
||||
const y = d.getFullYear()
|
||||
const mo = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const da = String(d.getDate()).padStart(2, '0')
|
||||
return `${y}-${mo}-${da}`
|
||||
}
|
||||
|
||||
function dayStartMs(d: Date): number {
|
||||
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime()
|
||||
}
|
||||
|
||||
function dayAtMinutes(d: Date, minutes: number): number {
|
||||
return dayStartMs(d) + minutes * 60000
|
||||
}
|
||||
|
||||
function mergeIntervals(intervals: Interval[]): Interval[] {
|
||||
if (intervals.length === 0) return []
|
||||
const sorted = [...intervals].sort((a, b) => a[0] - b[0])
|
||||
const merged: Interval[] = [[sorted[0][0], sorted[0][1]]]
|
||||
for (let i = 1; i < sorted.length; i++) {
|
||||
const last = merged[merged.length - 1]
|
||||
const [s, e] = sorted[i]
|
||||
if (s <= last[1]) {
|
||||
last[1] = Math.max(last[1], e)
|
||||
} else {
|
||||
merged.push([s, e])
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
function intersectInterval(a: Interval, b: Interval): Interval | null {
|
||||
const lo = Math.max(a[0], b[0])
|
||||
const hi = Math.min(a[1], b[1])
|
||||
return hi > lo ? [lo, hi] : null
|
||||
}
|
||||
|
||||
function subtractInterval(base: Interval, sub: Interval): Interval[] {
|
||||
const [bs, be] = base
|
||||
const [ss, se] = sub
|
||||
if (se <= bs || ss >= be) return [base]
|
||||
const out: Interval[] = []
|
||||
if (ss > bs) out.push([bs, ss])
|
||||
if (se < be) out.push([se, be])
|
||||
return out
|
||||
}
|
||||
|
||||
function subtractIntervals(base: Interval, subs: Interval[]): Interval[] {
|
||||
let result: Interval[] = [base]
|
||||
for (const sub of subs) {
|
||||
const next: Interval[] = []
|
||||
for (const r of result) {
|
||||
next.push(...subtractInterval(r, sub))
|
||||
}
|
||||
result = next
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function intervalMinutes(intervals: Interval[]): number {
|
||||
return intervals.reduce((sum, [a, b]) => sum + (b - a) / 60000, 0)
|
||||
}
|
||||
|
||||
function buildWorkdayWindows(
|
||||
anchorDay: Date,
|
||||
windows: OvertimeWindows
|
||||
): Interval | null {
|
||||
const startMin = parseHm(windows.workdayOvertimeStart)
|
||||
const endMin = parseHm(windows.workdayOvertimeEnd)
|
||||
if (startMin == null || endMin == null) return null
|
||||
|
||||
const anchorStart = dayAtMinutes(anchorDay, startMin)
|
||||
const nextDay = new Date(anchorDay)
|
||||
nextDay.setDate(nextDay.getDate() + 1)
|
||||
const anchorEnd = dayAtMinutes(nextDay, endMin)
|
||||
if (anchorEnd <= anchorStart) return null
|
||||
return [anchorStart, anchorEnd]
|
||||
}
|
||||
|
||||
function buildRestDaySegments(day: Date, windows: OvertimeWindows): Interval[] {
|
||||
const breakStart = parseHm(windows.restBreakStart)
|
||||
const breakEnd = parseHm(windows.restBreakEnd)
|
||||
if (breakStart == null || breakEnd == null) return []
|
||||
|
||||
const day0 = dayStartMs(day)
|
||||
const nextDay = new Date(day)
|
||||
nextDay.setDate(nextDay.getDate() + 1)
|
||||
const dayEnd = dayStartMs(nextDay)
|
||||
|
||||
const segments: Interval[] = []
|
||||
if (breakStart > 0) segments.push([day0, dayAtMinutes(day, breakStart)])
|
||||
if (breakEnd < 24 * 60) segments.push([dayAtMinutes(day, breakEnd), dayEnd])
|
||||
return segments.filter(([a, b]) => b > a)
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算加班时长(小时,1 位小数)。
|
||||
* end <= start 或非法输入返回 null。
|
||||
*/
|
||||
export function calcOvertimeHours(
|
||||
startStr: string,
|
||||
endStr: string,
|
||||
windows: OvertimeWindows = DEFAULT_OVERTIME_WINDOWS,
|
||||
isRestDay: RestDayResolver
|
||||
): number | null {
|
||||
const start = parseDt(startStr)
|
||||
const end = parseDt(endStr)
|
||||
if (!start || !end || end.getTime() <= start.getTime()) return null
|
||||
|
||||
const query: Interval = [start.getTime(), end.getTime()]
|
||||
const startDay = new Date(start.getFullYear(), start.getMonth(), start.getDate())
|
||||
const endDay = new Date(end.getFullYear(), end.getMonth(), end.getDate())
|
||||
|
||||
const workdayIntervals: Interval[] = []
|
||||
const anchor = new Date(startDay)
|
||||
anchor.setDate(anchor.getDate() - 1)
|
||||
const lastAnchor = new Date(endDay)
|
||||
while (anchor.getTime() <= lastAnchor.getTime()) {
|
||||
const ymd = formatYmd(anchor)
|
||||
if (!isRestDay(ymd)) {
|
||||
const win = buildWorkdayWindows(anchor, windows)
|
||||
if (win) {
|
||||
const hit = intersectInterval(win, query)
|
||||
if (hit) workdayIntervals.push(hit)
|
||||
}
|
||||
}
|
||||
anchor.setDate(anchor.getDate() + 1)
|
||||
}
|
||||
|
||||
const workdayMerged = mergeIntervals(workdayIntervals)
|
||||
|
||||
const restIntervals: Interval[] = []
|
||||
const day = new Date(startDay)
|
||||
while (day.getTime() <= endDay.getTime()) {
|
||||
const ymd = formatYmd(day)
|
||||
if (isRestDay(ymd)) {
|
||||
for (const seg of buildRestDaySegments(day, windows)) {
|
||||
const hit = intersectInterval(seg, query)
|
||||
if (hit) {
|
||||
const remaining = subtractIntervals(hit, workdayMerged)
|
||||
restIntervals.push(...remaining)
|
||||
}
|
||||
}
|
||||
}
|
||||
day.setDate(day.getDate() + 1)
|
||||
}
|
||||
|
||||
const totalMinutes = intervalMinutes(workdayMerged) + intervalMinutes(restIntervals)
|
||||
return Math.round((totalMinutes / 60) * 10) / 10
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { DEFAULT_OVERTIME_WINDOWS } from '@/utils/oa-overtime-hours'
|
||||
|
||||
/** FormCreate Designer DragRule:加班套件 */
|
||||
|
||||
let _uidSeq = 0
|
||||
@@ -66,7 +68,7 @@ function buildOvertimeKitChildren() {
|
||||
type: 'inputNumber',
|
||||
field: durationField,
|
||||
title: '时长(h)',
|
||||
info: '请手动填写加班时长',
|
||||
info: '可根据起止时间自动计算,支持手改',
|
||||
$required: true,
|
||||
props: {
|
||||
_fc_kit_field: 'overtimeDuration',
|
||||
@@ -97,6 +99,7 @@ export const overtimeKitDragRule = {
|
||||
return {
|
||||
type: 'overtimeKit',
|
||||
props: {
|
||||
...DEFAULT_OVERTIME_WINDOWS,
|
||||
personField: built.personField,
|
||||
startField: built.startField,
|
||||
endField: built.endField,
|
||||
@@ -106,6 +109,35 @@ export const overtimeKitDragRule = {
|
||||
}
|
||||
},
|
||||
props() {
|
||||
return []
|
||||
return [
|
||||
{
|
||||
type: 'input',
|
||||
field: 'workdayOvertimeStart',
|
||||
title: '工作日加班起',
|
||||
value: DEFAULT_OVERTIME_WINDOWS.workdayOvertimeStart,
|
||||
props: { placeholder: 'HH:mm' }
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: 'workdayOvertimeEnd',
|
||||
title: '工作日加班止(次日)',
|
||||
value: DEFAULT_OVERTIME_WINDOWS.workdayOvertimeEnd,
|
||||
props: { placeholder: 'HH:mm' }
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: 'restBreakStart',
|
||||
title: '休息日午休起',
|
||||
value: DEFAULT_OVERTIME_WINDOWS.restBreakStart,
|
||||
props: { placeholder: 'HH:mm' }
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: 'restBreakEnd',
|
||||
title: '休息日午休止',
|
||||
value: DEFAULT_OVERTIME_WINDOWS.restBreakEnd,
|
||||
props: { placeholder: 'HH:mm' }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
/** 加班套件运行时:时长仅手动填写,补齐数字框左对齐;加班人默认当前登录人 */
|
||||
/** 加班套件运行时:时长可按起止自动计算,支持手改;加班人默认当前登录人 */
|
||||
|
||||
import {
|
||||
buildCurrentOwnerPerson,
|
||||
type OwnerUserSnapshot
|
||||
} from '@/utils/oa-owner-field-defaults'
|
||||
import {
|
||||
calcOvertimeHours,
|
||||
DEFAULT_OVERTIME_WINDOWS,
|
||||
type OvertimeWindows,
|
||||
type RestDayResolver
|
||||
} from '@/utils/oa-overtime-hours'
|
||||
|
||||
export const OVERTIME_MANUAL_PREFIX = '__manual_'
|
||||
|
||||
function asRules(schema: unknown): Record<string, unknown>[] {
|
||||
if (Array.isArray(schema)) return schema.filter((r) => r && typeof r === 'object') as any
|
||||
@@ -29,16 +37,22 @@ function walk(rules: Record<string, unknown>[], out: Record<string, unknown>[])
|
||||
|
||||
export type OvertimeKitBinding = {
|
||||
personField?: string
|
||||
durationField?: string
|
||||
startField: string
|
||||
endField: string
|
||||
durationField: string
|
||||
windows: OvertimeWindows
|
||||
}
|
||||
|
||||
function resolveBinding(kit: Record<string, unknown>): OvertimeKitBinding {
|
||||
function resolveBinding(kit: Record<string, unknown>): OvertimeKitBinding | null {
|
||||
const props = (kit.props && typeof kit.props === 'object' ? kit.props : {}) as Record<
|
||||
string,
|
||||
any
|
||||
>
|
||||
let personField = props.personField ? String(props.personField) : undefined
|
||||
let startField = props.startField ? String(props.startField) : undefined
|
||||
let endField = props.endField ? String(props.endField) : undefined
|
||||
let durationField = props.durationField ? String(props.durationField) : undefined
|
||||
|
||||
const children = (
|
||||
Array.isArray(kit.children)
|
||||
? kit.children
|
||||
@@ -46,19 +60,66 @@ function resolveBinding(kit: Record<string, unknown>): OvertimeKitBinding {
|
||||
? props.rule
|
||||
: []
|
||||
) as Record<string, any>[]
|
||||
|
||||
for (const c of children) {
|
||||
if (!c?.field) continue
|
||||
const sem = String(c.props?._fc_kit_field || '')
|
||||
if (sem === 'overtimePerson' && !personField) personField = String(c.field)
|
||||
if (sem === 'overtimeStart' && !startField) startField = String(c.field)
|
||||
if (sem === 'overtimeEnd' && !endField) endField = String(c.field)
|
||||
if (sem === 'overtimeDuration' && !durationField) durationField = String(c.field)
|
||||
}
|
||||
return { personField, durationField }
|
||||
|
||||
if (!startField || !endField || !durationField) {
|
||||
const dateFields: string[] = []
|
||||
let dur: string | undefined
|
||||
for (const c of children) {
|
||||
if (!c?.field) continue
|
||||
const t = String(c.type || '')
|
||||
if (t === 'datePicker' || t === 'date' || t === 'timePicker' || t === 'time') {
|
||||
dateFields.push(String(c.field))
|
||||
} else if (
|
||||
(t === 'inputNumber' || t === 'number') &&
|
||||
(String(c.title || '').includes('时长') || String(c.props?._fc_kit_field || '') === 'overtimeDuration')
|
||||
) {
|
||||
dur = String(c.field)
|
||||
}
|
||||
}
|
||||
startField = startField || dateFields[0]
|
||||
endField = endField || dateFields[1]
|
||||
durationField = durationField || dur
|
||||
}
|
||||
|
||||
if (!startField || !endField || !durationField) return null
|
||||
|
||||
return {
|
||||
personField,
|
||||
startField,
|
||||
endField,
|
||||
durationField,
|
||||
windows: {
|
||||
workdayOvertimeStart: String(
|
||||
props.workdayOvertimeStart || DEFAULT_OVERTIME_WINDOWS.workdayOvertimeStart
|
||||
),
|
||||
workdayOvertimeEnd: String(
|
||||
props.workdayOvertimeEnd || DEFAULT_OVERTIME_WINDOWS.workdayOvertimeEnd
|
||||
),
|
||||
restBreakStart: String(props.restBreakStart || DEFAULT_OVERTIME_WINDOWS.restBreakStart),
|
||||
restBreakEnd: String(props.restBreakEnd || DEFAULT_OVERTIME_WINDOWS.restBreakEnd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function listOvertimeKitBindings(schema: unknown): OvertimeKitBinding[] {
|
||||
const flat: Record<string, unknown>[] = []
|
||||
walk(asRules(schema), flat)
|
||||
return flat.filter((r) => String(r.type || '') === 'overtimeKit').map(resolveBinding)
|
||||
const out: OvertimeKitBinding[] = []
|
||||
for (const r of flat) {
|
||||
if (String(r.type || '') !== 'overtimeKit') continue
|
||||
const b = resolveBinding(r)
|
||||
if (b) out.push(b)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function isEmptyPersonValue(raw: unknown): boolean {
|
||||
@@ -91,28 +152,57 @@ export function applyOvertimeKitDefaults(
|
||||
return data
|
||||
}
|
||||
|
||||
function resolveDurationField(kit: Record<string, unknown>): string | undefined {
|
||||
const binding = resolveBinding(kit)
|
||||
if (binding.durationField) return binding.durationField
|
||||
const props = (kit.props && typeof kit.props === 'object' ? kit.props : {}) as Record<
|
||||
string,
|
||||
any
|
||||
>
|
||||
const children = (
|
||||
Array.isArray(kit.children)
|
||||
? kit.children
|
||||
: Array.isArray(props.rule)
|
||||
? props.rule
|
||||
: []
|
||||
) as Record<string, any>[]
|
||||
for (const c of children) {
|
||||
if (!c?.field) continue
|
||||
const t = String(c.type || '')
|
||||
if ((t === 'inputNumber' || t === 'number') && String(c.title || '').includes('时长')) {
|
||||
return String(c.field)
|
||||
/** 未手改时写回时长;返回是否有变更 */
|
||||
export function applyOvertimeKitDurationsToFormData(
|
||||
schema: unknown,
|
||||
formData: Record<string, unknown>,
|
||||
isRestDay: RestDayResolver
|
||||
): { data: Record<string, unknown>; changed: boolean } {
|
||||
const data = { ...formData }
|
||||
let changed = false
|
||||
for (const kit of listOvertimeKitBindings(schema)) {
|
||||
const manualKey = OVERTIME_MANUAL_PREFIX + kit.durationField
|
||||
if (data[manualKey]) continue
|
||||
const hours = calcOvertimeHours(
|
||||
String(data[kit.startField] || ''),
|
||||
String(data[kit.endField] || ''),
|
||||
kit.windows,
|
||||
isRestDay
|
||||
)
|
||||
if (hours == null) continue
|
||||
if (data[kit.durationField] !== hours) {
|
||||
data[kit.durationField] = hours
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
return { data, changed }
|
||||
}
|
||||
|
||||
export function markOvertimeDurationManual(
|
||||
formData: Record<string, unknown>,
|
||||
durationField: string,
|
||||
manual = true
|
||||
) {
|
||||
const data = { ...formData }
|
||||
const key = OVERTIME_MANUAL_PREFIX + durationField
|
||||
if (manual) data[key] = true
|
||||
else delete data[key]
|
||||
return data
|
||||
}
|
||||
|
||||
export function isOvertimeDurationField(schema: unknown, field: string): boolean {
|
||||
return listOvertimeKitBindings(schema).some((k) => k.durationField === field)
|
||||
}
|
||||
|
||||
export function findOvertimeKitByStartOrEnd(
|
||||
schema: unknown,
|
||||
field: string
|
||||
): OvertimeKitBinding | null {
|
||||
return (
|
||||
listOvertimeKitBindings(schema).find(
|
||||
(k) => k.startField === field || k.endField === field
|
||||
) || null
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,14 +214,14 @@ export function ensureOvertimeKitRuleProps(rules: unknown): any[] {
|
||||
if (!raw || typeof raw !== 'object') return raw
|
||||
const rule: any = { ...(raw as object) }
|
||||
if (String(rule.type || '') === 'overtimeKit') {
|
||||
const durationField = resolveDurationField(rule)
|
||||
const binding = resolveBinding(rule)
|
||||
const patchChildren = (list: any[]): any[] =>
|
||||
list.map((c) => {
|
||||
if (!c || typeof c !== 'object') return c
|
||||
const child: any = { ...c }
|
||||
const t = String(child.type || '')
|
||||
const isDuration =
|
||||
(durationField && child.field === durationField) ||
|
||||
(binding && child.field === binding.durationField) ||
|
||||
((t === 'inputNumber' || t === 'number') &&
|
||||
String(child.title || '').includes('时长'))
|
||||
if (isDuration) {
|
||||
|
||||
@@ -19,8 +19,13 @@ export type ProgressPersonInput = {
|
||||
export type PersonLineTone = 'ok' | 'pending' | 'danger' | 'mute' | ''
|
||||
|
||||
export type ProgressPersonLine = {
|
||||
/** 完整一行(含时间),详情页等纯文本场景用 */
|
||||
text: string
|
||||
tone: PersonLineTone
|
||||
/** 不含时间的主体,打印右对齐时间用 */
|
||||
body: string
|
||||
/** 审批时间(可空) */
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
const ACTED_STATUS = new Set(['approved', 'rejected', 'returned', 'completed', 'transferred'])
|
||||
@@ -52,6 +57,21 @@ function toneForStatus(status: string): PersonLineTone {
|
||||
return ''
|
||||
}
|
||||
|
||||
function pushLine(
|
||||
out: ProgressPersonLine[],
|
||||
body: string,
|
||||
timestamp: string,
|
||||
tone: PersonLineTone
|
||||
) {
|
||||
const ts = String(timestamp || '').trim()
|
||||
out.push({
|
||||
body,
|
||||
timestamp: ts,
|
||||
text: ts ? `${body} ${ts}` : body,
|
||||
tone
|
||||
})
|
||||
}
|
||||
|
||||
/** 将 progress.people 格式化为「姓名 意见/状态 时间」纯文本行 */
|
||||
export function formatProgressPersonLines(
|
||||
people: ProgressPersonInput[] | null | undefined
|
||||
@@ -67,7 +87,7 @@ export function formatProgressPersonLines(
|
||||
const tone = toneForStatus(status)
|
||||
|
||||
if (status === 'done') {
|
||||
out.push({ text: `${name} 无需处理`, tone: 'mute' })
|
||||
pushLine(out, `${name} 无需处理`, '', 'mute')
|
||||
continue
|
||||
}
|
||||
if (status === 'transferred') {
|
||||
@@ -77,34 +97,25 @@ export function formatProgressPersonLines(
|
||||
? `转交给${target} ${comment}`
|
||||
: `转交给${target}`
|
||||
: comment || statusFallbackLabel('transferred')
|
||||
out.push({
|
||||
text: ts ? `${name} ${mid} ${ts}` : `${name} ${mid}`,
|
||||
tone: 'mute'
|
||||
})
|
||||
pushLine(out, `${name} ${mid}`, ts, 'mute')
|
||||
continue
|
||||
}
|
||||
if (status === 'pending' || status === 'running' || status === 'not_reached' || !status) {
|
||||
// 无 status 时:若有意见/时间仍按已处理拼;否则待处理
|
||||
if (!status && (comment || ts)) {
|
||||
const mid = comment || statusFallbackLabel('approved')
|
||||
out.push({
|
||||
text: ts ? `${name} ${mid} ${ts}` : `${name} ${mid}`,
|
||||
tone: 'ok'
|
||||
})
|
||||
pushLine(out, `${name} ${mid}`, ts, 'ok')
|
||||
continue
|
||||
}
|
||||
out.push({ text: `${name} 待处理`, tone: 'pending' })
|
||||
pushLine(out, `${name} 待处理`, '', 'pending')
|
||||
continue
|
||||
}
|
||||
if (ACTED_STATUS.has(status) || comment || ts) {
|
||||
const mid = comment || statusFallbackLabel(status)
|
||||
out.push({
|
||||
text: ts ? `${name} ${mid} ${ts}` : `${name} ${mid}`,
|
||||
tone: tone || 'ok'
|
||||
})
|
||||
pushLine(out, `${name} ${mid}`, ts, tone || 'ok')
|
||||
continue
|
||||
}
|
||||
out.push({ text: `${name} 待处理`, tone: 'pending' })
|
||||
pushLine(out, `${name} 待处理`, '', 'pending')
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -50,3 +50,58 @@ export function getOaUploadDisplayName(file: OaUploadFileLike | null | undefined
|
||||
return '未命名文件'
|
||||
}
|
||||
}
|
||||
|
||||
/** 打印 PDF:上传字段值 → 仅附件文件名列表(不含 MinIO/目录路径) */
|
||||
export function formatOaUploadPathsForPrint(value: unknown): string[] {
|
||||
if (value == null || value === '') return []
|
||||
if (Array.isArray(value)) {
|
||||
const out: string[] = []
|
||||
for (const item of value) {
|
||||
if (typeof item === 'string') {
|
||||
const parts = item
|
||||
.split(',')
|
||||
.map((x) => x.trim())
|
||||
.filter(Boolean)
|
||||
for (const p of parts) {
|
||||
out.push(getOaUploadDisplayName({ url: p }))
|
||||
}
|
||||
} else if (item && typeof item === 'object') {
|
||||
out.push(getOaUploadDisplayName(item as OaUploadFileLike))
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
return value
|
||||
.split(',')
|
||||
.map((x) => x.trim())
|
||||
.filter(Boolean)
|
||||
.map((p) => getOaUploadDisplayName({ url: p }))
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
return [getOaUploadDisplayName(value as OaUploadFileLike)]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/** 是否像对象存储 / 附件地址(打印展示时应收成文件名) */
|
||||
export function isOaStoredFileRef(text: string): boolean {
|
||||
const s = String(text || '').trim()
|
||||
if (!s) return false
|
||||
if (/\/minio\//i.test(s)) return true
|
||||
if (/^https?:\/\//i.test(s) && /\.[a-z0-9]{2,5}(\?|$)/i.test(s)) return true
|
||||
if (s.startsWith('/') && /\.[a-z0-9]{2,5}(\?|$)/i.test(s)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印单元格文案:若整段为附件路径(可多条,顿号/逗号分隔),仅保留文件名。
|
||||
* 普通业务文案原样返回,避免误伤「省 / 市 / 区」等路径。
|
||||
*/
|
||||
export function formatOaPrintAttachmentText(text: unknown): string {
|
||||
const s = String(text ?? '').trim()
|
||||
if (!s || s === '-') return s
|
||||
const parts = s.split(/[、,]/).map((x) => x.trim()).filter(Boolean)
|
||||
if (!parts.length || !parts.every(isOaStoredFileRef)) return s
|
||||
return parts.map((p) => getOaUploadDisplayName({ url: p })).join('、')
|
||||
}
|
||||
@@ -60,7 +60,12 @@
|
||||
</div>
|
||||
|
||||
<div v-show="activeStep === 'flow'" class="oa-designer__step oa-designer__flow-step">
|
||||
<FlowDesigner v-model="flowTreeJson" :candidates="conditionCandidates" />
|
||||
<!-- v-if:进入流程 Tab 再挂载,避免打开设计器即拉取用户列表 -->
|
||||
<FlowDesigner
|
||||
v-if="activeStep === 'flow'"
|
||||
v-model="flowTreeJson"
|
||||
:candidates="conditionCandidates"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-show="activeStep === 'advanced'" class="oa-designer__step">
|
||||
|
||||
Reference in new issue
Block a user