优化优化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import ElementPlus from 'element-plus'
|
||||
import ElementPlus, { ElMessageBox } from 'element-plus'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
getOutboundDispatch,
|
||||
getPreload,
|
||||
smartSplit,
|
||||
voidEvidence,
|
||||
} from '../api'
|
||||
|
||||
vi.mock('../api', async (importOriginal) => {
|
||||
@@ -19,6 +20,7 @@ vi.mock('../api', async (importOriginal) => {
|
||||
getOutboundDispatch: vi.fn(),
|
||||
getPreload: vi.fn(),
|
||||
smartSplit: vi.fn(),
|
||||
voidEvidence: vi.fn(),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -50,6 +52,7 @@ describe('UnifiedOrderWorkflowPanel preload editor', () => {
|
||||
vi.mocked(getEvidence).mockReset().mockResolvedValue({ inboundId: '2086085512165634051', evidences: [] })
|
||||
vi.mocked(getPreload).mockReset().mockResolvedValue(preload('REF-OLD'))
|
||||
vi.mocked(smartSplit).mockReset()
|
||||
vi.mocked(voidEvidence).mockReset()
|
||||
})
|
||||
|
||||
it('renders the formal preload table and keeps the operation column first', async () => {
|
||||
@@ -116,4 +119,41 @@ describe('UnifiedOrderWorkflowPanel preload editor', () => {
|
||||
expect(wrapper.text()).not.toContain('完成装柜')
|
||||
expect(wrapper.findAll('button').some((button) => button.text() === '作废')).toBe(false)
|
||||
})
|
||||
|
||||
it('uses a validated dialog when voiding evidence', async () => {
|
||||
vi.mocked(getEvidence).mockResolvedValue({
|
||||
inboundId: '2086085512165634051',
|
||||
evidences: [
|
||||
{ id: '1', inboundId: '2086085512165634051', tenantId: '2086085512165634052', evidenceType: 'PHOTO_STEP_1', fileId: '11', fileName: 'wrong.jpg', sealNo: null, remark: null, version: 2, status: 'ACTIVE', createdAt: null, updatedAt: null },
|
||||
],
|
||||
})
|
||||
vi.mocked(voidEvidence).mockResolvedValue({} as never)
|
||||
const prompt = vi.spyOn(ElMessageBox, 'prompt').mockResolvedValue({ value: '照片上传错误' } as never)
|
||||
const wrapper = mountPanel(['platform:firstleg:inbound:loading:view', 'platform:firstleg:inbound:loading:edit'], 'LOADING')
|
||||
await flushPromises()
|
||||
|
||||
const voidButton = wrapper.findAll('button').find((button) => button.text() === '作废')
|
||||
expect(voidButton).toBeTruthy()
|
||||
await voidButton!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(prompt).toHaveBeenCalledWith(
|
||||
'作废后照片仍会保留在审计记录中。',
|
||||
'作废证据照片',
|
||||
expect.objectContaining({
|
||||
inputType: 'textarea',
|
||||
inputPlaceholder: '请输入作废原因',
|
||||
type: 'warning',
|
||||
}),
|
||||
)
|
||||
const options = prompt.mock.calls[0]?.[2]
|
||||
expect(options?.inputValidator?.(' ')).toBe('作废原因不能为空')
|
||||
expect(voidEvidence).toHaveBeenCalledWith(
|
||||
'2086085512165634052',
|
||||
'2086085512165634051',
|
||||
'1',
|
||||
{ expectedVersion: 2, reason: '照片上传错误' },
|
||||
)
|
||||
prompt.mockRestore()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { RefreshCw, Save, Check, Play, Camera, Eye, Plus, Pencil, Trash2 } from '@lucide/vue'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { ApiResponseError, getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http'
|
||||
@@ -345,8 +346,21 @@ async function uploadAndSaveEvidence(type: EvidenceType, event: Event) {
|
||||
|
||||
async function markEvidenceVoided(item: Evidence) {
|
||||
if (!canEvidence.value || !item.id || String(item.id).startsWith('draft-')) return
|
||||
const reason = window.prompt('请输入照片作废原因')?.trim()
|
||||
if (!reason) return
|
||||
let reason = ''
|
||||
try {
|
||||
const result = await ElMessageBox.prompt('作废后照片仍会保留在审计记录中。', '作废证据照片', {
|
||||
inputType: 'textarea',
|
||||
inputPlaceholder: '请输入作废原因',
|
||||
inputValidator: (value) => Boolean(value?.trim()) || '作废原因不能为空',
|
||||
confirmButtonText: '确认作废',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
reason = result.value.trim()
|
||||
} catch (cause) {
|
||||
if (cause === 'cancel' || cause === 'close') return
|
||||
throw cause
|
||||
}
|
||||
const result = await run(`evidence-void-${item.id}`, () => voidEvidence(props.tenantId, props.inboundId, item.id, {
|
||||
expectedVersion: item.version,
|
||||
reason,
|
||||
|
||||
Reference in New Issue
Block a user