Files
platforms/frontend/platform_admin/scripts/check-gasorder-creator-linkage.mjs
2026-08-14 01:15:33 +08:00

43 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 功能:静态检查配送订单创建方类型与业务主体候选的动态联动。
* 版本v1.1.0
*/
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const resources = readFileSync(new URL('../src/api/resources.ts', import.meta.url), 'utf8');
const form = readFileSync(new URL('../src/views/resource/ResourceFieldForm.vue', import.meta.url), 'utf8');
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'",
"delivery: '/delivery_basic'",
"gas: '/gas_basic'",
]) {
assert.ok(resources.includes(mapping), `创建方动态资源缺少映射:${mapping}`);
}
assert.match(resources, /label: '创建方'/, '创建方字段必须使用业务名称');
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('配送订单创建方检查通过:合同主体自动带出,工作人员按履约组织筛选,切换合同会重新匹配。');