提交
This commit is contained in:
1 parent
80138c6388
commit
693e8a678e
682 files changed
+211375
-5306
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user