修复配送订单创建方合同约束

This commit is contained in:
czl231
2026-08-14 01:15:33 +08:00
parent 9c3abf76d5
commit 08f1a917b3
9 changed files with 407 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
/**
* 功能:静态检查配送订单创建方类型与业务主体候选的动态联动。
* 版本v1.0.0
* 版本v1.1.0
*/
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
@@ -10,6 +10,7 @@ const form = readFileSync(new URL('../src/views/resource/ResourceFieldForm.vue',
const linkage = readFileSync(new URL('../src/views/resource/use-resource-relation-linkage.ts', import.meta.url), 'utf8');
assert.match(resources, /parentKey: 'creator_type'/, '创建方必须由创建方类型驱动');
assert.match(resources, /contextParentKey: 'gasorder_contract_identity'/, '创建方必须同时受配送合同约束');
for (const mapping of [
"user: '/user_account'",
"staff: '/staff_account'",
@@ -19,10 +20,23 @@ for (const mapping of [
assert.ok(resources.includes(mapping), `创建方动态资源缺少映射:${mapping}`);
}
assert.match(resources, /label: '创建方'/, '创建方字段必须使用业务名称');
assert.match(resources, /创建方类型已变更,请重新选择创建方/, '切换类型时缺少清空提示');
assert.match(form, /field\.dynamicRelation && !relationResource\(field\)/, '未选择类型时必须禁用创建方');
for (const fixedIdentity of [
"user: 'user_account_identity'",
"gas: 'gas_basic_identity'",
"delivery: 'delivery_basic_identity'",
]) {
assert.ok(resources.includes(fixedIdentity), `合同固定创建方缺少映射:${fixedIdentity}`);
}
assert.match(resources, /delivery_basic_unassigned/, '无配送点合同时工作人员必须限定为气站直属人员');
assert.match(resources, /所选合同未指定配送点,不能以配送点作为创建方/, '合同缺少配送点时必须给出明确提示');
assert.match(resources, /创建方类型已变更,已按当前合同重新匹配创建方/, '切换类型时缺少重新匹配提示');
assert.match(resources, /relationFilters: \{ status: '1' \}/, '工作人员候选必须限定为启用状态');
assert.match(form, /field\.dynamicRelation[\s\S]*?contextParentKey/, '未选择合同时必须禁用创建方');
assert.match(form, /v-else-if="field\.type === 'select'"[\s\S]*?emit\('change-relation'/, '普通选择框未触发动态联动');
assert.match(linkage, /reloadDynamicOptions/, '动态关系候选未接入加载流程');
assert.match(linkage, /fixedIdentityKeys/, '合同唯一创建方未接入自动带出');
assert.match(linkage, /scopeFilters/, '工作人员候选未接入合同组织筛选');
assert.match(linkage, /contextDynamicChildren/, '切换合同时未重新匹配创建方');
assert.match(linkage, /form\[childField\.key\] = ''/, '切换类型时未清空旧创建方');
console.log('配送订单创建方检查通过:四类创建方按类型动态加载,切换类型会清空旧值。');
console.log('配送订单创建方检查通过:合同主体自动带出,工作人员按履约组织筛选,切换合同会重新匹配。');