fix(pl): 优化证件行内绑定并保护已关联数据免于误改
This commit is contained in:
1 parent
ed22f7df4e
commit
d30a406aa6
12 files changed
+300
-54
No files matched your search
@@ -512,3 +512,57 @@ test('产品加载失败可再次展开重试,加载中不能改选择', async
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
|
||||
test('inline binding adds an empty row, requires contract, and resets products on change', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
try {
|
||||
await s.edit()
|
||||
s.addContractBinding()
|
||||
assert.equal(s.form.value.contractBindings.length, 1)
|
||||
assert.equal(s.form.value.contractBindings[0].contractId, '')
|
||||
await s.save()
|
||||
assert.equal(h.writes.length, 0)
|
||||
s.changeBindingContract(0, 'c1')
|
||||
h.productRequests.at(-1).resolve([{ id: 'p1', productName: '产品1' }])
|
||||
await Promise.resolve()
|
||||
await Promise.resolve()
|
||||
s.setBindingProducts(0, ['p1'])
|
||||
s.changeBindingContract(0, 'c2')
|
||||
assert.deepEqual(s.form.value.contractBindings[0].products, [])
|
||||
assert.equal(s.form.value.contractBindings[0].contractId, 'c2')
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
|
||||
test('referenced bindings and references cannot be edited or removed', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
try {
|
||||
h.setCert({
|
||||
referencesEditable: false,
|
||||
contractBindings: [
|
||||
{
|
||||
id: 'b',
|
||||
contractId: 'c',
|
||||
editLocked: true,
|
||||
products: [{ id: 'p', contractProductId: 'p1' }]
|
||||
}
|
||||
],
|
||||
purchaseRefs: [{ id: 'r', referenceType: 'unknown', referenceNo: 'ref' }]
|
||||
})
|
||||
s.kind.value = 'transport'
|
||||
await s.edit({ id: 'cert' })
|
||||
s.removeContractBinding(0)
|
||||
assert.equal(s.form.value.contractBindings.length, 1)
|
||||
s.changeBindingContract(0, 'other')
|
||||
assert.equal(s.form.value.contractBindings[0].contractId, 'c')
|
||||
s.removeReference(0)
|
||||
s.addReference()
|
||||
assert.equal(s.form.value.purchaseRefs.length, 1)
|
||||
assert.ok(h.messages.some((m) => m.includes('联系管理员')))
|
||||
} finally {
|
||||
h.stop()
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user