diff --git a/src/store/department.ts b/src/store/department.ts index 4ae0b2a4..d8f49c97 100644 --- a/src/store/department.ts +++ b/src/store/department.ts @@ -26,8 +26,7 @@ export const useDepartmentStore = defineStore({ }, setSelectedKeys(value: string[], type?: string) { // 分页保留选中项 - // this.crossPageKeys = type === 'pagination' ? [...new Set([...this.crossPageKeys, ...value])] : value; - this.crossPageKeys = [...new Set([...this.crossPageKeys, ...value])]; + this.crossPageKeys = type === 'concat' ? [...new Set([...this.crossPageKeys, ...value])] : value; } } }) \ No newline at end of file diff --git a/src/views/system/Department/user/components/AddBindUserDialog.vue b/src/views/system/Department/user/components/AddBindUserDialog.vue index 45bbe673..091e9e6b 100644 --- a/src/views/system/Department/user/components/AddBindUserDialog.vue +++ b/src/views/system/Department/user/components/AddBindUserDialog.vue @@ -7,9 +7,10 @@ centered :confirmLoading="loading" @ok="confirm" - @cancel="emits('update:visible', false)" + @cancel="cancel" > @@ -63,7 +63,8 @@ const confirm = () => { message.success('操作成功'); emits('confirm'); emits('update:visible', false); - table._selectedRowKeys = []; + // table._selectedRowKeys = []; + department.setSelectedKeys([]); }) .finally(() => (loading.value = false)); } else { @@ -72,6 +73,11 @@ const confirm = () => { } }; +const cancel = () => { + emits('update:visible', false); + department.setSelectedKeys([]); +}; + const columns = [ { title: '姓名', @@ -134,42 +140,24 @@ const table = reactive({ } }, onSelectChange: (keys: string[]) => { - table._selectedRowKeys = keys; + // console.log('手动选择改变: ', keys); + // table._selectedRowKeys = keys; + department.setSelectedKeys(keys, keys.length ? 'concat' : ''); }, cancelSelect: () => { - table._selectedRowKeys = []; + // console.log('分页会 取消选择', 1111111111); + // table._selectedRowKeys = []; + department.setSelectedKeys([], 'concat'); }, }); watch( - () => table._selectedRowKeys, + () => department.crossPageKeys, (val: string[]) => { - // console.log('_selectedRowKeys: ', val); - department.setSelectedKeys(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); - // } + // console.log('crossPageKeys: ', val); + table._selectedRowKeys = val; }, ); -// watch( -// () => department.crossPageKeys, -// (val: string[]) => { -// // console.log('crossPageKeys: ', val); -// table._selectedRowKeys = val; -// }, -// ); -const handlePageChange = () => { - console.log('PageChange'); - // department.setSelectedKeys([], 'pagination'); -};