Commit 66e4d2ef authored by zhangwenshuai's avatar zhangwenshuai

update column

parent b8ff5b9b
...@@ -15,23 +15,23 @@ ...@@ -15,23 +15,23 @@
.colBrief { .colBrief {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: @marginSmX; flex: 1;
//flex: 1; overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.colIcon { .colIcon {
display: flex;
width: @textFontGen; width: @textFontGen;
color: @textPrimaryColor; color: @textPrimaryColor;
margin-right: 5px; margin-right: 5px;
} }
.colTitle { .colTitle {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left; text-align: left;
color: @textPrimaryColor; color: @textPrimaryColor;
font-weight: @weightSemiblod; font-weight: @weightSemiblod;
display: flex; display: flex;
margin-right: @marginSmX;
&.required:before { &.required:before {
display: inline-block; display: inline-block;
margin-right: 4px; margin-right: 4px;
...@@ -60,36 +60,35 @@ ...@@ -60,36 +60,35 @@
} }
} }
} }
} .sortArrowGroup {
.upArrow {
.sortArrowGroup { width: 0;
.upArrow { height: 0;
width: 0; border-left: 3px solid transparent;
height: 0; border-right: 3px solid transparent;
border-left: 3px solid transparent; border-bottom: 6px solid #d8d8d8;
border-right: 3px solid transparent; margin-bottom: 2px;
border-bottom: 6px solid #d8d8d8; cursor: pointer;
margin-bottom: 2px; &:hover {
cursor: pointer; border-bottom-color: #5088e4;
&:hover { }
border-bottom-color: #5088e4; &.selected {
} border-bottom-color: #5088e4;
&.selected { }
border-bottom-color: #5088e4;
}
}
.downArrow {
width: 0;
height: 0;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 6px solid #d8d8d8;
cursor: pointer;
&:hover {
border-top-color: #5088e4;
} }
&.selected { .downArrow {
border-top-color: #5088e4; width: 0;
height: 0;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 6px solid #d8d8d8;
cursor: pointer;
&:hover {
border-top-color: #5088e4;
}
&.selected {
border-top-color: #5088e4;
}
} }
} }
} }
......
...@@ -76,17 +76,18 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -76,17 +76,18 @@ export default class TableColumn extends PureComponent<ColumnProps> {
rowSelection, rowSelection,
icon, icon,
required, required,
leftMargin = 0,
} = this.props; } = this.props;
const { value = [] } = sortConfig || {}; const { value = [] } = sortConfig || {};
const sort = value.find((item: any) => { const sort = value.find((item: any) => {
return item.colName === columnName; return item.colName === columnName;
}); });
const { sortType }: { sortType: string } = sort || {}; const { sortType }: { sortType: string } = sort || {};
let marginLeft:any = 0; let marginLeft: any = 0;
if (columnIndex === 0 && (rowSelection || showIndex)) { if (columnIndex === 0 && (rowSelection || showIndex)) {
marginLeft = '72px'; marginLeft = `${leftMargin + 36}px`;
if (!rowSelection) { if (!rowSelection) {
marginLeft = '91px'; marginLeft = `${leftMargin + 70}px`;
} }
} }
return ( return (
...@@ -102,31 +103,31 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -102,31 +103,31 @@ export default class TableColumn extends PureComponent<ColumnProps> {
</Tooltip> </Tooltip>
)} )}
</span> </span>
{sortConfig && !!sortFlag && (
<div className={s.sortArrowGroup}>
<div
className={sortType === 'ASC' ? classNames(s.upArrow, s.selected) : s.upArrow}
onClick={() => {
if (sortType === 'ASC') {
this.removeSort();
return;
}
this.changeSort('ASC');
}}
/>
<div
className={sortType === 'DESC' ? classNames(s.downArrow, s.selected) : s.downArrow}
onClick={() => {
if (sortType === 'DESC') {
this.removeSort();
return;
}
this.changeSort('DESC');
}}
/>
</div>
)}
</div> </div>
{sortConfig && !!sortFlag && (
<div className={s.sortArrowGroup}>
<div
className={sortType === 'ASC' ? classNames(s.upArrow, s.selected) : s.upArrow}
onClick={() => {
if (sortType === 'ASC') {
this.removeSort();
return;
}
this.changeSort('ASC');
}}
/>
<div
className={sortType === 'DESC' ? classNames(s.downArrow, s.selected) : s.downArrow}
onClick={() => {
if (sortType === 'DESC') {
this.removeSort();
return;
}
this.changeSort('DESC');
}}
/>
</div>
)}
</div> </div>
); );
} }
......
...@@ -239,12 +239,13 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -239,12 +239,13 @@ export default class AirTable extends Component<TableProps, TableState> {
showIndex, showIndex,
rowSelection, rowSelection,
dataSource, dataSource,
canResized, canResized = true,
onDragResized, onDragResized,
canSorted, canSorted,
onDragSorted, onDragSorted,
tableId, tableId,
cachedFeAttr, cachedFeAttr,
leftMargin,
} = this.props; } = this.props;
const { columns } = this.state; const { columns } = this.state;
const formatColumns = this.memoizeFormatColumns(columns, cachedFeAttr, tableId); const formatColumns = this.memoizeFormatColumns(columns, cachedFeAttr, tableId);
...@@ -299,6 +300,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -299,6 +300,7 @@ export default class AirTable extends Component<TableProps, TableState> {
dataSource={dataSource} dataSource={dataSource}
icon={icon} icon={icon}
required={requiredFlag} required={requiredFlag}
leftMargin={leftMargin}
/> />
</DragSorted> </DragSorted>
</DragResized> </DragResized>
......
...@@ -92,6 +92,7 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -92,6 +92,7 @@ class AirTable extends React.Component<CommonProps, CommonState> {
tableId, tableId,
cachedFeAttr, cachedFeAttr,
renderFirstLeft, renderFirstLeft,
leftMargin,
} = this.props; } = this.props;
const sortConfig = operateConfig const sortConfig = operateConfig
&& operateConfig.menusGroup && operateConfig.menusGroup
...@@ -156,6 +157,7 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -156,6 +157,7 @@ class AirTable extends React.Component<CommonProps, CommonState> {
canSorted={canSorted} canSorted={canSorted}
onDragSorted={onDragSorted} onDragSorted={onDragSorted}
renderFirstLeft={renderFirstLeft} renderFirstLeft={renderFirstLeft}
leftMargin={leftMargin}
/> />
</div> </div>
</div> </div>
......
...@@ -85,6 +85,7 @@ export interface TableProps extends LoadConfigProps { ...@@ -85,6 +85,7 @@ export interface TableProps extends LoadConfigProps {
onEmitMsg?: Function; // 是否支持消息协同 onEmitMsg?: Function; // 是否支持消息协同
cachedFeAttr?: boolean; // 是否启用前端缓存 cachedFeAttr?: boolean; // 是否启用前端缓存
renderFirstLeft?:Function; // 第一个单元格特殊渲染 renderFirstLeft?:Function; // 第一个单元格特殊渲染
leftMargin?: number; // 第一个表头左侧对齐距离
} }
export interface TableState { export interface TableState {
columns: ColumnProps[]; columns: ColumnProps[];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment