A报表传递形式有很深的 struct .每种形式都有自己的格式,每种格式都有自己的频率.
const forms = [
{
value: "1",
label: 'Email',
formats: [
{
value: '1',
label: 'PDF',
frequency: [
{
value: 'D',
label: 'Daily',
},
{
value: 'W',
label: 'Weekly',
},
],
},
{
value: '2',
label: 'XML',
frequency: [
{
value: 'D',
label: 'Daily',
},
],
},
],
},
{
value: '2',
label: 'Post',
formats: [
{
value: '1',
label: 'PDF',
frequency: [
{
value: 'D',
label: 'Daily',
},
{
value: 'W',
label: 'Weekly',
},
],
},
{
value: '2',
label: 'XML',
frequency: [
{
value: 'D',
label: 'Daily',
},
],
},
],
},
];
我还有另一个数组,其中包含表示表单 struct 的限制/规则的对象.现在我需要以某种方式循环每个选项,并将其与这些限制进行比较.如果该选项将与限制对象之一具有相同的值(形式、格式和频率),则该特定选项将从 struct 中移除,或者将基于隐藏值保留在那里.我如何才能做到这一点,或者我应该使用什么策略?
const restrictions = [
{form: '1', format: '1', frequency: 'D', hide: false},
{form: '1', format: '2', frequency: 'W', hide: true},
{form: '2', format: '1', frequency: 'D', hide: true},
{form: '2', format: '2', frequency: 'W', hide: false},
]