asb_cloud_front/src/components/factory.ts

35 lines
854 B
TypeScript
Raw Normal View History

2021-07-29 11:38:09 +05:00
export const makeColumn = (title:string, key:string, other?:any) => ({
2021-07-29 11:22:25 +05:00
title: title,
key: key,
dataIndex: key,
...other,
})
2021-07-29 11:22:25 +05:00
2021-07-30 15:13:15 +05:00
export const makeColumnsPlanFact = (title:string, key:string|string[], gruopOther?:any, columsOther?:any|any[]) =>
2021-07-29 11:22:25 +05:00
{
2021-07-30 15:13:15 +05:00
let keyPlanLocal = key
let keyFactLocal = key
2021-07-29 11:22:25 +05:00
2021-07-30 15:13:15 +05:00
if(key instanceof Array){
keyPlanLocal = key[0]
keyFactLocal = key[1]
}else{
keyPlanLocal = key + 'Plan'
keyFactLocal = key + 'Fact'
2021-07-29 11:22:25 +05:00
}
2021-07-30 15:13:15 +05:00
let columsOtherLoacl :any[2]
if(columsOther instanceof Array)
columsOtherLoacl = [columsOther[0], columsOther[1]]
else
columsOtherLoacl = [columsOther, columsOther]
2021-07-29 11:22:25 +05:00
return {
title: title,
2021-07-30 15:13:15 +05:00
...gruopOther,
children: [
makeColumn('план', keyPlanLocal, columsOtherLoacl[0]),
makeColumn('факт', keyFactLocal, columsOtherLoacl[1]),
2021-07-29 11:22:25 +05:00
]
}
}