From 79452f06dbb651da162fc2045c09e777bb14f452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Fri, 30 Jul 2021 15:13:15 +0500 Subject: [PATCH] components factory update --- src/components/factory.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/factory.ts b/src/components/factory.ts index e53dbaa..95f9e28 100644 --- a/src/components/factory.ts +++ b/src/components/factory.ts @@ -5,22 +5,31 @@ export const makeColumn = (title:string, key:string, other?:any) => ({ ...other, }) -export const makeColumnsPlanFact = (title:string, keyPlan:string, keyFact?:string, groupOther?:any) => +export const makeColumnsPlanFact = (title:string, key:string|string[], gruopOther?:any, columsOther?:any|any[]) => { - let keyPlanLocal = keyPlan - let keyFactLocal = keyFact ?? '' + let keyPlanLocal = key + let keyFactLocal = key - if(!keyFact){ - keyPlanLocal = keyPlan + 'Plan' - keyFactLocal = keyPlan + 'Fact' + if(key instanceof Array){ + keyPlanLocal = key[0] + keyFactLocal = key[1] + }else{ + keyPlanLocal = key + 'Plan' + keyFactLocal = key + 'Fact' } + let columsOtherLoacl :any[2] + if(columsOther instanceof Array) + columsOtherLoacl = [columsOther[0], columsOther[1]] + else + columsOtherLoacl = [columsOther, columsOther] + return { title: title, - ...groupOther, - children: [ - makeColumn('план', keyPlanLocal), - makeColumn('факт', keyFactLocal), + ...gruopOther, + children: [ + makeColumn('план', keyPlanLocal, columsOtherLoacl[0]), + makeColumn('факт', keyFactLocal, columsOtherLoacl[1]), ] } } \ No newline at end of file