2021-08-20 12:31:24 +05:00
|
|
|
|
export { Table } from 'antd'
|
2021-08-20 10:49:20 +05:00
|
|
|
|
export { EditableTable } from './EditableTable'
|
|
|
|
|
export { DatePickerWrapper } from './DatePickerWrapper'
|
2021-08-20 12:31:24 +05:00
|
|
|
|
export { SelectFromDictionary } from './SelectFromDictionary'
|
2021-08-20 10:49:20 +05:00
|
|
|
|
|
|
|
|
|
export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/
|
|
|
|
|
export const formatDate='YYYY.MM.DD HH:mm'
|
|
|
|
|
|
|
|
|
|
export const numericColumnOptions = {
|
|
|
|
|
editable: true,
|
|
|
|
|
initialValue: 0,
|
|
|
|
|
width:100,
|
|
|
|
|
formItemRules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: `Введите число`,
|
|
|
|
|
pattern: RegExpIsFloat,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
other - объект с дополнительными свойствами колонки
|
|
|
|
|
поддерживаются все базовые свойства из описания https://ant.design/components/table/#Column
|
|
|
|
|
плю дополнительные для колонок EditableTable:
|
|
|
|
|
editable - редактируемая колонка, bool
|
|
|
|
|
input - react компонента редактора (<Input/>, <InputNumber/>, <DatePickerWrapper/>...)
|
|
|
|
|
isRequired - значение может быть пустым,
|
|
|
|
|
formItemClass - css класс для <FormItem/>, если требуется
|
|
|
|
|
formItemRules - массив правил валидации значений https://ant.design/components/form/#Rule,
|
|
|
|
|
initialValue - дефолтное значение при добавлении новой строки
|
|
|
|
|
*/
|
|
|
|
|
export const makeColumn = (title:string, key:string, other?:any) => ({
|
|
|
|
|
title: title,
|
|
|
|
|
key: key,
|
|
|
|
|
dataIndex: key,
|
|
|
|
|
...other,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export const makeColumnsPlanFact = (title:string, key:string|string[], columsOther?:any|any[], gruopOther?:any) =>
|
|
|
|
|
{
|
|
|
|
|
let keyPlanLocal = key
|
|
|
|
|
let keyFactLocal = key
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
...gruopOther,
|
|
|
|
|
children: [
|
|
|
|
|
makeColumn('план', keyPlanLocal, columsOtherLoacl[0]),
|
|
|
|
|
makeColumn('факт', keyFactLocal, columsOtherLoacl[1]),
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PaginationContainer = {
|
|
|
|
|
skip?: number;
|
|
|
|
|
take?: number;
|
|
|
|
|
count?: number;
|
|
|
|
|
items?: any[] | null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const makePaginationObject = (paginationContainer:PaginationContainer, ...other:any) => {
|
|
|
|
|
let page = 1 + Math.floor((paginationContainer.skip??0) /(paginationContainer.take??1));
|
|
|
|
|
return {
|
|
|
|
|
...other,
|
|
|
|
|
pageSize: paginationContainer.take,
|
|
|
|
|
total: paginationContainer.count ?? paginationContainer.items?.length ?? 0,
|
|
|
|
|
current: page,
|
|
|
|
|
}
|
2021-08-20 12:31:24 +05:00
|
|
|
|
}
|