fix(通用功能): 全选框下拉列表,点击选择所有数据或者可见数据,不出现勾选效果
--bug=1022406 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001022406
This commit is contained in:
parent
9350fbbf18
commit
d8d04062d1
|
@ -137,13 +137,13 @@ import {
|
||||||
_sort,
|
_sort,
|
||||||
checkTableRowIsSelect,
|
checkTableRowIsSelect,
|
||||||
clearShareDragParam,
|
clearShareDragParam,
|
||||||
|
deleteTableRow,
|
||||||
getCustomTableHeader,
|
getCustomTableHeader,
|
||||||
getSelectDataCounts,
|
getSelectDataCounts,
|
||||||
handleRowDrop,
|
handleRowDrop,
|
||||||
saveCustomTableWidth,
|
saveCustomTableWidth,
|
||||||
saveLastTableSortField,
|
saveLastTableSortField,
|
||||||
setUnSelectIds,
|
setUnSelectIds,
|
||||||
toggleAllSelection,
|
|
||||||
} from "../../utils/tableUtils";
|
} from "../../utils/tableUtils";
|
||||||
import MsTableHeaderSelectPopover from "./MsTableHeaderSelectPopover";
|
import MsTableHeaderSelectPopover from "./MsTableHeaderSelectPopover";
|
||||||
import MsTablePagination from "../pagination/TablePagination";
|
import MsTablePagination from "../pagination/TablePagination";
|
||||||
|
@ -337,6 +337,7 @@ export default {
|
||||||
}
|
}
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
this.checkTableRowIsSelect();
|
this.checkTableRowIsSelect();
|
||||||
|
this.deleteTableRow();
|
||||||
this.listenRowDrop();
|
this.listenRowDrop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -421,11 +422,7 @@ export default {
|
||||||
this.condition
|
this.condition
|
||||||
);
|
);
|
||||||
setUnSelectIds(selection, this.condition, this.selectRows);
|
setUnSelectIds(selection, this.condition, this.selectRows);
|
||||||
this.selectDataCounts = getSelectDataCounts(
|
this.selectDataCounts = this.selectRows.size
|
||||||
this.condition,
|
|
||||||
this.total,
|
|
||||||
this.selectRows
|
|
||||||
);
|
|
||||||
this.selectIds = Array.from(this.selectRows).map((o) => o.id);
|
this.selectIds = Array.from(this.selectRows).map((o) => o.id);
|
||||||
//有的组件需要回调父组件的函数,做下一步处理
|
//有的组件需要回调父组件的函数,做下一步处理
|
||||||
this.$emit("callBackSelectAll", selection);
|
this.$emit("callBackSelectAll", selection);
|
||||||
|
@ -458,6 +455,11 @@ export default {
|
||||||
this.condition.selectAll = data;
|
this.condition.selectAll = data;
|
||||||
//显示隐藏菜单
|
//显示隐藏菜单
|
||||||
_handleSelectAll(this, this.data, this.data, this.selectRows);
|
_handleSelectAll(this, this.data, this.data, this.selectRows);
|
||||||
|
//选中行
|
||||||
|
this.selectRows.forEach(t => {
|
||||||
|
this.$refs.table.toggleRowSelection(t, true);
|
||||||
|
})
|
||||||
|
this.deleteTableRow();
|
||||||
//设置未选择ID(更新)
|
//设置未选择ID(更新)
|
||||||
this.condition.unSelectIds = [];
|
this.condition.unSelectIds = [];
|
||||||
//更新统计信息
|
//更新统计信息
|
||||||
|
@ -553,6 +555,15 @@ export default {
|
||||||
this.selectRows
|
this.selectRows
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
deleteTableRow() {
|
||||||
|
deleteTableRow(
|
||||||
|
this,
|
||||||
|
this.condition,
|
||||||
|
this.data,
|
||||||
|
this.$refs.table,
|
||||||
|
this.selectRows
|
||||||
|
);
|
||||||
|
},
|
||||||
clearSelection() {
|
clearSelection() {
|
||||||
this.clearSelectRows();
|
this.clearSelectRows();
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,9 +31,9 @@ export function _handleSelectAll(component, selection, tableData, selectRows, co
|
||||||
tableData.forEach(item => {
|
tableData.forEach(item => {
|
||||||
component.$set(item, "showMore", false);
|
component.$set(item, "showMore", false);
|
||||||
});
|
});
|
||||||
if (condition) {
|
}
|
||||||
condition.selectAll = false;
|
if (condition) {
|
||||||
}
|
condition.selectAll = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,22 @@ export function checkTableRowIsSelect(component, condition, tableData, table, se
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除不需要的row(使用场景:点击表格下拉框全选时,在翻页的时候会把翻页的数据也加勾选,如果勾选了,table认为已经选中,当点击只选此页数据时,前几页的数据不会消失)
|
||||||
|
export function deleteTableRow(component, condition, tableData, table, selectRows) {
|
||||||
|
//所有以选中的数据
|
||||||
|
let selectRowMap = new Map();
|
||||||
|
for (let selectRow of selectRows) {
|
||||||
|
selectRowMap.set(selectRow.id, selectRow);
|
||||||
|
}
|
||||||
|
//表格标为选中的数据
|
||||||
|
table.selection.forEach(t => {
|
||||||
|
if (!selectRowMap.get(t.id)) {
|
||||||
|
table.toggleRowSelection(t, false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
||||||
export function checkTableRowIsSelected(veuObj, table) {
|
export function checkTableRowIsSelected(veuObj, table) {
|
||||||
veuObj.$nextTick(function () {
|
veuObj.$nextTick(function () {
|
||||||
|
|
Loading…
Reference in New Issue