修复学费页面移动端布局
This commit is contained in:
1 parent
3dacb48b53
commit
14ebc367c2
3 files changed
+108
-6
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
for (const role of ['Student', 'AcademicAdmin']) {
|
||||
test(`${role} tuition and fee catalog fit a mobile viewport`, async ({ page }) => {
|
||||
await page.setViewportSize({ width: 360, height: 800 })
|
||||
const user = { id: 'user-1', userName: 'user', displayName: '测试用户', roles: [role], permissions: [], effectiveDataScope: 'All' }
|
||||
await page.addInitScript(savedUser => {
|
||||
localStorage.setItem('jiaowu_token', 'test-token')
|
||||
localStorage.setItem('jiaowu_user', JSON.stringify(savedUser))
|
||||
localStorage.setItem('jiaowu_access_expires_at', '2099-01-01T00:00:00Z')
|
||||
localStorage.setItem('jiaowu_session_expires_at', '2099-01-01T00:00:00Z')
|
||||
}, user)
|
||||
const bill = { id: 'bill-1', termName: '2026 秋季学期', studentName: '测试学生', studentNumber: '20260101', baseTuition: 100, basePaid: 0, creditFee: 30, creditPaid: 0, accommodationFee: 50, accommodationPaid: 0, reconciliationAdjustment: 0, adjustmentPaid: 0, isPayable: true }
|
||||
await page.route(url => url.pathname.startsWith('/api/'), route => {
|
||||
const path = new URL(route.request().url()).pathname
|
||||
if (path === '/api/auth/me') return route.fulfill({ json: user })
|
||||
if (path === '/api/plugins/runtime') return route.fulfill({ json: [{ id: 'mingxu.campus-services', isEnabled: true, navigationPaths: [], capabilities: [] }] })
|
||||
if (path === '/api/tuition/mine') return route.fulfill({ json: [bill] })
|
||||
if (path === '/api/tuition/mine/payments') return route.fulfill({ json: [] })
|
||||
if (path === '/api/tuition/terms') return route.fulfill({ json: [{ id: 'term-1', name: '秋季', isCurrent: true, setting: { status: 'OpenForPayment', creditUnitPrice: 10 } }] })
|
||||
if (path === '/api/tuition/bills') return route.fulfill({ json: { items: [bill], total: 1 } })
|
||||
if (path === '/api/fee-catalog') return route.fulfill({ json: [{ id: 'fee-1', name: '学生证补办工本费', description: '长期收费项目', presetAmounts: [10, 20], allowCustomAmount: true, isEnabled: true }] })
|
||||
if (path === '/api/fee-catalog/payments') return route.fulfill({ json: [] })
|
||||
return route.fulfill({ json: {} })
|
||||
})
|
||||
await page.goto('/tuition')
|
||||
const billCard = page.locator('.tuition .mobile-record').first()
|
||||
await expect(billCard).toBeVisible()
|
||||
await expect(billCard.getByText('基础学费')).toBeVisible()
|
||||
await expect(billCard.getByRole('button', { name: role === 'Student' ? '缴基础费' : '余额划扣' }).first()).toBeVisible()
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true)
|
||||
await page.getByRole('tab', { name: '项目缴费' }).click()
|
||||
const feeCard = page.locator('.fee-catalog .mobile-record').first()
|
||||
await expect(feeCard.getByText('学生证补办工本费')).toBeVisible()
|
||||
await expect(feeCard.getByRole('button', { name: role === 'Student' ? '余额缴费' : '编辑收费项目' })).toBeVisible()
|
||||
if (role === 'Student') {
|
||||
const input = feeCard.locator('.el-input-number input')
|
||||
await input.fill('15')
|
||||
await expect(input).toHaveValue('15')
|
||||
}
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true)
|
||||
await page.setViewportSize({ width: 1440, height: 900 })
|
||||
await expect(page.locator('.fee-catalog .desktop-table').first()).toBeVisible()
|
||||
await expect(feeCard).toBeHidden()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -70,7 +70,22 @@ onMounted(load)
|
||||
<div class="fee-catalog">
|
||||
<el-card>
|
||||
<template #header><div class="card-heading"><strong>{{ t('feeCatalog.title') }}</strong><el-button v-if="!student" type="primary" @click="edit()">{{ t('feeCatalog.create') }}</el-button></div></template>
|
||||
<el-table :data="items">
|
||||
<div class="mobile-list">
|
||||
<el-empty v-if="!items.length" />
|
||||
<article v-for="item in items" :key="item.id" class="mobile-record">
|
||||
<div class="mobile-heading"><strong>{{ item.name }}</strong><el-tag v-if="!student" :type="item.isEnabled ? 'success' : 'info'">{{ item.isEnabled ? t('feeCatalog.enabled') : t('feeCatalog.disabled') }}</el-tag></div>
|
||||
<p v-if="item.description">{{ item.description }}</p>
|
||||
<p><span>{{ t('feeCatalog.presets') }}:</span>{{ item.presetAmounts.map(money).join(' / ') || '—' }}</p>
|
||||
<p v-if="!student"><span>{{ t('feeCatalog.custom') }}:</span>{{ item.allowCustomAmount ? t('feeCatalog.yes') : t('feeCatalog.no') }}</p>
|
||||
<div v-if="student" class="mobile-payment">
|
||||
<el-select v-if="item.presetAmounts.length" v-model="selections[item.id]" :placeholder="t('feeCatalog.selectAmount')"><el-option v-for="amount in item.presetAmounts" :key="amount" :label="money(amount)" :value="amount" /></el-select>
|
||||
<el-input-number v-if="item.allowCustomAmount" v-model="selections[item.id]" :min="0.01" :max="99999999.99" :precision="2" :controls="false" :placeholder="t('feeCatalog.selectAmount')" />
|
||||
<el-button type="primary" :loading="paying" @click="pay(item)">{{ t('feeCatalog.pay') }}</el-button>
|
||||
</div>
|
||||
<el-button v-else class="mobile-edit" type="primary" plain @click="edit(item)">{{ t('feeCatalog.edit') }}</el-button>
|
||||
</article>
|
||||
</div>
|
||||
<el-table class="desktop-table" :data="items">
|
||||
<el-table-column prop="name" :label="t('feeCatalog.name')" min-width="150" />
|
||||
<el-table-column prop="description" :label="t('feeCatalog.description')" min-width="180" />
|
||||
<el-table-column :label="t('feeCatalog.presets')" min-width="170"><template #default="{ row }">{{ (row as FeeItem).presetAmounts.map(money).join(' / ') || '—' }}</template></el-table-column>
|
||||
@@ -88,7 +103,15 @@ onMounted(load)
|
||||
</el-card>
|
||||
<el-card>
|
||||
<template #header>{{ t('feeCatalog.history') }}</template>
|
||||
<el-table :data="payments">
|
||||
<div class="mobile-list">
|
||||
<el-empty v-if="!payments.length" />
|
||||
<article v-for="payment in payments" :key="payment.id" class="mobile-record">
|
||||
<div class="mobile-heading"><strong>{{ payment.itemName }}</strong><strong>{{ money(payment.amount) }}</strong></div>
|
||||
<p v-if="!student">{{ payment.studentName }} · {{ payment.studentNumber }}</p>
|
||||
<p>{{ new Date(payment.createdAt).toLocaleString(locale) }}</p>
|
||||
</article>
|
||||
</div>
|
||||
<el-table class="desktop-table" :data="payments">
|
||||
<el-table-column v-if="!student" prop="studentNumber" :label="t('tuition.studentNumber')" />
|
||||
<el-table-column v-if="!student" prop="studentName" :label="t('tuition.student')" />
|
||||
<el-table-column prop="itemName" :label="t('feeCatalog.name')" />
|
||||
@@ -108,4 +131,9 @@ onMounted(load)
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>.fee-catalog{display:grid;gap:18px}.card-heading{display:flex;align-items:center;justify-content:space-between}</style>
|
||||
<style scoped>
|
||||
.fee-catalog{display:grid;gap:18px;min-width:0}.card-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.mobile-list{display:none}
|
||||
@media(max-width:720px){
|
||||
.desktop-table{display:none}.mobile-list{display:grid;gap:12px}.mobile-record{min-width:0;padding:14px;border:1px solid var(--el-border-color-light);border-radius:10px}.mobile-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:10px}.mobile-heading strong{min-width:0;overflow-wrap:anywhere}.mobile-record p{margin:8px 0 0;color:var(--el-text-color-regular);overflow-wrap:anywhere}.mobile-record p span{color:var(--el-text-color-secondary)}.mobile-payment{display:grid;gap:8px;margin-top:14px}.mobile-payment :deep(.el-select),.mobile-payment :deep(.el-input-number),.mobile-payment .el-button,.mobile-edit{width:100%}.mobile-edit{margin-top:14px}
|
||||
}
|
||||
</style>
|
||||
@@ -147,7 +147,23 @@ onMounted(load)
|
||||
|
||||
<el-card>
|
||||
<div v-if="!isStudent" class="bill-filter"><el-input v-model="keyword" clearable :placeholder="t('tuition.searchPlaceholder')" @keyup.enter="page = 1; load()" /><el-button @click="page = 1; load()">{{ t('tuition.search') }}</el-button></div>
|
||||
<el-table :data="rows" :empty-text="t('tuition.empty')">
|
||||
<div class="mobile-list">
|
||||
<el-empty v-if="!rows.length" :description="t('tuition.empty')" />
|
||||
<article v-for="row in rows" :key="row.id" class="mobile-record">
|
||||
<h3>{{ isStudent ? row.termName : `${row.studentName} · ${row.studentNumber}` }}</h3>
|
||||
<div v-for="entry in [
|
||||
{ key: 'BaseTuition', label: t('tuition.baseTuition'), total: row.baseTuition, paid: row.basePaid, action: t('tuition.payBase') },
|
||||
{ key: 'CreditFee', label: t('tuition.creditFee'), total: row.creditFee, paid: row.creditPaid, action: t('tuition.payCredits') },
|
||||
{ key: 'AccommodationFee', label: t('tuition.accommodationFee'), total: row.accommodationFee, paid: row.accommodationPaid, action: t('tuition.payAccommodation') },
|
||||
{ key: 'ReconciliationAdjustment', label: t('tuition.adjustment'), total: row.reconciliationAdjustment, paid: row.adjustmentPaid, action: t('tuition.payAdjustment') },
|
||||
]" :key="entry.key" class="mobile-fee">
|
||||
<div><strong>{{ entry.label }}</strong><span>{{ money(entry.total) }}</span><small>{{ t('tuition.remaining', { amount: money(remaining(entry.total, entry.paid)) }) }}</small><small v-if="entry.key === 'CreditFee' && entry.paid > entry.total">{{ t('tuition.overpaid', { amount: money(entry.paid - entry.total) }) }}</small></div>
|
||||
<el-button v-if="remaining(entry.total, entry.paid) > 0 && (!isStudent || row.isPayable)" size="small" type="primary" plain @click="isStudent ? pay(row, entry.key) : charge(row, entry.key, remaining(entry.total, entry.paid))">{{ isStudent ? entry.action : t('feeCatalog.charge') }}</el-button>
|
||||
</div>
|
||||
<el-button v-if="!isStudent" class="mobile-reconcile" type="warning" plain @click="reconcile(row)">{{ t('tuition.reconcile') }}</el-button>
|
||||
</article>
|
||||
</div>
|
||||
<el-table class="desktop-table" :data="rows" :empty-text="t('tuition.empty')">
|
||||
<el-table-column v-if="!isStudent" prop="studentNumber" :label="t('tuition.studentNumber')" width="140" />
|
||||
<el-table-column v-if="!isStudent" prop="studentName" :label="t('tuition.student')" width="120" />
|
||||
<el-table-column v-if="isStudent" prop="termName" :label="t('tuition.term')" min-width="160" />
|
||||
@@ -180,7 +196,15 @@ onMounted(load)
|
||||
</el-card>
|
||||
<el-card v-if="isStudent" class="history">
|
||||
<template #header>{{ t('feeCatalog.tuitionHistory') }}</template>
|
||||
<el-table :data="payments">
|
||||
<div class="mobile-list">
|
||||
<el-empty v-if="!payments.length" />
|
||||
<article v-for="payment in payments" :key="payment.id" class="mobile-record mobile-history">
|
||||
<strong>{{ payment.termName }} · {{ t(`feeCatalog.items.${payment.item}`) }}</strong>
|
||||
<span>{{ money(payment.amount) }} · {{ t(`feeCatalog.methods.${payment.method}`) }}</span>
|
||||
<small>{{ new Date(payment.confirmedAt).toLocaleString(locale) }}</small>
|
||||
</article>
|
||||
</div>
|
||||
<el-table class="desktop-table" :data="payments">
|
||||
<el-table-column prop="termName" :label="t('tuition.term')" />
|
||||
<el-table-column :label="t('feeCatalog.name')"><template #default="{ row }">{{ t(`feeCatalog.items.${(row as Payment).item}`) }}</template></el-table-column>
|
||||
<el-table-column :label="t('feeCatalog.amount')"><template #default="{ row }">{{ money((row as Payment).amount) }}</template></el-table-column>
|
||||
@@ -195,5 +219,8 @@ onMounted(load)
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tuition{display:grid;gap:18px}.workbench,.history{margin-bottom:18px}.history{margin-top:18px}.tuition header p{margin:0;color:#17867c;font-size:12px;font-weight:800;letter-spacing:.16em}.tuition h2{margin:6px 0;color:#183b56}.tuition header span,small{color:#738596}.toolbar,.bill-filter{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:14px}.toolbar .el-select,.bill-filter .el-input{width:260px}small{display:block;margin-top:4px}.el-pagination{justify-content:flex-end;margin-top:16px}@media(max-width:720px){.toolbar>*,.bill-filter>*{width:100%!important}}
|
||||
.tuition{display:grid;gap:18px;min-width:0}.tuition :deep(.el-tabs),.tuition :deep(.el-tab-pane){min-width:0}.workbench,.history{margin-bottom:18px}.history{margin-top:18px}.tuition header p{margin:0;color:#17867c;font-size:12px;font-weight:800;letter-spacing:.16em}.tuition h2{margin:6px 0;color:#183b56}.tuition header span,small{color:#738596}.toolbar,.bill-filter{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:14px}.toolbar .el-select,.bill-filter .el-input{width:260px}small{display:block;margin-top:4px}.el-pagination{justify-content:flex-end;margin-top:16px}.mobile-list{display:none}
|
||||
@media(max-width:720px){
|
||||
.toolbar>*:not([hidden]),.bill-filter>*{width:100%!important;margin-left:0}.desktop-table{display:none}.mobile-list{display:grid;gap:12px}.mobile-record{min-width:0;border:1px solid var(--el-border-color-light);border-radius:10px;padding:14px}.mobile-record h3{margin:0 0 8px;font-size:16px;overflow-wrap:anywhere}.mobile-fee{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid var(--el-border-color-lighter)}.mobile-fee>div{min-width:0}.mobile-fee strong{display:block}.mobile-fee span{display:block;margin-top:4px}.mobile-fee .el-button{flex-shrink:0}.mobile-reconcile{width:100%;margin-top:8px}.mobile-history strong,.mobile-history span{display:block;overflow-wrap:anywhere}.mobile-history span{margin-top:6px}.el-pagination{justify-content:center}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user