优化
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, getCurrentInstance, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox, type UploadFile } from 'element-plus'
|
||||
import { ArrowLeft, CreditCard, Download, Eye, HandCoins, Plus, RotateCcw, XCircle } from '@lucide/vue'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
@@ -39,7 +39,6 @@ type SettlementRow = FinanceReceivableSettlement | FinancePayableSettlement
|
||||
|
||||
const props = defineProps<{ kind: 'receivable' | 'payable'; settlementId?: string }>()
|
||||
const emit = defineEmits<{ openDetail: [settlementId: string]; back: [] }>()
|
||||
const appRouter = getCurrentInstance()?.appContext.config.globalProperties.$router
|
||||
const access = useAccessPreviewStore()
|
||||
const customers = ref<PlatformTenantResource[]>([])
|
||||
const filters = ref<QueryModel>({ customerId: '', supplierName: '', settlementNo: '', status: '' })
|
||||
@@ -183,13 +182,7 @@ async function load(model: QueryModel = filters.value) {
|
||||
|
||||
function openDetail(row: unknown) {
|
||||
selectedRow.value = row as SettlementRow
|
||||
const settlementId = selectedRow.value.id
|
||||
if (appRouter) {
|
||||
const listPath = props.kind === 'receivable' ? '/finance/settlement-receivables' : '/finance/settlement-payables'
|
||||
void appRouter.push(`${listPath}/${encodeURIComponent(settlementId)}`)
|
||||
return
|
||||
}
|
||||
emit('openDetail', settlementId)
|
||||
emit('openDetail', selectedRow.value.id)
|
||||
}
|
||||
|
||||
async function loadDetail(settlementId: string) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import ElementPlus, { ElMessageBox } from 'element-plus'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { useAuthStore } from '@/core/auth/auth'
|
||||
@@ -20,7 +19,6 @@ import {
|
||||
import type { FinanceReconciliationDetail, FinanceSettlementDetail, FinanceStatementReadModel } from '../types'
|
||||
import FinanceCustomerStatementsView from './FinanceCustomerStatementsView.vue'
|
||||
import FinanceFormalSettlementPage from './FinanceFormalSettlementPage.vue'
|
||||
import FinanceSettlementReceivablesView from './FinanceSettlementReceivablesView.vue'
|
||||
|
||||
vi.mock('@/modules/iam', () => ({ listPlatformTenants: vi.fn() }))
|
||||
vi.mock('../api/finance', () => ({
|
||||
@@ -191,26 +189,6 @@ describe('finance G3/G4 page operations', () => {
|
||||
expect(vm.customerName('2088')).toBe('—')
|
||||
})
|
||||
|
||||
it('navigates from the receivable list to its independent detail route', async () => {
|
||||
const pinia = piniaWithPermissions(['platform:finance:settlement-ar:list'])
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/finance/settlement-receivables', component: { template: '<div />' } },
|
||||
{ path: '/finance/settlement-receivables/:settlementId', component: { template: '<div />' } },
|
||||
],
|
||||
})
|
||||
await router.push('/finance/settlement-receivables')
|
||||
await router.isReady()
|
||||
const wrapper = mount(FinanceSettlementReceivablesView, { global: { plugins: [pinia, router, ElementPlus] } })
|
||||
await flushPromises()
|
||||
|
||||
;(wrapper.findComponent(FinanceFormalSettlementPage).vm as unknown as { openDetail(row: { id: string }): void }).openDetail({ id: '63' })
|
||||
await flushPromises()
|
||||
|
||||
expect(router.currentRoute.value.fullPath).toBe('/finance/settlement-receivables/63')
|
||||
})
|
||||
|
||||
it('keeps settled settlements readable and exportable while hiding receipt actions', async () => {
|
||||
vi.mocked(getFinanceSettlement).mockResolvedValue({ ...receivable, status: 'PAID', paidAmount: 300, outstandingAmount: 0 })
|
||||
const pinia = piniaWithPermissions(['platform:finance:settlement-ar:list', 'platform:finance:receipt:create'])
|
||||
|
||||
@@ -6,7 +6,7 @@ import FinanceFormalSettlementPage from './FinanceFormalSettlementPage.vue'
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const settlementId = computed(() => String(route.params.settlementId || ''))
|
||||
function openDetail(id: string) { void router.push(`/finance/settlement-receivables/${encodeURIComponent(id)}`) }
|
||||
function openDetail(id: string) { void router.push({ name: 'finance-settlement-receivable-detail', params: { settlementId: id } }) }
|
||||
function back() { void router.push({ name: 'finance-settlement-receivables' }) }
|
||||
</script>
|
||||
<template><FinanceFormalSettlementPage kind="receivable" :settlement-id="settlementId" @open-detail="openDetail" @back="back" /></template>
|
||||
|
||||
Reference in New Issue
Block a user