Add configurable approval timeliness guidance

This commit is contained in:
biss committed 2026-12-01 15:10:54 +08:00
1 parent 31a75d3bca
commit 8f4ea907e4
4 files changed
+54 -4

No files matched your search

+14 -1
View File
@@ -93,6 +93,15 @@ const isStudent = computed(
);
const pending = ref<any[]>([]);
const timelinessEnabled = ref(false);
function approvalDeadline(value: string) {
const utc = new Date(/(?:Z|[+-]\d\d:\d\d)$/i.test(value) ? value : value + 'Z');
const china = new Date(utc.getTime() + 8 * 3600000);
const late = china.getUTCHours() >= 16;
const deadline = Date.UTC(china.getUTCFullYear(), china.getUTCMonth(), china.getUTCDate() + 1, late ? 12 : 0) - 8 * 3600000;
const label = new Intl.DateTimeFormat('zh-CN', { timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(deadline);
return `${Date.now() >= deadline ? '已超时' : late ? '优先处理' : '当日处理'} · 目标 ${label}(北京时间)`;
}
const leavePanel = ref<InstanceType<typeof StudentLeavePanel> | null>(null);
async function showLeave(id: string) {
await leavePanel.value?.focusLeave(id);
@@ -402,6 +411,7 @@ async function load() {
if (sequence !== loadSequence) return;
targetMissing.value = false;
pending.value = [data];
timelinessEnabled.value = false;
pendingTotal.value = 1;
pendingCounts.value = {};
} else {
@@ -417,6 +427,8 @@ async function load() {
});
if (sequence !== loadSequence) return;
pending.value = data.items;
timelinessEnabled.value = data.timelinessEnabled;
if (timelinessEnabled.value) oldestFirst.value = true;
pendingTotal.value = data.total;
pendingCounts.value = data.counts ?? {};
}
@@ -1347,7 +1359,7 @@ onMounted(async () => {
}}</span>
<el-switch
v-model="oldestFirst"
:disabled="!!targetApprovalId"
:disabled="timelinessEnabled || !!targetApprovalId"
:active-text="t('approvalCenterExtra.oldestFirst')"
@change="
pendingPage = 1;
@@ -1409,6 +1421,7 @@ onMounted(async () => {
>
<div class="appr-body">
<b>{{ item.title }}</b>
<p v-if="timelinessEnabled">{{ approvalDeadline(item.time) }}</p>
<p>{{ item.desc }}</p>
<small
>{{ item.college }} ·
+16 -1
View File
@@ -9,16 +9,25 @@ const loading = ref(false)
const saving = ref(false)
const notification = reactive({ emailEnabled: false, emailFromAddress: '', emailFromName: '', maxAttempts: 5 })
const savingNotification = ref(false)
const timeliness = reactive({ enabled: false })
const savingTimeliness = ref(false)
async function load() {
loading.value = true
try {
const [businessResponse, notificationResponse] = await Promise.all([http.get('/business-settings'), http.get('/notification-settings')])
const [businessResponse, notificationResponse, timelinessResponse] = await Promise.all([http.get('/business-settings'), http.get('/notification-settings'), http.get('/business-settings/approval-timeliness')])
Object.assign(form, businessResponse.data)
Object.assign(notification, notificationResponse.data)
Object.assign(timeliness, timelinessResponse.data)
}
catch (error) { ElMessage.error(apiErrorMessage(error)) }
finally { loading.value = false }
}
async function saveTimeliness() {
savingTimeliness.value = true
try { await http.put('/business-settings/approval-timeliness', timeliness); ElMessage.success('审批时限设置已保存') }
catch (error) { ElMessage.error(apiErrorMessage(error)) }
finally { savingTimeliness.value = false }
}
async function saveNotification() {
savingNotification.value = true
try { await http.put('/notification-settings', notification); ElMessage.success('通知设置已保存') }
@@ -52,6 +61,12 @@ onMounted(load)
<el-form-item label="证明编号前缀"><el-input v-model="form.documentNumberPrefix" maxlength="32" /></el-form-item>
<el-button type="primary" native-type="submit" :loading="saving">保存设置</el-button>
</el-form>
<el-form class="settings-form surface-card" label-position="top" @submit.prevent="saveTimeliness">
<h2>审批处理时限</h2>
<p>启用后,待办按时间先后排列并显示目标时限。北京时间 16:00 前提交的事项须当日处理;16:00 起提交的事项次日中午 12:00 前优先处理。按自然日计算,含周末和节假日。多级审批以申请时间为共同目标;部分旧事项缺少提交时间时使用创建或更新时间。</p>
<el-form-item label="启用审批时限提示"><el-switch v-model="timeliness.enabled" /></el-form-item>
<el-button type="primary" native-type="submit" :loading="savingTimeliness">保存审批设置</el-button>
</el-form>
<el-form class="settings-form surface-card" label-position="top" @submit.prevent="saveNotification">
<h2>邮件通知</h2>
<p>SMTP 服务器和凭据由部署环境配置。关闭后,已排队的邮件暂停投递;关闭期间生成的通知不会补发邮件。修改通常在下一次投递扫描时生效。</p>