feat(pl): 实现合同产品用证与额度结转以支持购买证和运输证全流程管理。

This commit is contained in:
wuzilong committed 2026-11-01 18:56:05 +08:00
1 parent cb0344498a
commit fb866c7fa7
104 files changed
+10187 -3833

No files matched your search

@@ -3,7 +3,7 @@ import test from 'node:test'
import { readFileSync } from 'node:fs'
import { parse } from '@vue/compiler-sfc'
import ts from 'typescript'
import { computed, effectScope, ref, watch, nextTick } from 'vue'
import { computed, effectScope } from 'vue'
import { useMobilePlanListDetails } from '../src/views/m/pl/plan/mobileListDetails'
import { formatBrandConstraintLabel } from '../src/utils/crm-product-brand'
import { getPlanProductActualQuantity } from '../src/utils/pl-display'
@@ -103,75 +103,4 @@ test('certificate expanded card joins list standard names, preserves segment emp
scope.stop()
})
test('actual certificate list expands only the requested card and fetches mobile segment metadata', async () => {
const source = parse(
readFileSync(new URL('../src/views/m/pl/plan-cert/index.vue', import.meta.url), 'utf8')
).descriptor.scriptSetup!.content
const ast = ts.createSourceFile('list.ts', source, ts.ScriptTarget.Latest, true)
const code = ast.statements
.filter(
(n) =>
(ts.isVariableStatement(n) &&
n.declarationList.declarations.some((d) => d.name.getText(ast) === 'planDetails')) ||
(ts.isFunctionDeclaration(n) && n.name?.text === 'toggleExpanded') ||
(ts.isExpressionStatement(n) &&
ts.isCallExpression(n.expression) &&
n.expression.expression.getText(ast) === 'watch' &&
n.expression.arguments[0]?.getText(ast) === 'expandedIds')
)
.map((n) => n.getText(ast))
.join('\n')
const calls: any[] = []
const env = {
useMobilePlanListDetails,
watch,
expandedIds: ref(new Set()),
requestKey: () => 'scope',
planApi: {
get: (id: string, mobile: boolean) =>
new Promise((resolve) => calls.push({ id, mobile, resolve }))
}
}
const scope = effectScope()
const api = scope.run(() =>
new Function(
...Object.keys(env),
`${ts.transpile(code, { target: ts.ScriptTarget.ESNext })};return {planDetails,toggleExpanded}`
)(...Object.values(env))
)
assert.equal(calls.length, 0)
api.toggleExpanded('A', true)
await nextTick()
assert.deepEqual(
calls.map(({ id, mobile }) => [id, mobile]),
[['A', true]]
)
assert.equal(api.planDetails.records.A.plan, null)
calls[0].resolve({
id: 'A',
products: [{ id: 'p', productName: '根别名' }],
deliveries: [
{
products: [
{
planProductId: 'p',
mobileProductMeta: { aliasName: '段次别名', brandMode: 'any', brandName: '' }
}
]
}
]
})
await api.planDetails.ensure('A')
const plan = api.planDetails.cardPlan({
id: 'A',
products: [{ id: 'p', productName: '标准产品' }]
})
const rendered = card(plan)
assert.equal(rendered.productNameLabel.value, '标准产品')
assert.equal(rendered.productLine(plan.deliveries[0].products[0], 'delivery').alias, '段次别名')
api.toggleExpanded('A', false)
api.toggleExpanded('A', true)
await nextTick()
assert.equal(calls.length, 1)
scope.stop()
})
// Retired attachment/ready list expansion is replaced by real quota list coverage in quota-mobile-state.test.ts.