feat(fleet): select versioned sales quotes and isolate cost drafts

This commit is contained in:
2026-10-03 13:20:35 +08:00
parent 3440f9dd11
commit 5641ea0f7e
15 changed files with 288 additions and 31 deletions
@@ -17,7 +17,7 @@ const row: VehicleCareRecord = { recordNo: 'VR-ONE', vehicleId: '71', vehiclePla
const container = { template: '<div><slot name="header"/><slot/></div>' }
const input = { name: 'ElInput', props: ['modelValue'], emits: ['update:modelValue'], template: '<input :value="modelValue" @input="$emit(\'update:modelValue\', $event.target.value)"/>' }
const table = { name: 'DataTable', props: ['data', 'page', 'pageSize', 'columns'], emits: ['update:page'], template: '<div><slot name="toolbar-actions"/><div v-for="row in data" :key="row.recordNo"><slot name="actions" :row="row"/><span data-test="status"><slot name="status" :row="row"/></span><span data-test="payment"><slot name="payment" :row="row"/></span><span data-test="cost"><slot name="cost" :row="row"/></span></div></div>' }
const dialog = { name: 'AppDialog', props: ['modelValue'], emits: ['confirm'], template: '<div v-if="modelValue"><slot/><button @click="$emit(\'confirm\')">保存</button></div>' }
const dialog = { name: 'AppDialog', props: ['modelValue', 'showConfirm'], emits: ['confirm'], template: '<div v-if="modelValue"><slot/><button @click="$emit(\'confirm\')">保存</button></div>' }
const wrappers: VueWrapper[] = []
function mount(component: object, props: Record<string, unknown>): VueWrapper {
const wrapper = shallowMount(component, { props, global: { directives: { loading: () => undefined }, stubs: {
@@ -164,3 +164,17 @@ it('editing an exception does not mutate the displayed source until a command su
expect(exception.details.incident?.description).toBe('原异常描述')
expect(api.updateVehicleCare).not.toHaveBeenCalled()
})
it('does not let an older finance batch overwrite the status just read for the opened record', async () => {
const repair: VehicleCareRecord = { ...row, details: { ...row.details, recordType: 'REPAIR' } }
vi.mocked(api.listVehicleCare).mockResolvedValue({ records: [repair], page: 1, size: 10, total: 1, pages: 1 })
vi.mocked(api.getVehicleCare).mockResolvedValue(repair)
let finish!: (value: Awaited<ReturnType<typeof api.listVehicleCareFinance>>) => void
vi.mocked(api.listVehicleCareFinance).mockImplementationOnce(() => new Promise(resolve => { finish = resolve }))
.mockResolvedValueOnce([{ recordNo: row.recordNo, status: 'PENDING_FINANCE', sourceVersion: '1', submittedRecordVersion: '1', finance: null }])
const wrapper = mount(VehicleCareTable, { vehicleId: '71', plate: 'VEH-A', recordType: 'REPAIR' }); await flushPromises()
wrapper.findComponent({ name: 'RowActions' }).vm.$emit('action', 'finance'); await flushPromises()
finish([{ recordNo: row.recordNo, status: 'UNLINKED', sourceVersion: null, submittedRecordVersion: null, finance: null }]); await flushPromises()
expect(wrapper.get('[data-test="payment"]').text()).not.toBe('未提交财务')
expect(wrapper.findComponent({ name: 'AppDialog' }).props('showConfirm')).toBe(false)
})