Add leave forms and course approval comments

This commit is contained in:
biss committed 2026-11-20 20:12:36 +08:00
1 parent 26e169b220
commit 298c8ccf4b
5 files changed
+109 -9

No files matched your search

+6
View File
@@ -3,6 +3,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { ElMessage, ElMessageBox } from 'element-plus'
import http, { apiErrorMessage } from '../api/http'
import { downloadApiFile } from '../api/excel'
const props = defineProps<{ student: boolean; manager: boolean }>()
const { locale } = useI18n()
@@ -39,6 +40,10 @@ async function downloadAttachment(file: { id: string; fileName: string }) {
setTimeout(() => URL.revokeObjectURL(url), 1000)
} catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
async function downloadForm(row: any) {
try { await downloadApiFile(`/student-leaves/${row.id}/form.docx`, 'student-leave.docx') }
catch (e) { ElMessage.error(apiErrorMessage(e)) }
}
const formatTime = (value: string) => new Date(value.endsWith('Z') ? value : value + 'Z').toLocaleString()
async function load() {
try { rows.value = (await http.get(props.student ? '/student-leaves/mine' : '/student-leaves/pending')).data }
@@ -101,6 +106,7 @@ onMounted(async () => {
<el-table-column v-if="student" prop="reviewComment" :label="tr('审核意见', 'Review comment')" min-width="120" show-overflow-tooltip />
<el-table-column :label="tr('操作', 'Actions')" min-width="150"><template #default="{ row }">
<el-button link @click="showAttachments(row)">{{ tr('附件', 'Attachments') }}</el-button>
<el-button link @click="downloadForm(row)">{{ tr('下载申请表', 'Download form') }}</el-button>
<el-button v-if="student && row.status === 'Submitted'" link @click="withdraw(row)">{{ tr('撤回', 'Withdraw') }}</el-button>
<template v-if="manager && !student"><el-button link type="primary" @click="review(row, true)">{{ tr('通过', 'Approve') }}</el-button><el-button link type="danger" @click="review(row, false)">{{ tr('驳回', 'Reject') }}</el-button></template>
</template></el-table-column>
+25 -2
View File
@@ -128,6 +128,9 @@ const substituteKeyword = ref("");
const rejectDialog = ref(false);
const rejectItem = ref<any>(null);
const rejectComment = ref("");
const approveDialog = ref(false);
const approveTarget = ref<any>(null);
const approveComment = ref("");
const reviewInProgress = ref(false);
const workflowDialog = ref(false);
const workflowSettings = ref<{ type: string; reviewerRole: string }[]>([]);
@@ -456,10 +459,22 @@ async function submitForm() {
}
async function approveItem(item: any) {
if (reviewInProgress.value) return;
if (["CourseExemption", "DeferredExam", "CourseSubstitution"].includes(item.type)) {
approveTarget.value = item;
approveComment.value = "";
approveDialog.value = true;
return;
}
await approveWithComment(item, "");
}
async function approveWithComment(item: any, comment: string) {
if (reviewInProgress.value) return;
reviewInProgress.value = true;
try {
if (await submitReview(item, true, "")) {
if (await submitReview(item, true, comment)) {
approveDialog.value = false;
ElMessage.success(t("approvalBatch.approved"));
if (targetApprovalId.value)
await router.replace({ path: "/approvals", query: { tab: "pending" } });
@@ -641,7 +656,7 @@ async function submitReview(item: any, approved: boolean, comment: string) {
: "reject";
await http.post(
`${ep}/${item.id}/${action}`,
approved ? undefined : { comment },
approved && !["CourseExemption", "DeferredExam", "CourseSubstitution"].includes(item.type) ? undefined : { comment },
);
}
return true;
@@ -1681,6 +1696,14 @@ onMounted(async () => {
</template>
</el-dialog>
<el-dialog v-model="approveDialog" :title="attachmentText('审核通过', 'Approve')" width="min(480px, 95vw)">
<el-input v-model="approveComment" type="textarea" :rows="4" maxlength="500" show-word-limit
:placeholder="attachmentText('审核意见(选填)', 'Review comment (optional)')" />
<template #footer>
<el-button @click="approveDialog = false">{{ t('businessLabels.cancel') }}</el-button>
<el-button type="primary" :loading="reviewInProgress" @click="approveTarget && approveWithComment(approveTarget, approveComment.trim())">{{ t('businessLabels.approve') }}</el-button>
</template>
</el-dialog>
<el-dialog
v-model="rejectDialog"
:title="t('statusChanges.rejectTitle')"