Skip to content

Commit

Permalink
fix(table): 列拖动后,选中行列拖动后到距离被重置了
Browse files Browse the repository at this point in the history
  • Loading branch information
LoopZhou committed May 12, 2022
1 parent 34b04f0 commit 5f264cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions src/table/hooks/useRowSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ export default function useRowSelect(props: TdPrimaryTableProps) {

// eslint-disable-next-line
function getSelectedHeader(h: CreateElement) {
const isIndeterminate = intersectionKeys.value.length > 0 && intersectionKeys.value.length < canSelectedRows.value.length;
return () => (
<Checkbox
checked={intersectionKeys.value.length === canSelectedRows.value.length}
indeterminate={isIndeterminate}
indeterminate={
intersectionKeys.value.length > 0 && intersectionKeys.value.length < canSelectedRows.value.length
}
disabled={!canSelectedRows.value.length}
{...{ on: { change: handleSelectAll } }}
/>
Expand Down Expand Up @@ -139,18 +140,12 @@ export default function useRowSelect(props: TdPrimaryTableProps) {
function formatToRowSelectColumn(col: PrimaryTableCol) {
const isSelection = ['multiple', 'single'].includes(col.type);
if (!isSelection) return col;

!col.width
&& Object.assign(col, {
width: 64,
});

const result = Object.assign(col, {
return {
...col,
width: col.width || 64,
cell: (h: CreateElement, p: PrimaryTableCellParams<TableRowData>) => renderSelectCell(h, p),
title: col.type === 'multiple' ? getSelectedHeader(h) : '',
});

return result;
};
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/table/primary-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default defineComponent({
const getColumns = (columns: PrimaryTableCol<TableRowData>[]) => {
const arr: PrimaryTableCol<TableRowData>[] = [];
for (let i = 0, len = columns.length; i < len; i++) {
let item = columns[i];
let item = { ...columns[i] };
// 自定义列显示控制
const isDisplayColumn = item.children?.length || tDisplayColumns.value?.includes(item.colKey);
if (!isDisplayColumn && props.columnController) continue;
Expand Down

0 comments on commit 5f264cb

Please sign in to comment.