zmdms-webui 0.0.4 → 0.0.6
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/README.md +22 -12
- package/dist/es/_virtual/_tslib.js +39 -1
- package/dist/es/button/button.d.ts +5 -3
- package/dist/es/button/button.js +7 -18
- package/dist/es/detaillist/index.d.ts +5 -0
- package/dist/es/detaillist/index.js +5 -0
- package/dist/es/detaillist/item.d.ts +21 -0
- package/dist/es/detaillist/item.js +26 -0
- package/dist/es/detaillist/list.d.ts +15 -0
- package/dist/es/detaillist/list.js +19 -0
- package/dist/es/dynamicsetting/dynamicSetting.d.ts +2 -2
- package/dist/es/dynamicsetting/interface.d.ts +6 -1
- package/dist/es/dynamicsetting/useDynamic.js +2 -0
- package/dist/es/footer/footer.js +1 -1
- package/dist/es/forgetpassword/forgetPassword.js +2 -2
- package/dist/es/form/detaultDom.js +11 -0
- package/dist/es/form/form.d.ts +1 -0
- package/dist/es/form/form.js +8 -5
- package/dist/es/form/formItems.js +4 -2
- package/dist/es/form/hooks.js +8 -8
- package/dist/es/form/interface.d.ts +5 -4
- package/dist/es/formitem/formItem.js +26 -9
- package/dist/es/login/index.d.ts +1 -0
- package/dist/es/login/index.js +2 -2
- package/dist/es/modal/index.d.ts +5 -0
- package/dist/es/modal/index.js +5 -0
- package/dist/es/modal/interface.d.ts +16 -0
- package/dist/es/modal/modal.d.ts +5 -0
- package/dist/es/modal/modal.js +34 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusSquareOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/PicRightOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons/es/icons/PlusOutlined.js +15 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/MinusOutlined.js +5 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/MinusSquareOutlined.js +5 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/PicRightOutlined.js +5 -0
- package/dist/es/node_modules/@ant-design/icons-svg/es/asn/PlusOutlined.js +5 -0
- package/dist/es/table/components/ColumnAddDel.js +21 -0
- package/dist/es/table/components/ColumnDynamic.js +14 -0
- package/dist/es/table/components/CopyIcon.js +4 -2
- package/dist/es/table/components/EnhanceCell.js +17 -6
- package/dist/es/table/components/EnhanceRow.js +12 -2
- package/dist/es/table/components/hooks.js +18 -2
- package/dist/es/table/components/useDragRef.js +56 -0
- package/dist/es/table/constant.js +6 -2
- package/dist/es/table/hooks.js +154 -5
- package/dist/es/table/interface.d.ts +51 -4
- package/dist/es/table/table.js +122 -16
- package/dist/es/table/useColumns.js +47 -4
- package/dist/es/table/useDynamicListByColumns.js +1 -1
- package/dist/es/table/useInnerPagination.js +60 -0
- package/dist/es/table/useSummary.js +286 -0
- package/dist/es/table/useTableValidate.js +208 -0
- package/dist/es/table/utils.js +4 -3
- package/dist/index.build.d.ts +3 -1
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/index.es.js +3 -1
- package/dist/index.umd.js +2 -2
- package/package.json +5 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __rest, __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useState, useCallback, useImperativeHandle } from 'react';
|
|
4
|
+
import { Modal as Modal$1 } from 'antd';
|
|
5
|
+
import classNames from '../node_modules/classnames/index.js';
|
|
6
|
+
|
|
7
|
+
var Modal = function (_a, ref) {
|
|
8
|
+
var className = _a.className, defaultOpen = _a.defaultOpen, resetProps = __rest(_a, ["className", "defaultOpen"]);
|
|
9
|
+
var classes = classNames("ztxk-modal", className);
|
|
10
|
+
var _b = useState(defaultOpen), open = _b[0], setOpen = _b[1];
|
|
11
|
+
var close = useCallback(function () {
|
|
12
|
+
setOpen(false);
|
|
13
|
+
}, []);
|
|
14
|
+
useImperativeHandle(ref, function () {
|
|
15
|
+
return {
|
|
16
|
+
open: function () {
|
|
17
|
+
setOpen(true);
|
|
18
|
+
},
|
|
19
|
+
close: function () {
|
|
20
|
+
setOpen(false);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return (jsx(Modal$1, __assign({ open: open, onCancel: close, className: classes }, resetProps)));
|
|
25
|
+
};
|
|
26
|
+
var ModalComponent = forwardRef(Modal);
|
|
27
|
+
ModalComponent.displayName = "ZTXK_WEBUI_ModalComponent";
|
|
28
|
+
ModalComponent.info = Modal$1.info;
|
|
29
|
+
ModalComponent.success = Modal$1.success;
|
|
30
|
+
ModalComponent.error = Modal$1.error;
|
|
31
|
+
ModalComponent.warning = Modal$1.warning;
|
|
32
|
+
ModalComponent.confirm = Modal$1.confirm;
|
|
33
|
+
|
|
34
|
+
export { ModalComponent as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _objectSpread2 from '../../../../@babel/runtime/helpers/esm/objectSpread2.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import MinusOutlinedSvg from '../../../icons-svg/es/asn/MinusOutlined.js';
|
|
4
|
+
import AntdIcon from '../components/AntdIcon.js';
|
|
5
|
+
|
|
6
|
+
var MinusOutlined = function MinusOutlined(props, ref) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
8
|
+
ref: ref,
|
|
9
|
+
icon: MinusOutlinedSvg
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
MinusOutlined.displayName = 'MinusOutlined';
|
|
13
|
+
var MinusOutlined$1 = /*#__PURE__*/React.forwardRef(MinusOutlined);
|
|
14
|
+
|
|
15
|
+
export { MinusOutlined$1 as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _objectSpread2 from '../../../../@babel/runtime/helpers/esm/objectSpread2.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import MinusSquareOutlinedSvg from '../../../icons-svg/es/asn/MinusSquareOutlined.js';
|
|
4
|
+
import AntdIcon from '../components/AntdIcon.js';
|
|
5
|
+
|
|
6
|
+
var MinusSquareOutlined = function MinusSquareOutlined(props, ref) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
8
|
+
ref: ref,
|
|
9
|
+
icon: MinusSquareOutlinedSvg
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
MinusSquareOutlined.displayName = 'MinusSquareOutlined';
|
|
13
|
+
var MinusSquareOutlined$1 = /*#__PURE__*/React.forwardRef(MinusSquareOutlined);
|
|
14
|
+
|
|
15
|
+
export { MinusSquareOutlined$1 as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _objectSpread2 from '../../../../@babel/runtime/helpers/esm/objectSpread2.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PicRightOutlinedSvg from '../../../icons-svg/es/asn/PicRightOutlined.js';
|
|
4
|
+
import AntdIcon from '../components/AntdIcon.js';
|
|
5
|
+
|
|
6
|
+
var PicRightOutlined = function PicRightOutlined(props, ref) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
8
|
+
ref: ref,
|
|
9
|
+
icon: PicRightOutlinedSvg
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
PicRightOutlined.displayName = 'PicRightOutlined';
|
|
13
|
+
var PicRightOutlined$1 = /*#__PURE__*/React.forwardRef(PicRightOutlined);
|
|
14
|
+
|
|
15
|
+
export { PicRightOutlined$1 as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _objectSpread2 from '../../../../@babel/runtime/helpers/esm/objectSpread2.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PlusOutlinedSvg from '../../../icons-svg/es/asn/PlusOutlined.js';
|
|
4
|
+
import AntdIcon from '../components/AntdIcon.js';
|
|
5
|
+
|
|
6
|
+
var PlusOutlined = function PlusOutlined(props, ref) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
8
|
+
ref: ref,
|
|
9
|
+
icon: PlusOutlinedSvg
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
PlusOutlined.displayName = 'PlusOutlined';
|
|
13
|
+
var PlusOutlined$1 = /*#__PURE__*/React.forwardRef(PlusOutlined);
|
|
14
|
+
|
|
15
|
+
export { PlusOutlined$1 as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// This icon file is generated automatically.
|
|
2
|
+
var MinusOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M872 474H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h720c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z" } }] }, "name": "minus", "theme": "outlined" };
|
|
3
|
+
var MinusOutlinedSvg = MinusOutlined;
|
|
4
|
+
|
|
5
|
+
export { MinusOutlinedSvg as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// This icon file is generated automatically.
|
|
2
|
+
var MinusSquareOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z" } }, { "tag": "path", "attrs": { "d": "M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z" } }] }, "name": "minus-square", "theme": "outlined" };
|
|
3
|
+
var MinusSquareOutlinedSvg = MinusSquareOutlined;
|
|
4
|
+
|
|
5
|
+
export { MinusSquareOutlinedSvg as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// This icon file is generated automatically.
|
|
2
|
+
var PicRightOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M952 792H72c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h880c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0-632H72c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h880c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-24 500c8.8 0 16-7.2 16-16V380c0-8.8-7.2-16-16-16H416c-8.8 0-16 7.2-16 16v264c0 8.8 7.2 16 16 16h512zM472 436h400v152H472V436zM80 646c0 4.4 3.6 8 8 8h224c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H88c-4.4 0-8 3.6-8 8v56zm8-204h224c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H88c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8z" } }] }, "name": "pic-right", "theme": "outlined" };
|
|
3
|
+
var PicRightOutlinedSvg = PicRightOutlined;
|
|
4
|
+
|
|
5
|
+
export { PicRightOutlinedSvg as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// This icon file is generated automatically.
|
|
2
|
+
var PlusOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "defs", "attrs": {}, "children": [{ "tag": "style", "attrs": {} }] }, { "tag": "path", "attrs": { "d": "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z" } }, { "tag": "path", "attrs": { "d": "M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z" } }] }, "name": "plus", "theme": "outlined" };
|
|
3
|
+
var PlusOutlinedSvg = PlusOutlined;
|
|
4
|
+
|
|
5
|
+
export { PlusOutlinedSvg as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import MinusSquareOutlined from '../../node_modules/@ant-design/icons/es/icons/MinusSquareOutlined.js';
|
|
5
|
+
import PlusOutlined from '../../node_modules/@ant-design/icons/es/icons/PlusOutlined.js';
|
|
6
|
+
import MinusOutlined from '../../node_modules/@ant-design/icons/es/icons/MinusOutlined.js';
|
|
7
|
+
import { Popconfirm } from 'antd';
|
|
8
|
+
|
|
9
|
+
var ColumnAddDel = function (_a) {
|
|
10
|
+
var isAdd = _a.isAdd, isDel = _a.isDel, onAddAndDel = _a.onAddAndDel, index = _a.index;
|
|
11
|
+
return (jsxs(Fragment, { children: [isAdd ? (jsx("div", __assign({ className: "ztxk-column--adddel-icon" }, { children: jsx(PlusOutlined, { title: "\u65B0\u589E\u4E00\u884C", onClick: function () {
|
|
12
|
+
onAddAndDel && onAddAndDel("add", index);
|
|
13
|
+
} }) }))) : null, isDel ? (jsx("div", __assign({ className: "ztxk-column--adddel-icon" }, { children: jsx(Popconfirm, __assign({ title: "\u786E\u5B9A\u5220\u9664\u5417\uFF1F", onConfirm: function () { return onAddAndDel && onAddAndDel("del", index); } }, { children: jsx(MinusOutlined, { title: "\u5220\u9664\u4E00\u884C" }) })) }))) : null] }));
|
|
14
|
+
};
|
|
15
|
+
var ColumnDelAll = memo(function (_a) {
|
|
16
|
+
var onAddAndDel = _a.onAddAndDel;
|
|
17
|
+
return (jsx(Popconfirm, __assign({ title: "\u786E\u5B9A\u5220\u9664\u6240\u6709\u5417\uFF1F", onConfirm: function () { return onAddAndDel && onAddAndDel("delAll", 0); } }, { children: jsx(MinusSquareOutlined, { title: "\u5220\u9664\u6240\u6709\u884C" }) })));
|
|
18
|
+
});
|
|
19
|
+
var ColumnAddDel$1 = memo(ColumnAddDel);
|
|
20
|
+
|
|
21
|
+
export { ColumnDelAll, ColumnAddDel$1 as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import PicRightOutlined from '../../node_modules/@ant-design/icons/es/icons/PicRightOutlined.js';
|
|
4
|
+
|
|
5
|
+
var ColumnDynamic = function (_a) {
|
|
6
|
+
var dynamicSettingRef = _a.dynamicSettingRef;
|
|
7
|
+
return (jsx(PicRightOutlined, { onClick: function () {
|
|
8
|
+
var _a;
|
|
9
|
+
(_a = dynamicSettingRef === null || dynamicSettingRef === void 0 ? void 0 : dynamicSettingRef.current) === null || _a === void 0 ? void 0 : _a.setVisible(true);
|
|
10
|
+
} }));
|
|
11
|
+
};
|
|
12
|
+
var ColumnDynamic$1 = memo(ColumnDynamic);
|
|
13
|
+
|
|
14
|
+
export { ColumnDynamic$1 as default };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { memo } from 'react';
|
|
2
3
|
import { copyColData } from '../utils.js';
|
|
3
4
|
import IconFont from '../../icon/index.js';
|
|
4
5
|
|
|
5
6
|
var CopyIcon = function (_a) {
|
|
6
7
|
var copyKey = _a.copyKey, dataSourceRef = _a.dataSourceRef;
|
|
7
8
|
return (jsx(IconFont, { type: "icon-copy", style: { fontSize: "22px" }, className: "thead-icon", title: "\u590D\u5236\u6574\u5217", onClick: function () { return copyColData(copyKey, dataSourceRef.current); } }));
|
|
8
|
-
};
|
|
9
|
+
};
|
|
10
|
+
var CopyIcon$1 = memo(CopyIcon);
|
|
9
11
|
|
|
10
|
-
export { CopyIcon as default };
|
|
12
|
+
export { CopyIcon$1 as default };
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { __rest, __assign } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { useEditing, useIptRef } from './hooks.js';
|
|
4
|
+
import { useEditing, useIptRef, useTdRef } from './hooks.js';
|
|
5
|
+
import { getInnerIndex } from '../useInnerPagination.js';
|
|
5
6
|
import MemoInput from '../../input/input.js';
|
|
6
7
|
import InputNumber from '../../inputnumber/inputNumber.js';
|
|
7
8
|
|
|
8
9
|
var EnhanceCell = function (props) {
|
|
9
|
-
var record = props.record,
|
|
10
|
+
var record = props.record, propsIndex = props.index, editable = props.editable, editableConfig = props.editableConfig, dataIndex = props.dataIndex; props.title; var onEditableSave = props.onEditableSave; props.onMouseEnter; props.onMouseLeave; var children = props.children, currentPage = props.currentPage, isValidate = props.isValidate, resetProps = __rest(props, ["record", "index", "editable", "editableConfig", "dataIndex", "title", "onEditableSave", "onMouseEnter", "onMouseLeave", "children", "currentPage", "isValidate"]);
|
|
11
|
+
// 设置最新的index
|
|
12
|
+
var index = getInnerIndex(currentPage, propsIndex);
|
|
10
13
|
// 当前数据
|
|
11
14
|
var _a = useState(record ? record[dataIndex] : undefined), val = _a[0], setVal = _a[1];
|
|
12
15
|
// 当前是否是编辑状态 性能优化,显示纯字段比显示一个完整的组件 性能要高出许多
|
|
13
16
|
var _b = useEditing(), editing = _b.editing, toggleEdit = _b.toggleEdit;
|
|
14
17
|
// 输入框ref对象
|
|
15
18
|
var iptRef = useIptRef(editing);
|
|
19
|
+
// 单元格Ref
|
|
20
|
+
var _c = useTdRef(), tdRef = _c.tdRef, removeErrorClass = _c.removeErrorClass;
|
|
16
21
|
// 触发表格保存事件
|
|
17
22
|
var onSave = function (info) {
|
|
18
23
|
var _a;
|
|
@@ -24,25 +29,31 @@ var EnhanceCell = function (props) {
|
|
|
24
29
|
};
|
|
25
30
|
// 如果开启编辑 那么内部直接代理
|
|
26
31
|
if (editable) {
|
|
27
|
-
var
|
|
32
|
+
var _d = editableConfig || {
|
|
28
33
|
type: "input",
|
|
29
|
-
}, type =
|
|
34
|
+
}, type = _d.type, resetEditableConfigProps = __rest(_d, ["type"]);
|
|
30
35
|
var CurrentReactNode = null;
|
|
31
36
|
// 输入框处理
|
|
32
37
|
if (type === "input") {
|
|
33
38
|
CurrentReactNode = (jsx(MemoInput, __assign({ value: val, onChange: function (e) {
|
|
34
39
|
setVal(e.target.value);
|
|
40
|
+
if (isValidate) {
|
|
41
|
+
removeErrorClass();
|
|
42
|
+
}
|
|
35
43
|
}, onPressEnter: onSave, onBlur: onSave, ref: iptRef }, resetEditableConfigProps)));
|
|
36
44
|
}
|
|
37
45
|
// 数字输入框处理
|
|
38
46
|
if (type === "inputNumber") {
|
|
39
47
|
CurrentReactNode = (jsx(InputNumber, __assign({ value: val, onChange: function (value) {
|
|
40
48
|
setVal(value);
|
|
49
|
+
if (isValidate) {
|
|
50
|
+
removeErrorClass();
|
|
51
|
+
}
|
|
41
52
|
}, onPressEnter: onSave, onBlur: onSave, ref: iptRef }, resetEditableConfigProps)));
|
|
42
53
|
}
|
|
43
|
-
return (jsx("td", __assign({}, resetProps, { children: editing ? (jsx("div", __assign({ className: "ztxk-table__enhance-cell" }, { children: CurrentReactNode }))) : (jsx("div", __assign({ className: "ztxk-table__enhance-cell-wrap", onClick: toggleEdit }, { children: children }))) })));
|
|
54
|
+
return (jsx("td", __assign({ ref: tdRef }, resetProps, { children: editing ? (jsx("div", __assign({ className: "ztxk-table__enhance-cell" }, { children: CurrentReactNode }))) : (jsx("div", __assign({ className: "ztxk-table__enhance-cell-wrap", onClick: toggleEdit }, { children: children }))) })));
|
|
44
55
|
}
|
|
45
|
-
return jsx("td", __assign({}, resetProps, { children: children }));
|
|
56
|
+
return (jsx("td", __assign({ ref: tdRef }, resetProps, { children: children })));
|
|
46
57
|
};
|
|
47
58
|
|
|
48
59
|
export { EnhanceCell as default };
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { __rest, __assign } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import classNames from '../../node_modules/classnames/index.js';
|
|
4
|
+
import useDragRef from './useDragRef.js';
|
|
4
5
|
|
|
5
|
-
var
|
|
6
|
+
var BasicRow = function (props) {
|
|
6
7
|
var className = props.className, resetProps = __rest(props, ["className"]);
|
|
7
8
|
var classes = classNames("ztxk-table__enhance-row", className);
|
|
8
9
|
return jsx("tr", __assign({ className: classes }, resetProps));
|
|
10
|
+
};
|
|
11
|
+
// 拖拽行配置
|
|
12
|
+
var MoveRow = function (props) {
|
|
13
|
+
var className = props.className, style = props.style, index = props.index, moveRow = props.moveRow, resetProps = __rest(props, ["className", "style", "index", "moveRow"]);
|
|
14
|
+
var ref = useDragRef(index, moveRow).ref;
|
|
15
|
+
var classes = classNames("ztxk-table__enhance-row", className
|
|
16
|
+
// isOver ? dropClassName : ""
|
|
17
|
+
);
|
|
18
|
+
return (jsx("tr", __assign({ ref: ref, style: __assign({ cursor: "move" }, style), className: classes }, resetProps)));
|
|
9
19
|
};
|
|
10
20
|
|
|
11
|
-
export {
|
|
21
|
+
export { BasicRow, MoveRow };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { useState, useRef, useEffect } from 'react';
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import { ERROR_TD_CLASSNAME } from '../constant.js';
|
|
2
3
|
|
|
4
|
+
// 设置是否编辑状态
|
|
3
5
|
function useEditing() {
|
|
4
6
|
var _a = useState(false), editing = _a[0], setEditing = _a[1];
|
|
5
7
|
var toggleEdit = function () {
|
|
@@ -19,6 +21,20 @@ function useIptRef(editing) {
|
|
|
19
21
|
}
|
|
20
22
|
}, [editing]);
|
|
21
23
|
return iptRef;
|
|
24
|
+
}
|
|
25
|
+
function useTdRef() {
|
|
26
|
+
var tdRef = useRef();
|
|
27
|
+
var removeErrorClass = useCallback(function () {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (tdRef.current &&
|
|
30
|
+
((_b = (_a = tdRef.current.classList).contains) === null || _b === void 0 ? void 0 : _b.call(_a, ERROR_TD_CLASSNAME))) {
|
|
31
|
+
tdRef.current.classList.remove(ERROR_TD_CLASSNAME);
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
return {
|
|
35
|
+
tdRef: tdRef,
|
|
36
|
+
removeErrorClass: removeErrorClass,
|
|
37
|
+
};
|
|
22
38
|
}
|
|
23
39
|
|
|
24
|
-
export { useEditing, useIptRef };
|
|
40
|
+
export { useEditing, useIptRef, useTdRef };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { TABLE_DRAG_ROW_TYPE } from '../constant.js';
|
|
3
|
+
import { useDrop } from '../../node_modules/react-dnd/dist/hooks/useDrop/useDrop.js';
|
|
4
|
+
import { useDrag } from '../../node_modules/react-dnd/dist/hooks/useDrag/useDrag.js';
|
|
5
|
+
|
|
6
|
+
function useDragRef(index, moveRow) {
|
|
7
|
+
var ref = useRef(null);
|
|
8
|
+
// 定义放置项
|
|
9
|
+
var _a = useDrop(function () { return ({
|
|
10
|
+
accept: TABLE_DRAG_ROW_TYPE,
|
|
11
|
+
collect: function (monitor) {
|
|
12
|
+
var dragIndex = (monitor.getItem() || {}).index;
|
|
13
|
+
if (dragIndex === index) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
// 这里暂时不做拖放的样式 使用浏览器的默认样式
|
|
18
|
+
// isOver: monitor.isOver(),
|
|
19
|
+
// dropClassName:
|
|
20
|
+
// dragIndex < index ? " drop-over-downward" : " drop-over-upward",
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
drop: function (item) {
|
|
24
|
+
if (!moveRow) {
|
|
25
|
+
throw new Error("请定义移动行后触发的函数 onmoveRow");
|
|
26
|
+
}
|
|
27
|
+
moveRow(item.index, index);
|
|
28
|
+
},
|
|
29
|
+
}); }, [index]), drop = _a[1];
|
|
30
|
+
// 定义拖拽项
|
|
31
|
+
var _b = useDrag({
|
|
32
|
+
type: TABLE_DRAG_ROW_TYPE,
|
|
33
|
+
item: { index: index },
|
|
34
|
+
collect: function (monitor) { return ({
|
|
35
|
+
isDragging: monitor.isDragging(),
|
|
36
|
+
}); },
|
|
37
|
+
canDrag: function (monitor) { var _a;
|
|
38
|
+
// 解决拖拽行中有input 选中时 不让其拖拽
|
|
39
|
+
return !((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase().match(/input|textarea/)); },
|
|
40
|
+
}), drag = _b[1];
|
|
41
|
+
drop(drag(ref));
|
|
42
|
+
if (moveRow) {
|
|
43
|
+
return {
|
|
44
|
+
ref: ref,
|
|
45
|
+
// isOver,
|
|
46
|
+
// dropClassName,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ref: ref,
|
|
51
|
+
// isOver: null,
|
|
52
|
+
// dropClassName: null,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { useDragRef as default };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
var TABLE_DYNAMIC_KEY = "ztxk-webui-dynamic-table";
|
|
1
|
+
var TABLE_DYNAMIC_KEY = "ztxk-webui-dynamic-table";
|
|
2
|
+
var TABLE_DRAG_ROW_TYPE = Symbol("table-drag-row");
|
|
3
|
+
var INNER_TABLE_PAGINATION_POSITION = ["bottomLeft"];
|
|
4
|
+
var INNER_TABLE_PAGINATION_PAGESIZEOPTIONS = ["10", "20", "30", "40"];
|
|
5
|
+
var ERROR_TD_CLASSNAME = "error-td";
|
|
2
6
|
|
|
3
|
-
export { TABLE_DYNAMIC_KEY };
|
|
7
|
+
export { ERROR_TD_CLASSNAME, INNER_TABLE_PAGINATION_PAGESIZEOPTIONS, INNER_TABLE_PAGINATION_POSITION, TABLE_DRAG_ROW_TYPE, TABLE_DYNAMIC_KEY };
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
3
|
+
import update from '../node_modules/immutability-helper/index.js';
|
|
4
|
+
import { getInnerIndex } from './useInnerPagination.js';
|
|
2
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @param dataSourceRef 数据引用
|
|
8
|
+
* @param onTableChange 外部传入的change事件
|
|
9
|
+
* @returns 编辑表格change事件
|
|
10
|
+
*/
|
|
3
11
|
function useEditChange(dataSourceRef, onTableChange) {
|
|
4
12
|
// 内部表格编辑事件
|
|
5
13
|
var onEditableSave = useCallback(function (record, index, dataIndex, otherInfo) {
|
|
@@ -15,10 +23,151 @@ function useEditChange(dataSourceRef, onTableChange) {
|
|
|
15
23
|
type: "edit",
|
|
16
24
|
currentIndex: index,
|
|
17
25
|
});
|
|
18
|
-
},
|
|
19
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
-
[onTableChange]);
|
|
26
|
+
}, [dataSourceRef, onTableChange]);
|
|
21
27
|
return onEditableSave;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @param dataSourceRef 数据引用
|
|
31
|
+
* @param onTableChange 外部传入的change事件
|
|
32
|
+
* @param isMove 是否需要拖拽排序
|
|
33
|
+
* @returns 排序相关方法
|
|
34
|
+
*/
|
|
35
|
+
function useMoveRowChange(dataSourceRef, onTableChange, options) {
|
|
36
|
+
var isMove = options.isMove, refreshScuCell = options.refreshScuCell, currentPage = options.currentPage;
|
|
37
|
+
var moveRow = useCallback(function (dI, hI) {
|
|
38
|
+
var _a;
|
|
39
|
+
// 内部分页时,获取数据真正的行数
|
|
40
|
+
var dragIndex = getInnerIndex(currentPage, dI);
|
|
41
|
+
var hoverIndex = getInnerIndex(currentPage, hI);
|
|
42
|
+
if (dragIndex === hoverIndex) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var copyDataSource = (_a = dataSourceRef.current) === null || _a === void 0 ? void 0 : _a.slice();
|
|
46
|
+
var dragRow = copyDataSource[dragIndex];
|
|
47
|
+
var newDataSource = update(copyDataSource, {
|
|
48
|
+
$splice: [
|
|
49
|
+
[dragIndex, 1],
|
|
50
|
+
[hoverIndex, 0, dragRow],
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
refreshScuCell && refreshScuCell();
|
|
54
|
+
onTableChange &&
|
|
55
|
+
onTableChange(newDataSource, dataSourceRef.current, {
|
|
56
|
+
type: "move",
|
|
57
|
+
dragIndex: dragIndex,
|
|
58
|
+
hoverIndex: hoverIndex,
|
|
59
|
+
});
|
|
60
|
+
}, [dataSourceRef, onTableChange, refreshScuCell, currentPage]);
|
|
61
|
+
var onRow = useCallback(function (_, index) {
|
|
62
|
+
return {
|
|
63
|
+
index: index,
|
|
64
|
+
moveRow: moveRow,
|
|
65
|
+
};
|
|
66
|
+
}, [moveRow]);
|
|
67
|
+
return {
|
|
68
|
+
onRow: isMove ? onRow : undefined,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @param dataSourceRef 数据引用
|
|
73
|
+
* @param onTableChange 外部传入的change事件
|
|
74
|
+
* @param options 增减行相关配置
|
|
75
|
+
* @returns 增减相关方法
|
|
76
|
+
*/
|
|
77
|
+
function useAddAndDelChange(dataSourceRef, onTableChange, options) {
|
|
78
|
+
var rowKey = options.rowKey, addMode = options.addMode, addCallback = options.addCallback, refreshScuCell = options.refreshScuCell, isAddAndDelAuto = options.isAddAndDelAuto, currentPage = options.currentPage;
|
|
79
|
+
// addCallback TODO:
|
|
80
|
+
var onAddAndDel = useCallback(function (type, i) {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
var _c;
|
|
83
|
+
// 内部分页时,获取数据真正的行数
|
|
84
|
+
var index = getInnerIndex(currentPage, i);
|
|
85
|
+
var newDataSource = (_c = dataSourceRef.current) === null || _c === void 0 ? void 0 : _c.slice();
|
|
86
|
+
if (type === "delAll") {
|
|
87
|
+
if (Array.isArray(newDataSource) && newDataSource.length > 0) {
|
|
88
|
+
refreshScuCell && refreshScuCell();
|
|
89
|
+
onTableChange &&
|
|
90
|
+
onTableChange([], dataSourceRef.current, {
|
|
91
|
+
type: type,
|
|
92
|
+
currentIndex: index,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// 新增 删除行为 开发自行处理
|
|
98
|
+
if (isAddAndDelAuto) {
|
|
99
|
+
refreshScuCell && refreshScuCell();
|
|
100
|
+
onTableChange &&
|
|
101
|
+
onTableChange(newDataSource, dataSourceRef.current, {
|
|
102
|
+
type: type,
|
|
103
|
+
currentIndex: index,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
var currentRecord = newDataSource[index]; // 当前数据项
|
|
107
|
+
// 经过外部处理后的数据
|
|
108
|
+
var outsideRecord = addCallback
|
|
109
|
+
? addCallback(currentRecord, { index: index })
|
|
110
|
+
: {};
|
|
111
|
+
if (type === "add") {
|
|
112
|
+
var newRecord = {};
|
|
113
|
+
if (addMode === "blank") {
|
|
114
|
+
newRecord = __assign((_a = {}, _a[String(rowKey)] = "".concat(Date.now(), "-").concat(index),
|
|
115
|
+
// 证明这条数据是新增的,提交时需要把rowKey删除
|
|
116
|
+
_a.__INNER__ADD__DATA = true, _a), outsideRecord);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
newRecord = __assign(__assign(__assign({}, currentRecord), (_b = {}, _b[String(rowKey)] = "".concat(Date.now(), "-").concat(index), _b.__INNER__ADD__DATA = true, _b)), outsideRecord);
|
|
120
|
+
}
|
|
121
|
+
newDataSource.splice(index + 1, 0, newRecord);
|
|
122
|
+
}
|
|
123
|
+
else if (type === "del") {
|
|
124
|
+
newDataSource.splice(index, 1);
|
|
125
|
+
}
|
|
126
|
+
refreshScuCell && refreshScuCell();
|
|
127
|
+
onTableChange &&
|
|
128
|
+
onTableChange(newDataSource, dataSourceRef.current, {
|
|
129
|
+
type: type,
|
|
130
|
+
currentIndex: index,
|
|
131
|
+
});
|
|
132
|
+
}, [
|
|
133
|
+
addCallback,
|
|
134
|
+
addMode,
|
|
135
|
+
dataSourceRef,
|
|
136
|
+
onTableChange,
|
|
137
|
+
rowKey,
|
|
138
|
+
refreshScuCell,
|
|
139
|
+
isAddAndDelAuto,
|
|
140
|
+
]);
|
|
141
|
+
return onAddAndDel;
|
|
142
|
+
}
|
|
143
|
+
// SCU刷新逻辑
|
|
144
|
+
// 这么写的原因是 如果拖拽行 增减行后,并不能触发column的scu
|
|
145
|
+
// 之前的写法是,通过useState刷新。但是 setState会触发整个组件的刷新
|
|
146
|
+
// 设置数据后,本身会触发setState。导致执行两次rerender。每个单元格都会执行rerender
|
|
147
|
+
// 通过Ref并不会触发 setState 通过setTimeout也不会导致每一个单元格的刷新出现问题
|
|
148
|
+
function useScuRfresh() {
|
|
149
|
+
var timeOutRef = useRef(null);
|
|
150
|
+
var tableSCURefreshRef = useRef();
|
|
151
|
+
var refreshScuCell = useCallback(function () {
|
|
152
|
+
tableSCURefreshRef.current = true;
|
|
153
|
+
}, []);
|
|
154
|
+
var getRefreshScuCell = useCallback(function () {
|
|
155
|
+
if (tableSCURefreshRef.current) {
|
|
156
|
+
if (timeOutRef.current) {
|
|
157
|
+
clearTimeout(timeOutRef.current);
|
|
158
|
+
timeOutRef.current = null;
|
|
159
|
+
}
|
|
160
|
+
timeOutRef.current = setTimeout(function () {
|
|
161
|
+
tableSCURefreshRef.current = false;
|
|
162
|
+
});
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}, []);
|
|
167
|
+
return {
|
|
168
|
+
refreshScuCell: refreshScuCell,
|
|
169
|
+
getRefreshScuCell: getRefreshScuCell,
|
|
170
|
+
};
|
|
22
171
|
}
|
|
23
172
|
|
|
24
|
-
export { useEditChange };
|
|
173
|
+
export { useAddAndDelChange, useEditChange, useMoveRowChange, useScuRfresh };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Table } from 'antd';
|
|
2
|
-
import { TableProps, ColumnType } from 'antd/lib/table';
|
|
2
|
+
import { TableProps, TablePaginationConfig, ColumnType } from 'antd/lib/table';
|
|
3
3
|
import { IInputProps } from '../input/input.js';
|
|
4
4
|
import { IInputNumberProps } from '../inputnumber/inputNumber.js';
|
|
5
5
|
|
|
@@ -13,21 +13,68 @@ interface IColumnType<RecordType> extends ColumnType<RecordType> {
|
|
|
13
13
|
isCopy?: boolean | string | string[];
|
|
14
14
|
editable?: boolean;
|
|
15
15
|
editableConfig?: IEditableConfig;
|
|
16
|
+
validate?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
key?: string;
|
|
19
|
+
columnKey?: string;
|
|
20
|
+
validate?: (record: any, index: number, key: string) => Promise<{
|
|
21
|
+
msg?: string;
|
|
22
|
+
pass: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
16
25
|
}
|
|
17
26
|
interface IColumnGroupType<RecordType> extends Omit<IColumnType<RecordType>, "dataIndex"> {
|
|
18
27
|
children: IColumnsType<RecordType>;
|
|
19
28
|
}
|
|
20
29
|
type IColumnsTypeProp<RecordType> = IColumnGroupType<RecordType> | IColumnType<RecordType>;
|
|
21
30
|
declare type IColumnsType<RecordType = unknown> = IColumnsTypeProp<RecordType>[];
|
|
31
|
+
interface ITableRefHandel {
|
|
32
|
+
getRealyIndex?: (index: number) => number;
|
|
33
|
+
getDynamicList?: () => any;
|
|
34
|
+
tableValidate?: () => Promise<any>;
|
|
35
|
+
clearErrorClass?: () => void;
|
|
36
|
+
}
|
|
22
37
|
interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"> {
|
|
38
|
+
isFlex?: boolean;
|
|
39
|
+
tablePreferences?: any;
|
|
23
40
|
dynamicKey?: string;
|
|
24
41
|
columns?: IColumnsType<RecordType>;
|
|
25
42
|
onTableChange?: (dataSource: any, preDataSource: any, other?: {
|
|
26
|
-
currentIndex
|
|
27
|
-
|
|
43
|
+
currentIndex?: number;
|
|
44
|
+
dragIndex?: number;
|
|
45
|
+
hoverIndex?: number;
|
|
46
|
+
type?: "edit" | "move" | "add" | "del" | "delAll";
|
|
28
47
|
}) => void;
|
|
29
48
|
isEdit?: boolean;
|
|
30
49
|
isMove?: boolean;
|
|
50
|
+
isAdd?: boolean;
|
|
51
|
+
addMode?: "blank" | "copy";
|
|
52
|
+
addCallback?: (record: any, info: {
|
|
53
|
+
index: number;
|
|
54
|
+
}) => any;
|
|
55
|
+
isDel?: boolean;
|
|
56
|
+
isDelAll?: boolean;
|
|
57
|
+
isAddAndDelAuto?: boolean;
|
|
58
|
+
summaryConfig?: ISummaryConfig[];
|
|
59
|
+
summaryFixed?: boolean;
|
|
60
|
+
isInnerPagination?: boolean;
|
|
61
|
+
innerPaginationPageSize?: number;
|
|
62
|
+
innerPaginationPosition?: string[];
|
|
63
|
+
innerPaginationPageSizeOptions?: TablePaginationConfig["pageSizeOptions"];
|
|
64
|
+
tableRefHandle?: React.MutableRefObject<ITableRefHandel>;
|
|
65
|
+
tableName?: string;
|
|
66
|
+
}
|
|
67
|
+
interface IFields {
|
|
68
|
+
toFixedNum?: number | number[];
|
|
69
|
+
key: string;
|
|
70
|
+
showKey?: string | string[];
|
|
71
|
+
value?: string | number | (string | number)[];
|
|
72
|
+
callback?: (v: any) => any;
|
|
73
|
+
}
|
|
74
|
+
interface ISummaryConfig {
|
|
75
|
+
type: "subtotal" | "total";
|
|
76
|
+
fields: (string | IFields)[];
|
|
77
|
+
title?: string;
|
|
31
78
|
}
|
|
32
79
|
interface TableComponent<T> extends React.FC<ITableProps<T>> {
|
|
33
80
|
SELECTION_COLUMN: typeof Table.SELECTION_COLUMN;
|
|
@@ -40,4 +87,4 @@ interface TableComponent<T> extends React.FC<ITableProps<T>> {
|
|
|
40
87
|
Summary: typeof Table.Summary;
|
|
41
88
|
}
|
|
42
89
|
|
|
43
|
-
export { IColumnGroupType, IColumnType, IColumnsType, IColumnsTypeProp, IEditableConfig, ITableProps, TableComponent };
|
|
90
|
+
export { IColumnGroupType, IColumnType, IColumnsType, IColumnsTypeProp, IEditableConfig, IFields, ISummaryConfig, ITableProps, TableComponent };
|