Files
platforms/frontend/platform_admin/scripts/check-contract-product-entry.mjs
2026-08-14 20:10:09 +08:00

40 lines
2.5 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 listSource = readFileSync(
new URL('../src/views/shared/CrudListPage.vue', import.meta.url),
'utf8',
);
const detailSource = readFileSync(
new URL('../src/views/resource/ResourceRecordPage.vue', import.meta.url),
'utf8',
);
const resourcesSource = readFileSync(
new URL('../src/api/resources.ts', import.meta.url),
'utf8',
);
const formSource = readFileSync(
new URL('../src/views/resource/ResourceFieldForm.vue', import.meta.url),
'utf8',
);
assert.match(listSource, /definition\.name === 'gasorder_contract' && Number\(record\.contract_status\) === 0/, '绑定入口必须仅展示在草稿合同列表行');
assert.match(listSource, />\s*绑定气瓶\s*</, '草稿合同操作列必须展示“绑定气瓶”按钮');
assert.match(listSource, /name: 'user-contract-products-create'/, '绑定入口必须跳转合同气瓶新建页');
assert.match(listSource, /relation_key: 'gasorder_contract_identity'/, '绑定入口必须指定合同关系字段');
assert.match(listSource, /owner_identity: String\(row\.identity \?\? ''\)/, '绑定入口必须预填所选合同唯一标识');
assert.match(listSource, /return_to: route\.fullPath/, '绑定完成后必须支持返回合同列表');
assert.doesNotMatch(detailSource, />\s*绑定气瓶\s*</, '合同详情页不应继续展示绑定按钮');
assert.match(detailSource, /definition\.value\.name === 'gasorder_contract_product'[\s\S]*field\.key === 'gasorder_contract_identity'[\s\S]*route\.query\.relation_key === 'gasorder_contract_identity'[\s\S]*Boolean\(route\.query\.owner_identity\)/, '从合同列表进入时必须锁定预填合同');
assert.match(resourcesSource, /readonlyRelationText: true, displayRelationLabel: true/, '锁定合同必须以可读名称展示');
assert.match(resourcesSource, /label: '智能气阀'/, '绑定表单不得继续显示“智能气阀唯一标识”');
assert.match(resourcesSource, /该合同用户暂无可绑定的智能气阀/, '空候选必须说明合同用户归属前置条件');
assert.match(resourcesSource, /routeName: 'product-info'/, '空候选必须提供智能气阀管理入口');
assert.match(formSource, /navigateRelationEmptyAction/, '关系空状态必须渲染可执行的站内引导');
console.log('合同气瓶绑定入口检查通过:草稿合同可绑定气阀,空候选会解释归属条件并跳转智能气阀管理。');