feat(pl): 调整计划用证布局并在单张证件保存后重置表单。
This commit is contained in:
1 parent
26c6dc3a93
commit
0e83e22847
4 files changed
+516
-281
No files matched your search
@@ -78,7 +78,7 @@ function harness() {
|
||||
...model.newCert(kind as any),
|
||||
id,
|
||||
certNo: 'EXISTING',
|
||||
attachmentUrls: 'a.png,b.png',
|
||||
attachmentUrls: 'a.png',
|
||||
...certData
|
||||
},
|
||||
save: async (kind: string, body: any, id?: string) => {
|
||||
@@ -148,6 +148,7 @@ test('type changes immediately while options load and stale options cannot enter
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
const options = h.deferOptions()
|
||||
const switching = s.changeFormKind('transport')
|
||||
assert.equal(s.formKind.value, 'transport')
|
||||
@@ -166,6 +167,7 @@ test('new form type changes without closing dialog or changing the list, and dri
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
assert.equal(s.formKind?.value, 'purchase')
|
||||
await s.changeFormKind('transport')
|
||||
assert.equal(s.formKind.value, 'transport')
|
||||
@@ -189,6 +191,7 @@ test('switch clears old certificate data after confirmation, preserving attachme
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.form.value.certNo = 'PURCHASE-1'
|
||||
s.form.value.entryMode = 'image_parse'
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
@@ -209,6 +212,7 @@ test('cancel type switch and existing certificate edit preserve data and origina
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.form.value.certNo = 'KEEP'
|
||||
h.cancelSwitch()
|
||||
s.selectedFormKind.value = 'transport'
|
||||
@@ -219,7 +223,7 @@ test('cancel type switch and existing certificate edit preserve data and origina
|
||||
await s.edit({ id: 'existing' })
|
||||
await s.changeFormKind('transport')
|
||||
assert.equal(s.formKind.value, 'purchase')
|
||||
assert.equal(s.form.value.attachmentUrls, 'a.png,b.png')
|
||||
assert.equal(s.form.value.attachmentUrls, 'a.png')
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
@@ -230,6 +234,7 @@ test('single attachment is automatically selected, parsing uses form type and pr
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
await s.changeFormKind('transport')
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
await vue.nextTick()
|
||||
@@ -257,6 +262,7 @@ test('missing, removed, multiple new attachments and uploads in progress never s
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = ''
|
||||
const empty = s.recognize()
|
||||
assert.equal(h.parses.length, 0)
|
||||
await empty
|
||||
@@ -293,6 +299,7 @@ test('closed or switched forms reject delayed recognition results', async () =>
|
||||
if (action === 'close') {
|
||||
s.formVisible.value = false
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
} else await s.changeFormKind('transport')
|
||||
h.parses[0].resolve({ candidates: { certNo: 'OLD' }, invalidFields: {} })
|
||||
await parsing
|
||||
@@ -355,6 +362,7 @@ test('产品勾选往返保留原范围ID;关闭重开后拒绝旧合同和产
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.addContractBinding('c')
|
||||
h.productRequests[0].resolve([{ id: 'p' }, { id: 'p2' }])
|
||||
await vue.nextTick()
|
||||
@@ -368,6 +376,7 @@ test('产品勾选往返保留原范围ID;关闭重开后拒绝旧合同和产
|
||||
const products = s.loadBindingProducts('c')
|
||||
s.formVisible.value = false
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
h.contractRequests.at(-1).resolve([{ id: 'stale', contractNo: '旧合同' }])
|
||||
h.productRequests.forEach((r) => r.resolve([{ id: 'stale', productName: '旧产品' }]))
|
||||
await Promise.all([search, products])
|
||||
@@ -407,6 +416,7 @@ test('后发合同搜索覆盖先发,租户切换使保存和读取旧结果
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
const first = s.searchBindingContracts('first'),
|
||||
second = s.searchBindingContracts('second')
|
||||
h.contractRequests[1].resolve([{ id: 'second', contractNo: 'SECOND', contractName: '' }])
|
||||
@@ -438,6 +448,7 @@ test('新增多合同连同证面成功提交一次,移除全部提交明确
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.addContractBinding('one')
|
||||
s.addContractBinding('two')
|
||||
h.productRequests[0].resolve([{ id: 'p1' }])
|
||||
@@ -453,7 +464,7 @@ test('新增多合同连同证面成功提交一次,移除全部提交明确
|
||||
h.writes[0].body.contractBindings.map((b: any) => b.contractId),
|
||||
['one', 'two']
|
||||
)
|
||||
assert.equal(s.formVisible.value, false)
|
||||
assert.equal(s.formVisible.value, true)
|
||||
h.setCert({ contractBindings: [{ id: 'b', contractId: 'one', products: [] }] })
|
||||
await s.edit({ id: 'existing' })
|
||||
s.removeContractBinding(0)
|
||||
@@ -469,6 +480,7 @@ test('同合同产品后发请求优先,移除重加使移除前请求失效',
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.addContractBinding('c')
|
||||
const second = s.loadBindingProducts('c')
|
||||
h.productRequests[1].resolve([{ id: 'new', productName: '新产品' }])
|
||||
@@ -496,6 +508,7 @@ test('产品加载失败可再次展开重试,加载中不能改选择', async
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.addContractBinding('c')
|
||||
h.productRequests[0].reject(new Error('network'))
|
||||
await vue.nextTick()
|
||||
@@ -518,6 +531,7 @@ test('inline binding adds an empty row, requires contract, and resets products o
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.addContractBinding()
|
||||
assert.equal(s.form.value.contractBindings.length, 1)
|
||||
assert.equal(s.form.value.contractBindings[0].contractId, '')
|
||||
@@ -589,3 +603,100 @@ test('recognition cannot populate locked empty references while other empty fiel
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
|
||||
test('successful edit clears attachment and remark and becomes a fresh open form', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit({ id: 'existing' })
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.form.value.remark = '本张备注'
|
||||
await s.save()
|
||||
assert.equal(h.writes[0].body.remark, '本张备注')
|
||||
assert.equal(s.formVisible.value, true)
|
||||
assert.equal(s.editingId.value, '')
|
||||
assert.equal(s.form.value.attachmentUrls, '')
|
||||
assert.equal(s.form.value.remark, '')
|
||||
s.form.value.attachmentUrls = 'next.png'
|
||||
await s.save()
|
||||
assert.equal(h.writes[1].id, undefined)
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
|
||||
test('save and recognition reject missing or historical multiple attachments', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit({ id: 'existing' })
|
||||
for (const urls of ['', 'a.png,b.png']) {
|
||||
s.form.value.attachmentUrls = urls
|
||||
await vue.nextTick()
|
||||
s.recognitionImage.value = urls.split(',')[0]
|
||||
await s.save()
|
||||
const parsing = s.recognize()
|
||||
for (const p of h.parses) p.resolve({ candidates: {}, invalidFields: {} })
|
||||
await parsing
|
||||
}
|
||||
assert.equal(h.writes.length, 0)
|
||||
assert.equal(h.parses.length, 0)
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
|
||||
test('new transport save keeps its type open while failures and recognition preserve the current remark', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
await s.changeFormKind('transport')
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
s.form.value.remark = '不得丢失'
|
||||
await s.save()
|
||||
assert.equal(s.formVisible.value, true)
|
||||
assert.equal(s.kind.value, 'transport')
|
||||
assert.equal(s.formKind.value, 'transport')
|
||||
assert.equal(s.form.value.remark, '')
|
||||
assert.deepEqual(s.form.value.purchaseRefs, [])
|
||||
assert.deepEqual(s.form.value.contractBindings, [])
|
||||
s.form.value.attachmentUrls = 'two.png'
|
||||
s.form.value.remark = '失败保留'
|
||||
s.recognizing.value = true
|
||||
await s.save()
|
||||
assert.equal(h.writes.length, 1)
|
||||
assert.equal(s.form.value.remark, '失败保留')
|
||||
s.recognizing.value = false
|
||||
h.failSave()
|
||||
await assert.rejects(s.save(), /保存失败/)
|
||||
assert.equal(s.form.value.remark, '失败保留')
|
||||
assert.equal(s.form.value.attachmentUrls, 'two.png')
|
||||
assert.equal(s.formVisible.value, true)
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
|
||||
test('saving while transport purchase candidates load refreshes candidates for the next session', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
const old = h.deferOptions()
|
||||
const switching = s.changeFormKind('transport')
|
||||
const fresh = h.deferOptions()
|
||||
s.form.value.attachmentUrls = 'one.png'
|
||||
await s.save()
|
||||
old.resolve([{ id: 'stale' }])
|
||||
await switching
|
||||
assert.deepEqual(s.purchases.value, [])
|
||||
fresh.resolve([{ id: 'fresh' }])
|
||||
await Promise.resolve()
|
||||
await vue.nextTick()
|
||||
assert.deepEqual(s.purchases.value, [{ id: 'fresh' }])
|
||||
assert.equal(s.formVisible.value, true)
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user