@cloudbase/weda-ui 3.1.6 → 3.2.0

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.
Files changed (82) hide show
  1. package/dist/configs/components/chart/bar.json +14 -7
  2. package/dist/configs/components/chart/line.json +14 -7
  3. package/dist/configs/components/chart/pie.json +12 -6
  4. package/dist/configs/components/form/departTreeSelect.json +124 -0
  5. package/dist/configs/components/form/userTreeSelect.json +128 -0
  6. package/dist/configs/components/formdetail.json +105 -0
  7. package/dist/configs/components/listView.json +9 -1
  8. package/dist/configs/components/lottery.json +1 -1
  9. package/dist/configs/components/tabs.json +10 -9
  10. package/dist/configs/components/wxOpenApi/share.json +5 -2
  11. package/dist/configs/index.d.ts +6 -0
  12. package/dist/configs/index.js +6 -0
  13. package/dist/docs/common/format.js +24 -5
  14. package/dist/web/actions/showModal/index.css +3 -0
  15. package/dist/web/actions/showModal/index.d.ts +1 -0
  16. package/dist/web/actions/showModal/index.js +1 -0
  17. package/dist/web/components/calendar/index.js +10 -2
  18. package/dist/web/components/carousel/index.js +4 -0
  19. package/dist/web/components/chart/common/core/eChartBase.js +8 -2
  20. package/dist/web/components/form/form/index.js +10 -7
  21. package/dist/web/components/form/location/common/mapChoose.js +2 -0
  22. package/dist/web/components/form/location/common/mapView.js +2 -0
  23. package/dist/web/components/form/location/components/LocationH5/location.h5.js +3 -1
  24. package/dist/web/components/form/location/components/LocationH5/location.module.css +3 -0
  25. package/dist/web/components/form/select/h5.js +4 -0
  26. package/dist/web/components/form/select/index.js +2 -8
  27. package/dist/web/components/form/switch/index.js +3 -2
  28. package/dist/web/components/form/switch/switch.module.css +7 -0
  29. package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -0
  30. package/dist/web/components/form/uploader/uploader.h5.js +41 -17
  31. package/dist/web/components/form/uploader/uploader.pc.js +31 -2
  32. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +36 -14
  33. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +34 -11
  34. package/dist/web/components/form/userOrgSelect/comTool.d.ts +7 -0
  35. package/dist/web/components/form/userOrgSelect/comTool.js +89 -0
  36. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.d.ts +20 -0
  37. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +259 -0
  38. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +4 -0
  39. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +153 -0
  40. package/dist/web/components/form/userOrgSelect/departTreeSelect/index.d.ts +2 -0
  41. package/dist/web/components/form/userOrgSelect/departTreeSelect/index.js +17 -0
  42. package/dist/web/components/form/userOrgSelect/index.d.ts +2 -0
  43. package/dist/web/components/form/userOrgSelect/index.js +17 -0
  44. package/dist/web/components/form/userOrgSelect/userOrgSelect.less +643 -0
  45. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +24 -0
  46. package/dist/web/components/form/userOrgSelect/userTreeSelect.h5.js +276 -0
  47. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +9 -0
  48. package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.js +229 -0
  49. package/dist/web/components/form/userOrgSelect/utils.d.ts +35 -0
  50. package/dist/web/components/form/userOrgSelect/utils.js +72 -0
  51. package/dist/web/components/formdetail/index.css +115 -0
  52. package/dist/web/components/formdetail/index.d.ts +28 -0
  53. package/dist/web/components/formdetail/index.js +170 -0
  54. package/dist/web/components/index.d.ts +3 -0
  55. package/dist/web/components/index.js +3 -0
  56. package/dist/web/components/listView/index.css +35 -5
  57. package/dist/web/components/listView/index.js +92 -68
  58. package/dist/web/components/listView/interface.d.ts +5 -0
  59. package/dist/web/components/lottery/index.js +2 -1
  60. package/dist/web/components/lottery/lotteryUtil.js +1 -0
  61. package/dist/web/components/navigationBar/index.css +21 -29
  62. package/dist/web/components/richText/index.css +1 -0
  63. package/dist/web/components/swiper/index.js +5 -1
  64. package/dist/web/components/wedaVideo/index.js +1 -0
  65. package/dist/web/utils/getUserService.d.ts +17 -0
  66. package/dist/web/utils/getUserService.js +148 -0
  67. package/dist/web/utils/platform.js +2 -0
  68. package/dist/web/weda-ui.css +9 -0
  69. package/package.json +14 -13
  70. package/dist/asset-manifest.json +0 -17
  71. package/dist/index.html +0 -88
  72. package/dist/static/js/bundle.js +0 -963
  73. package/dist/static/js/bundle.js.map +0 -1
  74. package/dist/static/js/main.chunk.js +0 -8841
  75. package/dist/static/js/main.chunk.js.map +0 -1
  76. package/dist/static/js/vendors~main.chunk.js +0 -247885
  77. package/dist/static/js/vendors~main.chunk.js.map +0 -1
  78. package/dist/static/media/ef6fa527e24e354765d806b826b41391.fa67580a.svg +0 -627
  79. package/dist/web/components/auth/index.d.ts +0 -10
  80. package/dist/web/components/auth/index.js +0 -37
  81. package/dist/web/utils/events.d.ts +0 -1
  82. package/dist/web/utils/events.js +0 -2
