fix: bug#10766
This commit is contained in:
parent
e9f84f959a
commit
cea070b35c
|
@ -26,8 +26,7 @@ export const useDepartmentStore = defineStore({
|
||||||
},
|
},
|
||||||
setSelectedKeys(value: string[], type?: string) {
|
setSelectedKeys(value: string[], type?: string) {
|
||||||
// 分页保留选中项
|
// 分页保留选中项
|
||||||
// this.crossPageKeys = type === 'pagination' ? [...new Set([...this.crossPageKeys, ...value])] : value;
|
this.crossPageKeys = type === 'concat' ? [...new Set([...this.crossPageKeys, ...value])] : value;
|
||||||
this.crossPageKeys = [...new Set([...this.crossPageKeys, ...value])];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -7,9 +7,10 @@
|
||||||
centered
|
centered
|
||||||
:confirmLoading="loading"
|
:confirmLoading="loading"
|
||||||
@ok="confirm"
|
@ok="confirm"
|
||||||
@cancel="emits('update:visible', false)"
|
@cancel="cancel"
|
||||||
>
|
>
|
||||||
<pro-search
|
<pro-search
|
||||||
|
type="simple"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
target="category"
|
target="category"
|
||||||
@search="(params:any)=>queryParams = {...params}"
|
@search="(params:any)=>queryParams = {...params}"
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
:pagination="{
|
:pagination="{
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
pageSizeOptions: ['10', '20', '50', '100'],
|
pageSizeOptions: ['10', '20', '50', '100'],
|
||||||
change: handlePageChange,
|
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -63,7 +63,8 @@ const confirm = () => {
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
emits('confirm');
|
emits('confirm');
|
||||||
emits('update:visible', false);
|
emits('update:visible', false);
|
||||||
table._selectedRowKeys = [];
|
// table._selectedRowKeys = [];
|
||||||
|
department.setSelectedKeys([]);
|
||||||
})
|
})
|
||||||
.finally(() => (loading.value = false));
|
.finally(() => (loading.value = false));
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,6 +73,11 @@ const confirm = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const cancel = () => {
|
||||||
|
emits('update:visible', false);
|
||||||
|
department.setSelectedKeys([]);
|
||||||
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: '姓名',
|
title: '姓名',
|
||||||
|
@ -134,42 +140,24 @@ const table = reactive({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSelectChange: (keys: string[]) => {
|
onSelectChange: (keys: string[]) => {
|
||||||
table._selectedRowKeys = keys;
|
// console.log('手动选择改变: ', keys);
|
||||||
|
// table._selectedRowKeys = keys;
|
||||||
|
department.setSelectedKeys(keys, keys.length ? 'concat' : '');
|
||||||
},
|
},
|
||||||
cancelSelect: () => {
|
cancelSelect: () => {
|
||||||
table._selectedRowKeys = [];
|
// console.log('分页会 取消选择', 1111111111);
|
||||||
|
// table._selectedRowKeys = [];
|
||||||
|
department.setSelectedKeys([], 'concat');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => table._selectedRowKeys,
|
() => department.crossPageKeys,
|
||||||
(val: string[]) => {
|
(val: string[]) => {
|
||||||
// console.log('_selectedRowKeys: ', val);
|
// console.log('crossPageKeys: ', val);
|
||||||
department.setSelectedKeys(val);
|
table._selectedRowKeys = val;
|
||||||
|
|
||||||
// const newKeys = [];
|
|
||||||
// val.forEach((key: string) => {
|
|
||||||
// if (!department.crossPageKeys.includes(key)) {
|
|
||||||
// newKeys.push(key);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// if (newKeys.length) {
|
|
||||||
// department.setSelectedKeys(val);
|
|
||||||
// console.log('_selectedRowKeys: ', val);
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// watch(
|
|
||||||
// () => department.crossPageKeys,
|
|
||||||
// (val: string[]) => {
|
|
||||||
// // console.log('crossPageKeys: ', val);
|
|
||||||
// table._selectedRowKeys = val;
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
const handlePageChange = () => {
|
|
||||||
console.log('PageChange');
|
|
||||||
// department.setSelectedKeys([], 'pagination');
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|
Loading…
Reference in New Issue