import { describe, expect, it } from 'vitest';
|
import { isReprintMeasureLocked, reprintMeasureOptions } from '../dmsReprintMeasure';
|
const field = { __vModel__: 'cuoshi', __config__: { relationTable: 'dms_wenjian_bupingheng_dengji_zixiang' } };
|
describe('DMS重打措施编辑限制', () => {
|
it('保留措施3名称但禁选,不污染共享字典缓存', () => {
|
const options = [
|
{ enCode: 'cuoshi1', fullName: '作废补打' },
|
{ enCode: 'cuoshi3', fullName: '原流水重打' },
|
];
|
const result = reprintMeasureOptions(field, options);
|
expect(result[1]).toEqual({ ...options[1], disabled: true });
|
expect(options[1]).not.toHaveProperty('disabled');
|
expect(result[0]).toBe(options[0]);
|
});
|
it('旧登录缓存缺少措施3时保留已发布表单名称且仍不可选', () => {
|
const configured = { enCode: 'cuoshi3', fullName: '措施3:原流水重打' };
|
const cached = [{ enCode: 'cuoshi1', fullName: '作废补打' }];
|
const result = reprintMeasureOptions({ ...field, options: [configured] }, cached);
|
expect(result).toEqual([...cached, { ...configured, disabled: true }]);
|
const initialized = { ...field, options: reprintMeasureOptions({ ...field, options: [configured] }, []) };
|
expect(reprintMeasureOptions(initialized, cached)).toEqual(result);
|
expect(cached).toHaveLength(1);
|
expect(configured).not.toHaveProperty('disabled');
|
});
|
it('已有措施3锁定字段,其他措施可编辑', () => {
|
expect(isReprintMeasureLocked(field, { cuoshi: 'cuoshi3' })).toBe(true);
|
expect(isReprintMeasureLocked(field, { cuoshi: 'cuoshi1' })).toBe(false);
|
});
|
it('不影响其他业务表', () => {
|
const options = [{ enCode: 'cuoshi3' }];
|
const other = { ...field, __config__: { relationTable: 'other' } };
|
expect(reprintMeasureOptions(other, options)).toBe(options);
|
expect(isReprintMeasureLocked(other, { cuoshi: 'cuoshi3' })).toBe(false);
|
});
|
});
|