/** * 功能:静态检查配送订单创建方类型与业务主体候选的动态联动。 * 版本:v1.0.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'/, '创建方必须由创建方类型驱动'); 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: '创建方'/, '创建方字段必须使用业务名称'); assert.match(resources, /创建方类型已变更,请重新选择创建方/, '切换类型时缺少清空提示'); assert.match(form, /field\.dynamicRelation && !relationResource\(field\)/, '未选择类型时必须禁用创建方'); assert.match(form, /v-else-if="field\.type === 'select'"[\s\S]*?emit\('change-relation'/, '普通选择框未触发动态联动'); assert.match(linkage, /reloadDynamicOptions/, '动态关系候选未接入加载流程'); assert.match(linkage, /form\[childField\.key\] = ''/, '切换类型时未清空旧创建方'); console.log('配送订单创建方检查通过:四类创建方按类型动态加载,切换类型会清空旧值。');