Integrate leave and discipline approval tasks

This commit is contained in:
biss committed 2026-12-01 10:14:54 +08:00
1 parent 167af46687
commit 784b5b76f2
6 files changed
+80 -7

No files matched your search

+7 -1
View File
@@ -6,6 +6,7 @@ import http, { apiErrorMessage } from '../api/http'
import { downloadApiFile } from '../api/excel'
const props = defineProps<{ student: boolean; manager: boolean }>()
const emit = defineEmits<{ reviewed: [] }>()
const { locale } = useI18n()
const zh = computed(() => locale.value.startsWith('zh'))
const tr = (cn: string, en: string) => zh.value ? cn : en
@@ -49,6 +50,11 @@ async function load() {
try { rows.value = (await http.get(props.student ? '/student-leaves/mine' : '/student-leaves/pending')).data }
catch (e) { ElMessage.error(apiErrorMessage(e) || tr('加载请假记录失败', 'Could not load leave requests')) }
}
async function focusLeave(id: string) {
try { rows.value = (await http.get('/student-leaves/pending', { params: { id } })).data }
catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
defineExpose({ focusLeave })
async function submit() {
if (!form.startAt || !form.endAt || !form.reason.trim() || new Date(form.endAt) <= new Date(form.startAt)) {
ElMessage.warning(tr('请填写有效的起止时间和事由', 'Enter a valid time range and reason')); return
@@ -77,7 +83,7 @@ async function review(row: any, approved: boolean) {
const result = await ElMessageBox.prompt(tr('请填写审核意见(驳回时必填)', 'Review comment (required when rejecting)'), tr('审核请假', 'Review leave'), {
inputValidator: (value: string) => approved || !!value?.trim() || tr('请填写驳回原因', 'Enter a reason'), inputType: 'textarea',
})
await http.post(`/student-leaves/${row.id}/review`, { approved, comment: result.value }); await load()
await http.post(`/student-leaves/${row.id}/review`, { approved, comment: result.value }); await load(); emit('reviewed')
ElMessage.success(tr('审核完成', 'Review saved'))
} catch (e) { if (e !== 'cancel' && e !== 'close') ElMessage.error(apiErrorMessage(e) || tr('审核失败', 'Review failed')) }
}
+14 -3
View File
@@ -91,6 +91,11 @@ const isStudent = computed(
);
const pending = ref<any[]>([]);
const leavePanel = ref<InstanceType<typeof StudentLeavePanel> | null>(null);
async function showLeave(id: string) {
await leavePanel.value?.focusLeave(id);
document.getElementById('student-leave-panel')?.scrollIntoView({ behavior: 'smooth' });
}
const reviewed = ref<any[]>([]);
const reviewedPage = ref(1);
const reviewedTotal = ref(0);
@@ -723,6 +728,8 @@ function approvalLabel(item: any) {
if (item.type === "TeachingImprovement")
return t("approvalCenterExtra.teachingImprovement");
if (item.type === "GraduationClearance") return t("approvalCenterClearance");
if (item.type === "StudentLeave") return attachmentText("学生请假", "Student leave");
if (item.type === "StudentDiscipline") return attachmentText("学生处分", "Student discipline");
const extra: Record<string, string> = {
GradeSubmissionBatch: "gradeBatch",
ExperimentGradeSheet: "experimentGrade",
@@ -791,6 +798,7 @@ function approvalRoute(type: string) {
GradeAppeal: "/grades",
TeachingImprovement: "/evaluations",
GraduationClearance: "/graduation-clearance",
StudentDiscipline: "/student-disciplines",
};
return routes[type];
}
@@ -981,7 +989,7 @@ onMounted(async () => {
</template>
</el-dialog>
<StudentLeavePanel v-if="isStudent || isManager" :student="!!isStudent" :manager="isManager" />
<div id="student-leave-panel"><StudentLeavePanel v-if="isStudent || isManager" ref="leavePanel" :student="!!isStudent" :manager="isManager" @reviewed="load" /></div>
<section v-if="isStudent" v-loading="loading" class="application-launcher">
<button
@@ -1226,7 +1234,7 @@ onMounted(async () => {
$router.push({
path: approvalRoute(item.type),
query:
item.type === 'ClassroomReservation' ? { tab: 'review' } : item.type === 'AssessmentDeclaration' ? { tab: 'reviews' } : item.type === 'AssessmentAppeal' ? { tab: 'appeals' } : {},
item.type === 'StudentDiscipline' ? { id: item.id } : item.type === 'ClassroomReservation' ? { tab: 'review' } : item.type === 'AssessmentDeclaration' ? { tab: 'reviews' } : item.type === 'AssessmentAppeal' ? { tab: 'appeals' } : {},
})
"
>{{ t("approvalBatch.view") }}</el-button
@@ -1249,6 +1257,9 @@ onMounted(async () => {
>{{ t("businessLabels.approve") }}</el-button
>
</div>
<div v-else-if="item.type === 'StudentLeave'" class="appr-actions">
<el-button size="small" text type="primary" @click="showLeave(item.id)">{{ t('approvalBatch.view') }}</el-button>
</div>
<div v-else-if="approvalRoute(item.type)" class="appr-actions">
<el-button
v-if="progressTypes.has(item.type)"
@@ -1266,7 +1277,7 @@ onMounted(async () => {
$router.push({
path: approvalRoute(item.type),
query:
item.type === 'ClassroomReservation' ? { tab: 'review' } : item.type === 'AssessmentDeclaration' ? { tab: 'reviews' } : item.type === 'AssessmentAppeal' ? { tab: 'appeals' } : {},
item.type === 'StudentDiscipline' ? { id: item.id } : item.type === 'ClassroomReservation' ? { tab: 'review' } : item.type === 'AssessmentDeclaration' ? { tab: 'reviews' } : item.type === 'AssessmentAppeal' ? { tab: 'appeals' } : {},
})
"
>
+3 -1
View File
@@ -2,6 +2,7 @@
import CustomExportDialog from '../components/CustomExportDialog.vue'
import { downloadApiFile } from '../api/excel'
import { onMounted, reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import http, { apiErrorMessage } from '../api/http'
import { useAuthStore } from '../stores/auth'
@@ -56,7 +57,8 @@ async function transition(next: string) {
await http.post(`/student-disciplines/${selected.value.id}/transition`, { state: next, comment: result.value || null }); ElMessage.success('操作成功'); await load(); await detail(selected.value.id)
} catch (e) { if (e !== 'cancel' && e !== 'close') ElMessage.error(apiErrorMessage(e)) }
}
onMounted(() => { void load(); void loadTypes() })
const route = useRoute()
onMounted(() => { void load(); void loadTypes(); const id = route.query.id; if (typeof id === 'string') void detail(id) })
</script>
<template>