@@ -0,0 +1,115 @@
1
+ .form-detail-wrap {
2
+ width: 100%;
3
+ }
4
+ .form-detail-wrap .form-detail-content-wrap {
5
+ border: 0.07143rem solid #dcdcdc;
6
+ margin-top: 0.85714rem;
7
+ }
8
+ .form-detail-wrap
9
+ .form-detail-content-wrap
10
+ .form-detail-group-header-container {
11
+ height: 3.42857rem;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: space-between;
15
+ background: #f1f2f5;
16
+ padding: 0.92857rem 1.42857rem;
17
+ border-bottom: 0.07143rem solid #dcdcdc;
18
+ }
19
+ .form-detail-wrap
20
+ .form-detail-content-wrap
21
+ .form-detail-group-header-container
22
+ .form-detail-title-container {
23
+ display: flex;
24
+ color: rgba(0, 0, 0, 0.9);
25
+ }
26
+ .form-detail-wrap .form-detail-content-wrap .form-detail-header-text {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: space-between;
30
+ color: rgba(0, 0, 0, 0.9);
31
+ flex: 1;
32
+ }
33
+ .form-detail-wrap
34
+ .form-detail-content-wrap
35
+ .form-detail-group-content-container {
36
+ padding: 1.07143rem 1.14286rem;
37
+ }
38
+ .form-detail-wrap .form-detail-add-button,
39
+ .form-detail-wrap .form-detail-delete-button {
40
+ cursor: pointer;
41
+ color: #0052d9;
42
+ font-size: 1rem;
43
+ }
44
+
45
+ .form-detail-wrap .form-detail-add-button {
46
+ padding: 0.57143rem 1.14286rem 1.14286rem 1.14286rem;
47
+ display: inline-flex;
48
+ align-items: center;
49
+ }
50
+ .form-detail-wrap .form-detail-add-button > .weda-ui {
51
+ vertical-align: baseline;
52
+ padding-right: 0.35714rem;
53
+ line-height: 1;
54
+ }
55
+ .h5-form-detail-wrap {
56
+ width: 100%;
57
+ }
58
+ .h5-form-detail-wrap .form-detail-content-wrap {
59
+ margin: 0;
60
+ border: none;
61
+ }
62
+ .h5-form-detail-wrap
63
+ .form-detail-content-wrap
64
+ .form-detail-group-header-container {
65
+ height: 2.85714rem;
66
+ border: none;
67
+ }
68
+ .h5-form-detail-wrap
69
+ .form-detail-content-wrap
70
+ .form-detail-group-content-container {
71
+ width: 100%;
72
+ padding: 0;
73
+ }
74
+ .form-detail-wrap .form-detail-title-index {
75
+ padding-left: 0.35714rem;
76
+ }
77
+ .form-detail-wrap .form-detail-title-index::before {
78
+ content: '(';
79
+ }
80
+ .form-detail-wrap .form-detail-title-index::after {
81
+ content: ')';
82
+ }
83
+ .h5-form-detail-wrap .form-detail-add-button {
84
+ font-size: 1.14286rem;
85
+ line-height: 1;
86
+ }
87
+ .h5-form-detail-wrap
88
+ .form-detail-content-wrap
89
+ .form-detail-group-header-container {
90
+ position: relative;
91
+ }
92
+ .h5-form-detail-wrap
93
+ .form-detail-content-wrap
94
+ .form-detail-group-header-container::before {
95
+ content: '';
96
+ width: 100%;
97
+ position: absolute;
98
+ height: 0.07143rem;
99
+ background: #f1f2f5;
100
+ top: -0.07143rem;
101
+ left: 0;
102
+ z-index: 5;
103
+ }
104
+ .h5-form-detail-wrap
105
+ .form-detail-content-wrap
106
+ .form-detail-group-header-container::after {
107
+ content: '';
108
+ width: 100%;
109
+ position: absolute;
110
+ height: 0.07143rem;
111
+ background: #f1f2f5;
112
+ bottom: -0.07143rem;
113
+ left: 0;
114
+ z-index: 5;
115
+ }
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import type { CommonPropsType, ICompRef } from '../../types';
3
+ import './index.css';
4
+ export interface PropsType extends CommonPropsType {
5
+ name?: string;
6
+ value?: any;
7
+ isPureArray?: boolean;
8
+ parent: any;
9
+ }
10
+ declare type TCompRef = ICompRef<{
11
+ addition: () => void;
12
+ remove: (key: string) => void;
13
+ }>;
14
+ export declare const reorderContext: (data: any, name: any, isPureArray: any) => any;
15
+ export declare const newContextItem: (childFormItem: any, name: any, isPureArray: any) => {
16
+ index: number;
17
+ _id: string;
18
+ };
19
+ export declare const changeHandle: ({ type, name, data, childFormItem, isPureArray, params, }: {
20
+ type: any;
21
+ name: any;
22
+ data: any;
23
+ childFormItem: any;
24
+ isPureArray: any;
25
+ params: any;
26
+ }) => any;
27
+ declare const _default: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<TCompRef>>;
28
+ export default _default;
@@ -0,0 +1,170 @@
1
+ import React, { useEffect, useRef, forwardRef, useImperativeHandle, useState, } from 'react';
2
+ import destr from 'destr';
3
+ import classNames from '../../utils/classnames';
4
+ import { usePlatform, randomStr } from '../../utils/platform';
5
+ import isObjectEqual from '../../utils/isObjectEqual';
6
+ import './index.css';
7
+ export const reorderContext = (data, name, isPureArray) => data.map((i, index) => {
8
+ const item = { ...i };
9
+ Object.keys(i).forEach((j) => {
10
+ var _a;
11
+ if ((_a = item[j]) === null || _a === void 0 ? void 0 : _a.name) {
12
+ item[j].name = isPureArray
13
+ ? `${name}[${index}]`
14
+ : `${name}[${index}].${j}`;
15
+ }
16
+ });
17
+ item.index = index;
18
+ return item;
19
+ });
20
+ export const newContextItem = (childFormItem, name, isPureArray) => {
21
+ const mock = { index: 0, _id: randomStr() };
22
+ childFormItem === null || childFormItem === void 0 ? void 0 : childFormItem.forEach((i) => {
23
+ mock[i] = {
24
+ name: isPureArray ? `${name}[0]` : `${name}[0].${i}`,
25
+ value: null,
26
+ };
27
+ });
28
+ return mock;
29
+ };
30
+ export const changeHandle = ({ type, name, data, childFormItem, isPureArray, params, }) => {
31
+ switch (type) {
32
+ case 'add': {
33
+ const mock = newContextItem(childFormItem, name, isPureArray);
34
+ data.push({ ...mock, _id: randomStr() });
35
+ data = reorderContext(data, name, isPureArray);
36
+ break;
37
+ }
38
+ case 'remove': {
39
+ data.splice(params.index, 1);
40
+ data = reorderContext(data, name, isPureArray);
41
+ break;
42
+ }
43
+ case 'change': {
44
+ data = data.map((i) => {
45
+ const item = { ...i };
46
+ for (const [key, subItem] of Object.entries(item)) {
47
+ if (params.name === (subItem === null || subItem === void 0 ? void 0 : subItem.name)) {
48
+ item[key].value = params === null || params === void 0 ? void 0 : params.value;
49
+ }
50
+ }
51
+ return item;
52
+ });
53
+ break;
54
+ }
55
+ default: {
56
+ break;
57
+ }
58
+ }
59
+ return data;
60
+ };
61
+ export default forwardRef(function FormDetail(props, ref) {
62
+ const { className, id, style, children, events, name, value: initDetailValue, isPureArray, parent, } = props;
63
+ const observeRef = useRef(null); // 当前监听对象
64
+ const [defaultValue, setDetailValue] = useState([]);
65
+ const [contextData, setContextData] = useState([]);
66
+ const [childFormItem, setCildFormItem] = useState([]);
67
+ const platform = usePlatform();
68
+ const init = (defaultValue) => {
69
+ var _a;
70
+ const formDetailItemValue = {};
71
+ let childFormItem = defaultValue[0] ? Object.keys(defaultValue[0]) : [];
72
+ // 纯数组,默认key值为'arrayItem'
73
+ if (isPureArray) {
74
+ childFormItem = ['arrayItem'];
75
+ }
76
+ setCildFormItem(childFormItem);
77
+ let initialValues = [];
78
+ try {
79
+ initialValues = defaultValue.map((i, index) => {
80
+ let item = {};
81
+ if (isPureArray) {
82
+ // eslint-disable-next-line no-prototype-builtins
83
+ const val = (i === null || i === void 0 ? void 0 : i.hasOwnProperty('arrayItem')) ? null : i;
84
+ item['arrayItem'] = { name: `${name}[${index}]`, value: val };
85
+ formDetailItemValue[`${name}[${index}]`] = val;
86
+ }
87
+ else {
88
+ item = { ...i };
89
+ Object.keys(i).forEach((j) => {
90
+ const key = `${name}[${index}].${j}`;
91
+ const val = i[j];
92
+ item[j] = { name: key, value: val };
93
+ formDetailItemValue[key] = val;
94
+ });
95
+ }
96
+ item.index = index;
97
+ item._id = randomStr();
98
+ return item;
99
+ });
100
+ }
101
+ catch (error) {
102
+ console.log(error);
103
+ }
104
+ const mock = newContextItem(childFormItem, name, isPureArray);
105
+ const data = (initialValues === null || initialValues === void 0 ? void 0 : initialValues.length) ? initialValues : [mock];
106
+ setContextData(data);
107
+ (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, {
108
+ data,
109
+ });
110
+ // 解决web端,编辑场景不回显初始值的问题
111
+ // eslint-disable-next-line rulesdir/no-timer
112
+ setTimeout(() => {
113
+ if (!isObjectEqual(formDetailItemValue, {})) {
114
+ parent.setValue(formDetailItemValue);
115
+ }
116
+ }, 0);
117
+ };
118
+ // 初始化context的值
119
+ useEffect(() => {
120
+ if (!isObjectEqual(initDetailValue, defaultValue)) {
121
+ setDetailValue(initDetailValue);
122
+ init(initDetailValue);
123
+ }
124
+ }, [initDetailValue]);
125
+ useEffect(() => {
126
+ init(initDetailValue);
127
+ setDetailValue(initDetailValue);
128
+ // 组件卸载时触发
129
+ return () => {
130
+ var _a, _b;
131
+ (_a = observeRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
132
+ (_b = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _b === void 0 ? void 0 : _b.call(events, { data: [] });
133
+ };
134
+ }, []);
135
+ const onChange = (type, params) => {
136
+ var _a;
137
+ let data = destr(contextData);
138
+ data = changeHandle({
139
+ type,
140
+ name,
141
+ data,
142
+ childFormItem,
143
+ isPureArray,
144
+ params,
145
+ });
146
+ setContextData(data);
147
+ (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data });
148
+ };
149
+ useImperativeHandle(ref, () => {
150
+ return {
151
+ methods: {
152
+ addition: () => {
153
+ onChange('add', null);
154
+ },
155
+ remove: (params) => {
156
+ onChange('remove', params);
157
+ },
158
+ change: (params) => {
159
+ onChange('change', params);
160
+ },
161
+ },
162
+ };
163
+ }, [onChange]);
164
+ return (React.createElement("div", { className: classNames({
165
+ 'weda-ui': true,
166
+ 'form-detail-wrap': true,
167
+ 'h5-form-detail-wrap': platform === 'h5',
168
+ [className]: className,
169
+ }), id: id, style: style, role: "container", "data-testid": "formDetail" }, children));
170
+ });
@@ -45,3 +45,6 @@ export { default as Phone } from "./phone";
45
45
  export { default as PhoneCode } from "./phoneCode";
46
46
  export { default as Share } from "./share";
47
47
  export { default as Lottery } from "./lottery";
48
+ export { default as UserTreeSelect } from "./form/userOrgSelect/index";
49
+ export { default as DepartTreeSelect } from "./form/userOrgSelect/departTreeSelect/index";
50
+ export { default as FormDetail } from "./formdetail";
@@ -90,5 +90,8 @@ export { default as Phone } from './phone';
90
90
  export { default as PhoneCode } from './phoneCode';
91
91
  export { default as Share } from './share';
92
92
  export { default as Lottery } from './lottery';
93
+ export { default as UserTreeSelect } from './form/userOrgSelect/index';
94
+ export { default as DepartTreeSelect } from './form/userOrgSelect/departTreeSelect/index';
95
+ export { default as FormDetail } from './formdetail';
93
96
  import 'weui/dist/style/weui.css';
94
97
  import '../weda-ui.css';
@@ -2,6 +2,25 @@
2
2
  overflow-y: auto;
3
3
  max-height: 100%;
4
4
  overflow-x: hidden;
5
+ display: flex;
6
+ flex-direction: column;
7
+ }
8
+
9
+ /* 列表内容区域 */
10
+ .weda-list-view__containor .weda-list-view__content {
11
+ position: relative;
12
+ flex-grow: 2;
13
+ }
14
+
15
+ .weda-list-view__containor .weda-list-view__content-blank {
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ flex-direction: column;
20
+ }
21
+
22
+ .weda-list-view__containor .weda-list-view__empty {
23
+ color: rgba(0, 0, 0, 0.4);
5
24
  }
