|
@@ -127,48 +127,37 @@ watch(
|
|
|
const selectedRowKeys = ref([])
|
|
|
let cancelSelectRowKeys=[]//取消选择的keys
|
|
|
function tableSelectChange(value, ctx) {
|
|
|
- console.log(ctx);
|
|
|
- const selectLength=selectedRowKeys.value.length
|
|
|
- if(ctx.type==="uncheck"){
|
|
|
- if(ctx.currentRowKey==="CHECK_ALL_BOX"){//点击的表格上的全选
|
|
|
- tableData.value.forEach(i=>{
|
|
|
- cancelSelectRowKeys.push(i.ChartInfoId)
|
|
|
- })
|
|
|
- }else{
|
|
|
- cancelSelectRowKeys.push(ctx.currentRowKey)
|
|
|
+ if (ctx.type === 'uncheck') {
|
|
|
+ if (ctx.currentRowKey === 'CHECK_ALL_BOX') {
|
|
|
+ tableData.value.forEach(i => cancelSelectRowKeys.push(i.ChartInfoId));
|
|
|
+ } else {
|
|
|
+ cancelSelectRowKeys.push(ctx.currentRowKey);
|
|
|
}
|
|
|
-
|
|
|
- if(selectLength===0){
|
|
|
- filterState.indeterminate=false
|
|
|
- filterState.checkAll=false
|
|
|
- cancelSelectRowKeys=[]
|
|
|
- }else{
|
|
|
- filterState.indeterminate=true
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if(ctx.type==='check'&&selectedRowKeys.value.length>0){
|
|
|
- if(selectLength===pagination.value.total){
|
|
|
- filterState.checkAll=true
|
|
|
- filterState.indeterminate=false
|
|
|
- cancelSelectRowKeys=[]
|
|
|
- }else{
|
|
|
- filterState.indeterminate=true
|
|
|
- cancelSelectRowKeys=cancelSelectRowKeys.filter(i=>selectedRowKeys.value.includes(i))
|
|
|
+ filterState.indeterminate = selectedRowKeys.value.length > 0;
|
|
|
+ filterState.checkAll = selectedRowKeys.value.length === 0 ? false : filterState.checkAll;
|
|
|
+ } else if (ctx.type === 'check') {
|
|
|
+ filterState.indeterminate = true;
|
|
|
+ if (selectedRowKeys.value.length === pagination.value.total) {
|
|
|
+ filterState.checkAll = true;
|
|
|
+ filterState.indeterminate = false;
|
|
|
+ cancelSelectRowKeys = [];
|
|
|
+ } else {
|
|
|
+ cancelSelectRowKeys = cancelSelectRowKeys.filter(i => selectedRowKeys.value.includes(i));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function handleClickCheckAll(check) {
|
|
|
- filterState.indeterminate=false
|
|
|
- selectedRowKeys.value=[]
|
|
|
- cancelSelectRowKeys=[]
|
|
|
- if(check){
|
|
|
- // 全选
|
|
|
- tableData.value.forEach(item=>{
|
|
|
- selectedRowKeys.value.push(item.ChartInfoId)
|
|
|
- })
|
|
|
+ if(!check&&filterState.indeterminate){
|
|
|
+ selectedRowKeys.value=[...selectedRowKeys.value,...cancelSelectRowKeys]
|
|
|
+ cancelSelectRowKeys=[]
|
|
|
+ filterState.indeterminate = false;
|
|
|
+ filterState.checkAll=true
|
|
|
+ return
|
|
|
}
|
|
|
+ filterState.indeterminate = false;
|
|
|
+ selectedRowKeys.value = check ? tableData.value.map(item => item.ChartInfoId) : [];
|
|
|
+ cancelSelectRowKeys = [];
|
|
|
}
|
|
|
|
|
|
|