141 lines
8.7 KiB
Vue
141 lines
8.7 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { Download, Refresh, Search } from '@element-plus/icons-vue'
|
|
import http, { apiErrorMessage } from '../api/http'
|
|
import { downloadApiFile } from '../api/excel'
|
|
|
|
const loading = ref(false)
|
|
const scanning = ref(false)
|
|
const batches = ref<any[]>([])
|
|
const total = ref(0)
|
|
const scan = ref<any>()
|
|
const rollbackPolicy = ref('')
|
|
const query = reactive({ page: 1, pageSize: 20, module: '', status: '' })
|
|
const { locale, t } = useI18n()
|
|
|
|
const moduleValues = ['base-data', 'courses', 'personnel', 'identity', 'attendance', 'grades', 'experiment-grades', 'other-exams', 'physical-fitness', 'dormitory', 'dormitory-hygiene', 'campus-wallet', 'tuition']
|
|
const moduleOptions = computed(() => moduleValues.map(value => ({ value, label: t(`dataQuality.modules.${value}`) })))
|
|
|
|
const statusValues = ['PreviewSucceeded', 'Succeeded', 'Failed']
|
|
const statusLabel = (value: string) => t(`dataQuality.statuses.${value}`)
|
|
const statusTypes: Record<string, 'success' | 'warning' | 'danger'> = {
|
|
PreviewSucceeded: 'warning', Succeeded: 'success', Failed: 'danger',
|
|
}
|
|
const severityLabel = (value: string) => t(`dataQuality.severities.${value}`)
|
|
|
|
const totalIssues = computed(() =>
|
|
(scan.value?.errorCount ?? 0) +
|
|
(scan.value?.warningCount ?? 0) +
|
|
(scan.value?.infoCount ?? 0))
|
|
|
|
function moduleLabel(value: string) {
|
|
return moduleOptions.value.find(item => item.value === value)?.label ?? value
|
|
}
|
|
|
|
async function loadBatches(reset = false) {
|
|
if (reset) query.page = 1
|
|
loading.value = true
|
|
try {
|
|
const { data } = await http.get('/data-quality/batches', {
|
|
params: {
|
|
page: query.page,
|
|
pageSize: query.pageSize,
|
|
module: query.module || undefined,
|
|
status: query.status || undefined,
|
|
},
|
|
})
|
|
batches.value = data.items
|
|
total.value = data.total
|
|
rollbackPolicy.value = data.rollbackPolicy
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
async function runScan() {
|
|
scanning.value = true
|
|
try {
|
|
scan.value = (await http.get('/data-quality/scan')).data
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
} finally {
|
|
scanning.value = false
|
|
}
|
|
}
|
|
|
|
async function downloadErrors(row: any) {
|
|
try {
|
|
await downloadApiFile(
|
|
`/data-quality/batches/${row.id}/errors.xlsx`,
|
|
t('dataQuality.errorFilename', { module: moduleLabel(row.module) }),
|
|
)
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
onMounted(() => Promise.all([loadBatches(), runScan()]))
|
|
</script>
|
|
|
|
<template>
|
|
<div class="page-shell">
|
|
<header class="page-heading">
|
|
<div>
|
|
<p class="eyebrow">DATA QUALITY</p>
|
|
<h1>{{ t('dataQuality.title') }}</h1>
|
|
<p>{{ t('dataQuality.description') }}</p>
|
|
</div>
|
|
<el-button :icon="Refresh" :loading="scanning" @click="runScan">{{ t('dataQuality.rescan') }}</el-button>
|
|
</header>
|
|
|
|
<section class="summary-grid">
|
|
<article><span>{{ t('dataQuality.totalIssues') }}</span><b>{{ totalIssues }}</b><small>{{ t('dataQuality.currentScope') }}</small></article>
|
|
<article class="error"><span>{{ t('dataQuality.error') }}</span><b>{{ scan?.errorCount ?? 0 }}</b><small>{{ t('dataQuality.priority') }}</small></article>
|
|
<article class="warning"><span>{{ t('dataQuality.warning') }}</span><b>{{ scan?.warningCount ?? 0 }}</b><small>{{ t('dataQuality.businessImpact') }}</small></article>
|
|
<article><span>{{ t('dataQuality.batches') }}</span><b>{{ total }}</b><small>{{ t('dataQuality.batchStatuses') }}</small></article>
|
|
</section>
|
|
|
|
<section class="panel quality-panel" v-loading="scanning">
|
|
<header><div><h2>{{ t('dataQuality.checks') }}</h2><p>{{ t('dataQuality.checksDescription') }}</p></div><span>{{ scan?.scope === 'College' ? t('dataQuality.collegeScope') : t('dataQuality.schoolScope') }}</span></header>
|
|
<div class="check-grid">
|
|
<article v-for="item in scan?.checks ?? []" :key="item.code" :class="item.severity">
|
|
<div><b>{{ item.name }}</b><el-tag :type="item.severity === 'error' ? 'danger' : item.severity === 'warning' ? 'warning' : 'info'">{{ severityLabel(item.severity) }}</el-tag></div>
|
|
<strong>{{ item.count }}</strong>
|
|
<p>{{ item.description }}</p>
|
|
</article>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="panel">
|
|
<header><div><h2>{{ t('dataQuality.importBatches') }}</h2><p>{{ t('dataQuality.privacyNote') }}</p></div></header>
|
|
<div class="toolbar">
|
|
<el-select v-model="query.module" clearable :placeholder="t('dataQuality.allModules')">
|
|
<el-option v-for="item in moduleOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
<el-select v-model="query.status" clearable :placeholder="t('dataQuality.allStatuses')">
|
|
<el-option v-for="value in statusValues" :key="value" :label="statusLabel(value)" :value="value" />
|
|
</el-select>
|
|
<el-button :icon="Search" @click="loadBatches(true)">{{ t('dataQuality.search') }}</el-button>
|
|
</div>
|
|
<el-alert class="rollback-note" type="info" :closable="false" show-icon :title="rollbackPolicy" />
|
|
<el-table v-loading="loading" :data="batches" :empty-text="t('dataQuality.empty')">
|
|
<el-table-column :label="t('dataQuality.moduleTarget')" min-width="190"><template #default="{ row }"><b>{{ moduleLabel(row.module) }}</b><small class="block">{{ row.target }}</small></template></el-table-column>
|
|
<el-table-column prop="fileName" :label="t('dataQuality.file')" min-width="210" show-overflow-tooltip />
|
|
<el-table-column :label="t('dataQuality.status')" width="110"><template #default="{ row }"><el-tag :type="statusTypes[row.status]">{{ statusLabel(row.status) }}</el-tag></template></el-table-column>
|
|
<el-table-column :label="t('dataQuality.result')" width="190"><template #default="{ row }">{{ t('dataQuality.resultSummary', { total: row.totalRows, created: row.createdCount, updated: row.updatedCount }) }}</template></el-table-column>
|
|
<el-table-column :label="t('dataQuality.operator')" width="130"><template #default="{ row }">{{ row.operatorName || row.createdByUserId }}</template></el-table-column>
|
|
<el-table-column :label="t('dataQuality.completedAt')" width="180"><template #default="{ row }">{{ new Date(row.completedAt).toLocaleString(locale) }}</template></el-table-column>
|
|
<el-table-column :label="t('dataQuality.error')" width="110"><template #default="{ row }"><el-button v-if="row.errorCount" link type="danger" :icon="Download" @click="downloadErrors(row)">{{ t('dataQuality.errorCount', { count: row.errorCount }) }}</el-button><span v-else>—</span></template></el-table-column>
|
|
</el-table>
|
|
<el-pagination v-model:current-page="query.page" v-model:page-size="query.pageSize" :total="total" layout="total, prev, pager, next" @current-change="loadBatches()" />
|
|
</section>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.page-shell{padding:24px;display:grid;gap:20px}.page-heading,.panel>header{display:flex;justify-content:space-between;align-items:flex-start;gap:20px}.page-heading h1,.panel h2{margin:4px 0 6px;color:#17233f}.page-heading p,.panel p{margin:0;color:#6b778d}.eyebrow{color:#326cb3!important;font-size:12px;font-weight:800;letter-spacing:.14em}.summary-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.summary-grid article{display:grid;gap:5px;padding:18px;border:1px solid #e3e9f2;border-radius:15px;background:#fff}.summary-grid span,.summary-grid small{color:#718096}.summary-grid b{font-size:30px;color:#244d82}.summary-grid .error b{color:#b42318}.summary-grid .warning b{color:#a15c00}.panel{display:grid;gap:16px;padding:20px;border:1px solid #e1e7f0;border-radius:17px;background:#fff}.panel>header>span{padding:6px 10px;border-radius:99px;background:#edf3fb;color:#42638e}.check-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.check-grid article{padding:14px;border:1px solid #e4e9f1;border-radius:13px}.check-grid article.error{border-color:#f0c2be}.check-grid article.warning{border-color:#efd5a9}.check-grid article>div{display:flex;justify-content:space-between;gap:8px}.check-grid strong{display:block;margin:12px 0 5px;font-size:26px;color:#263c5c}.check-grid p{font-size:13px;line-height:1.55}.toolbar{display:flex;gap:10px;flex-wrap:wrap}.toolbar .el-select{width:180px}.rollback-note{margin-top:-4px}.block{display:block;margin-top:3px;color:#7b8798}.el-pagination{justify-content:flex-end}@media(max-width:1100px){.summary-grid,.check-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:650px){.page-shell{padding:16px}.page-heading,.panel>header{flex-direction:column}.summary-grid,.check-grid{grid-template-columns:1fr}.toolbar .el-select{width:100%}}
|
|
</style>
|