6
25
 
7
26
  .weda-list-view-card {
@@ -10,7 +29,21 @@
10
29
  margin-right: 0.21429rem;
11
30
  }
12
31
 
13
- /* 加载更多 */
32
+ .weda-list-view__containor
33
+ .weda-list-view__more.weda-list-view__content-loading {
34
+ background-color: transparent;
35
+ position: absolute;
36
+ top: 0;
37
+ bottom: 0;
38
+ left: 0;
39
+ right: 0;
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ padding: 0.35714rem 0;
44
+ }
45
+
46
+ /* 加载更多区域 */
14
47
  .weda-list-view__containor .weda-list-view__more {
15
48
  width: 100%;
16
49
  }
@@ -30,7 +63,7 @@
30
63
  cursor: pointer;
31
64
  }
32
65
 
33
- /* 加载更多 ... */
66
+ /* 加载更多的Symbol ... */
34
67
  .weda-list-view__containor .weda-list-view__more .weda-list-view__more-symbol {
35
68
  display: flex;
36
69
  align-items: center;
@@ -57,9 +90,6 @@
57
90
  }
58
91
 
59
92
  /* 加载更多 分页 */
60
- .weda-list-view__containor .weda-list-view__more {
61
- background-color: #fff;
62
- }
63
93
  .weda-list-view__containor
