zmdms-webui 0.0.44 → 0.0.45
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/es/button/button.js +3 -1
- package/dist/es/button/buttonDownload.d.ts +5 -3
- package/dist/es/button/buttonDownload.js +22 -4
- package/dist/es/button/buttonExport.js +1 -1
- package/dist/es/button/buttonPreview.d.ts +26 -0
- package/dist/es/button/buttonPreview.js +34 -0
- package/dist/es/button/interface.d.ts +3 -0
- package/dist/es/config/ZtxkContext.d.ts +3 -1
- package/dist/es/config/ZtxkContext.js +2 -0
- package/dist/es/config/constant.js +4 -0
- package/dist/es/config/index.js +1 -0
- package/dist/es/config/useBaseContext.js +13 -0
- package/dist/es/form/detaultDom.js +2 -2
- package/dist/es/form/form.js +2 -1
- package/dist/es/form/interface.d.ts +2 -0
- package/dist/es/formitem/formItem.d.ts +11 -0
- package/dist/es/formitem/formItem.js +3 -1
- package/dist/es/table/components/SortTitle.js +4 -12
- package/dist/es/table/hooks.js +53 -23
- package/dist/es/table/interface.d.ts +14 -1
- package/dist/es/table/table.js +9 -3
- package/dist/es/table/useColumns.js +5 -1
- package/dist/es/uploadlist/uploadTable.js +26 -21
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/package.json +1 -1
package/dist/es/button/button.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Button as Button$1 } from 'antd';
|
|
|
4
4
|
import classNames from '../node_modules/classnames/index.js';
|
|
5
5
|
import ButtonDownload from './buttonDownload.js';
|
|
6
6
|
import ButtonExport from './buttonExport.js';
|
|
7
|
+
import ButtonPreview from './buttonPreview.js';
|
|
7
8
|
|
|
8
9
|
var Button = function (props) {
|
|
9
10
|
var _a;
|
|
@@ -52,6 +53,7 @@ var ButtonCom = Button;
|
|
|
52
53
|
ButtonCom.displayName = "ZTXK_WEBUI_Button";
|
|
53
54
|
ButtonCom.Group = Button$1.Group;
|
|
54
55
|
ButtonCom.Download = ButtonDownload;
|
|
55
|
-
ButtonCom.Export = ButtonExport;
|
|
56
|
+
ButtonCom.Export = ButtonExport;
|
|
57
|
+
ButtonCom.Preview = ButtonPreview;
|
|
56
58
|
|
|
57
59
|
export { ButtonCom as default };
|
|
@@ -3,13 +3,15 @@ import { IButtonProps } from './interface.js';
|
|
|
3
3
|
|
|
4
4
|
interface IButtonDownloadProps extends Omit<IButtonProps, "onClick"> {
|
|
5
5
|
/** 附件id */
|
|
6
|
-
|
|
6
|
+
attachId: string;
|
|
7
7
|
/** 附件名 */
|
|
8
|
-
|
|
8
|
+
attachName: string;
|
|
9
|
+
/** 附件大小 */
|
|
10
|
+
attachSize?: number;
|
|
9
11
|
/** 是否通过公共链接下载 */
|
|
10
12
|
isPublic?: boolean;
|
|
11
13
|
/** 服务器地址 */
|
|
12
|
-
API_BASEURL
|
|
14
|
+
API_BASEURL?: string;
|
|
13
15
|
/** 代理点击事件 如果下载结束后 还需做别的处理 */
|
|
14
16
|
onClick?: (e: any, info: any) => void;
|
|
15
17
|
}
|
|
@@ -3,16 +3,20 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import ButtonCom from './button.js';
|
|
5
5
|
import { downloadFile } from 'zmdms-utils';
|
|
6
|
+
import '../config/ZtxkContext.js';
|
|
7
|
+
import useBaseContext from '../config/useBaseContext.js';
|
|
8
|
+
import { message } from 'antd';
|
|
6
9
|
|
|
7
10
|
var ButtonDownload = function (props) {
|
|
8
|
-
var
|
|
11
|
+
var attachId = props.attachId, attachName = props.attachName, isPublic = props.isPublic, API_BASEURL = props.API_BASEURL, onClick = props.onClick, resetProps = __rest(props, ["attachId", "attachName", "isPublic", "API_BASEURL", "onClick"]);
|
|
9
12
|
var _a = useState(false), loading = _a[0], setLoading = _a[1];
|
|
13
|
+
var apiBaseUrl = useBaseContext().apiBaseUrl;
|
|
10
14
|
var onClickHandle = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11
15
|
return __generator(this, function (_a) {
|
|
12
|
-
if (
|
|
16
|
+
if (attachId) {
|
|
13
17
|
setLoading(true);
|
|
14
|
-
return [2 /*return*/, downloadFile(
|
|
15
|
-
API_BASEURL: API_BASEURL,
|
|
18
|
+
return [2 /*return*/, downloadFile(attachId, attachName || "", {
|
|
19
|
+
API_BASEURL: API_BASEURL || apiBaseUrl,
|
|
16
20
|
open: isPublic,
|
|
17
21
|
})
|
|
18
22
|
.then(function (res) {
|
|
@@ -21,6 +25,20 @@ var ButtonDownload = function (props) {
|
|
|
21
25
|
})
|
|
22
26
|
.catch(function (err) {
|
|
23
27
|
onClick && onClick(e, { result: false });
|
|
28
|
+
try {
|
|
29
|
+
err
|
|
30
|
+
.text()
|
|
31
|
+
.then(function (e) {
|
|
32
|
+
var result = JSON.parse("{");
|
|
33
|
+
message.error(result.msg || "下载失败!");
|
|
34
|
+
})
|
|
35
|
+
.catch(function (err2) {
|
|
36
|
+
message.error("下载失败!");
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err1) {
|
|
40
|
+
message.error("下载失败!");
|
|
41
|
+
}
|
|
24
42
|
setLoading(false);
|
|
25
43
|
})];
|
|
26
44
|
}
|
|
@@ -41,7 +41,7 @@ var ButtonExport = function (props) {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
}); };
|
|
44
|
-
return (jsx(ButtonCom, __assign({ type: "
|
|
44
|
+
return (jsx(ButtonCom, __assign({ type: "default", loading: loading, onClick: onClickHandle }, resetProps)));
|
|
45
45
|
};
|
|
46
46
|
ButtonExport.displayName = "ZTXK_WEBUI_ButtonExport";
|
|
47
47
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { IButtonProps } from './interface.js';
|
|
3
|
+
|
|
4
|
+
interface IButtonPreviewProps extends Omit<IButtonProps, "onClick"> {
|
|
5
|
+
/** 附件id */
|
|
6
|
+
attachId: string;
|
|
7
|
+
/** 附件名 */
|
|
8
|
+
attachName: string;
|
|
9
|
+
/** 附件大小 */
|
|
10
|
+
attachSize?: number;
|
|
11
|
+
/** 附件列表 */
|
|
12
|
+
attachList?: {
|
|
13
|
+
attachId: string;
|
|
14
|
+
attachName: string;
|
|
15
|
+
[props: string]: string;
|
|
16
|
+
}[];
|
|
17
|
+
/** 是否通过公共链接下载 */
|
|
18
|
+
isPublic?: boolean;
|
|
19
|
+
/** 文件服务器地址 */
|
|
20
|
+
FILE_BASEURL?: string;
|
|
21
|
+
/** 代理点击事件 如果下载结束后 还需做别的处理 */
|
|
22
|
+
onClick?: (e: any, info: any) => void;
|
|
23
|
+
}
|
|
24
|
+
declare const ButtonPreview: React__default.FC<IButtonPreviewProps>;
|
|
25
|
+
|
|
26
|
+
export { IButtonPreviewProps, ButtonPreview as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import ButtonCom from './button.js';
|
|
4
|
+
import { formatUnit, previewFile } from 'zmdms-utils';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '../config/ZtxkContext.js';
|
|
7
|
+
import useBaseContext from '../config/useBaseContext.js';
|
|
8
|
+
import { MAX_PREVIEW_SIZE } from '../config/constant.js';
|
|
9
|
+
import { message } from 'antd';
|
|
10
|
+
|
|
11
|
+
var ButtonPreview = function (props) {
|
|
12
|
+
var attachId = props.attachId, attachName = props.attachName, attachSize = props.attachSize, attachList = props.attachList; props.isPublic; var FILE_BASEURL = props.FILE_BASEURL; props.onClick; var resetProps = __rest(props, ["attachId", "attachName", "attachSize", "attachList", "isPublic", "FILE_BASEURL", "onClick"]);
|
|
13
|
+
var fileBaseUrl = useBaseContext().fileBaseUrl;
|
|
14
|
+
var onClickHandle = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
15
|
+
return __generator(this, function (_a) {
|
|
16
|
+
if (attachId) {
|
|
17
|
+
if (attachSize && attachSize > MAX_PREVIEW_SIZE) {
|
|
18
|
+
message.info("\u6587\u4EF6\u5927\u4E8E".concat(formatUnit(MAX_PREVIEW_SIZE), ",\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\uFF0C\u8BF7\u5148\u4E0B\u8F7D\u540E\u67E5\u770B"));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
previewFile(attachId, attachName, {
|
|
22
|
+
API_BASEURL: FILE_BASEURL || fileBaseUrl,
|
|
23
|
+
fileList: attachList,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return [2 /*return*/];
|
|
28
|
+
});
|
|
29
|
+
}); };
|
|
30
|
+
return jsx(ButtonCom, __assign({ type: "link", onClick: onClickHandle }, resetProps));
|
|
31
|
+
};
|
|
32
|
+
ButtonPreview.displayName = "ZTXK_WEBUI_ButtonPreview";
|
|
33
|
+
|
|
34
|
+
export { ButtonPreview as default };
|
|
@@ -2,6 +2,7 @@ import { Button } from 'antd';
|
|
|
2
2
|
import { ButtonProps } from 'antd/es/button';
|
|
3
3
|
import ButtonDownload from './buttonDownload.js';
|
|
4
4
|
import ButtonExport from './buttonExport.js';
|
|
5
|
+
import ButtonPreview from './buttonPreview.js';
|
|
5
6
|
|
|
6
7
|
interface IButtonProps extends ButtonProps {
|
|
7
8
|
}
|
|
@@ -12,6 +13,8 @@ interface ButtonComponent extends React.FC<IButtonProps> {
|
|
|
12
13
|
Download: typeof ButtonDownload;
|
|
13
14
|
/** 导出按钮 */
|
|
14
15
|
Export: typeof ButtonExport;
|
|
16
|
+
/** 预览按钮 */
|
|
17
|
+
Preview: typeof ButtonPreview;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
export { ButtonComponent, IButtonProps };
|
|
@@ -5,7 +5,9 @@ import React__default from 'react';
|
|
|
5
5
|
*/
|
|
6
6
|
interface IZtxkConfig {
|
|
7
7
|
locale: "zh-cn" | "en";
|
|
8
|
+
apiBaseUrl: string;
|
|
9
|
+
fileBaseUrl: string;
|
|
8
10
|
}
|
|
9
11
|
declare const ZtxkContext: React__default.Context<IZtxkConfig>;
|
|
10
12
|
|
|
11
|
-
export { ZtxkContext as default };
|
|
13
|
+
export { IZtxkConfig, ZtxkContext as default };
|
package/dist/es/config/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import ZtxkContext from './ZtxkContext.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 获取语言配置 目前支持中文、英文
|
|
6
|
+
* @returns 返回当前语言配置
|
|
7
|
+
*/
|
|
8
|
+
function useBaseContext() {
|
|
9
|
+
var ztxkConfig = useContext(ZtxkContext);
|
|
10
|
+
return ztxkConfig;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { useBaseContext as default };
|
|
@@ -3,8 +3,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
|
|
5
5
|
var DefaultDom = function (_a) {
|
|
6
|
-
var children = _a.children, value = _a.value;
|
|
7
|
-
return (jsx("div", __assign({ className: "ztxk-form--detault-dom" }, { children: children ? children : value ? value : "— —" })));
|
|
6
|
+
var children = _a.children, value = _a.value, style = _a.style;
|
|
7
|
+
return (jsx("div", __assign({ className: "ztxk-form--detault-dom", style: style }, { children: children ? children : value ? value : "— —" })));
|
|
8
8
|
};
|
|
9
9
|
var DefaultDom$1 = memo(DefaultDom);
|
|
10
10
|
|
package/dist/es/form/form.js
CHANGED
|
@@ -18,7 +18,7 @@ var FORM_DYNAMIC_KEY = "ztxk-webui-dynamic-form";
|
|
|
18
18
|
// 用户配置优先,先从远端获取到 表单配置信息。
|
|
19
19
|
// 给子元素设置好了表单配置信息后 接下来的内容 交给动态列配置接管
|
|
20
20
|
var Form = function (props) {
|
|
21
|
-
var form = props.form, bottomBorder = props.bottomBorder, _a = props.isFlex, isFlex = _a === void 0 ? true : _a, wrapClassName = props.wrapClassName, leftClassName = props.leftClassName; props.itemClassName; var rightWrapVisible = props.rightWrapVisible, rightClassName = props.rightClassName, children = props.children, dynamicKey = props.dynamicKey, formPreferences = props.formPreferences, items = props.items, outsideState = props.outsideState, onValuesChange = props.onValuesChange, onResetHandle = props.onResetHandle, onSearchHandle = props.onSearchHandle, type = props.type, restProps = __rest(props, ["form", "bottomBorder", "isFlex", "wrapClassName", "leftClassName", "itemClassName", "rightWrapVisible", "rightClassName", "children", "dynamicKey", "formPreferences", "items", "outsideState", "onValuesChange", "onResetHandle", "onSearchHandle", "type"]);
|
|
21
|
+
var form = props.form, bottomBorder = props.bottomBorder, _a = props.isFlex, isFlex = _a === void 0 ? true : _a, wrapClassName = props.wrapClassName, leftClassName = props.leftClassName; props.itemClassName; var rightWrapVisible = props.rightWrapVisible, rightClassName = props.rightClassName, children = props.children, dynamicKey = props.dynamicKey, formPreferences = props.formPreferences, items = props.items, outsideState = props.outsideState, onValuesChange = props.onValuesChange, onResetHandle = props.onResetHandle, onSearchHandle = props.onSearchHandle, type = props.type, directionColumn = props.directionColumn, restProps = __rest(props, ["form", "bottomBorder", "isFlex", "wrapClassName", "leftClassName", "itemClassName", "rightWrapVisible", "rightClassName", "children", "dynamicKey", "formPreferences", "items", "outsideState", "onValuesChange", "onResetHandle", "onSearchHandle", "type", "directionColumn"]);
|
|
22
22
|
// 获取新的items
|
|
23
23
|
var configInfoItems = useFormPreferencesCreateNewItems(formPreferences, items).configInfoItems;
|
|
24
24
|
// 根据items 和 dynamicKey 获取到动态列配置信息
|
|
@@ -31,6 +31,7 @@ var Form = function (props) {
|
|
|
31
31
|
// 左容器类名
|
|
32
32
|
var leftClasses = classNames("ztxk-form__left", leftClassName, {
|
|
33
33
|
"ztxk-form__left--flex": isFlex,
|
|
34
|
+
"ztxk-form__left--flex-direction": directionColumn,
|
|
34
35
|
});
|
|
35
36
|
// 右容器类名
|
|
36
37
|
var rightClasses = classNames("ztxk-form__right", rightClassName);
|
|
@@ -76,10 +76,21 @@ interface IFormItem extends FormItemProps {
|
|
|
76
76
|
*/
|
|
77
77
|
shouldUpdateBeOutsideState?: (prevOutsideState: any, nextOutsideState: any) => boolean;
|
|
78
78
|
/**
|
|
79
|
+
* @deprecated 此属性已经废弃,可以删除掉这个属性
|
|
79
80
|
* item 类型
|
|
80
81
|
* 当需要一些表单除外的样式时 使用
|
|
81
82
|
*/
|
|
82
83
|
nonForm?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* 是否自定义表单项
|
|
86
|
+
*/
|
|
87
|
+
isCustomItem?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* 自定义表单项样式
|
|
90
|
+
* default 默认样式
|
|
91
|
+
* fill 表示输入框还是同样的高度,只是去除上下边框
|
|
92
|
+
*/
|
|
93
|
+
customStyle?: "default" | "fill";
|
|
83
94
|
}
|
|
84
95
|
declare const _default: React__default.NamedExoticComponent<IFormItem & {
|
|
85
96
|
outsideState: any;
|
|
@@ -9,7 +9,7 @@ import { Col } from 'antd';
|
|
|
9
9
|
|
|
10
10
|
var FormItem = function (props) {
|
|
11
11
|
var _a;
|
|
12
|
-
var children = props.children, isDisplay = props.isDisplay, isRequired = props.isRequired, isChangeable = props.isChangeable, isStress = props.isStress, preNode = props.preNode, nextNode = props.nextNode; props.dynamicDisabled; var hiddenBorder = props.hiddenBorder, singleSelectShowBorder = props.singleSelectShowBorder, hiddenLabel = props.hiddenLabel, width = props.width, className = props.className, itemClassName = props.itemClassName, render = props.render, shouldUpdateNames = props.shouldUpdateNames; props.shouldUpdateClear; var dependencies = props.dependencies, shouldUpdate = props.shouldUpdate; props.index; props.outsideState; props.shouldUpdateBeOutsideState; props.nonForm; var resetProps = __rest(props, ["children", "isDisplay", "isRequired", "isChangeable", "isStress", "preNode", "nextNode", "dynamicDisabled", "hiddenBorder", "singleSelectShowBorder", "hiddenLabel", "width", "className", "itemClassName", "render", "shouldUpdateNames", "shouldUpdateClear", "dependencies", "shouldUpdate", "index", "outsideState", "shouldUpdateBeOutsideState", "nonForm"]);
|
|
12
|
+
var children = props.children, isDisplay = props.isDisplay, isRequired = props.isRequired, isChangeable = props.isChangeable, isStress = props.isStress, preNode = props.preNode, nextNode = props.nextNode; props.dynamicDisabled; var hiddenBorder = props.hiddenBorder, singleSelectShowBorder = props.singleSelectShowBorder, hiddenLabel = props.hiddenLabel, width = props.width, className = props.className, itemClassName = props.itemClassName, render = props.render, shouldUpdateNames = props.shouldUpdateNames; props.shouldUpdateClear; var dependencies = props.dependencies, shouldUpdate = props.shouldUpdate; props.index; props.outsideState; props.shouldUpdateBeOutsideState; props.nonForm; var isCustomItem = props.isCustomItem, customStyle = props.customStyle, resetProps = __rest(props, ["children", "isDisplay", "isRequired", "isChangeable", "isStress", "preNode", "nextNode", "dynamicDisabled", "hiddenBorder", "singleSelectShowBorder", "hiddenLabel", "width", "className", "itemClassName", "render", "shouldUpdateNames", "shouldUpdateClear", "dependencies", "shouldUpdate", "index", "outsideState", "shouldUpdateBeOutsideState", "nonForm", "isCustomItem", "customStyle"]);
|
|
13
13
|
var form = MemoForm.useFormInstance();
|
|
14
14
|
// 根据配置属性,判断是否渲染表单项
|
|
15
15
|
// 是否显示表单项
|
|
@@ -56,6 +56,8 @@ var FormItem = function (props) {
|
|
|
56
56
|
"ztxk-form__item--hidden-label": hiddenLabel,
|
|
57
57
|
"ztxk-form__item--single-show-border": singleSelectShowBorder,
|
|
58
58
|
"ztxk-form__item--stress": isStress,
|
|
59
|
+
"ztxk-form__item--custom": isCustomItem,
|
|
60
|
+
"ztxk-form__item--custom-fill": customStyle === "fill",
|
|
59
61
|
});
|
|
60
62
|
if (dependencies) {
|
|
61
63
|
return (jsxs(ItemWrap, __assign({ width: width, className: className }, { children: [preNode ? preNode : null, jsx(MemoForm.Item, __assign({ dependencies: dependencies, noStyle: true }, { children: function (formInstance) {
|
|
@@ -18,25 +18,17 @@ var SortTitle = function (_a) {
|
|
|
18
18
|
var currentOrd;
|
|
19
19
|
if (order === ASCEND) {
|
|
20
20
|
currentOrd = DESCEND;
|
|
21
|
-
setCustomOrder({
|
|
22
|
-
field: field,
|
|
23
|
-
order: currentOrd,
|
|
24
|
-
});
|
|
25
21
|
}
|
|
26
22
|
else if (order === DESCEND) {
|
|
27
23
|
currentOrd = null;
|
|
28
|
-
setCustomOrder({
|
|
29
|
-
field: field,
|
|
30
|
-
order: currentOrd,
|
|
31
|
-
});
|
|
32
24
|
}
|
|
33
25
|
else {
|
|
34
26
|
currentOrd = ASCEND;
|
|
35
|
-
setCustomOrder({
|
|
36
|
-
field: field,
|
|
37
|
-
order: currentOrd,
|
|
38
|
-
});
|
|
39
27
|
}
|
|
28
|
+
setCustomOrder({
|
|
29
|
+
field: field,
|
|
30
|
+
order: currentOrd,
|
|
31
|
+
});
|
|
40
32
|
onChange && onChange({ field: field, order: currentOrd });
|
|
41
33
|
};
|
|
42
34
|
var currentTitle = useMemo(function () {
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -170,16 +170,25 @@ function useScuRfresh() {
|
|
|
170
170
|
getRefreshScuCell: getRefreshScuCell,
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
/**
|
|
174
|
+
* 自定义排序方法
|
|
175
|
+
* 排序会触发onTableChange事件,即排序会改变数据源
|
|
176
|
+
* 如果排序改变了数据源,那么数据没法恢复到初始状态
|
|
177
|
+
*/
|
|
174
178
|
function useCustomSort(dataSource, onTableChange, options) {
|
|
175
|
-
var refreshScuCell = options.refreshScuCell;
|
|
179
|
+
var refreshScuCell = options.refreshScuCell, rowKey = options.rowKey, serviceOrder = options.serviceOrder;
|
|
176
180
|
// 排序的数据
|
|
177
|
-
var _a = useState(
|
|
178
|
-
var
|
|
179
|
-
|
|
181
|
+
var _a = useState(undefined), order = _a[0], setOrder = _a[1];
|
|
182
|
+
var isSelfChange = useRef(false);
|
|
183
|
+
// 记录初始数据的顺序(根据rowKey记录)
|
|
184
|
+
var innerOrderDataSource = useRef();
|
|
180
185
|
var customSortHandle = useCallback(function (info) {
|
|
181
186
|
if (Array.isArray(dataSource) && dataSource.length > 1) {
|
|
182
187
|
var field_1 = info.field, order_1 = info.order;
|
|
188
|
+
if (serviceOrder) {
|
|
189
|
+
serviceOrder(info);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
183
192
|
var handle_1 = function (a, b) {
|
|
184
193
|
var result = a[field_1] - b[field_1];
|
|
185
194
|
if (!isNaN(result)) {
|
|
@@ -193,45 +202,66 @@ function useCustomSort(dataSource, onTableChange, options) {
|
|
|
193
202
|
}
|
|
194
203
|
return 0;
|
|
195
204
|
};
|
|
205
|
+
var newDataSource_1 = [];
|
|
196
206
|
if (order_1 === "ascend") {
|
|
197
|
-
|
|
207
|
+
newDataSource_1 = dataSource.slice().sort(function (a, b) {
|
|
198
208
|
return handle_1(a, b);
|
|
199
209
|
});
|
|
200
|
-
setSortDataSource(newDataSource);
|
|
201
|
-
isSelfChange.current = true;
|
|
202
|
-
refreshScuCell && refreshScuCell();
|
|
203
|
-
onTableChange &&
|
|
204
|
-
onTableChange(newDataSource, dataSource, { type: "sort" });
|
|
205
210
|
}
|
|
206
211
|
else if (order_1 === "descend") {
|
|
207
|
-
|
|
212
|
+
newDataSource_1 = dataSource.slice().sort(function (a, b) {
|
|
208
213
|
return -handle_1(a, b);
|
|
209
214
|
});
|
|
210
|
-
setSortDataSource(newDataSource);
|
|
211
|
-
isSelfChange.current = true;
|
|
212
|
-
refreshScuCell && refreshScuCell();
|
|
213
|
-
onTableChange &&
|
|
214
|
-
onTableChange(newDataSource, dataSource, { type: "sort" });
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
|
-
|
|
217
|
+
// 通过之前排序好的数组Key,返回一个新的数据
|
|
218
|
+
// 之所以这么做 是因为有可能排序后,数据做了修改、增减。
|
|
219
|
+
// 所以不能单纯的记录排序之前的数据为准
|
|
220
|
+
if (Array.isArray(innerOrderDataSource.current) &&
|
|
221
|
+
typeof rowKey === "string") {
|
|
222
|
+
innerOrderDataSource.current.forEach(function (key) {
|
|
223
|
+
var item = dataSource.find(function (d) { return d[rowKey] === key; });
|
|
224
|
+
if (item) {
|
|
225
|
+
newDataSource_1.push(item);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
newDataSource_1 = dataSource;
|
|
231
|
+
}
|
|
218
232
|
}
|
|
233
|
+
// 表示当前修改数据的行为 由组件内部触发 不需要清空order
|
|
234
|
+
isSelfChange.current = true;
|
|
235
|
+
// 针对配置了scu的列做处理
|
|
236
|
+
refreshScuCell && refreshScuCell();
|
|
237
|
+
// 真实的更新数据
|
|
238
|
+
onTableChange &&
|
|
239
|
+
onTableChange(newDataSource_1, dataSource, {
|
|
240
|
+
type: "sort",
|
|
241
|
+
order: order_1,
|
|
242
|
+
field: field_1,
|
|
243
|
+
});
|
|
219
244
|
}
|
|
220
|
-
}, [dataSource, onTableChange, refreshScuCell]);
|
|
245
|
+
}, [dataSource, onTableChange, refreshScuCell, rowKey, serviceOrder]);
|
|
221
246
|
/**
|
|
222
247
|
* 表格数据更新的时候 重置下当前排序的数据 以及 排序的方式
|
|
223
248
|
* 但是如果是因为点击排序触发的表格数据更新 那么不做处理
|
|
224
249
|
*/
|
|
225
250
|
useEffect(function () {
|
|
251
|
+
if (serviceOrder) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
226
254
|
if (!isSelfChange.current) {
|
|
227
|
-
|
|
255
|
+
if (typeof rowKey === "string") {
|
|
256
|
+
innerOrderDataSource.current = dataSource.map(function (item) {
|
|
257
|
+
return item[rowKey];
|
|
258
|
+
});
|
|
259
|
+
}
|
|
228
260
|
setOrder(undefined);
|
|
229
261
|
}
|
|
230
262
|
isSelfChange.current = false;
|
|
231
|
-
}, [dataSource]);
|
|
263
|
+
}, [dataSource, rowKey, serviceOrder]);
|
|
232
264
|
return {
|
|
233
|
-
sortDataSource: sortDataSource,
|
|
234
|
-
setSortDataSource: setSortDataSource,
|
|
235
265
|
order: order,
|
|
236
266
|
setOrder: setOrder,
|
|
237
267
|
customSortHandle: customSortHandle,
|
|
@@ -129,6 +129,7 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
129
129
|
dragIndex?: number;
|
|
130
130
|
hoverIndex?: number;
|
|
131
131
|
type?: "edit" | "move" | "add" | "del" | "delAll" | "fillDown" | "sort";
|
|
132
|
+
[prop: string]: any;
|
|
132
133
|
}) => void;
|
|
133
134
|
/**
|
|
134
135
|
* 是否开启表格编辑功能
|
|
@@ -181,6 +182,11 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
181
182
|
* 表格的名字 一个页面存在多个表格时 发起表格验证时,可以提示哪个表格出现问题
|
|
182
183
|
*/
|
|
183
184
|
tableName?: string;
|
|
185
|
+
/**
|
|
186
|
+
* 服务端排序返回事件
|
|
187
|
+
* 如果开启服务端排序,那么前端这边不做排序处理,只返回设置的字段
|
|
188
|
+
*/
|
|
189
|
+
serviceOrder?: (order: IOrder) => void;
|
|
184
190
|
}
|
|
185
191
|
interface IFields {
|
|
186
192
|
/**
|
|
@@ -226,6 +232,13 @@ interface TableComponent<T> extends React.FC<ITableProps<T>> {
|
|
|
226
232
|
Column: typeof Table.Column;
|
|
227
233
|
ColumnGroup: typeof Table.ColumnGroup;
|
|
228
234
|
Summary: typeof Table.Summary;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 排序相关类型
|
|
238
|
+
*/
|
|
239
|
+
interface IOrder {
|
|
240
|
+
field: string;
|
|
241
|
+
order: "ascend" | "descend" | undefined;
|
|
229
242
|
}
|
|
230
243
|
|
|
231
|
-
export { IColumnGroupType, IColumnType, IColumnsType, IColumnsTypeProp, IEditableConfig, IFields, ISummaryConfig, ITableProps, TableComponent };
|
|
244
|
+
export { IColumnGroupType, IColumnType, IColumnsType, IColumnsTypeProp, IEditableConfig, IFields, IOrder, ISummaryConfig, ITableProps, TableComponent };
|
package/dist/es/table/table.js
CHANGED
|
@@ -29,7 +29,7 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
|
|
|
29
29
|
// TODO: 实现表头自定义伸缩
|
|
30
30
|
var Table = function (props) {
|
|
31
31
|
// console.log("表格渲染");
|
|
32
|
-
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, _c = props.isDelAll, isDelAll = _c === void 0 ? true : _c, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _d = props.summaryFixed, summaryFixed = _d === void 0 ? true : _d, isInnerPagination = props.isInnerPagination, _e = props.innerPaginationPageSize, innerPaginationPageSize = _e === void 0 ? 30 : _e, _f = props.innerPaginationPosition, innerPaginationPosition = _f === void 0 ? INNER_TABLE_PAGINATION_POSITION : _f, _g = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _g === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _g, tableRefHandle = props.tableRefHandle, tableName = props.tableName, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "addMode", "addCallback", "isDel", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "tableRefHandle", "tableName"]);
|
|
32
|
+
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, _c = props.isDelAll, isDelAll = _c === void 0 ? true : _c, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _d = props.summaryFixed, summaryFixed = _d === void 0 ? true : _d, isInnerPagination = props.isInnerPagination, _e = props.innerPaginationPageSize, innerPaginationPageSize = _e === void 0 ? 30 : _e, _f = props.innerPaginationPosition, innerPaginationPosition = _f === void 0 ? INNER_TABLE_PAGINATION_POSITION : _f, _g = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _g === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _g, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "addMode", "addCallback", "isDel", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "tableRefHandle", "tableName", "serviceOrder"]);
|
|
33
33
|
var classes = classNames("ztxk-table", className, {
|
|
34
34
|
"ztxk-table--flex": isFlex,
|
|
35
35
|
});
|
|
@@ -68,7 +68,9 @@ var Table = function (props) {
|
|
|
68
68
|
var _l = useCustomSort(dataSource, onTableChange, {
|
|
69
69
|
refreshScuCell: refreshScuCell,
|
|
70
70
|
currentPage: currentPage,
|
|
71
|
-
|
|
71
|
+
rowKey: props === null || props === void 0 ? void 0 : props.rowKey,
|
|
72
|
+
serviceOrder: serviceOrder,
|
|
73
|
+
}), order = _l.order, setOrder = _l.setOrder, customSortHandle = _l.customSortHandle;
|
|
72
74
|
// 处理列配置信息 得到新的列配置信息
|
|
73
75
|
var newColumns = useColumns(columns, {
|
|
74
76
|
dynamicKey: dynamicKey,
|
|
@@ -126,12 +128,15 @@ var Table = function (props) {
|
|
|
126
128
|
// 暴露给外部一些方法
|
|
127
129
|
useImperativeHandle(tableRefHandle, function () {
|
|
128
130
|
return {
|
|
131
|
+
/** 获取真实的索引,内部分页时使用 */
|
|
129
132
|
getRealyIndex: function (index) {
|
|
130
133
|
return getInnerIndex(currentPage, index);
|
|
131
134
|
},
|
|
135
|
+
/** 获取当前表格的配置信息 */
|
|
132
136
|
getDynamicList: function () {
|
|
133
137
|
return currentDynamicList;
|
|
134
138
|
},
|
|
139
|
+
/** 表格的验证方法 */
|
|
135
140
|
tableValidate: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
136
141
|
return __generator(this, function (_a) {
|
|
137
142
|
switch (_a.label) {
|
|
@@ -150,11 +155,12 @@ var Table = function (props) {
|
|
|
150
155
|
}
|
|
151
156
|
});
|
|
152
157
|
}); },
|
|
158
|
+
/** 清除错误样式 */
|
|
153
159
|
clearErrorClass: clearErrorClass,
|
|
154
160
|
};
|
|
155
161
|
});
|
|
156
162
|
// 表格
|
|
157
|
-
var SingleTable = (jsx(Table$1, __assign({ className: classes, bordered: bordered, dataSource:
|
|
163
|
+
var SingleTable = (jsx(Table$1, __assign({ className: classes, bordered: bordered, dataSource: dataSource, columns: newColumns, components: componentsMemo, onRow: onRow, summary: getSummaryHandle, pagination: isInnerPagination
|
|
158
164
|
? pagination
|
|
159
165
|
? pagination
|
|
160
166
|
: paginationConfig
|
|
@@ -18,6 +18,7 @@ function useColumns(columns, options) {
|
|
|
18
18
|
var myNewColumns = [];
|
|
19
19
|
if (Array.isArray(newColumns)) {
|
|
20
20
|
newColumns.forEach(function (column) {
|
|
21
|
+
var _a;
|
|
21
22
|
var _column = __assign(__assign({}, column), { __title: column.title });
|
|
22
23
|
var isCopy = _column.isCopy, editable = _column.editable, editableConfig = _column.editableConfig, title = _column.title, key = _column.key, validate = _column.validate, isRequire = _column.isRequire, isFillDown = _column.isFillDown, isOrder = _column.isOrder;
|
|
23
24
|
var _key = key ? key : _column === null || _column === void 0 ? void 0 : _column.dataIndex;
|
|
@@ -32,11 +33,14 @@ function useColumns(columns, options) {
|
|
|
32
33
|
display: "flex",
|
|
33
34
|
alignItems: "center",
|
|
34
35
|
justifyContent: "space-between",
|
|
36
|
+
flex: "1",
|
|
35
37
|
} }, { children: jsxs(Fragment, { children: [_column.title, jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange })] }) })));
|
|
36
38
|
}
|
|
37
39
|
// 列头增加必填标识
|
|
38
40
|
if (isRequire) {
|
|
39
|
-
_column.title = (jsxs(
|
|
41
|
+
_column.title = (jsxs("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: [jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" })), typeof _column.title === "function"
|
|
42
|
+
? (_a = _column.title) === null || _a === void 0 ? void 0 : _a.call(_column, {})
|
|
43
|
+
: _column.title] })));
|
|
40
44
|
}
|
|
41
45
|
// 如果列添加可编辑配置
|
|
42
46
|
if (editable && isEdit) {
|