ztxkui 3.8.3 → 3.8.5
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.
- package/dist/DemoCom/FormDemo.js +222 -0
- package/dist/TableDemo/BasicTable.d.ts +3 -1
- package/dist/TableDemo/BasicTable.js +3 -2
- package/dist/TableDemo/index.js +3 -0
- package/dist/components/Table/hooks/useColumns.d.ts +4 -0
- package/dist/components/Table/hooks/useColumns.js +71 -2
- package/dist/components/Table/table.js +28 -25
- package/dist/components/business/SearchContainer/hooks/useDynamic.js +37 -0
- package/package.json +1 -1
package/dist/DemoCom/FormDemo.js
CHANGED
|
@@ -127,6 +127,228 @@ var FormDemo = function () {
|
|
|
127
127
|
React.createElement(Select, null)),
|
|
128
128
|
React.createElement(SearchItem, { name: "type5", width: "all", label: "\u4F60\u597D" },
|
|
129
129
|
React.createElement(Input.TextArea, { showCount: true, maxLength: 5000, autoSize: { minRows: 3, maxRows: 5 } }))),
|
|
130
|
+
React.createElement(SearchRight, { onSearchHandle: function () {
|
|
131
|
+
var _a;
|
|
132
|
+
(_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.setToggleHandle(false);
|
|
133
|
+
console.log(form.getFieldsValue());
|
|
134
|
+
}, onResetHandle: function () { } }))),
|
|
135
|
+
React.createElement(Form, { name: "test-list", form: form },
|
|
136
|
+
React.createElement(SearchContainer, { dark: true },
|
|
137
|
+
React.createElement(SearchLeft, { configInfo: configInfoMemo, isDynamic: true, dynamicStorageKey: "symbol-key-00002", isToggle: true, handleRef: handleRef },
|
|
138
|
+
React.createElement(SearchItem, { width: "half", name: "pwNo", configname: "pwNoCopy", label: "\u5165\u5E93\u5355\u53F7", rules: [
|
|
139
|
+
{
|
|
140
|
+
required: true,
|
|
141
|
+
message: '采购基本数据-请选择入库单号',
|
|
142
|
+
},
|
|
143
|
+
] },
|
|
144
|
+
React.createElement(Input.TextArea, { autoSize: true, allowClear: true, disabled: true, onChange: function (e) {
|
|
145
|
+
console.log(e.target.value);
|
|
146
|
+
} })),
|
|
147
|
+
React.createElement(SearchItem, { width: "half", name: "pwNo1", label: "\u5165\u5E93\u5355\u53F71", rules: [
|
|
148
|
+
{
|
|
149
|
+
required: false,
|
|
150
|
+
message: '采购基本数据-请选择入库单号1',
|
|
151
|
+
},
|
|
152
|
+
] },
|
|
153
|
+
React.createElement(Input, null)),
|
|
154
|
+
React.createElement(SearchItem, { width: "half", name: "status", label: "\u5355\u636E\u72B6\u6001" },
|
|
155
|
+
React.createElement(Select, { onChange: function (value) {
|
|
156
|
+
setStatus(value);
|
|
157
|
+
} },
|
|
158
|
+
React.createElement(Select.Option, { value: "1" }, "\u662F"),
|
|
159
|
+
React.createElement(Select.Option, { value: "0" }, "\u5426"))),
|
|
160
|
+
React.createElement(SearchItem, { name: "intime", configname: "startTime", label: "\u5165\u5E93\u65E5\u671F" },
|
|
161
|
+
React.createElement(RangePicker, null)),
|
|
162
|
+
React.createElement(SearchItem, { name: "intime1", configname: "startTime", label: "\u5165\u5E93\u65E5\u671F" },
|
|
163
|
+
React.createElement(DatePicker, null)),
|
|
164
|
+
React.createElement(SearchItem, { name: "warehouseId", label: "\u4ED3\u5E93\u540D\u79F0" },
|
|
165
|
+
React.createElement(Select, null)),
|
|
166
|
+
React.createElement(SearchItem, { name: "companyId", label: "\u516C\u53F8\u540D\u79F0" },
|
|
167
|
+
React.createElement(Select, null)),
|
|
168
|
+
React.createElement(SearchItem, { name: "companyId1", label: "\u516C\u53F8\u540D\u79F01" },
|
|
169
|
+
React.createElement(Input.TextArea, { autoSize: true })),
|
|
170
|
+
React.createElement(SearchItem, { name: "depId", label: "\u90E8\u95E8\u540D\u79F0", rules: [{ required: true, message: '请选择部门名称' }] },
|
|
171
|
+
React.createElement(Select, { allowClear: true },
|
|
172
|
+
React.createElement(Select.Option, { value: "1" }, "\u662F"),
|
|
173
|
+
React.createElement(Select.Option, { value: "0" }, "\u5426"))),
|
|
174
|
+
React.createElement(SearchItem, { name: "test1", label: "", hiddenLabelName: "\u6D4B\u8BD5\u90E8\u95E8\u4E0D\u663E\u793A" },
|
|
175
|
+
React.createElement(Checkbox.Group, null,
|
|
176
|
+
React.createElement(Checkbox, { value: "1" }, "\u662F"),
|
|
177
|
+
React.createElement(Checkbox, { value: "2" }, "\u5426"))),
|
|
178
|
+
React.createElement(SearchItem, { name: "test2", label: "\u90E8\u95E8\u540D\u79F0", rules: [{ required: true, message: '请选择仓库名称' }] },
|
|
179
|
+
React.createElement(Radio.Group, null,
|
|
180
|
+
React.createElement(Radio, { value: "1" }, "\u662F"),
|
|
181
|
+
React.createElement(Radio, { value: "2" }, "\u5426"))),
|
|
182
|
+
React.createElement(SearchItem, { name: "test3", label: "\u90E8\u95E8\u540D\u79F0" },
|
|
183
|
+
React.createElement(InputNumber, null)),
|
|
184
|
+
React.createElement(SearchItem, { name: "test4", label: "\u90E8\u95E8\u540D\u79F0" },
|
|
185
|
+
React.createElement(Input.TextArea, { autoSize: true })),
|
|
186
|
+
React.createElement(SearchItem, { name: "type1", width: "half", noLabel: true },
|
|
187
|
+
React.createElement(Select, null)),
|
|
188
|
+
React.createElement(SearchItem, { name: "type2", width: "half", noLabel: true },
|
|
189
|
+
React.createElement(Input, null)),
|
|
190
|
+
React.createElement(SearchItem, { name: "type3", width: "half", noLabel: true },
|
|
191
|
+
React.createElement(Select, null)),
|
|
192
|
+
React.createElement(SearchItem, { name: "type4", width: "half", noLabel: true },
|
|
193
|
+
React.createElement(Select, null)),
|
|
194
|
+
React.createElement(SearchItem, { name: "type44", width: "half", label: "\u4F60\u597D" },
|
|
195
|
+
React.createElement(Select, null)),
|
|
196
|
+
React.createElement(SearchItem, { name: "type6", width: "half", label: "\u4F60\u597D6" },
|
|
197
|
+
React.createElement(Select, null)),
|
|
198
|
+
React.createElement(SearchItem, { name: "type7", width: "half", label: "\u4F60\u597D7" },
|
|
199
|
+
React.createElement(Select, null)),
|
|
200
|
+
React.createElement(SearchItem, { name: "type8", width: "half", label: "\u4F60\u597D811" },
|
|
201
|
+
React.createElement(Select, null)),
|
|
202
|
+
React.createElement(SearchItem, { name: "type5", width: "all", label: "\u4F60\u597D" },
|
|
203
|
+
React.createElement(Input.TextArea, { showCount: true, maxLength: 5000, autoSize: { minRows: 3, maxRows: 5 } }))),
|
|
204
|
+
React.createElement(SearchRight, { onSearchHandle: function () {
|
|
205
|
+
var _a;
|
|
206
|
+
(_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.setToggleHandle(false);
|
|
207
|
+
console.log(form.getFieldsValue());
|
|
208
|
+
}, onResetHandle: function () { } }))),
|
|
209
|
+
React.createElement(Form, { name: "test-list", form: form },
|
|
210
|
+
React.createElement(SearchContainer, { dark: true },
|
|
211
|
+
React.createElement(SearchLeft, { configInfo: configInfoMemo, isDynamic: true, dynamicStorageKey: "symbol-key-00003", isToggle: true, handleRef: handleRef },
|
|
212
|
+
React.createElement(SearchItem, { width: "half", name: "pwNo", configname: "pwNoCopy", label: "\u5165\u5E93\u5355\u53F7", rules: [
|
|
213
|
+
{
|
|
214
|
+
required: true,
|
|
215
|
+
message: '采购基本数据-请选择入库单号',
|
|
216
|
+
},
|
|
217
|
+
] },
|
|
218
|
+
React.createElement(Input.TextArea, { autoSize: true, allowClear: true, disabled: true, onChange: function (e) {
|
|
219
|
+
console.log(e.target.value);
|
|
220
|
+
} })),
|
|
221
|
+
React.createElement(SearchItem, { width: "half", name: "pwNo1", label: "\u5165\u5E93\u5355\u53F71", rules: [
|
|
222
|
+
{
|
|
223
|
+
required: false,
|
|
224
|
+
message: '采购基本数据-请选择入库单号1',
|
|
225
|
+
},
|
|
226
|
+
] },
|
|
227
|
+
React.createElement(Input, null)),
|
|
228
|
+
React.createElement(SearchItem, { width: "half", name: "status", label: "\u5355\u636E\u72B6\u6001" },
|
|
229
|
+
React.createElement(Select, { onChange: function (value) {
|
|
230
|
+
setStatus(value);
|
|
231
|
+
} },
|
|
232
|
+
React.createElement(Select.Option, { value: "1" }, "\u662F"),
|
|
233
|
+
React.createElement(Select.Option, { value: "0" }, "\u5426"))),
|
|
234
|
+
React.createElement(SearchItem, { name: "intime", configname: "startTime", label: "\u5165\u5E93\u65E5\u671F" },
|
|
235
|
+
React.createElement(RangePicker, null)),
|
|
236
|
+
React.createElement(SearchItem, { name: "intime1", configname: "startTime", label: "\u5165\u5E93\u65E5\u671F" },
|
|
237
|
+
React.createElement(DatePicker, null)),
|
|
238
|
+
React.createElement(SearchItem, { name: "warehouseId", label: "\u4ED3\u5E93\u540D\u79F0" },
|
|
239
|
+
React.createElement(Select, null)),
|
|
240
|
+
React.createElement(SearchItem, { name: "companyId", label: "\u516C\u53F8\u540D\u79F0" },
|
|
241
|
+
React.createElement(Select, null)),
|
|
242
|
+
React.createElement(SearchItem, { name: "companyId1", label: "\u516C\u53F8\u540D\u79F01" },
|
|
243
|
+
React.createElement(Input.TextArea, { autoSize: true })),
|
|
244
|
+
React.createElement(SearchItem, { name: "depId", label: "\u90E8\u95E8\u540D\u79F0", rules: [{ required: true, message: '请选择部门名称' }] },
|
|
245
|
+
React.createElement(Select, { allowClear: true },
|
|
246
|
+
React.createElement(Select.Option, { value: "1" }, "\u662F"),
|
|
247
|
+
React.createElement(Select.Option, { value: "0" }, "\u5426"))),
|
|
248
|
+
React.createElement(SearchItem, { name: "test1", label: "", hiddenLabelName: "\u6D4B\u8BD5\u90E8\u95E8\u4E0D\u663E\u793A" },
|
|
249
|
+
React.createElement(Checkbox.Group, null,
|
|
250
|
+
React.createElement(Checkbox, { value: "1" }, "\u662F"),
|
|
251
|
+
React.createElement(Checkbox, { value: "2" }, "\u5426"))),
|
|
252
|
+
React.createElement(SearchItem, { name: "test2", label: "\u90E8\u95E8\u540D\u79F0", rules: [{ required: true, message: '请选择仓库名称' }] },
|
|
253
|
+
React.createElement(Radio.Group, null,
|
|
254
|
+
React.createElement(Radio, { value: "1" }, "\u662F"),
|
|
255
|
+
React.createElement(Radio, { value: "2" }, "\u5426"))),
|
|
256
|
+
React.createElement(SearchItem, { name: "test3", label: "\u90E8\u95E8\u540D\u79F0" },
|
|
257
|
+
React.createElement(InputNumber, null)),
|
|
258
|
+
React.createElement(SearchItem, { name: "test4", label: "\u90E8\u95E8\u540D\u79F0" },
|
|
259
|
+
React.createElement(Input.TextArea, { autoSize: true })),
|
|
260
|
+
React.createElement(SearchItem, { name: "type1", width: "half", noLabel: true },
|
|
261
|
+
React.createElement(Select, null)),
|
|
262
|
+
React.createElement(SearchItem, { name: "type2", width: "half", noLabel: true },
|
|
263
|
+
React.createElement(Input, null)),
|
|
264
|
+
React.createElement(SearchItem, { name: "type3", width: "half", noLabel: true },
|
|
265
|
+
React.createElement(Select, null)),
|
|
266
|
+
React.createElement(SearchItem, { name: "type4", width: "half", noLabel: true },
|
|
267
|
+
React.createElement(Select, null)),
|
|
268
|
+
React.createElement(SearchItem, { name: "type44", width: "half", label: "\u4F60\u597D" },
|
|
269
|
+
React.createElement(Select, null)),
|
|
270
|
+
React.createElement(SearchItem, { name: "type6", width: "half", label: "\u4F60\u597D6" },
|
|
271
|
+
React.createElement(Select, null)),
|
|
272
|
+
React.createElement(SearchItem, { name: "type7", width: "half", label: "\u4F60\u597D7" },
|
|
273
|
+
React.createElement(Select, null)),
|
|
274
|
+
React.createElement(SearchItem, { name: "type8", width: "half", label: "\u4F60\u597D811" },
|
|
275
|
+
React.createElement(Select, null)),
|
|
276
|
+
React.createElement(SearchItem, { name: "type5", width: "all", label: "\u4F60\u597D" },
|
|
277
|
+
React.createElement(Input.TextArea, { showCount: true, maxLength: 5000, autoSize: { minRows: 3, maxRows: 5 } }))),
|
|
278
|
+
React.createElement(SearchRight, { onSearchHandle: function () {
|
|
279
|
+
var _a;
|
|
280
|
+
(_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.setToggleHandle(false);
|
|
281
|
+
console.log(form.getFieldsValue());
|
|
282
|
+
}, onResetHandle: function () { } }))),
|
|
283
|
+
React.createElement(Form, { name: "test-list", form: form },
|
|
284
|
+
React.createElement(SearchContainer, { dark: true },
|
|
285
|
+
React.createElement(SearchLeft, { configInfo: configInfoMemo, isDynamic: true, dynamicStorageKey: "symbol-key-00004", isToggle: true, handleRef: handleRef },
|
|
286
|
+
React.createElement(SearchItem, { width: "half", name: "pwNo", configname: "pwNoCopy", label: "\u5165\u5E93\u5355\u53F7", rules: [
|
|
287
|
+
{
|
|
288
|
+
required: true,
|
|
289
|
+
message: '采购基本数据-请选择入库单号',
|
|
290
|
+
},
|
|
291
|
+
] },
|
|
292
|
+
React.createElement(Input.TextArea, { autoSize: true, allowClear: true, disabled: true, onChange: function (e) {
|
|
293
|
+
console.log(e.target.value);
|
|
294
|
+
} })),
|
|
295
|
+
React.createElement(SearchItem, { width: "half", name: "pwNo1", label: "\u5165\u5E93\u5355\u53F71", rules: [
|
|
296
|
+
{
|
|
297
|
+
required: false,
|
|
298
|
+
message: '采购基本数据-请选择入库单号1',
|
|
299
|
+
},
|
|
300
|
+
] },
|
|
301
|
+
React.createElement(Input, null)),
|
|
302
|
+
React.createElement(SearchItem, { width: "half", name: "status", label: "\u5355\u636E\u72B6\u6001" },
|
|
303
|
+
React.createElement(Select, { onChange: function (value) {
|
|
304
|
+
setStatus(value);
|
|
305
|
+
} },
|
|
306
|
+
React.createElement(Select.Option, { value: "1" }, "\u662F"),
|
|
307
|
+
React.createElement(Select.Option, { value: "0" }, "\u5426"))),
|
|
308
|
+
React.createElement(SearchItem, { name: "intime", configname: "startTime", label: "\u5165\u5E93\u65E5\u671F" },
|
|
309
|
+
React.createElement(RangePicker, null)),
|
|
310
|
+
React.createElement(SearchItem, { name: "intime1", configname: "startTime", label: "\u5165\u5E93\u65E5\u671F" },
|
|
311
|
+
React.createElement(DatePicker, null)),
|
|
312
|
+
React.createElement(SearchItem, { name: "warehouseId", label: "\u4ED3\u5E93\u540D\u79F0" },
|
|
313
|
+
React.createElement(Select, null)),
|
|
314
|
+
React.createElement(SearchItem, { name: "companyId", label: "\u516C\u53F8\u540D\u79F0" },
|
|
315
|
+
React.createElement(Select, null)),
|
|
316
|
+
React.createElement(SearchItem, { name: "companyId1", label: "\u516C\u53F8\u540D\u79F01" },
|
|
317
|
+
React.createElement(Input.TextArea, { autoSize: true })),
|
|
318
|
+
React.createElement(SearchItem, { name: "depId", label: "\u90E8\u95E8\u540D\u79F0", rules: [{ required: true, message: '请选择部门名称' }] },
|
|
319
|
+
React.createElement(Select, { allowClear: true },
|
|
320
|
+
React.createElement(Select.Option, { value: "1" }, "\u662F"),
|
|
321
|
+
React.createElement(Select.Option, { value: "0" }, "\u5426"))),
|
|
322
|
+
React.createElement(SearchItem, { name: "test1", label: "", hiddenLabelName: "\u6D4B\u8BD5\u90E8\u95E8\u4E0D\u663E\u793A" },
|
|
323
|
+
React.createElement(Checkbox.Group, null,
|
|
324
|
+
React.createElement(Checkbox, { value: "1" }, "\u662F"),
|
|
325
|
+
React.createElement(Checkbox, { value: "2" }, "\u5426"))),
|
|
326
|
+
React.createElement(SearchItem, { name: "test2", label: "\u90E8\u95E8\u540D\u79F0", rules: [{ required: true, message: '请选择仓库名称' }] },
|
|
327
|
+
React.createElement(Radio.Group, null,
|
|
328
|
+
React.createElement(Radio, { value: "1" }, "\u662F"),
|
|
329
|
+
React.createElement(Radio, { value: "2" }, "\u5426"))),
|
|
330
|
+
React.createElement(SearchItem, { name: "test3", label: "\u90E8\u95E8\u540D\u79F0" },
|
|
331
|
+
React.createElement(InputNumber, null)),
|
|
332
|
+
React.createElement(SearchItem, { name: "test4", label: "\u90E8\u95E8\u540D\u79F0" },
|
|
333
|
+
React.createElement(Input.TextArea, { autoSize: true })),
|
|
334
|
+
React.createElement(SearchItem, { name: "type1", width: "half", noLabel: true },
|
|
335
|
+
React.createElement(Select, null)),
|
|
336
|
+
React.createElement(SearchItem, { name: "type2", width: "half", noLabel: true },
|
|
337
|
+
React.createElement(Input, null)),
|
|
338
|
+
React.createElement(SearchItem, { name: "type3", width: "half", noLabel: true },
|
|
339
|
+
React.createElement(Select, null)),
|
|
340
|
+
React.createElement(SearchItem, { name: "type4", width: "half", noLabel: true },
|
|
341
|
+
React.createElement(Select, null)),
|
|
342
|
+
React.createElement(SearchItem, { name: "type44", width: "half", label: "\u4F60\u597D" },
|
|
343
|
+
React.createElement(Select, null)),
|
|
344
|
+
React.createElement(SearchItem, { name: "type6", width: "half", label: "\u4F60\u597D6" },
|
|
345
|
+
React.createElement(Select, null)),
|
|
346
|
+
React.createElement(SearchItem, { name: "type7", width: "half", label: "\u4F60\u597D7" },
|
|
347
|
+
React.createElement(Select, null)),
|
|
348
|
+
React.createElement(SearchItem, { name: "type8", width: "half", label: "\u4F60\u597D811" },
|
|
349
|
+
React.createElement(Select, null)),
|
|
350
|
+
React.createElement(SearchItem, { name: "type5", width: "all", label: "\u4F60\u597D" },
|
|
351
|
+
React.createElement(Input.TextArea, { showCount: true, maxLength: 5000, autoSize: { minRows: 3, maxRows: 5 } }))),
|
|
130
352
|
React.createElement(SearchRight, { onSearchHandle: function () {
|
|
131
353
|
var _a;
|
|
132
354
|
(_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.setToggleHandle(false);
|
|
@@ -11,7 +11,8 @@ import { Table } from '../index';
|
|
|
11
11
|
// 自定义组件
|
|
12
12
|
// 其他文件
|
|
13
13
|
import { dataSource } from './data';
|
|
14
|
-
var BasicTable = function () {
|
|
14
|
+
var BasicTable = function (_a) {
|
|
15
|
+
var dynamicKey = _a.dynamicKey;
|
|
15
16
|
var columns = [
|
|
16
17
|
{
|
|
17
18
|
title: '序号',
|
|
@@ -90,6 +91,6 @@ var BasicTable = function () {
|
|
|
90
91
|
React.createElement("br", null),
|
|
91
92
|
React.createElement("b", null, "\u5217\u4F38\u7F29\uFF1B"),
|
|
92
93
|
"isResizableColumn\u5C5E\u6027\u9ED8\u8BA4\u4E3Atrue\uFF0C\u5982\u679C\u4E0D\u9700\u8981\u5217\u4F38\u7F29\u53EF\u4EE5\u4F20\u5165false"),
|
|
93
|
-
React.createElement(Table, { dataSource: dataSource, columns: columns, rowKey: "id", showColumnDynamic: true, showColumnDynamicKey:
|
|
94
|
+
React.createElement(Table, { dataSource: dataSource, columns: columns, rowKey: "id", showColumnDynamic: true, showColumnDynamicKey: dynamicKey || 'symbol-id-1' })));
|
|
94
95
|
};
|
|
95
96
|
export default BasicTable;
|
package/dist/TableDemo/index.js
CHANGED
|
@@ -15,6 +15,9 @@ import ModalTable from './ModalTable';
|
|
|
15
15
|
var TableDemo = function () {
|
|
16
16
|
return (React.createElement("div", null,
|
|
17
17
|
React.createElement(BasicTable, null),
|
|
18
|
+
React.createElement(BasicTable, { dynamicKey: "symbol-id-2" }),
|
|
19
|
+
React.createElement(BasicTable, { dynamicKey: "symbol-id-3" }),
|
|
20
|
+
React.createElement(BasicTable, { dynamicKey: "symbol-id-4" }),
|
|
18
21
|
React.createElement(EditableTable, null),
|
|
19
22
|
React.createElement(ModalTable, null)));
|
|
20
23
|
};
|
|
@@ -28,6 +28,10 @@ interface IProps<RecordType> {
|
|
|
28
28
|
configInfo?: IConfigInfo;
|
|
29
29
|
}
|
|
30
30
|
export declare const getTableLayoutFullData: (columns: any, tableLayout: any) => any;
|
|
31
|
+
export declare const LOCALSTORAGE_KEY = "ztui_dynamic_table_key";
|
|
32
|
+
export declare const LOCALSTORAGE_LRU_KEY = "ztui_dynamic_table_lru_key";
|
|
33
|
+
export declare const LOCALSTORAGE_LRU_MAX_SIZE = 3;
|
|
34
|
+
export declare function setDynamicKey(dynamicStorageKey: string, value: any): void;
|
|
31
35
|
declare function useColumns<RecordType>(props: IProps<RecordType>): {
|
|
32
36
|
newColumns: any;
|
|
33
37
|
dynamicColumns: any;
|
|
@@ -72,15 +72,84 @@ export var getTableLayoutFullData = function (columns, tableLayout) {
|
|
|
72
72
|
}
|
|
73
73
|
return columns;
|
|
74
74
|
};
|
|
75
|
+
// 搜索表单存储位置信息key
|
|
76
|
+
export var LOCALSTORAGE_KEY = 'ztui_dynamic_table_key';
|
|
77
|
+
// 搜索表单LRU排序规则key
|
|
78
|
+
export var LOCALSTORAGE_LRU_KEY = 'ztui_dynamic_table_lru_key';
|
|
79
|
+
// 搜索表单存储表单最大长度
|
|
80
|
+
export var LOCALSTORAGE_LRU_MAX_SIZE = 3;
|
|
75
81
|
function getStorage(key) {
|
|
82
|
+
// 历史数据处理
|
|
83
|
+
// 直接从localstorage中取key值,如果能取到,那么需要删除原先的值,重新设置到统一出处
|
|
84
|
+
// 如果不能取到,那么什么都不做
|
|
76
85
|
try {
|
|
77
|
-
var
|
|
78
|
-
|
|
86
|
+
var value = JSON.parse(localStorage.getItem(key) || '') || '';
|
|
87
|
+
if (value) {
|
|
88
|
+
localStorage.removeItem(key);
|
|
89
|
+
setDynamicKey(key, value);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
//
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
var obj = {};
|
|
97
|
+
try {
|
|
98
|
+
obj = JSON.parse(localStorage.getItem(LOCALSTORAGE_KEY) || '{}') || {};
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
console.error(err);
|
|
102
|
+
}
|
|
103
|
+
var result = obj[key] || '';
|
|
104
|
+
return result;
|
|
79
105
|
}
|
|
80
106
|
catch (err) {
|
|
81
107
|
return null;
|
|
82
108
|
}
|
|
83
109
|
}
|
|
110
|
+
export function setDynamicKey(dynamicStorageKey, value) {
|
|
111
|
+
var obj = {};
|
|
112
|
+
var lruKeys = [];
|
|
113
|
+
try {
|
|
114
|
+
obj = JSON.parse(localStorage.getItem(LOCALSTORAGE_KEY) || '{}') || {};
|
|
115
|
+
lruKeys =
|
|
116
|
+
JSON.parse(localStorage.getItem(LOCALSTORAGE_LRU_KEY) || '[]') || [];
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
console.error(err);
|
|
120
|
+
}
|
|
121
|
+
// 需要初始化lru排序数据
|
|
122
|
+
if (lruKeys.length !== Object.keys(obj).length) {
|
|
123
|
+
lruKeys = Object.keys(obj);
|
|
124
|
+
}
|
|
125
|
+
// 设置值之前,先判断是否满足LRU条件,最后面的最新鲜
|
|
126
|
+
var currentKeyIndex = lruKeys.findIndex(function (lruKey) { return lruKey === dynamicStorageKey; });
|
|
127
|
+
// 如果新增key本身就在原keys里面,那删除原key,将原key添加最新鲜的位置
|
|
128
|
+
// 如果不在原keys里面,那么直接添加到最新鲜的位置
|
|
129
|
+
if (currentKeyIndex !== -1) {
|
|
130
|
+
lruKeys.splice(currentKeyIndex, 1);
|
|
131
|
+
lruKeys.push(dynamicStorageKey);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
lruKeys.push(dynamicStorageKey);
|
|
135
|
+
}
|
|
136
|
+
var length = lruKeys.length;
|
|
137
|
+
// 长度是否有问题
|
|
138
|
+
// 如果长度大于最大可存储长度,那么删除最老旧的元素
|
|
139
|
+
// 把对象里面存储的最老旧元素清除
|
|
140
|
+
if (length > LOCALSTORAGE_LRU_MAX_SIZE) {
|
|
141
|
+
var oldKey = lruKeys.shift();
|
|
142
|
+
try {
|
|
143
|
+
delete obj[oldKey];
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
//
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
obj[dynamicStorageKey] = value;
|
|
150
|
+
localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(obj));
|
|
151
|
+
localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
|
|
152
|
+
}
|
|
84
153
|
function useColumns(props) {
|
|
85
154
|
var columns = props.columns, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, delIconText = props.delIconText, showDynamicHandle = props.showDynamicHandle, onEditableSave = props.onEditableSave, configInfo = props.configInfo;
|
|
86
155
|
var tableLayout = getStorage(showColumnDynamicKey);
|
|
@@ -69,7 +69,7 @@ import TableDynamic from './table-dynamic';
|
|
|
69
69
|
import TableEnhanceRow from './table-enhance-row';
|
|
70
70
|
import TableEnhanceCell from './table-enhance-cell';
|
|
71
71
|
import TableResizableTitle from './table-resizable-title';
|
|
72
|
-
import useColumns from './hooks/useColumns';
|
|
72
|
+
import useColumns, { setDynamicKey } from './hooks/useColumns';
|
|
73
73
|
import getSummaryData from './utils/getSummaryData';
|
|
74
74
|
import { domFind } from './utils/dom';
|
|
75
75
|
import { tableValidate } from './utils/validate';
|
|
@@ -175,14 +175,14 @@ function Table(props) {
|
|
|
175
175
|
return __assign({}, item);
|
|
176
176
|
});
|
|
177
177
|
if (showColumnDynamicKey) {
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
// let catchColumnsStr = '{}';
|
|
179
|
+
// try {
|
|
180
|
+
// catchColumnsStr = JSON.stringify(catchColumns);
|
|
181
|
+
// } catch (err) {
|
|
182
|
+
// console.log(err);
|
|
183
|
+
// }
|
|
184
|
+
// localStorage.setItem(showColumnDynamicKey, catchColumnsStr);
|
|
185
|
+
setDynamicKey(showColumnDynamicKey, catchColumns);
|
|
186
186
|
}
|
|
187
187
|
onDynamicChange && onDynamicChange(catchColumns);
|
|
188
188
|
}
|
|
@@ -205,14 +205,14 @@ function Table(props) {
|
|
|
205
205
|
return __assign({}, item);
|
|
206
206
|
});
|
|
207
207
|
if (showColumnDynamicKey) {
|
|
208
|
-
|
|
209
|
-
try {
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
// let catchColumnsStr = '{}';
|
|
209
|
+
// try {
|
|
210
|
+
// catchColumnsStr = JSON.stringify(catchColumns);
|
|
211
|
+
// } catch (err) {
|
|
212
|
+
// console.log(err);
|
|
213
|
+
// }
|
|
214
|
+
// localStorage.setItem(showColumnDynamicKey, catchColumnsStr);
|
|
215
|
+
setDynamicKey(showColumnDynamicKey, catchColumns);
|
|
216
216
|
}
|
|
217
217
|
onDynamicChange && onDynamicChange(catchColumns);
|
|
218
218
|
hideDynamicHandle();
|
|
@@ -272,14 +272,14 @@ function Table(props) {
|
|
|
272
272
|
return __assign({}, item);
|
|
273
273
|
});
|
|
274
274
|
if (showColumnDynamicKey) {
|
|
275
|
-
|
|
276
|
-
try {
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
275
|
+
// let catchColumnsStr = '{}';
|
|
276
|
+
// try {
|
|
277
|
+
// catchColumnsStr = JSON.stringify(catchColumns);
|
|
278
|
+
// } catch (err) {
|
|
279
|
+
// console.log(err);
|
|
280
|
+
// }
|
|
281
|
+
// localStorage.setItem(showColumnDynamicKey, catchColumnsStr);
|
|
282
|
+
setDynamicKey(showColumnDynamicKey, catchColumns);
|
|
283
283
|
}
|
|
284
284
|
setNewColumns(_newColumns);
|
|
285
285
|
};
|
|
@@ -303,6 +303,9 @@ function Table(props) {
|
|
|
303
303
|
var _a;
|
|
304
304
|
// 获取表格元素
|
|
305
305
|
var tableContent = domFind(tableRef.current, '.ant-table-content');
|
|
306
|
+
if (!tableContent) {
|
|
307
|
+
tableContent = domFind(tableRef.current, '.ant-table-container');
|
|
308
|
+
}
|
|
306
309
|
var tableBody = domFind(tableContent, '.ant-table-tbody');
|
|
307
310
|
var tr = tableBody === null || tableBody === void 0 ? void 0 : tableBody.children;
|
|
308
311
|
var arrTr = Array.prototype.slice.call(tr);
|
|
@@ -10,7 +10,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import React, { useEffect, useState } from 'react';
|
|
13
|
+
// 搜索表单存储位置信息key
|
|
13
14
|
var LOCALSTORAGE_KEY = 'ztui_dynamic_list_key';
|
|
15
|
+
// 搜索表单LRU排序规则key
|
|
16
|
+
var LOCALSTORAGE_LRU_KEY = 'ztui_dynamic_list_lru_key';
|
|
17
|
+
// 搜索表单存储表单最大长度
|
|
18
|
+
var LOCALSTORAGE_LRU_MAX_SIZE = 500;
|
|
14
19
|
/**
|
|
15
20
|
* @description 将动态配置存在本地存储中
|
|
16
21
|
* @param dynamicStorageKey 保留的key值
|
|
@@ -18,14 +23,46 @@ var LOCALSTORAGE_KEY = 'ztui_dynamic_list_key';
|
|
|
18
23
|
*/
|
|
19
24
|
export function setDynamicKey(dynamicStorageKey, value) {
|
|
20
25
|
var obj = {};
|
|
26
|
+
var lruKeys = [];
|
|
21
27
|
try {
|
|
22
28
|
obj = JSON.parse(localStorage.getItem(LOCALSTORAGE_KEY) || '{}') || {};
|
|
29
|
+
lruKeys =
|
|
30
|
+
JSON.parse(localStorage.getItem(LOCALSTORAGE_LRU_KEY) || '[]') || [];
|
|
23
31
|
}
|
|
24
32
|
catch (err) {
|
|
25
33
|
console.error(err);
|
|
26
34
|
}
|
|
35
|
+
// 需要初始化lru排序数据
|
|
36
|
+
if (lruKeys.length !== Object.keys(obj).length) {
|
|
37
|
+
lruKeys = Object.keys(obj);
|
|
38
|
+
}
|
|
39
|
+
// 设置值之前,先判断是否满足LRU条件,最后面的最新鲜
|
|
40
|
+
var currentKeyIndex = lruKeys.findIndex(function (lruKey) { return lruKey === dynamicStorageKey; });
|
|
41
|
+
// 如果新增key本身就在原keys里面,那删除原key,将原key添加最新鲜的位置
|
|
42
|
+
// 如果不在原keys里面,那么直接添加到最新鲜的位置
|
|
43
|
+
if (currentKeyIndex !== -1) {
|
|
44
|
+
lruKeys.splice(currentKeyIndex, 1);
|
|
45
|
+
lruKeys.push(dynamicStorageKey);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
lruKeys.push(dynamicStorageKey);
|
|
49
|
+
}
|
|
50
|
+
var length = lruKeys.length;
|
|
51
|
+
// 长度是否有问题
|
|
52
|
+
// 如果长度大于最大可存储长度,那么删除最老旧的元素
|
|
53
|
+
// 把对象里面存储的最老旧元素清除
|
|
54
|
+
if (length > LOCALSTORAGE_LRU_MAX_SIZE) {
|
|
55
|
+
var oldKey = lruKeys.shift();
|
|
56
|
+
try {
|
|
57
|
+
delete obj[oldKey];
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
//
|
|
61
|
+
}
|
|
62
|
+
}
|
|
27
63
|
obj[dynamicStorageKey] = value;
|
|
28
64
|
localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(obj));
|
|
65
|
+
localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
|
|
29
66
|
}
|
|
30
67
|
/**
|
|
31
68
|
* @description 比对方法,获取最终数据
|