64
94
  .weda-list-view__more.weda-list-view__more-bottomLoad {
65
95
  background-color: transparent;
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef, useMemo, useCallback, } from 'react';
1
+ import React, { useState, useEffect, useRef, useCallback, } from 'react';
2
2
  import { callDataSource } from '../../utils/tcb';
3
3
  import { isInIde, getWhereList } from '../../utils/platform';
4
4
  import classNames from '../../utils/classnames';
@@ -12,34 +12,32 @@ const getIdeMockData = (length = 3) => Array.from({ length }).map(() => Object.c
12
12
  * 数据容器-列表视图
13
13
  */
14
14
  export default function ListView(props) {
15
- var _a, _b, _c, _d;
15
+ var _a, _b, _c;
16
16
  const { dataSourceType, bindConnectMetadata, connectorMethod, connectorParams, datasource, orderBy, orderType, where, template, pageSize = 5, pagination, events, className, children, isRecords = true, //是否展示回调recoreds字段
17
+ isSetStatus = false, //是否开启加载状态
17
18
  appCloud = { callDataSource, isInIde }, beforeDataChange = (v) => v, ...rest } = props;
18
- const isModel = useMemo(() => dataSourceType !== 'custom-connector', [dataSourceType]);
19
- const methodName = useMemo(() => {
20
- var _a;
21
- if (isModel) {
22
- return ((_a = datasource === null || datasource === void 0 ? void 0 : datasource.extra) === null || _a === void 0 ? void 0 : _a.methodName) || 'wedaGetRecords';
23
- }
24
- else {
25
- return (connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name) || 'wedaGetRecords';
26
- }
27
- }, [(_a = datasource === null || datasource === void 0 ? void 0 : datasource.extra) === null || _a === void 0 ? void 0 : _a.methodName, connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name, isModel]); // 默认方法名
19
+ const isModel = dataSourceType !== 'custom-connector';
20
+ const methodName = isModel
21
+ ? ((_a = datasource === null || datasource === void 0 ? void 0 : datasource.extra) === null || _a === void 0 ? void 0 : _a.methodName) || 'wedaGetRecords'
22
+ : connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name; // 默认方法名
23
+ const dataSourceName = isModel
24
+ ? datasource === null || datasource === void 0 ? void 0 : datasource.name
25
+ : (_b = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _b === void 0 ? void 0 : _b.name;
28
26
  const [pageNo, setPageNo] = useState(1); // 分页状态
29
- const [loading, setLoading] = useState(false); // 触底刷新加载状态
30
27
  const [entry, setEntry] = useState(null); // 触底的observer对象
28
+ const [status, setStatus] = useState(''); // 查询状态
31
29
  const paramRef = useRef({
32
- dataSourceName: datasource === null || datasource === void 0 ? void 0 : datasource.name,
33
- bindConnectMetaName: (_b = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _b === void 0 ? void 0 : _b.name,
30
+ dataSourceName,
34
31
  methodName,
35
32
  params: { orderBy, orderType, where, pageNo: 1, pageSize, connectorParams },
36
33
  pagination,
37
34
  }); // 最新请求参数
38
35
  const dataRef = useRef({ total: 0, records: [] }); // 最新数据列表
39
36
  const observeRef = useRef(null); // 当前监听对象
40
- const isIdeMockData = (!(datasource === null || datasource === void 0 ? void 0 : datasource.name) || !((_c = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _c === void 0 ? void 0 : _c.name)) &&
41
- ((_d = appCloud === null || appCloud === void 0 ? void 0 : appCloud.isInIde) === null || _d === void 0 ? void 0 : _d.call(appCloud)); // 在ide环境且未绑定数据源时,存在mock数据逻辑
42
- const shouldBottomLoad = pagination === 'bottomLoad' && (entry === null || entry === void 0 ? void 0 : entry.isIntersecting) && !loading; // 能否触底加载
37
+ const isIdeMockData = !(dataSourceName && methodName) && ((_c = appCloud === null || appCloud === void 0 ? void 0 : appCloud.isInIde) === null || _c === void 0 ? void 0 : _c.call(appCloud)); // 在ide环境且未绑定数据源时,存在mock数据逻辑
38
+ const shouldBottomLoad = pagination === 'bottomLoad' &&
39
+ (entry === null || entry === void 0 ? void 0 : entry.isIntersecting) &&
40
+ ['', 'success'].includes(status); // 能否触底加载
43
41
  // 组件卸载时触发
44
42
  useEffect(() => {
45
43
  return () => {
@@ -50,16 +48,14 @@ export default function ListView(props) {
50
48
  }, []);
51
49
  // props 基本类型监听,需重新分页;处于 ide 且未绑定数据源时返回mock数据
52
50
  useEffect(() => {
53
- var _a, _b, _c;
51
+ var _a, _b;
54
52
  dataRef.current = { total: 0, records: [] };
55
- if ((isModel && (datasource === null || datasource === void 0 ? void 0 : datasource.name)) || (!isModel && (connectorMethod === null || connectorMethod === void 0 ? void 0 : connectorMethod.name))) {
53
+ if (!isIdeMockData) {
56
54
  fetchData({
57
- dataSourceName: isModel
58
- ? datasource === null || datasource === void 0 ? void 0 : datasource.name
59
- : (_a = bindConnectMetadata === null || bindConnectMetadata === void 0 ? void 0 : bindConnectMetadata.datasource) === null || _a === void 0 ? void 0 : _a.name,
55
+ dataSourceName,
60
56
  methodName,
61
57
  params: {
62
- ...(_b = paramRef.current) === null || _b === void 0 ? void 0 : _b.params,
58
+ ...(_a = paramRef.current) === null || _a === void 0 ? void 0 : _a.params,
63
59
  orderBy,
64
60
  orderType,
65
61
  pageNo: 1,
@@ -69,13 +65,19 @@ export default function ListView(props) {
69
65
  });
70
66
  }
71
67
  else {
72
- if (isIdeMockData) {
73
- (_c = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _c === void 0 ? void 0 : _c.call(events, {
74
- data: beforeDataChange(getIdeMockData(pageSize)),
75
- });
76
- }
68
+ (_b = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _b === void 0 ? void 0 : _b.call(events, {
69
+ data: beforeDataChange(getIdeMockData(pageSize)),
70
+ });
77
71
  }
78
- }, [methodName, pageSize, pagination, orderBy, orderType, datasource === null || datasource === void 0 ? void 0 : datasource.name]);
72
+ }, [
73
+ methodName,
74
+ dataSourceName,
75
+ pageSize,
76
+ pagination,
77
+ orderBy,
78
+ orderType,
79
+ isModel,
80
+ ]);
79
81
  // props 对象类型监听,需重新分页
80
82
  useEffect(() => {
81
83
  var _a, _b, _c, _d;
@@ -96,7 +98,7 @@ export default function ListView(props) {
96
98
  }
97
99
  }
98
100
  });
99
- // 监听触底加载事件,这里面的 setLoading 用 setTimeout包裹起来,所以会先执行新的children渲染,再执行 loading
101
+ // 监听触底加载事件
100
102
  useEffect(() => {
101
103
  var _a, _b;
102
104
  if (shouldBottomLoad && hasNextPage()) {
@@ -128,9 +130,7 @@ export default function ListView(props) {
128
130
  * 方法仅依赖入参和paramRef的参数
129
131
  */
130
132
  const fetchData = async (param) => {
131
- if (loading)
132
- return;
133
- setLoading(true);
133
+ var _a;
134
134
  // 合并参数
135
135
  const fetchParam = {
136
136
  ...paramRef.current,
@@ -139,6 +139,9 @@ export default function ListView(props) {
139
139
  };
140
140
  const { dataSourceName, methodName, params } = fetchParam;
141
141
  const { orderBy, orderType, pageNo, pageSize, where, connectorParams } = params || {};
142
+ if (status === 'loading' || !(dataSourceName && methodName))
143
+ return;
144
+ setStatus('loading');
142
145
  let tcbParams = {};
143
146
  // tcb分页参数
144
147
  if (!isNil(pageNo) && !isNil(pageSize)) {
@@ -160,22 +163,30 @@ export default function ListView(props) {
160
163
  }
161
164
  // tcb结果和事件
162
165
  let data = [];
163
- data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
164
- dataSourceName,
165
- methodName,
166
- params: tcbParams,
167
- }));
168
- paramRef.current = fetchParam;
169
- onEnvets(data);
166
+ const eventDatasource = isModel
167
+ ? datasource
168
+ : { ...bindConnectMetadata, ...connectorMethod };
169
+ try {
170
+ data = await (appCloud === null || appCloud === void 0 ? void 0 : appCloud.callDataSource({
171
+ dataSourceName,
172
+ methodName,
173
+ params: tcbParams,
174
+ }, true));
175
+ paramRef.current = fetchParam;
176
+ onEnvets(data, eventDatasource);
177
+ }
178
+ catch (e) {
179
+ setStatus(isModel ? 'fail' : '');
180
+ (_a = events === null || events === void 0 ? void 0 : events.queryFail) === null || _a === void 0 ? void 0 : _a.call(events, { datasource: eventDatasource, data: null });
181
+ }
170
182
  };
171
183
  /**
172
184
  * 根据fetchData方法返回值,回调给外部事件
173
- * datasource 是对象类型,所以总能拿到最新的值
174
185
  */
175
- const onEnvets = (data) => {
186
+ const onEnvets = (data, datasource) => {
176
187
  var _a, _b, _c, _d, _e, _f;
177
- const fetchRecords = [].concat(!isRecords && !isModel ? data : (data === null || data === void 0 ? void 0 : data.records) || []); //当数据详情调用连接器时,获取回调data数据
178
- const total = (data === null || data === void 0 ? void 0 : data.total) || fetchRecords.length;
188
+ const fetchRecords = [].concat(!isRecords && !isModel ? data : (data === null || data === void 0 ? void 0 : data.records) || []);
189
+ const total = (_a = data === null || data === void 0 ? void 0 : data.total) !== null && _a !== void 0 ? _a : fetchRecords.length;
179
190
  if (['loadMoreButton', 'bottomLoad'].includes(paramRef.current.pagination)) {
180
191
  dataRef.current = {
181
192
  total,
@@ -185,29 +196,24 @@ export default function ListView(props) {
185
196
  else {
186
197
  dataRef.current = { total, records: fetchRecords };
187
198
  }
188
- (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, {
199
+ (_b = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _b === void 0 ? void 0 : _b.call(events, {
189
200
  data: beforeDataChange(dataRef.current.records || []),
190
201
  });
191
- const eventDatSource = isModel
192
- ? datasource
193
- : { ...bindConnectMetadata, ...connectorMethod };
194
- if (JSON.stringify(data) === '{}') {
195
- (_b = events === null || events === void 0 ? void 0 : events.queryFail) === null || _b === void 0 ? void 0 : _b.call(events, { datasource: eventDatSource });
202
+ if (total === 0) {
203
+ (_c = events === null || events === void 0 ? void 0 : events.queryEmpty) === null || _c === void 0 ? void 0 : _c.call(events, {
204
+ datasource,
205
+ data: beforeDataChange([]),
206
+ });
207
+ setStatus(isModel ? 'empty' : '');
196
208
  }
197
209
  else {
198
- if (total === 0) {
199
- (_c = events === null || events === void 0 ? void 0 : events.queryEmpty) === null || _c === void 0 ? void 0 : _c.call(events, {
200
- datasource: eventDatSource,
201
- data: beforeDataChange([]),
202
- });
203
- }
204
- (_d = events === null || events === void 0 ? void 0 : events.querySuccess) === null || _d === void 0 ? void 0 : _d.call(events, {
205
- datasource: eventDatSource,
206
- data: beforeDataChange(dataRef.current.records),
207
- });
210
+ window.setTimeout(() => setStatus('success'), pagination === 'bottomLoad' ? 150 : 0);
208
211
  }
212
+ (_d = events === null || events === void 0 ? void 0 : events.querySuccess) === null || _d === void 0 ? void 0 : _d.call(events, {
213
+ datasource,
214
+ data: beforeDataChange(dataRef.current.records),
215
+ });
209
216
  setPageNo(((_f = (_e = paramRef.current) === null || _e === void 0 ? void 0 : _e.params) === null || _f === void 0 ? void 0 : _f.pageNo) || 1);
210
- window.setTimeout(() => setLoading(false));
211
217
  };
212
218
  /**
213
219
  * 分页,加载更多
@@ -217,23 +223,24 @@ export default function ListView(props) {
217
223
  if (isIdeMockData) {
218
224
  disabled = false;
219
225
  }
220
- return (!disabled &&
221
- (loading ? (LoadingSymbol) : (React.createElement("div", { className: `${BLOCK_NAME}__more-text`, onClick: () => fetchData({ params: { pageNo: pageNo + 1 } }) }, "\u52A0\u8F7D\u66F4\u591A"))));
226
+ if (status === 'loading')
227
+ return LoadingSymbol;
228
+ return (!disabled && (React.createElement("div", { className: `${BLOCK_NAME}__more-text`, onClick: () => fetchData({ params: { pageNo: pageNo + 1 } }) }, "\u52A0\u8F7D\u66F4\u591A")));
222
229
  };
223
230
  /**
224
231
  * 分页,底部刷新
225
232
  */
226
233
  const renderBottomLoad = () => {
227
- return (React.createElement("div", { ref: nodeRefCallback, className: `${BLOCK_NAME}__bottom-load` }, loading ? LoadingSymbol : !hasNextPage() && LoadEnd));
234
+ return (React.createElement("div", { ref: nodeRefCallback, className: `${BLOCK_NAME}__bottom-load` }, status === 'loading' ? LoadingSymbol : !hasNextPage() && LoadEnd));
228
235
  };
229
236
  /**
230
237
  * 分页,分页器,含ideMockData的判断
231
238
  */
232
239
  const renderPagination = () => {
233
- var _a;
240
+ var _a, _b;
234
241
  const preDisabeld = pageNo <= 1;
235
242
  const nextDisabeld = !hasNextPage();
236
- const total = ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.total) || 0;
243
+ const total = (_b = (_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.total) !== null && _b !== void 0 ? _b : 0;
237
244
  return (React.createElement("div", { className: `${BLOCK_NAME}__more-pagination` },
238
245
  React.createElement("div", { className: classNames(`${BLOCK_NAME}__pagination-pre`, preDisabeld ? '' : 'active'), onClick: () => !preDisabeld && fetchData({ params: { pageNo: pageNo - 1 } }) }, "\u4E0A\u4E00\u9875"),
239
246
  React.createElement("div", { className: classNames(`${BLOCK_NAME}__pagination-text`) },
@@ -242,6 +249,19 @@ export default function ListView(props) {
242
249
  isIdeMockData ? 1 : Math.ceil(total / pageSize)),
243
250
  React.createElement("div", { className: classNames(`${BLOCK_NAME}__pagination-next`, nextDisabeld ? '' : 'active'), onClick: () => !nextDisabeld && fetchData({ params: { pageNo: pageNo + 1 } }) }, "\u4E0B\u4E00\u9875")));
244
251
  };
252
+ /**
253
+ * 查询状态展示
254
+ */
255
+ const renderStatus = () => {
256
+ switch (status) {
257
+ case 'empty':
258
+ return React.createElement("div", { className: `${BLOCK_NAME}__empty` }, "\u6682\u65E0\u6570\u636E");
259
+ case 'fail':
260
+ return React.createElement("div", { className: `${BLOCK_NAME}__fail` }, "\u52A0\u8F7D\u5931\u8D25");
261
+ case 'loading':
262
+ return (pagination === 'pagination' && (React.createElement("div", { className: classNames(`${BLOCK_NAME}__more`, `${BLOCK_NAME}__content-loading`) }, LoadingSymbol)));
263
+ }
264
+ };
245
265
  /**
246
266
  * 加载中状态组件
247
267
  */
@@ -254,7 +274,11 @@ export default function ListView(props) {
254
274
  */
255
275
  const LoadEnd = React.createElement("div", null);
256
276
  return (React.createElement("div", { ...rest, className: classNames('weda-ui', `${BLOCK_NAME}__containor`, className) },
257
- children && (React.createElement("div", { className: template === 'cardList' ? `${BLOCK_NAME}-card` : '' }, children)),
277
+ children && (React.createElement("div", { className: classNames(template === 'cardList' ? `${BLOCK_NAME}-card` : '', `${BLOCK_NAME}__content`, ['empty', 'fail'].includes(status) && isSetStatus
278
+ ? `${BLOCK_NAME}__content-blank`
279
+ : '') },
280
+ children,
281
+ isSetStatus && renderStatus())),
258
282
  React.createElement("div", { className: classNames(`${BLOCK_NAME}__more`, `${BLOCK_NAME}__more-${pagination}`) },
259
283
  pagination === 'bottomLoad' && renderBottomLoad(),
260
284
  pagination === 'loadMoreButton' && renderLoadMore(),