@cloudbase/weda-ui 3.4.4 → 3.4.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/dist/configs/components/chart/bar.json +113 -8
- package/dist/configs/components/chart/line.js +113 -8
- package/dist/configs/components/chart/pie.json +113 -8
- package/dist/configs/components/chart/statisticsCard.json +57 -0
- package/dist/configs/components/dataView.js +7 -7
- package/dist/configs/components/form/input.json +48 -2
- package/dist/configs/components/form/richText.json +2 -1
- package/dist/configs/components/form/uploader.json +62 -14
- package/dist/configs/components/graphicCard.json +1 -1
- package/dist/configs/components/grid/col.js +4 -1
- package/dist/configs/components/grid/grid.js +8 -3
- package/dist/configs/components/grid/row.js +51 -3
- package/dist/configs/components/listView.js +113 -9
- package/dist/configs/components/navLayout.json +1 -1
- package/dist/configs/components/repeater.js +4 -1
- package/dist/configs/components/table.json +125 -9
- package/dist/configs/components/wd-bubble.js +6 -0
- package/dist/configs/components/wd-button.js +6 -0
- package/dist/configs/components/wd-divider.js +7 -18
- package/dist/configs/components/wd-icon.js +7 -0
- package/dist/configs/components/wd-image.js +7 -0
- package/dist/configs/components/wd-link.js +7 -2
- package/dist/configs/components/wd-text.js +14 -6
- package/dist/configs/index.js +0 -2
- package/dist/docs/common/componentList.js +1 -1
- package/dist/style/index.scss +1 -1
- package/dist/web/actions/showModal/index.js +1 -1
- package/dist/web/components/calendar/index.js +2 -2
- package/dist/web/components/chart/common/data-transform.js +1 -1
- package/dist/web/components/chart/statisticsCard/index.js +1 -1
- package/dist/web/components/flow/components/index.js +0 -4
- package/dist/web/components/flow/frame/index.js +4 -3
- package/dist/web/components/flow/frame/types.js +11 -5
- package/dist/web/components/flow/frame/utils.js +60 -1
- package/dist/web/components/flow/modules/chart/Chart.js +2 -3
- package/dist/web/components/flow/modules/chart/index.css +0 -3
- package/dist/web/components/flow/modules/combination/index.js +1 -1
- package/dist/web/components/flow/modules/operations/components/button/index.js +11 -0
- package/dist/web/components/flow/modules/operations/components/button/style.css +5 -0
- package/dist/web/components/flow/modules/operations/components/index.js +6 -0
- package/dist/web/components/flow/modules/operations/components/popup/index.js +100 -0
- package/dist/web/components/flow/modules/operations/components/popup/style.css +154 -0
- package/dist/web/components/flow/modules/operations/components/popup/types.js +1 -0
- package/dist/web/components/flow/modules/operations/components/user-select/index.js +43 -0
- package/dist/web/components/flow/modules/operations/components/user-select/style.css +4 -0
- package/dist/web/components/flow/modules/operations/components/user-select/types.js +1 -0
- package/dist/web/components/flow/modules/operations/config/approval-form-config.js +140 -0
- package/dist/web/components/flow/modules/operations/config/control-config.js +218 -0
- package/dist/web/components/flow/modules/operations/config/index.js +2 -0
- package/dist/web/components/flow/modules/operations/config/types.js +1 -0
- package/dist/web/components/flow/modules/operations/control.js +26 -0
- package/dist/web/components/flow/modules/operations/controls-items/add-assignee-btn.js +33 -0
- package/dist/web/components/flow/modules/operations/controls-items/apply-cc-btn.js +12 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/comment/index.js +188 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/comment/style.css +51 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/drawer-form/index.js +64 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/drawer-form/types.js +1 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/drawer-form/view-model.js +83 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/field/index.js +16 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/field/style.css +56 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/index.js +47 -0
- package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/style.css +60 -0
- package/dist/web/components/flow/modules/operations/controls-items/cancel-apply-btn.js +15 -0
- package/dist/web/components/flow/modules/operations/controls-items/check-list-popup/index.js +11 -0
- package/dist/web/components/flow/modules/operations/controls-items/check-list-popup/style.css +26 -0
- package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +98 -0
- package/dist/web/components/flow/modules/operations/controls-items/index.js +18 -0
- package/dist/web/components/flow/modules/operations/controls-items/initiation-btn.js +25 -0
- package/dist/web/components/flow/modules/operations/controls-items/revoke-modal/index.js +50 -0
- package/dist/web/components/flow/modules/operations/controls-items/revoke-modal/style.css +28 -0
- package/dist/web/components/flow/modules/operations/controls-items/roll-back-modal.js +104 -0
- package/dist/web/components/flow/modules/operations/controls-items/types.js +1 -0
- package/dist/web/components/flow/modules/operations/index.js +2 -0
- package/dist/web/components/flow/modules/operations/style.css +20 -0
- package/dist/web/components/flow/modules/operations/view-model.js +137 -0
- package/dist/web/components/flow/services/ideData/instance.js +2 -2
- package/dist/web/components/flow/services/ideData/pageDetail.js +1 -0
- package/dist/web/components/form/select/dropdown-select/h5.js +1 -1
- package/dist/web/components/form/select/dropdown-select/index.css +7 -0
- package/dist/web/components/form/select/index.js +2 -7
- package/dist/web/components/form/textarea/index.js +1 -1
- package/dist/web/components/form/uploader/index.css +19 -0
- package/dist/web/components/form/uploader/index.js +21 -3
- package/dist/web/components/form/uploader/uploader.h5.js +14 -8
- package/dist/web/components/form/uploader/uploader.pc.js +29 -16
- package/dist/web/components/form/uploaderFile/index.css +9 -5
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +23 -21
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +14 -10
- package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +0 -1
- package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +1 -1
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +43 -22
- package/dist/web/components/form/userOrgSelect/component/user-select-h5/user-select-h5.js +15 -4
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -2
- package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +4 -2
- package/dist/web/components/grid/col.js +81 -18
- package/dist/web/components/grid/grid.js +1 -1
- package/dist/web/components/grid/row.js +4 -2
- package/dist/web/components/index.js +1 -1
- package/dist/web/components/listView/index.js +98 -100
- package/dist/web/components/lottery/index.js +122 -123
- package/dist/web/components/richTextView/index.css +2 -0
- package/dist/web/components/swiper/index.js +14 -8
- package/dist/web/components/table/BaseTable.js +3 -3
- package/dist/web/components/table/ExportFileModalByApi/index.js +1 -1
- package/dist/web/components/table/ImportFileModal/index.js +1 -1
- package/dist/web/components/table/ImportFileModalByApi/index.js +1 -1
- package/dist/web/components/wd-bubble/wd-bubble.js +11 -3
- package/dist/web/components/wd-button/wd-button.js +22 -13
- package/dist/web/components/wd-divider/wd-divider.js +10 -7
- package/dist/web/components/wd-icon/wd-icon.js +12 -3
- package/dist/web/components/wd-image/index.js +12 -5
- package/dist/web/components/wd-link/wd-link.js +11 -3
- package/dist/web/components/wd-text/wd-text.js +15 -3
- package/dist/web/utils/hooks/use-cloud-id-temp-url.js +7 -2
- package/dist/web/utils/platform.js +9 -2
- package/dist/web/utils/tool.js +11 -0
- package/dist/web/utils/widget-api/index.js +3 -0
- package/package.json +7 -5
- package/dist/configs/components/auth.json +0 -17
- package/dist/web/components/flow/components/FlowUserSelect/index.css +0 -116
- package/dist/web/components/flow/components/FlowUserSelect/index.js +0 -115
- package/dist/web/components/flow/components/HighlightTextarea/index.css +0 -42
- package/dist/web/components/flow/components/HighlightTextarea/index.js +0 -131
- package/dist/web/components/flow/components/UserSelectModel/UserSelect.js +0 -74
- package/dist/web/components/flow/components/UserSelectModel/UserSelectMobile.css +0 -8
- package/dist/web/components/flow/components/UserSelectModel/UserSelectMobile.js +0 -86
- package/dist/web/components/flow/components/UserSelectModel/index.js +0 -18
- package/dist/web/components/flow/components/WedaUserTransfer/index.css +0 -3
- package/dist/web/components/flow/components/WedaUserTransfer/index.js +0 -162
- package/dist/web/components/flow/modules/control/ApprovalDrawer.css +0 -144
- package/dist/web/components/flow/modules/control/ApprovalDrawer.js +0 -178
- package/dist/web/components/flow/modules/control/ApprovalPopup.css +0 -115
- package/dist/web/components/flow/modules/control/ApprovalPopup.js +0 -241
- package/dist/web/components/flow/modules/control/Control.css +0 -29
- package/dist/web/components/flow/modules/control/Control.js +0 -93
- package/dist/web/components/flow/modules/control/ControlMobile.css +0 -69
- package/dist/web/components/flow/modules/control/ControlMobile.js +0 -133
- package/dist/web/components/flow/modules/control/FlowTaskInfoModal.css +0 -3
- package/dist/web/components/flow/modules/control/FlowTaskInfoModal.js +0 -31
- package/dist/web/components/flow/modules/control/constants/index.js +0 -35
- package/dist/web/components/flow/modules/control/index.js +0 -15
- package/dist/web/components/flow/modules/control/provider/index.js +0 -17
- package/dist/web/components/flow/modules/control/provider/useControlModel.js +0 -256
- package/dist/web/components/flow/modules/control/provider/useMobileModel.js +0 -86
- package/dist/web/components/flow/modules/control/provider/useRevokeAndBackHook.js +0 -82
- package/dist/web/components/flow/modules/control/utils/ControlModelUtils.js +0 -57
- package/dist/web/components/flow/modules/control/utils/index.js +0 -2
|
@@ -8,7 +8,7 @@ import { SelectedList } from '../selected-list';
|
|
|
8
8
|
import { fetchSearchUser } from '../../common/fetch-data-service';
|
|
9
9
|
import debounce from '../../../../../utils/debounce';
|
|
10
10
|
import '../index.css';
|
|
11
|
-
export const UserModel = ({ open,
|
|
11
|
+
export const UserModel = ({ open, onCancel, onConfirm, treeData, treeDataError, filterParams, }) => {
|
|
12
12
|
var _a;
|
|
13
13
|
const { selectedUserList, setSelectedUserIds, request, selectedUserIds, setSelectedUserList, multiple, setPageNo, confirmUserList, } = React.useContext(UserOrgContext) || {};
|
|
14
14
|
const [selectedOrgId, setSelectedOrgId] = useState(null);
|
|
@@ -49,7 +49,7 @@ export const UserModel = ({ open, setOpen, onCancel, onConfirm, treeData, treeDa
|
|
|
49
49
|
setErrInfo({ errorStatus: true, errorMessage: e });
|
|
50
50
|
}
|
|
51
51
|
}, 500);
|
|
52
|
-
return (React.createElement(Modal, { visible: open, caption: "\u9009\u62E9\u6210\u5458", onClose: () =>
|
|
52
|
+
return (React.createElement(Modal, { visible: open, caption: "\u9009\u62E9\u6210\u5458", onClose: () => onCancel(null), className: "weda-ui weda-ui-user-select-modal" },
|
|
53
53
|
React.createElement(Modal.Body, null,
|
|
54
54
|
React.createElement("div", { className: "weda-ui-user-select-container" },
|
|
55
55
|
React.createElement(ModalSearch, { searchList: searchUserList, errInfo: errInfo, loading: loading, keyWords: keyWords, selectedList: selectedUserList, multiple: multiple, setSelectedList: setSelectedUserList, selectedIds: selectedUserIds, filterParams: filterParams, onSearch: (key) => onSearch(key), onReset: () => setSearchUserList([]) }),
|
|
@@ -10,7 +10,7 @@ export const UserOrgContext = React.createContext(null);
|
|
|
10
10
|
export function UserSelectPC({ id, className, style, label = '人员选择', labelVisible = true, //标题显隐
|
|
11
11
|
placeholder = '请选择人员', disabled = false, layout = 'horizontal', requiredFlag = false, size = 'l', multiple = false, //多选
|
|
12
12
|
outerRef, request = defaultRequest, //接口请求
|
|
13
|
-
decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedUserList, setSelectedUserList, confirmUserList, setConfirmUserList, selectedUserIds, setSelectedUserIds, pageNo, setPageNo, pageSize, filterParams, treeData, error, }) {
|
|
13
|
+
decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedUserList, setSelectedUserList, confirmUserList, setConfirmUserList, selectedUserIds, setSelectedUserIds, pageNo, setPageNo, pageSize, filterParams, treeData, error, onConfirmSelectUser, }) {
|
|
14
14
|
// 外层组件类
|
|
15
15
|
const cls = classNames({
|
|
16
16
|
'weda-ui': true,
|
|
@@ -48,7 +48,9 @@ decorator, onCancel, onConfirm, errInfo, open, setOpen, selectedUserList, setSel
|
|
|
48
48
|
setSelectedUserList(confirmUserList);
|
|
49
49
|
setOpen(open);
|
|
50
50
|
}, appearance: 'button', button: React.createElement(InputTags, { tagsList: confirmUserList, placeholder: placeholder, multiple: multiple, errInfo: errInfo, disabled: disabled, onClose: (e, item) => {
|
|
51
|
-
|
|
51
|
+
const currentConfirmUserList = confirmUserList.filter((l) => (l === null || l === void 0 ? void 0 : l.id) !== (item === null || item === void 0 ? void 0 : item.id));
|
|
52
|
+
setConfirmUserList(currentConfirmUserList);
|
|
53
|
+
onConfirmSelectUser(currentConfirmUserList);
|
|
52
54
|
e.stopPropagation();
|
|
53
55
|
} }), overlayClassName: 'weda-ui-user-selected-overlay-hidden', style: { width: '100%' } },
|
|
54
56
|
React.createElement(UserModel, { open: open, setOpen: setOpen, onConfirm: onConfirm, onCancel: onCancel, treeData: treeData || [], treeDataError: error, filterParams: filterParams })))))({
|
|
@@ -1,33 +1,96 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import classNames from '../../utils/classnames';
|
|
3
|
+
import { usePlatform } from '../../utils/platform';
|
|
3
4
|
import './_utils.css';
|
|
5
|
+
// 和编辑器对应
|
|
6
|
+
const manualCheckedType = {
|
|
7
|
+
twelveAdjust: 'twelve-adjust',
|
|
8
|
+
exactAdjust: 'exact-adjust',
|
|
9
|
+
};
|
|
4
10
|
const numberRegex = /^\d{1,2}$/;
|
|
5
11
|
export default function Col(props) {
|
|
6
12
|
const { className: userClassName, id, style, alignSelf, widthType, lgWidthType, children, events, } = props;
|
|
7
|
-
const
|
|
13
|
+
const platform = usePlatform();
|
|
14
|
+
const classNameStyle = useMemo(() => {
|
|
8
15
|
const clsxObj = {
|
|
9
16
|
'wd-grid-col': true,
|
|
10
17
|
[`wd-g-align-self-${alignSelf}`]: alignSelf,
|
|
11
18
|
[userClassName]: userClassName,
|
|
12
19
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
let exactStyle = style;
|
|
21
|
+
if (platform === 'h5') {
|
|
22
|
+
// 移动端是否是12列手动调节
|
|
23
|
+
let isTwelveAdjust = true;
|
|
24
|
+
let twelveAdjustWidthType = widthType;
|
|
25
|
+
if (typeof widthType == 'object') {
|
|
26
|
+
twelveAdjustWidthType = widthType.value;
|
|
27
|
+
isTwelveAdjust = widthType.type === manualCheckedType.twelveAdjust;
|
|
28
|
+
}
|
|
29
|
+
if (isTwelveAdjust) {
|
|
30
|
+
clsxObj['wd-grid-col'] = true;
|
|
31
|
+
if (twelveAdjustWidthType === 'fit-content') {
|
|
32
|
+
// 适应内容
|
|
33
|
+
clsxObj['wd-grid-col-auto'] = true;
|
|
34
|
+
}
|
|
35
|
+
else if (twelveAdjustWidthType === 'auto-fill' && (style === null || style === void 0 ? void 0 : style.width)) {
|
|
36
|
+
// 自动填充,如果有宽,则设置宽生效
|
|
37
|
+
clsxObj['wd-grid-col'] = false;
|
|
38
|
+
exactStyle = style;
|
|
39
|
+
}
|
|
40
|
+
else if (
|
|
41
|
+
// 12列调节
|
|
42
|
+
typeof twelveAdjustWidthType === 'number' ||
|
|
43
|
+
(typeof twelveAdjustWidthType === 'string' &&
|
|
44
|
+
numberRegex.test(twelveAdjustWidthType))) {
|
|
45
|
+
clsxObj[`wd-grid-col-${twelveAdjustWidthType}`] = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// 像素精确调节
|
|
50
|
+
clsxObj['wd-grid-col'] = false;
|
|
51
|
+
exactStyle = { ...style, width: twelveAdjustWidthType };
|
|
52
|
+
}
|
|
26
53
|
}
|
|
27
54
|
else {
|
|
28
|
-
|
|
55
|
+
// pc 端是否是12列手动调节
|
|
56
|
+
let isTwelveAdjustLg = true;
|
|
57
|
+
let twelveAdjustWidthTypeLg = lgWidthType;
|
|
58
|
+
if (typeof lgWidthType == 'object') {
|
|
59
|
+
twelveAdjustWidthTypeLg = lgWidthType.value;
|
|
60
|
+
isTwelveAdjustLg = lgWidthType.type === manualCheckedType.twelveAdjust;
|
|
61
|
+
}
|
|
62
|
+
if (isTwelveAdjustLg) {
|
|
63
|
+
clsxObj['wd-grid-col'] = true;
|
|
64
|
+
if (twelveAdjustWidthTypeLg === 'fit-content') {
|
|
65
|
+
// 适应内容
|
|
66
|
+
clsxObj['wd-grid-col-lg-auto'] = true;
|
|
67
|
+
}
|
|
68
|
+
else if (twelveAdjustWidthTypeLg === 'auto-fill' && (style === null || style === void 0 ? void 0 : style.width)) {
|
|
69
|
+
// 自动填充,如果有宽,则设置宽生效
|
|
70
|
+
clsxObj['wd-grid-col'] = false;
|
|
71
|
+
exactStyle = style;
|
|
72
|
+
}
|
|
73
|
+
else if (
|
|
74
|
+
// 12列调节
|
|
75
|
+
typeof twelveAdjustWidthTypeLg === 'number' ||
|
|
76
|
+
(typeof twelveAdjustWidthTypeLg === 'string' &&
|
|
77
|
+
numberRegex.test(twelveAdjustWidthTypeLg))) {
|
|
78
|
+
clsxObj[`wd-grid-col-lg-${twelveAdjustWidthTypeLg}`] = true;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
clsxObj['wd-grid-col-lg'] = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// 像素精确调节
|
|
86
|
+
clsxObj['wd-grid-col'] = false;
|
|
87
|
+
exactStyle = { ...style, width: twelveAdjustWidthTypeLg };
|
|
88
|
+
}
|
|
29
89
|
}
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
90
|
+
return {
|
|
91
|
+
className: classNames(clsxObj),
|
|
92
|
+
style: exactStyle,
|
|
93
|
+
};
|
|
94
|
+
}, [alignSelf, lgWidthType, userClassName, widthType, style, platform]);
|
|
95
|
+
return (React.createElement("div", { className: classNameStyle.className, id: id, style: classNameStyle.style, onClick: (e) => { var _a; return (_a = events === null || events === void 0 ? void 0 : events.tap) === null || _a === void 0 ? void 0 : _a.call(events, {}, { originEvent: e }); }, "data-role": "wd-col" }, children));
|
|
33
96
|
}
|
|
@@ -10,7 +10,7 @@ export default function Grid(props) {
|
|
|
10
10
|
'wd-grid': true,
|
|
11
11
|
[`wd-grid-gx-${gutterX}`]: !isNil(gutterX),
|
|
12
12
|
// 产品要求gutterX 同时间决定row一个换行的间距和 row之间的间距
|
|
13
|
-
[`wd-grid-gy-${gutterY}`]: !isNil(gutterY),
|
|
13
|
+
// [`wd-grid-gy-${gutterY}`]: !isNil(gutterY),
|
|
14
14
|
[`wd-grid-grb-${gutterY}`]: !isNil(gutterY),
|
|
15
15
|
[userClassName]: userClassName,
|
|
16
16
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import classNames from '../../utils/classnames';
|
|
3
|
+
import { isNil } from '../../utils/lodash';
|
|
3
4
|
import './_utils.css';
|
|
4
5
|
export default function Row(props) {
|
|
5
|
-
const { className: userClassName, id, style, children, events, alignItems, } = props;
|
|
6
|
+
const { className: userClassName, id, style, children, events, alignItems, gutterX, } = props;
|
|
6
7
|
const className = useMemo(() => {
|
|
7
8
|
return classNames({
|
|
8
9
|
'wd-grid-row': true,
|
|
10
|
+
[`wd-grid-gx-${gutterX}`]: gutterX != -1 && !isNil(gutterX),
|
|
9
11
|
[`wd-g-align-items-${alignItems}`]: alignItems,
|
|
10
12
|
[userClassName]: userClassName,
|
|
11
13
|
});
|
|
12
|
-
}, [alignItems, userClassName]);
|
|
14
|
+
}, [alignItems, userClassName, gutterX]);
|
|
13
15
|
return (React.createElement("div", { className: className, id: id, style: style, onClick: (e) => { var _a; return (_a = events === null || events === void 0 ? void 0 : events.tap) === null || _a === void 0 ? void 0 : _a.call(events, {}, { originEvent: e }); }, "data-role": "wd-row" }, children));
|
|
14
16
|
}
|
|
@@ -103,7 +103,7 @@ export const ModelFlowChart = loadable(() => import('./flow/modules/chart'), {
|
|
|
103
103
|
export const ModelFlow = loadable(() => import('./flow/modules/combination'), {
|
|
104
104
|
fallback,
|
|
105
105
|
});
|
|
106
|
-
export const ModelFlowControl = loadable(() => import('./flow/modules/
|
|
106
|
+
export const ModelFlowControl = loadable(() => import('./flow/modules/operations'), { fallback });
|
|
107
107
|
export const ModelFlowBasic = loadable(() => import('./flow/modules/basic'), {
|
|
108
108
|
fallback,
|
|
109
109
|
});
|
|
@@ -123,13 +123,6 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
}, [shouldBottomLoad]);
|
|
126
|
-
// 组件方法
|
|
127
|
-
useImperativeHandle(ref, () => ({
|
|
128
|
-
methods: {
|
|
129
|
-
deleteOne: methodDeleteOne,
|
|
130
|
-
refresh: methodRefresh,
|
|
131
|
-
},
|
|
132
|
-
}));
|
|
133
126
|
// 清除延迟状态
|
|
134
127
|
const clearDelay = () => {
|
|
135
128
|
clearTimeout(delayRef.current.statusTimer);
|
|
@@ -158,76 +151,10 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
158
151
|
const { total = 0 } = dataRef.current || {};
|
|
159
152
|
return pageNo * pageSize < total;
|
|
160
153
|
};
|
|
161
|
-
/**
|
|
162
|
-
* 列表视图拉取数据
|
|
163
|
-
* 方法仅依赖入参和paramRef的参数
|
|
164
|
-
* isInitData: 是否初始化数据默认否, isFetchCurrent: 是否拉取当前所有数据默认否
|
|
165
|
-
*/
|
|
166
|
-
const fetchData = async (param, options) => {
|
|
167
|
-
var _a;
|
|
168
|
-
const fetchVersion = (delayRef.current.version = getUuid());
|
|
169
|
-
const { isInitData, isFetchCurrent } = options || {};
|
|
170
|
-
// 合并参数并保存,useEffect 中需要比对
|
|
171
|
-
paramRef.current = {
|
|
172
|
-
...paramRef.current,
|
|
173
|
-
...param,
|
|
174
|
-
params: { ...paramRef.current.params, ...param === null || param === void 0 ? void 0 : param.params },
|
|
175
|
-
};
|
|
176
|
-
const { dataSourceName, methodName, params } = paramRef.current;
|
|
177
|
-
const { orderBy, orderType, pageNo, pageSize, where, connectorParams } = params || {};
|
|
178
|
-
if (!(dataSourceName && methodName))
|
|
179
|
-
return;
|
|
180
|
-
setStatus('loading');
|
|
181
|
-
let tcbParams = {};
|
|
182
|
-
// tcb分页参数
|
|
183
|
-
if (!isNil(pageNo) && !isNil(pageSize)) {
|
|
184
|
-
tcbParams['pageNo'] = pageNo;
|
|
185
|
-
tcbParams['pageSize'] = pageSize;
|
|
186
|
-
}
|
|
187
|
-
if (isModel) {
|
|
188
|
-
// tcb排序参数
|
|
189
|
-
if (orderBy && ORDERTYPE.includes(orderType)) {
|
|
190
|
-
tcbParams['orderBy'] = orderBy;
|
|
191
|
-
tcbParams['orderType'] = orderType;
|
|
192
|
-
}
|
|
193
|
-
// tcb过滤参数
|
|
194
|
-
const whereEffected = [].concat(getWhereList(where));
|
|
195
|
-
whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
// 内部分页参数覆盖查询入参
|
|
199
|
-
tcbParams = Object.assign({}, connectorParams, tcbParams);
|
|
200
|
-
}
|
|
201
|
-
// tcb结果和事件
|
|
202
|
-
let data = {};
|
|
203
|
-
const eventDatasource = isModel
|
|
204
|
-
? datasource
|
|
205
|
-
: { ...bindConnectMetadata, ...connectorMethod };
|
|
206
|
-
try {
|
|
207
|
-
if (isFetchCurrent) {
|
|
208
|
-
data = await fetchDataLoop({ dataSourceName, methodName, params: tcbParams }, dataRef.current.records.length);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
|
|
212
|
-
dataSourceName,
|
|
213
|
-
methodName,
|
|
214
|
-
params: tcbParams,
|
|
215
|
-
}, true));
|
|
216
|
-
}
|
|
217
|
-
if (fetchVersion !== delayRef.current.version)
|
|
218
|
-
return;
|
|
219
|
-
isInitData && (dataRef.current = { total: 0, records: [] });
|
|
220
|
-
onEvents(data, eventDatasource);
|
|
221
|
-
}
|
|
222
|
-
catch (e) {
|
|
223
|
-
setStatus('fail');
|
|
224
|
-
(_a = events === null || events === void 0 ? void 0 : events.queryFail) === null || _a === void 0 ? void 0 : _a.call(events, { datasource: eventDatasource, data: null });
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
154
|
/**
|
|
228
155
|
* 循环调用接口获取当前已加载的数据
|
|
229
156
|
*/
|
|
230
|
-
const fetchDataLoop = async (param = {}, count = 0) => {
|
|
157
|
+
const fetchDataLoop = useCallback(async (param = {}, count = 0) => {
|
|
231
158
|
let [records, total] = [[], 0];
|
|
232
159
|
try {
|
|
233
160
|
const { dataSourceName, methodName, params } = param || {};
|
|
@@ -248,14 +175,15 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
248
175
|
console.error('fetchDataLoop: ', e);
|
|
249
176
|
}
|
|
250
177
|
return { records: records.slice(0, count), total };
|
|
251
|
-
};
|
|
178
|
+
}, [appCloud]);
|
|
252
179
|
/**
|
|
253
180
|
* 根据fetchData方法返回值,回调给外部事件
|
|
254
181
|
*/
|
|
255
|
-
const onEvents = (data, datasource) => {
|
|
182
|
+
const onEvents = useCallback((data, datasource) => {
|
|
256
183
|
var _a, _b;
|
|
257
|
-
const
|
|
258
|
-
const
|
|
184
|
+
const isDataViewApis = !isRecords && !isModel;
|
|
185
|
+
const fetchRecords = [].concat(isDataViewApis ? data : (data === null || data === void 0 ? void 0 : data.records) || []);
|
|
186
|
+
const total = isDataViewApis ? 0 : Number(data === null || data === void 0 ? void 0 : data.total) || 0;
|
|
259
187
|
if (['loadMoreButton', 'bottomLoad'].includes(paramRef.current.pagination)) {
|
|
260
188
|
dataRef.current = {
|
|
261
189
|
total,
|
|
@@ -269,7 +197,7 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
269
197
|
data: beforeDataChange(dataRef.current.records || []),
|
|
270
198
|
state: getContextState(),
|
|
271
199
|
});
|
|
272
|
-
if (total === 0) {
|
|
200
|
+
if (total === 0 && !isDataViewApis) {
|
|
273
201
|
setStatus('empty');
|
|
274
202
|
(_b = events === null || events === void 0 ? void 0 : events.queryEmpty) === null || _b === void 0 ? void 0 : _b.call(events, {
|
|
275
203
|
datasource,
|
|
@@ -298,7 +226,82 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
298
226
|
else {
|
|
299
227
|
successCb();
|
|
300
228
|
}
|
|
301
|
-
};
|
|
229
|
+
}, [beforeDataChange, events, isModel, isRecords, pagination]);
|
|
230
|
+
/**
|
|
231
|
+
* 列表视图拉取数据
|
|
232
|
+
* 方法仅依赖入参和paramRef的参数
|
|
233
|
+
* isInitData: 是否初始化数据默认否, isFetchCurrent: 是否拉取当前所有数据默认否
|
|
234
|
+
*/
|
|
235
|
+
const fetchData = useCallback(async (param, options) => {
|
|
236
|
+
var _a;
|
|
237
|
+
const fetchVersion = (delayRef.current.version = getUuid());
|
|
238
|
+
const { isInitData, isFetchCurrent } = options || {};
|
|
239
|
+
// 合并参数并保存,useEffect 中需要比对
|
|
240
|
+
paramRef.current = {
|
|
241
|
+
...paramRef.current,
|
|
242
|
+
...param,
|
|
243
|
+
params: { ...paramRef.current.params, ...param === null || param === void 0 ? void 0 : param.params },
|
|
244
|
+
};
|
|
245
|
+
const { dataSourceName, methodName, params } = paramRef.current;
|
|
246
|
+
const { orderBy, orderType, pageNo, pageSize, where, connectorParams } = params || {};
|
|
247
|
+
if (!(dataSourceName && methodName))
|
|
248
|
+
return;
|
|
249
|
+
setStatus('loading');
|
|
250
|
+
let tcbParams = {};
|
|
251
|
+
// tcb分页参数
|
|
252
|
+
if (!isNil(pageNo) && !isNil(pageSize)) {
|
|
253
|
+
tcbParams['pageNo'] = pageNo;
|
|
254
|
+
tcbParams['pageSize'] = pageSize;
|
|
255
|
+
}
|
|
256
|
+
if (isModel) {
|
|
257
|
+
// tcb排序参数
|
|
258
|
+
if (orderBy && ORDERTYPE.includes(orderType)) {
|
|
259
|
+
tcbParams['orderBy'] = orderBy;
|
|
260
|
+
tcbParams['orderType'] = orderType;
|
|
261
|
+
}
|
|
262
|
+
// tcb过滤参数
|
|
263
|
+
const whereEffected = [].concat(getWhereList(where));
|
|
264
|
+
whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
// 内部分页参数覆盖查询入参
|
|
268
|
+
tcbParams = Object.assign({}, connectorParams, tcbParams);
|
|
269
|
+
}
|
|
270
|
+
// tcb结果和事件
|
|
271
|
+
let data = {};
|
|
272
|
+
const eventDatasource = isModel
|
|
273
|
+
? datasource
|
|
274
|
+
: { ...bindConnectMetadata, ...connectorMethod };
|
|
275
|
+
try {
|
|
276
|
+
if (isFetchCurrent) {
|
|
277
|
+
data = await fetchDataLoop({ dataSourceName, methodName, params: tcbParams }, dataRef.current.records.length);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
|
|
281
|
+
dataSourceName,
|
|
282
|
+
methodName,
|
|
283
|
+
params: tcbParams,
|
|
284
|
+
}, true));
|
|
285
|
+
}
|
|
286
|
+
if (fetchVersion !== delayRef.current.version)
|
|
287
|
+
return;
|
|
288
|
+
isInitData && (dataRef.current = { total: 0, records: [] });
|
|
289
|
+
onEvents(data, eventDatasource);
|
|
290
|
+
}
|
|
291
|
+
catch (e) {
|
|
292
|
+
setStatus('fail');
|
|
293
|
+
(_a = events === null || events === void 0 ? void 0 : events.queryFail) === null || _a === void 0 ? void 0 : _a.call(events, { datasource: eventDatasource, data: null });
|
|
294
|
+
}
|
|
295
|
+
}, [
|
|
296
|
+
appCloud,
|
|
297
|
+
bindConnectMetadata,
|
|
298
|
+
connectorMethod,
|
|
299
|
+
datasource,
|
|
300
|
+
events,
|
|
301
|
+
fetchDataLoop,
|
|
302
|
+
isModel,
|
|
303
|
+
onEvents,
|
|
304
|
+
]);
|
|
302
305
|
/**
|
|
303
306
|
* 计算上下文对象数据
|
|
304
307
|
*/
|
|
@@ -311,23 +314,19 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
311
314
|
/**
|
|
312
315
|
* 组件刷新方法,重新初始化
|
|
313
316
|
*/
|
|
314
|
-
const methodRefreshFromStart = async () => {
|
|
317
|
+
const methodRefreshFromStart = useCallback(async () => {
|
|
315
318
|
try {
|
|
316
319
|
clearDelay();
|
|
317
320
|
await fetchData({ params: { pageNo: 1 } }, { isInitData: true });
|
|
318
|
-
alertErrorMessage({
|
|
319
|
-
message: LISTVIEW_MESSAGE.refresh_success,
|
|
320
|
-
icon: 'success',
|
|
321
|
-
});
|
|
322
321
|
}
|
|
323
322
|
catch (e) {
|
|
324
323
|
alertErrorMessage({ message: LISTVIEW_MESSAGE.refresh_fail });
|
|
325
324
|
}
|
|
326
|
-
};
|
|
325
|
+
}, [fetchData]);
|
|
327
326
|
/**
|
|
328
327
|
* 组件刷新当前方法,保持当前已加载的数据列表状态
|
|
329
328
|
*/
|
|
330
|
-
const methodRefreshKeepPage = async () => {
|
|
329
|
+
const methodRefreshKeepPage = useCallback(async () => {
|
|
331
330
|
try {
|
|
332
331
|
clearDelay();
|
|
333
332
|
const { pageNo, pageSize } = paramRef.current.params;
|
|
@@ -342,30 +341,26 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
342
341
|
else {
|
|
343
342
|
await methodRefreshFromStart();
|
|
344
343
|
}
|
|
345
|
-
alertErrorMessage({
|
|
346
|
-
message: LISTVIEW_MESSAGE.refresh_success,
|
|
347
|
-
icon: 'success',
|
|
348
|
-
});
|
|
349
344
|
}
|
|
350
345
|
catch (e) {
|
|
351
346
|
alertErrorMessage({ message: LISTVIEW_MESSAGE.refresh_fail });
|
|
352
347
|
}
|
|
353
|
-
};
|
|
348
|
+
}, [fetchData, methodRefreshFromStart, pagination]);
|
|
354
349
|
/**
|
|
355
350
|
* 组件刷新方法,通过类别区分
|
|
356
351
|
*/
|
|
357
|
-
const methodRefresh = (params) => {
|
|
352
|
+
const methodRefresh = useCallback((params) => {
|
|
358
353
|
if (typeof params === 'object' && (params === null || params === void 0 ? void 0 : params.type) === 'refreshKeepPage') {
|
|
359
354
|
methodRefreshKeepPage();
|
|
360
355
|
}
|
|
361
356
|
else {
|
|
362
357
|
methodRefreshFromStart();
|
|
363
358
|
}
|
|
364
|
-
};
|
|
359
|
+
}, [methodRefreshFromStart, methodRefreshKeepPage]);
|
|
365
360
|
/**
|
|
366
361
|
* 组件删除单条方法
|
|
367
362
|
*/
|
|
368
|
-
const methodDeleteOne = async (params) => {
|
|
363
|
+
const methodDeleteOne = useCallback(async (params) => {
|
|
369
364
|
try {
|
|
370
365
|
if (!isModel) {
|
|
371
366
|
return alertErrorMessage({
|
|
@@ -385,15 +380,18 @@ export default React.forwardRef(function ListView(props, ref) {
|
|
|
385
380
|
params: { _id },
|
|
386
381
|
}));
|
|
387
382
|
await methodRefreshKeepPage();
|
|
388
|
-
alertErrorMessage({
|
|
389
|
-
message: LISTVIEW_MESSAGE.deleteOne_success,
|
|
390
|
-
icon: 'success',
|
|
391
|
-
});
|
|
392
383
|
}
|
|
393
384
|
catch (e) {
|
|
394
385
|
alertErrorMessage({ message: LISTVIEW_MESSAGE.deleteOne_fail });
|
|
395
386
|
}
|
|
396
|
-
};
|
|
387
|
+
}, [appCloud, isModel, methodRefreshKeepPage]);
|
|
388
|
+
// 组件方法
|
|
389
|
+
useImperativeHandle(ref, () => ({
|
|
390
|
+
methods: {
|
|
391
|
+
deleteOne: methodDeleteOne,
|
|
392
|
+
refresh: methodRefresh,
|
|
393
|
+
},
|
|
394
|
+
}), [methodDeleteOne, methodRefresh]);
|
|
397
395
|
/**
|
|
398
396
|
* 分页,加载更多
|
|
399
397
|
*/
|