Add deep links for pending approval notifications
This commit is contained in:
1 parent
ce8982dba9
commit
4c95edb678
9 files changed
+191
-34
No files matched your search
@@ -59,6 +59,14 @@ const pending = ref<any[]>([])
|
||||
const pendingPage = ref(1)
|
||||
const pendingTotal = ref(0)
|
||||
const pendingPageSize = 20
|
||||
const targetApprovalType = computed(() => {
|
||||
const value = route.query.type
|
||||
return typeof value === 'string' ? value : undefined
|
||||
})
|
||||
const targetApprovalId = computed(() => {
|
||||
const value = route.query.id
|
||||
return typeof value === 'string' ? value : undefined
|
||||
})
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const tab = ref(isManager.value ? 'pending' : 'mine')
|
||||
@@ -176,11 +184,19 @@ async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
if (isManager.value) {
|
||||
const { data } = await http.get('/approvals/pending', {
|
||||
params: { page: pendingPage.value, pageSize: pendingPageSize },
|
||||
})
|
||||
pending.value = data.items
|
||||
pendingTotal.value = data.total
|
||||
if (targetApprovalType.value && targetApprovalId.value) {
|
||||
const { data } = await http.get(
|
||||
`/approvals/pending/${targetApprovalType.value}/${targetApprovalId.value}`,
|
||||
)
|
||||
pending.value = [data]
|
||||
pendingTotal.value = 1
|
||||
} else {
|
||||
const { data } = await http.get('/approvals/pending', {
|
||||
params: { page: pendingPage.value, pageSize: pendingPageSize },
|
||||
})
|
||||
pending.value = data.items
|
||||
pendingTotal.value = data.total
|
||||
}
|
||||
if (!pending.value.length && pendingPage.value > 1) {
|
||||
pendingPage.value--
|
||||
return await load()
|
||||
@@ -336,7 +352,7 @@ function courseScheduleText(course: CourseOption) {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (isManager.value && route.query.tab === 'pending') tab.value = 'pending'
|
||||
if (isManager.value && (route.query.tab === 'pending' || targetApprovalId.value)) tab.value = 'pending'
|
||||
return load()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Check, Plus, Refresh } from '@element-plus/icons-vue'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
@@ -35,6 +35,10 @@ const mineTotal = ref(0)
|
||||
const reviewPage = ref(1)
|
||||
const reviewTotal = ref(0)
|
||||
const pageSize = 20
|
||||
const targetAdjustmentId = computed(() => {
|
||||
const value = route.query.adjustmentId
|
||||
return typeof value === 'string' ? value : undefined
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
teachingTaskId: undefined as string | undefined,
|
||||
@@ -104,7 +108,12 @@ async function load(resetPages = false) {
|
||||
}
|
||||
if (isManager.value) {
|
||||
const response = await http.get('/course-adjustments/pending-reviews', {
|
||||
params: { academicTermId: termId.value, page: reviewPage.value, pageSize },
|
||||
params: {
|
||||
academicTermId: targetAdjustmentId.value ? undefined : termId.value,
|
||||
adjustmentId: targetAdjustmentId.value,
|
||||
page: reviewPage.value,
|
||||
pageSize,
|
||||
},
|
||||
})
|
||||
pendingReviews.value = response.data.items
|
||||
reviewTotal.value = response.data.total
|
||||
@@ -249,12 +258,21 @@ onMounted(async () => {
|
||||
ElMessage.error(apiErrorMessage(error))
|
||||
}
|
||||
await load()
|
||||
if (isManager.value && targetAdjustmentId.value) tab.value = 'reviews'
|
||||
if (isTeacher.value && route.query.create === '1') {
|
||||
openCreate()
|
||||
await router.replace({ path: '/course-adjustments' })
|
||||
}
|
||||
})
|
||||
|
||||
watch(targetAdjustmentId, async () => {
|
||||
if (isManager.value) {
|
||||
tab.value = 'reviews'
|
||||
reviewPage.value = 1
|
||||
await load()
|
||||
}
|
||||
})
|
||||
|
||||
function changeType() {
|
||||
form.targetDate = ''
|
||||
form.startPeriod = undefined
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
import { downloadApiFile, importExcel } from '../api/excel'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import { useRoute } from 'vue-router'
|
||||
import {
|
||||
academicTermLabel,
|
||||
academicTermOptionClass,
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
import { useScoreGridNavigation } from '../utils/scoreGridNavigation'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const route = useRoute()
|
||||
const { handleScoreGridKeydown } = useScoreGridNavigation('experiment-grade-entry')
|
||||
const isStudent = computed(() => auth.user?.roles.includes('Student') ?? false)
|
||||
const canViewAllColleges = computed(() =>
|
||||
@@ -34,6 +36,7 @@ const autoSaveState = ref<'idle' | 'saving' | 'saved' | 'error'>('idle')
|
||||
let autoSaveTimer: ReturnType<typeof setTimeout> | undefined
|
||||
let savedRecordSnapshot = ''
|
||||
let autoSaving = false
|
||||
const openedTargetSheetId = ref<string | undefined>()
|
||||
const terms = ref<any[]>([])
|
||||
const colleges = ref<any[]>([])
|
||||
const termId = ref('')
|
||||
@@ -55,6 +58,11 @@ const editingScheme = ref(false)
|
||||
const schemeProject = ref<any | null>(null)
|
||||
const importFileInput = ref<HTMLInputElement>()
|
||||
|
||||
const targetSheetId = computed(() => {
|
||||
const value = route.query.sheetId
|
||||
return typeof value === 'string' ? value : undefined
|
||||
})
|
||||
|
||||
const schemeForm = reactive({
|
||||
contributionWeight: 1,
|
||||
passScore: 60,
|
||||
@@ -208,20 +216,29 @@ async function load() {
|
||||
if (isStudent.value) {
|
||||
studentResults.value = (await http.get('/experiment-grades/mine')).data
|
||||
} else {
|
||||
const locatingSheet = targetSheetId.value
|
||||
const data = (await http.get('/experiment-grades/management', {
|
||||
params: {
|
||||
academicTermId: termId.value || undefined,
|
||||
status: statusFilter.value || undefined,
|
||||
collegeId: collegeId.value || undefined,
|
||||
keyword: projectKeyword.value.trim() || undefined,
|
||||
academicTermId: locatingSheet ? undefined : termId.value || undefined,
|
||||
status: locatingSheet ? undefined : statusFilter.value || undefined,
|
||||
collegeId: locatingSheet ? undefined : collegeId.value || undefined,
|
||||
keyword: locatingSheet ? undefined : projectKeyword.value.trim() || undefined,
|
||||
page: projectPage.value,
|
||||
pageSize: projectPageSize.value,
|
||||
sheetId: locatingSheet,
|
||||
},
|
||||
})).data
|
||||
courses.value = data.items
|
||||
courseTotal.value = data.total
|
||||
projectPage.value = data.page
|
||||
projectPageSize.value = data.pageSize
|
||||
const targetProject = targetSheetId.value && courses.value
|
||||
.flatMap((course: any) => course.projects)
|
||||
.find((project: any) => project.sheet?.id === targetSheetId.value)
|
||||
if (targetProject && openedTargetSheetId.value !== targetSheetId.value) {
|
||||
openedTargetSheetId.value = targetSheetId.value
|
||||
await openDetail(targetProject)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error(apiErrorMessage(error))
|
||||
@@ -343,6 +360,13 @@ async function saveRecords(automatic = false) {
|
||||
}
|
||||
|
||||
watch(() => detail.value?.records, scheduleAutoSave, { deep: true })
|
||||
watch(targetSheetId, async () => {
|
||||
openedTargetSheetId.value = undefined
|
||||
if (!isStudent.value) {
|
||||
projectPage.value = 1
|
||||
await load()
|
||||
}
|
||||
})
|
||||
|
||||
function downloadTemplate() {
|
||||
if (!detail.value) return
|
||||
|
||||
Loaded 3 of 9 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user