@hw-component/table 1.9.29 → 1.9.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
8
8
  import { jsx } from 'react/jsx-runtime';
9
9
  import { useHTableContext } from '../context.js';
10
10
  import { Dropdown, Checkbox, Menu } from 'antd';
11
- import { useMemo, useEffect } from 'react';
11
+ import { useMemo } from 'react';
12
12
 
13
13
  var RowSelectionTitle = function RowSelectionTitle(_ref) {
14
14
  var _ref$allPageCheck = _ref.allPageCheck,
@@ -132,33 +132,38 @@ var RowSelectionBox = function RowSelectionBox(_ref5) {
132
132
  _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
133
133
  keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys;
134
134
  var key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
135
- var check = function check(e) {
136
- var checked = e.target.checked;
135
+ var add = function add() {
137
136
  var newKeys = _toConsumableArray(keys);
138
137
  var newRowData = _toConsumableArray(rowData);
139
- if (checked) {
140
- newKeys.push(key);
141
- newRowData.push(data);
142
- console.log(newKeys, newRowData, "newKeys,newRowData");
143
- rowOnChange(newKeys, newRowData);
144
- onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
145
- return;
146
- }
138
+ newKeys.push(key);
139
+ newRowData.push(data);
140
+ rowOnChange(newKeys, newRowData);
141
+ onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
142
+ };
143
+ var cancel = function cancel() {
144
+ var newKeys = _toConsumableArray(keys);
147
145
  var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
148
- console.log(keyIndex, "keyIndex");
149
146
  _spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
150
- _spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
151
- console.log(newKeys, newRowData, "newKeys,newRowData");
147
+ var newRowData = rowData === null || rowData === void 0 ? void 0 : _filterInstanceProperty(rowData).call(rowData, function (item) {
148
+ var rowId = item[key];
149
+ var index = _indexOfInstanceProperty(newKeys).call(newKeys, rowId);
150
+ return index !== -1;
151
+ });
152
152
  rowOnChange(newKeys, newRowData);
153
153
  onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
154
154
  };
155
+ var check = function check(e) {
156
+ var checked = e.target.checked;
157
+ if (checked) {
158
+ add();
159
+ return;
160
+ }
161
+ cancel();
162
+ };
155
163
  var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
156
164
  _ref6$disabled = _ref6.disabled,
157
165
  disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
158
166
  var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
159
- useEffect(function () {
160
- console.log("检测一次");
161
- }, []);
162
167
  return jsx(Checkbox, {
163
168
  checked: checked,
164
169
  onChange: check,
@@ -133,33 +133,38 @@ var RowSelectionBox = function RowSelectionBox(_ref5) {
133
133
  _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
134
134
  keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys;
135
135
  var key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
136
- var check = function check(e) {
137
- var checked = e.target.checked;
136
+ var add = function add() {
138
137
  var newKeys = _toConsumableArray(keys);
139
138
  var newRowData = _toConsumableArray(rowData);
140
- if (checked) {
141
- newKeys.push(key);
142
- newRowData.push(data);
143
- console.log(newKeys, newRowData, "newKeys,newRowData");
144
- rowOnChange(newKeys, newRowData);
145
- onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
146
- return;
147
- }
139
+ newKeys.push(key);
140
+ newRowData.push(data);
141
+ rowOnChange(newKeys, newRowData);
142
+ onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
143
+ };
144
+ var cancel = function cancel() {
145
+ var newKeys = _toConsumableArray(keys);
148
146
  var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
149
- console.log(keyIndex, "keyIndex");
150
147
  _spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
151
- _spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
152
- console.log(newKeys, newRowData, "newKeys,newRowData");
148
+ var newRowData = rowData === null || rowData === void 0 ? void 0 : _filterInstanceProperty(rowData).call(rowData, function (item) {
149
+ var rowId = item[key];
150
+ var index = _indexOfInstanceProperty(newKeys).call(newKeys, rowId);
151
+ return index !== -1;
152
+ });
153
153
  rowOnChange(newKeys, newRowData);
154
154
  onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
155
155
  };
156
+ var check = function check(e) {
157
+ var checked = e.target.checked;
158
+ if (checked) {
159
+ add();
160
+ return;
161
+ }
162
+ cancel();
163
+ };
156
164
  var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
157
165
  _ref6$disabled = _ref6.disabled,
158
166
  disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
159
167
  var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
160
- React.useEffect(function () {
161
- console.log("检测一次");
162
- }, []);
163
168
  return jsxRuntime.jsx(antd.Checkbox, {
164
169
  checked: checked,
165
170
  onChange: check,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "1.9.29",
3
+ "version": "1.9.30",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -119,34 +119,36 @@ export const RowSelectionBox = ({
119
119
  const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
120
120
  const { rowData = [], keys = [] } = selectedRowData;
121
121
  const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
122
- const check = (e) => {
123
- const checked = e.target.checked;
122
+ const add=()=>{
124
123
  const newKeys = [...keys];
125
124
  const newRowData = [...rowData];
126
- if (checked) {
127
- newKeys.push(key);
128
- newRowData.push(data);
129
- console.log(newKeys,newRowData,"newKeys,newRowData")
130
- rowOnChange(newKeys, newRowData);
131
- onChange?.(newKeys, newRowData);
132
- return;
133
- }
125
+ newKeys.push(key);
126
+ newRowData.push(data);
127
+ rowOnChange(newKeys, newRowData);
128
+ onChange?.(newKeys, newRowData);
129
+ }
130
+ const cancel=()=>{
131
+ const newKeys = [...keys];
134
132
  const keyIndex = newKeys.indexOf(key);
135
- console.log(keyIndex,"keyIndex")
136
133
  newKeys.splice(keyIndex, 1);
137
- newRowData.splice(keyIndex, 1);
138
- console.log(newKeys,newRowData,"newKeys,newRowData")
134
+ const newRowData = rowData?.filter((item)=>{
135
+ const rowId=item[key];
136
+ const index=newKeys.indexOf(rowId);
137
+ return index!==-1;
138
+ });
139
139
  rowOnChange(newKeys, newRowData);
140
140
  onChange?.(newKeys, newRowData);
141
+ }
142
+ const check = (e) => {
143
+ const checked = e.target.checked;
144
+ if (checked) {
145
+ add();
146
+ return;
147
+ }
148
+ cancel()
141
149
  };
142
150
  const { disabled = false } = getCheckboxProps?.(data) || {};
143
151
  const checked=keys.indexOf(key) !== -1;
144
- useEffect(() => {
145
- if (checked){
146
-
147
- }
148
- console.log("检测一次")
149
- }, []);
150
152
  return (
151
153
  <Checkbox
152
154
  checked={checked}
@@ -181,7 +181,9 @@ export default () => {
181
181
  console.log(params, "lllll");
182
182
  },
183
183
  }}
184
- rowSelection={false}
184
+ rowSelection={{
185
+ allPageCheck:false
186
+ }}
185
187
  affixProps={{
186
188
  target: () => document.querySelector(".body"),
187
189
  }}