linkmore-design 1.1.27-alpha.1 → 1.1.27-alpha.4
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/LmEditTable/EditTable.d.ts +4 -0
- package/dist/LmEditTable/util.d.ts +3 -1
- package/dist/index.umd.js +428 -43
- package/dist/index.umd.min.js +21 -21
- package/dist/variables.css +17 -0
- package/es/CustomTableOption/style/index.css +3 -0
- package/es/CustomTableOption/style/variables.css +3 -0
- package/es/LmEditTable/EditTable.d.ts +4 -0
- package/es/LmEditTable/EditTable.js +329 -12
- package/es/LmEditTable/rowSort/DndContainerRow.js +4 -2
- package/es/LmEditTable/style/index.css +14 -0
- package/es/LmEditTable/style/variables.css +14 -0
- package/es/LmEditTable/util.d.ts +3 -1
- package/es/LmEditTable/util.js +61 -8
- package/es/LmEditTable/virtual/VirtualRow.js +11 -5
- package/es/LmEditTable/virtual/VirtualTable.js +3 -1
- package/es/LmFilter/baseFilter/index.js +3 -2
- package/es/LmFilter/filterFns/index.js +4 -2
- package/es/LmUpload/body/UploadCore.js +1 -1
- package/es/Radio/index.js +9 -1
- package/es/Switch/index.js +7 -2
- package/es/styles/variables.css +17 -0
- package/lib/CustomTableOption/style/index.css +3 -0
- package/lib/CustomTableOption/style/variables.css +3 -0
- package/lib/LmEditTable/EditTable.d.ts +4 -0
- package/lib/LmEditTable/EditTable.js +328 -11
- package/lib/LmEditTable/rowSort/DndContainerRow.js +3 -2
- package/lib/LmEditTable/style/index.css +14 -0
- package/lib/LmEditTable/style/variables.css +14 -0
- package/lib/LmEditTable/util.d.ts +3 -1
- package/lib/LmEditTable/util.js +62 -7
- package/lib/LmEditTable/virtual/VirtualRow.js +11 -5
- package/lib/LmEditTable/virtual/VirtualTable.js +3 -1
- package/lib/LmFilter/baseFilter/index.js +3 -2
- package/lib/LmFilter/filterFns/index.js +4 -2
- package/lib/LmUpload/body/UploadCore.js +1 -1
- package/lib/Radio/index.js +9 -1
- package/lib/Switch/index.js +9 -2
- package/lib/styles/variables.css +17 -0
- package/package.json +1 -1
|
@@ -112,8 +112,12 @@ var EditableRow = function EditableRow(_a) {
|
|
|
112
112
|
_Form$useForm2 = (0, _slicedToArray2.default)(_Form$useForm, 1),
|
|
113
113
|
form = _Form$useForm2[0];
|
|
114
114
|
|
|
115
|
+
var dataKey = props.dataKey,
|
|
116
|
+
pushAllForm = props.pushAllForm;
|
|
117
|
+
pushAllForm === null || pushAllForm === void 0 ? void 0 : pushAllForm(form, dataKey, index);
|
|
115
118
|
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
116
119
|
form: form,
|
|
120
|
+
disabled: props.disabled || false,
|
|
117
121
|
component: false
|
|
118
122
|
}, /*#__PURE__*/_react.default.createElement(EditableContext.Provider, {
|
|
119
123
|
value: form
|
|
@@ -128,6 +132,9 @@ var EditableSortRow = function EditableSortRow(_a) {
|
|
|
128
132
|
_Form$useForm4 = (0, _slicedToArray2.default)(_Form$useForm3, 1),
|
|
129
133
|
form = _Form$useForm4[0];
|
|
130
134
|
|
|
135
|
+
var dataKey = props.dataKey,
|
|
136
|
+
pushAllForm = props.pushAllForm;
|
|
137
|
+
pushAllForm === null || pushAllForm === void 0 ? void 0 : pushAllForm(form, dataKey, index);
|
|
131
138
|
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
132
139
|
form: form,
|
|
133
140
|
disabled: props.disabled || false,
|
|
@@ -695,6 +702,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
695
702
|
_props$quickOpetateCl = props.quickOpetateClearAll,
|
|
696
703
|
quickOpetateClearAll = _props$quickOpetateCl === void 0 ? true : _props$quickOpetateCl,
|
|
697
704
|
rowSelection = props.rowSelection,
|
|
705
|
+
rowDisabled = props.rowDisabled,
|
|
698
706
|
virtual = props.virtual,
|
|
699
707
|
sortOpen = props.sortOpen,
|
|
700
708
|
disabled = props.disabled,
|
|
@@ -709,7 +717,9 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
709
717
|
shouldUpdate = _props$shouldUpdate === void 0 ? false : _props$shouldUpdate,
|
|
710
718
|
_props$loading = props.loading,
|
|
711
719
|
loading = _props$loading === void 0 ? false : _props$loading,
|
|
712
|
-
|
|
720
|
+
_props$autoSizer = props.autoSizer,
|
|
721
|
+
autoSizer = _props$autoSizer === void 0 ? false : _props$autoSizer,
|
|
722
|
+
resetProps = __rest(props, ["value", "columns", "isEdit", "isAdd", "onChange", "rowKey", "rowHoverEdit", "isUseForm", "isHoverEdit", "useQuickOpetate", "quickOpetateClearAll", "rowSelection", "rowDisabled", "virtual", "sortOpen", "disabled", "colSortOpen", "indexCol", "filterChange", "size", "recordCreatorProps", "shouldUpdate", "loading", "autoSizer"]);
|
|
713
723
|
|
|
714
724
|
var _useControllableValue = (0, _ahooks.useControllableValue)({
|
|
715
725
|
value: (0, _util.checkRowKeyByDataSource)(props.value, _rowKey),
|
|
@@ -734,6 +744,14 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
734
744
|
_useControllableValue4 = (0, _slicedToArray2.default)(_useControllableValue3, 2),
|
|
735
745
|
localRowSelectList = _useControllableValue4[0],
|
|
736
746
|
setLocalRowSelectList = _useControllableValue4[1];
|
|
747
|
+
|
|
748
|
+
var _useControllableValue5 = (0, _ahooks.useControllableValue)({
|
|
749
|
+
value: {
|
|
750
|
+
disabledRows: (rowDisabled === null || rowDisabled === void 0 ? void 0 : rowDisabled.disabledRows) || []
|
|
751
|
+
}
|
|
752
|
+
}),
|
|
753
|
+
_useControllableValue6 = (0, _slicedToArray2.default)(_useControllableValue5, 1),
|
|
754
|
+
localDisabledRows = _useControllableValue6[0];
|
|
737
755
|
/** TODO: 当前展开的列 */
|
|
738
756
|
|
|
739
757
|
|
|
@@ -746,7 +764,16 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
746
764
|
var deepDataSourceRef = (0, _react.useRef)((0, _util.deepDataSourcePreKeys)(dataSource, _rowKey));
|
|
747
765
|
dataSourceRef.current = dataSource;
|
|
748
766
|
deepDataSourceRef.current = (0, _util.deepDataSourcePreKeys)(dataSource, _rowKey);
|
|
767
|
+
var disabledDataSourceRowKeys = (0, _react.useRef)((0, _util.checkTableRowIsDisable)(deepDataSourceRef.current, localDisabledRows.disabledRows, _rowKey));
|
|
768
|
+
disabledDataSourceRowKeys.current = (0, _util.checkTableRowIsDisable)(deepDataSourceRef.current, localDisabledRows.disabledRows, _rowKey);
|
|
749
769
|
var tableWarpRef = (0, _react.useRef)(null);
|
|
770
|
+
var autoSizerRef = (0, _react.useRef)(null);
|
|
771
|
+
var allFormListRef = (0, _react.useRef)({});
|
|
772
|
+
var scrollToIndexRef = (0, _react.useRef)(null);
|
|
773
|
+
|
|
774
|
+
var _Form$useForm5 = _linkmoreDesign.Form.useForm(),
|
|
775
|
+
_Form$useForm6 = (0, _slicedToArray2.default)(_Form$useForm5, 1),
|
|
776
|
+
checkForm = _Form$useForm6[0];
|
|
750
777
|
|
|
751
778
|
var onColSortEnd = function onColSortEnd(active, over) {
|
|
752
779
|
var _a;
|
|
@@ -1125,7 +1152,6 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1125
1152
|
render: function render(_, record, index) {
|
|
1126
1153
|
var _a, _b, _c;
|
|
1127
1154
|
|
|
1128
|
-
console.log(deepDataSourceRef.current, '--deepDataSourceRef.current', _rowKey);
|
|
1129
1155
|
return ((_c = (_b = (_a = deepDataSourceRef.current) === null || _a === void 0 ? void 0 : _a[record[_rowKey]]) === null || _b === void 0 ? void 0 : _b['_deepIds']) === null || _c === void 0 ? void 0 : _c.join('-')) || "".concat(index + 1);
|
|
1130
1156
|
}
|
|
1131
1157
|
} : Object.assign(Object.assign({
|
|
@@ -1291,12 +1317,249 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1291
1317
|
},
|
|
1292
1318
|
columns: columns.map(function (item) {
|
|
1293
1319
|
return (0, _lodash.omit)(item, ['render', 'sorter', 'onFilter', 'filters', 'componentProps', 'formProps', 'editable']);
|
|
1294
|
-
})
|
|
1320
|
+
}),
|
|
1321
|
+
// verify: async () => {
|
|
1322
|
+
// let allRule = {}
|
|
1323
|
+
// let time
|
|
1324
|
+
// let fullNum = 0
|
|
1325
|
+
// columns.forEach((col: any) => {
|
|
1326
|
+
// if (col?.formProps?.rules) {
|
|
1327
|
+
// allRule[col.dataIndex] = col?.formProps?.rules || []
|
|
1328
|
+
// }
|
|
1329
|
+
// })
|
|
1330
|
+
// const validator = new AsyncValidator(allRule);
|
|
1331
|
+
// let flag = true
|
|
1332
|
+
// let messageIndex = null
|
|
1333
|
+
// let errorRowKey = null
|
|
1334
|
+
// let errorInfo = null
|
|
1335
|
+
// const deepValidator = async (data, index) => {
|
|
1336
|
+
// for (let i = 0; i < data.length; i++) {
|
|
1337
|
+
// if (flag) {
|
|
1338
|
+
// try {
|
|
1339
|
+
// await validator.validate(data[i], (errors, fields) => {
|
|
1340
|
+
// if (errors) {
|
|
1341
|
+
// errorInfo = { errors, fields, value: data[i] };
|
|
1342
|
+
// flag = false
|
|
1343
|
+
// messageIndex = index === null ? i : index
|
|
1344
|
+
// errorRowKey = data?.[i]?.[rowKey]
|
|
1345
|
+
// } else if (data[i].children) {
|
|
1346
|
+
// deepValidator(data[i].children, i)
|
|
1347
|
+
// }
|
|
1348
|
+
// })
|
|
1349
|
+
// } catch (error) {
|
|
1350
|
+
// break;
|
|
1351
|
+
// }
|
|
1352
|
+
// }
|
|
1353
|
+
// }
|
|
1354
|
+
// }
|
|
1355
|
+
// await deepValidator(dataSource, null)
|
|
1356
|
+
// console.log(flag, 'fff')
|
|
1357
|
+
// if (flag) {
|
|
1358
|
+
// return Promise.resolve(dataSource)
|
|
1359
|
+
// } else {
|
|
1360
|
+
// setTimeout(() => {
|
|
1361
|
+
// if (messageIndex !== null) {
|
|
1362
|
+
// scrollToIndexRef.current?.(messageIndex, { align: 'center' })
|
|
1363
|
+
// time = setInterval(async () => {
|
|
1364
|
+
// fullNum++
|
|
1365
|
+
// if (fullNum > 5) {
|
|
1366
|
+
// clearInterval(time)
|
|
1367
|
+
// } else {
|
|
1368
|
+
// const form = (Object.values(allFormListRef.current || []).find((item: any) => item.key === errorRowKey) as any)?.form
|
|
1369
|
+
// if (form) {
|
|
1370
|
+
// try {
|
|
1371
|
+
// await form.validateFields()
|
|
1372
|
+
// console.log('验证成功')
|
|
1373
|
+
// } catch (error) {
|
|
1374
|
+
// console.log('验证失败', error)
|
|
1375
|
+
// return error
|
|
1376
|
+
// } finally {
|
|
1377
|
+
// clearInterval(time)
|
|
1378
|
+
// }
|
|
1379
|
+
// }
|
|
1380
|
+
// }
|
|
1381
|
+
// }, 500)
|
|
1382
|
+
// }
|
|
1383
|
+
// }, 100)
|
|
1384
|
+
// return Promise.reject(errorInfo)
|
|
1385
|
+
// }
|
|
1386
|
+
// },
|
|
1387
|
+
verify: function verify() {
|
|
1388
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
|
|
1389
|
+
var time, fullNum, flag, messageIndex, errorRowKey, errorInfo, deepValidator;
|
|
1390
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
|
1391
|
+
while (1) {
|
|
1392
|
+
switch (_context4.prev = _context4.next) {
|
|
1393
|
+
case 0:
|
|
1394
|
+
fullNum = 0;
|
|
1395
|
+
flag = true;
|
|
1396
|
+
messageIndex = null;
|
|
1397
|
+
errorRowKey = null;
|
|
1398
|
+
errorInfo = null;
|
|
1399
|
+
|
|
1400
|
+
deepValidator = function deepValidator(data, index) {
|
|
1401
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
1402
|
+
var _c, i;
|
|
1403
|
+
|
|
1404
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
1405
|
+
while (1) {
|
|
1406
|
+
switch (_context2.prev = _context2.next) {
|
|
1407
|
+
case 0:
|
|
1408
|
+
i = 0;
|
|
1409
|
+
|
|
1410
|
+
case 1:
|
|
1411
|
+
if (!(i < data.length)) {
|
|
1412
|
+
_context2.next = 21;
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
if (!flag) {
|
|
1417
|
+
_context2.next = 18;
|
|
1418
|
+
break;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
_context2.prev = 3;
|
|
1422
|
+
checkForm.resetFields();
|
|
1423
|
+
checkForm.setFieldsValue(data[i]);
|
|
1424
|
+
_context2.next = 8;
|
|
1425
|
+
return checkForm.validateFields();
|
|
1426
|
+
|
|
1427
|
+
case 8:
|
|
1428
|
+
if (data[i].children) {
|
|
1429
|
+
deepValidator(data[i].children, i);
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
_context2.next = 18;
|
|
1433
|
+
break;
|
|
1434
|
+
|
|
1435
|
+
case 11:
|
|
1436
|
+
_context2.prev = 11;
|
|
1437
|
+
_context2.t0 = _context2["catch"](3);
|
|
1438
|
+
errorInfo = {
|
|
1439
|
+
error: _context2.t0,
|
|
1440
|
+
value: data[i]
|
|
1441
|
+
};
|
|
1442
|
+
flag = false;
|
|
1443
|
+
messageIndex = index === null ? i : index;
|
|
1444
|
+
errorRowKey = (_c = data === null || data === void 0 ? void 0 : data[i]) === null || _c === void 0 ? void 0 : _c[_rowKey];
|
|
1445
|
+
return _context2.abrupt("break", 21);
|
|
1446
|
+
|
|
1447
|
+
case 18:
|
|
1448
|
+
i++;
|
|
1449
|
+
_context2.next = 1;
|
|
1450
|
+
break;
|
|
1451
|
+
|
|
1452
|
+
case 21:
|
|
1453
|
+
case "end":
|
|
1454
|
+
return _context2.stop();
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}, _callee2, null, [[3, 11]]);
|
|
1458
|
+
}));
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
_context4.next = 8;
|
|
1462
|
+
return deepValidator(dataSource, null);
|
|
1463
|
+
|
|
1464
|
+
case 8:
|
|
1465
|
+
if (!flag) {
|
|
1466
|
+
_context4.next = 12;
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
return _context4.abrupt("return", Promise.resolve(dataSource));
|
|
1471
|
+
|
|
1472
|
+
case 12:
|
|
1473
|
+
setTimeout(function () {
|
|
1474
|
+
var _a;
|
|
1475
|
+
|
|
1476
|
+
if (messageIndex !== null) {
|
|
1477
|
+
(_a = scrollToIndexRef.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndexRef, messageIndex, {
|
|
1478
|
+
align: 'center'
|
|
1479
|
+
});
|
|
1480
|
+
time = setInterval(function () {
|
|
1481
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3() {
|
|
1482
|
+
var _b, form;
|
|
1483
|
+
|
|
1484
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
1485
|
+
while (1) {
|
|
1486
|
+
switch (_context3.prev = _context3.next) {
|
|
1487
|
+
case 0:
|
|
1488
|
+
fullNum++;
|
|
1489
|
+
|
|
1490
|
+
if (!(fullNum > 5)) {
|
|
1491
|
+
_context3.next = 5;
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
clearInterval(time);
|
|
1496
|
+
_context3.next = 20;
|
|
1497
|
+
break;
|
|
1498
|
+
|
|
1499
|
+
case 5:
|
|
1500
|
+
form = (_b = Object.values(allFormListRef.current || []).find(function (item) {
|
|
1501
|
+
return item.key === errorRowKey;
|
|
1502
|
+
})) === null || _b === void 0 ? void 0 : _b.form;
|
|
1503
|
+
|
|
1504
|
+
if (!form) {
|
|
1505
|
+
_context3.next = 20;
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
_context3.prev = 7;
|
|
1510
|
+
_context3.next = 10;
|
|
1511
|
+
return form.validateFields();
|
|
1512
|
+
|
|
1513
|
+
case 10:
|
|
1514
|
+
console.log('验证成功');
|
|
1515
|
+
_context3.next = 17;
|
|
1516
|
+
break;
|
|
1517
|
+
|
|
1518
|
+
case 13:
|
|
1519
|
+
_context3.prev = 13;
|
|
1520
|
+
_context3.t0 = _context3["catch"](7);
|
|
1521
|
+
console.log('验证失败', _context3.t0);
|
|
1522
|
+
return _context3.abrupt("return", _context3.t0);
|
|
1523
|
+
|
|
1524
|
+
case 17:
|
|
1525
|
+
_context3.prev = 17;
|
|
1526
|
+
clearInterval(time);
|
|
1527
|
+
return _context3.finish(17);
|
|
1528
|
+
|
|
1529
|
+
case 20:
|
|
1530
|
+
case "end":
|
|
1531
|
+
return _context3.stop();
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}, _callee3, null, [[7, 13, 17, 20]]);
|
|
1535
|
+
}));
|
|
1536
|
+
}, 500);
|
|
1537
|
+
}
|
|
1538
|
+
}, 100);
|
|
1539
|
+
return _context4.abrupt("return", Promise.reject(errorInfo));
|
|
1540
|
+
|
|
1541
|
+
case 14:
|
|
1542
|
+
case "end":
|
|
1543
|
+
return _context4.stop();
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}, _callee4);
|
|
1547
|
+
}));
|
|
1548
|
+
}
|
|
1295
1549
|
};
|
|
1296
1550
|
});
|
|
1297
1551
|
var isShowAddAction = (0, _react.useMemo)(function () {
|
|
1298
1552
|
return isEdit && isAdd || isHoverEdit && isAdd;
|
|
1299
1553
|
}, [isEdit, isAdd, isHoverEdit]);
|
|
1554
|
+
|
|
1555
|
+
var pushAllForm = function pushAllForm(form, key, index) {
|
|
1556
|
+
allFormListRef.current[key] = {
|
|
1557
|
+
form: form,
|
|
1558
|
+
key: key,
|
|
1559
|
+
index: index
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1300
1563
|
var config = (0, _react.useRef)(Object.assign({
|
|
1301
1564
|
pagination: false,
|
|
1302
1565
|
tableLayout: 'fixed',
|
|
@@ -1307,7 +1570,11 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1307
1570
|
return record[_rowKey] || record.index || Math.random();
|
|
1308
1571
|
},
|
|
1309
1572
|
components: {
|
|
1310
|
-
table: virtual ?
|
|
1573
|
+
table: virtual ? function (props) {
|
|
1574
|
+
return /*#__PURE__*/_react.default.createElement(_virtual.VirtualTable, Object.assign({}, props, {
|
|
1575
|
+
fn: scrollToIndexRef
|
|
1576
|
+
}));
|
|
1577
|
+
} : null,
|
|
1311
1578
|
body: Object.assign({
|
|
1312
1579
|
row: function row(rowProps) {
|
|
1313
1580
|
return sortOpen ? EditableSortRow(Object.assign(Object.assign({}, rowProps), {
|
|
@@ -1316,7 +1583,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1316
1583
|
virtual: virtual
|
|
1317
1584
|
}));
|
|
1318
1585
|
},
|
|
1319
|
-
cell: MemoEditableCell
|
|
1586
|
+
cell: props.shouldUpdate ? EditableCell : MemoEditableCell
|
|
1320
1587
|
}, sortOpen ? {
|
|
1321
1588
|
wrapper: function wrapper(wrapperProps) {
|
|
1322
1589
|
var _a, _b, _c;
|
|
@@ -1340,11 +1607,42 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1340
1607
|
}
|
|
1341
1608
|
},
|
|
1342
1609
|
onRow: function onRow(record, index) {
|
|
1610
|
+
var _a;
|
|
1611
|
+
|
|
1343
1612
|
return {
|
|
1344
|
-
disabled: disabled
|
|
1613
|
+
disabled: disabled || !!((_a = disabledDataSourceRowKeys.current) === null || _a === void 0 ? void 0 : _a.includes(record[_rowKey])),
|
|
1614
|
+
dataKey: record[_rowKey],
|
|
1615
|
+
index: index,
|
|
1616
|
+
pushAllForm: pushAllForm
|
|
1345
1617
|
};
|
|
1346
1618
|
}
|
|
1347
1619
|
}, resetProps));
|
|
1620
|
+
(0, _react.useEffect)(function () {
|
|
1621
|
+
var _a;
|
|
1622
|
+
|
|
1623
|
+
if (autoSizer) {
|
|
1624
|
+
var tableClient = (_a = tableWarpRef === null || tableWarpRef === void 0 ? void 0 : tableWarpRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
1625
|
+
var height = (tableClient === null || tableClient === void 0 ? void 0 : tableClient.height) || '100%';
|
|
1626
|
+
var TailorHeight = size === 'middle' ? 48 : 40;
|
|
1627
|
+
|
|
1628
|
+
if (isAdd) {
|
|
1629
|
+
TailorHeight += 48;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
if (props.summary) {
|
|
1633
|
+
TailorHeight += 48;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
if (props.pagination) {
|
|
1637
|
+
TailorHeight += 48;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
autoSizerRef.current = {
|
|
1641
|
+
width: tableClient === null || tableClient === void 0 ? void 0 : tableClient.width,
|
|
1642
|
+
height: typeof height === 'string' ? "calc(".concat(height, " - ").concat(TailorHeight, "px)") : height - TailorHeight
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
}, []);
|
|
1348
1646
|
|
|
1349
1647
|
if (colSortOpen) {
|
|
1350
1648
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -1362,7 +1660,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1362
1660
|
items: columns.reduce(function (acc, item) {
|
|
1363
1661
|
return [].concat((0, _toConsumableArray2.default)(acc), [item.dataIndex]);
|
|
1364
1662
|
}, [])
|
|
1365
|
-
}, /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Table, Object.assign({}, (0, _util.checkDataSourceIsEmpty)(config.current, dataSourceRef.current), {
|
|
1663
|
+
}, /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Table, Object.assign({}, (0, _util.checkDataSourceIsEmpty)(config.current, dataSourceRef.current, autoSizerRef.current), {
|
|
1366
1664
|
loading: loading,
|
|
1367
1665
|
size: size || 'small',
|
|
1368
1666
|
columns: resultColumns,
|
|
@@ -1387,23 +1685,34 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1387
1685
|
isShowAddAction: isShowAddAction,
|
|
1388
1686
|
recordCreatorProps: recordCreatorProps,
|
|
1389
1687
|
handleAdd: handleAdd
|
|
1390
|
-
})
|
|
1688
|
+
}), /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
1689
|
+
form: checkForm,
|
|
1690
|
+
component: false
|
|
1691
|
+
}, columns.map(function (item) {
|
|
1692
|
+
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form.Item, Object.assign({
|
|
1693
|
+
noStyle: true,
|
|
1694
|
+
name: item.dataIndex
|
|
1695
|
+
}, (item === null || item === void 0 ? void 0 : item['formProps']) || {}));
|
|
1696
|
+
})));
|
|
1391
1697
|
} // @ts-ignore
|
|
1392
1698
|
|
|
1393
1699
|
|
|
1394
1700
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1395
|
-
className:
|
|
1701
|
+
className: (0, _classnames.default)('lm_editTable_warpper', autoSizer && 'lm_editable_autosize'),
|
|
1396
1702
|
ref: tableWarpRef
|
|
1397
1703
|
}, /*#__PURE__*/_react.default.createElement(_ConfigProvider.default, {
|
|
1398
1704
|
renderEmpty: loading ? function () {
|
|
1399
1705
|
return null;
|
|
1400
1706
|
} : _components.CustomizeRenderEmpty
|
|
1401
|
-
}, /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Table, Object.assign({}, (0, _util.checkDataSourceIsEmpty)(config.current, dataSourceRef.current), {
|
|
1707
|
+
}, /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Table, Object.assign({}, (0, _util.checkDataSourceIsEmpty)(config.current, dataSourceRef.current, autoSizerRef.current), {
|
|
1402
1708
|
size: size || 'small',
|
|
1403
1709
|
columns: resultColumns,
|
|
1404
1710
|
rowClassName: "editable-row",
|
|
1405
1711
|
bordered: true,
|
|
1406
1712
|
loading: loading,
|
|
1713
|
+
style: autoSizer ? {
|
|
1714
|
+
height: isAdd ? "calc(100% - ".concat(48, "px)") : '100%'
|
|
1715
|
+
} : undefined,
|
|
1407
1716
|
pagination: false,
|
|
1408
1717
|
// components={tableComponents}
|
|
1409
1718
|
expandable: (resetProps === null || resetProps === void 0 ? void 0 : resetProps.expandable) || {
|
|
@@ -1437,7 +1746,15 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1437
1746
|
isShowAddAction: isShowAddAction,
|
|
1438
1747
|
recordCreatorProps: recordCreatorProps,
|
|
1439
1748
|
handleAdd: handleAdd
|
|
1440
|
-
})
|
|
1749
|
+
}), /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
1750
|
+
form: checkForm,
|
|
1751
|
+
component: false
|
|
1752
|
+
}, columns.map(function (item) {
|
|
1753
|
+
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form.Item, Object.assign({
|
|
1754
|
+
noStyle: true,
|
|
1755
|
+
name: item.dataIndex
|
|
1756
|
+
}, (item === null || item === void 0 ? void 0 : item['formProps']) || {}));
|
|
1757
|
+
})));
|
|
1441
1758
|
});
|
|
1442
1759
|
|
|
1443
1760
|
var _default = /*#__PURE__*/(0, _react.memo)(EditTable);
|
|
@@ -19,6 +19,7 @@ var _modifiers = require("@dnd-kit/modifiers");
|
|
|
19
19
|
|
|
20
20
|
var _sortable = require("@dnd-kit/sortable");
|
|
21
21
|
|
|
22
|
+
/* eslint-disable no-unused-vars */
|
|
22
23
|
// 可拖拽容器
|
|
23
24
|
var DndContainer = function DndContainer(_ref) {
|
|
24
25
|
var children = _ref.children,
|
|
@@ -69,7 +70,8 @@ var DndContainer = function DndContainer(_ref) {
|
|
|
69
70
|
if (active.id !== over.id) {
|
|
70
71
|
move(active.id, over.id);
|
|
71
72
|
}
|
|
72
|
-
};
|
|
73
|
+
}; // @ts-ignore
|
|
74
|
+
|
|
73
75
|
|
|
74
76
|
var instance = {
|
|
75
77
|
isDragging: isDragging,
|
|
@@ -81,7 +83,6 @@ var DndContainer = function DndContainer(_ref) {
|
|
|
81
83
|
items: items,
|
|
82
84
|
tableWidth: tableWidth
|
|
83
85
|
};
|
|
84
|
-
console.log('instance', instance);
|
|
85
86
|
return /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
86
87
|
sensors: sensors,
|
|
87
88
|
onDragStart: handleDragStart,
|
|
@@ -670,6 +670,20 @@ p {
|
|
|
670
670
|
padding-left: 7px;
|
|
671
671
|
box-sizing: border-box;
|
|
672
672
|
}
|
|
673
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-wrapper,
|
|
674
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-nested-loading,
|
|
675
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-container,
|
|
676
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table,
|
|
677
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-container {
|
|
678
|
+
height: 100%;
|
|
679
|
+
}
|
|
680
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-wrapper .ant-table-body,
|
|
681
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-nested-loading .ant-table-body,
|
|
682
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-container .ant-table-body,
|
|
683
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table .ant-table-body,
|
|
684
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-container .ant-table-body {
|
|
685
|
+
height: calc(100% - 41px);
|
|
686
|
+
}
|
|
673
687
|
.lm_editTable_wrapperRange .inputRange {
|
|
674
688
|
display: inline-flex;
|
|
675
689
|
align-items: center;
|
|
@@ -158,6 +158,20 @@
|
|
|
158
158
|
padding-left: 7px;
|
|
159
159
|
box-sizing: border-box;
|
|
160
160
|
}
|
|
161
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-wrapper,
|
|
162
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-nested-loading,
|
|
163
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-container,
|
|
164
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table,
|
|
165
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-container {
|
|
166
|
+
height: 100%;
|
|
167
|
+
}
|
|
168
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-wrapper .ant-table-body,
|
|
169
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-nested-loading .ant-table-body,
|
|
170
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-spin-container .ant-table-body,
|
|
171
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table .ant-table-body,
|
|
172
|
+
.lm_editTable_warpper.lm_editable_autosize .ant-table-container .ant-table-body {
|
|
173
|
+
height: calc(100% - 41px);
|
|
174
|
+
}
|
|
161
175
|
.lm_editTable_wrapperRange .inputRange {
|
|
162
176
|
display: inline-flex;
|
|
163
177
|
align-items: center;
|
|
@@ -9,7 +9,9 @@ export declare function checkExpandIconColumnIndex({ rowSelection, sortOpen, ind
|
|
|
9
9
|
sortOpen: any;
|
|
10
10
|
indexCol: any;
|
|
11
11
|
}): number;
|
|
12
|
-
export declare function checkDataSourceIsEmpty(config: any, dataSource: any): any;
|
|
12
|
+
export declare function checkDataSourceIsEmpty(config: any, dataSource: any, scrollInfo: any): any;
|
|
13
|
+
/** 根据传入的disabedRows, 得出最终需要disabed的rowKeys */
|
|
14
|
+
export declare function checkTableRowIsDisable(deepDataSource: any, disabledRows: any, rowKey: any): any[];
|
|
13
15
|
declare const _default: {
|
|
14
16
|
isObjEmpty: typeof isObjEmpty;
|
|
15
17
|
};
|
package/lib/LmEditTable/util.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.checkDataSourceIsEmpty = checkDataSourceIsEmpty;
|
|
|
9
9
|
exports.checkExpandIconColumnIndex = checkExpandIconColumnIndex;
|
|
10
10
|
exports.checkMemoShouldUploadSpecialFun = checkMemoShouldUploadSpecialFun;
|
|
11
11
|
exports.checkRowKeyByDataSource = checkRowKeyByDataSource;
|
|
12
|
+
exports.checkTableRowIsDisable = checkTableRowIsDisable;
|
|
12
13
|
exports.deepDataSourcePreKeys = deepDataSourcePreKeys;
|
|
13
14
|
exports.default = void 0;
|
|
14
15
|
exports.getExpandStatus = getExpandStatus;
|
|
@@ -87,7 +88,7 @@ function getExpandStatus(children) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
90
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
91
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
91
92
|
|
|
92
93
|
var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
|
|
93
94
|
|
|
@@ -141,13 +142,17 @@ function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
|
141
142
|
return (0, _lodash.isEqual)(prev.style, next.style);
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
if (((_l = next.className) === null || _l === void 0 ? void 0 : _l.indexOf('ant-table-row-expand-icon-cell')) > -1) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
144
149
|
if (next.className.indexOf('ant-table-selection-column') > -1) {
|
|
145
|
-
return (0, _lodash.isEqual)((
|
|
150
|
+
return (0, _lodash.isEqual)((_o = (_m = prev.children) === null || _m === void 0 ? void 0 : _m[1]) === null || _o === void 0 ? void 0 : _o.props, (_q = (_p = next.children) === null || _p === void 0 ? void 0 : _p[1]) === null || _q === void 0 ? void 0 : _q.props);
|
|
146
151
|
}
|
|
147
152
|
/** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
|
|
148
153
|
|
|
149
154
|
|
|
150
|
-
if (((
|
|
155
|
+
if (((_r = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _r === void 0 ? void 0 : _r.quickcopy) || ((_s = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _s === void 0 ? void 0 : _s.quickcopy)) {
|
|
151
156
|
var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
|
|
152
157
|
var p = (0, _lodash.pick)(prev, pickProps);
|
|
153
158
|
var n = (0, _lodash.pick)(next, pickProps);
|
|
@@ -167,17 +172,67 @@ function checkExpandIconColumnIndex(_ref) {
|
|
|
167
172
|
return arr.length;
|
|
168
173
|
}
|
|
169
174
|
|
|
170
|
-
function checkDataSourceIsEmpty(config, dataSource) {
|
|
175
|
+
function checkDataSourceIsEmpty(config, dataSource, scrollInfo) {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
|
|
178
|
+
var resultConfig = Object.assign({}, config);
|
|
179
|
+
|
|
180
|
+
if (scrollInfo) {
|
|
181
|
+
resultConfig = Object.assign(Object.assign({}, resultConfig), {
|
|
182
|
+
scroll: {
|
|
183
|
+
x: ((_a = resultConfig.scroll) === null || _a === void 0 ? void 0 : _a.x) || '100%',
|
|
184
|
+
y: scrollInfo.height || ((_b = resultConfig.scroll) === null || _b === void 0 ? void 0 : _b.y)
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
171
189
|
if (dataSource.length) {
|
|
172
|
-
return
|
|
190
|
+
return resultConfig;
|
|
173
191
|
}
|
|
174
192
|
|
|
175
|
-
return Object.assign(Object.assign({},
|
|
176
|
-
components: Object.assign(Object.assign({},
|
|
193
|
+
return Object.assign(Object.assign({}, resultConfig), {
|
|
194
|
+
components: Object.assign(Object.assign({}, resultConfig.components), {
|
|
177
195
|
body: {}
|
|
178
196
|
})
|
|
179
197
|
});
|
|
180
198
|
}
|
|
199
|
+
/** 根据传入的disabedRows, 得出最终需要disabed的rowKeys */
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
function checkTableRowIsDisable(deepDataSource, disabledRows, rowKey) {
|
|
203
|
+
var disabledRkeys = [];
|
|
204
|
+
|
|
205
|
+
if (!disabledRows.length) {
|
|
206
|
+
return disabledRkeys;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
var disableIds = disabledRows.map(function (item) {
|
|
210
|
+
return (0, _lodash.isObject)(item) ? item === null || item === void 0 ? void 0 : item[rowKey] : item;
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
function deep(children, arrs) {
|
|
214
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (item) {
|
|
215
|
+
arrs.push(item[rowKey]);
|
|
216
|
+
|
|
217
|
+
if (item.children) {
|
|
218
|
+
deep(item.children, arrs);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (disableIds.length) {
|
|
224
|
+
disableIds === null || disableIds === void 0 ? void 0 : disableIds.forEach(function (item) {
|
|
225
|
+
disabledRkeys.push(item);
|
|
226
|
+
var record = deepDataSource[item];
|
|
227
|
+
|
|
228
|
+
if (record === null || record === void 0 ? void 0 : record.children) {
|
|
229
|
+
deep(record.children, disabledRkeys);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return disabledRkeys;
|
|
235
|
+
}
|
|
181
236
|
|
|
182
237
|
var _default = {
|
|
183
238
|
isObjEmpty: isObjEmpty
|