feat: align number columns text to right

This commit is contained in:
chenos 2021-01-06 16:15:01 +08:00
parent 8c679b0938
commit eac7734f07
2 changed files with 9 additions and 1 deletions

View File

@ -32,4 +32,9 @@
> *:last-child { > *:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
}
.ant-table-cell.noco-field-percent,
.ant-table-cell.noco-field-number {
text-align: right;
} }

View File

@ -7,6 +7,7 @@ import findIndex from 'lodash/findIndex';
import get from 'lodash/get'; import get from 'lodash/get';
import './style.less'; import './style.less';
import Field from '../Field'; import Field from '../Field';
import cloneDeep from 'lodash/cloneDeep';
export const SortableItem = sortableElement(props => <tr {...props} />); export const SortableItem = sortableElement(props => <tr {...props} />);
export const SortableContainer = sortableContainer(props => <tbody {...props} />); export const SortableContainer = sortableContainer(props => <tbody {...props} />);
@ -57,8 +58,10 @@ export const components = ({data = {}, rowKey, mutate, onMoved}: Props) => {
}; };
export function fields2columns(fields) { export function fields2columns(fields) {
const columns: any[] = fields.map(field => { const columns: any[] = fields.map(item => {
const field = cloneDeep(item);
field.render = (value) => field.interface === 'sort' ? <DragHandle/> : <Field viewType={'table'} schema={field} value={value}/>; field.render = (value) => field.interface === 'sort' ? <DragHandle/> : <Field viewType={'table'} schema={field} value={value}/>;
field.className = `${field.className||''} noco-field-${field.interface}`;
return { return {
...field, ...field,
...(field.component||{}), ...(field.component||{}),