@cloudbase/weda-ui 0.2.17 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/package.json +10 -5
- package/src/configs/components/button.json +0 -2
- package/src/configs/components/calendar.json +9 -3
- package/src/configs/components/carousel.json +18 -9
- package/src/configs/components/chart/bar.json +31 -12
- package/src/configs/components/chart/line.json +27 -10
- package/src/configs/components/chart/pie.json +22 -8
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +31 -11
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +123 -4
- package/src/configs/components/form/select.json +247 -13
- package/src/configs/components/graphicCard.json +90 -75
- package/src/configs/components/image.json +19 -8
- package/src/configs/components/link.json +25 -6
- package/src/configs/components/listView.json +83 -27
- package/src/configs/components/lottery.json +153 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +97 -79
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +6 -2
- package/src/configs/components/scrollVeiw.json +98 -34
- package/src/configs/components/swiper.json +22 -10
- package/src/configs/components/tabs.json +54 -9
- package/src/configs/components/text.json +43 -30
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +13 -0
- package/src/docs/common/format.tsx +112 -0
- package/src/docs/common/tableView.css +164 -0
- package/src/docs/common/tableView.tsx +273 -0
- package/src/docs/compsdocs/chart/Bar.mdx +159 -0
- package/src/docs/compsdocs/chart/Line.mdx +100 -0
- package/src/docs/compsdocs/chart/Pie.mdx +83 -0
- package/src/docs/compsdocs/chart/_category_.json +1 -0
- package/src/docs/compsdocs/chart/statisticsCard.mdx +51 -0
- package/src/docs/compsdocs/database/DataView.mdx +33 -0
- package/src/docs/compsdocs/database/ListView.mdx +33 -0
- package/src/docs/compsdocs/database/_category_.json +1 -0
- package/src/docs/compsdocs/form/Form.mdx +35 -0
- package/src/docs/compsdocs/form/FormCheckbox.mdx +35 -0
- package/src/docs/compsdocs/form/FormDate.mdx +30 -0
- package/src/docs/compsdocs/form/FormEmail.mdx +30 -0
- package/src/docs/compsdocs/form/FormImageUploader.mdx +31 -0
- package/src/docs/compsdocs/form/FormInput.mdx +30 -0
- package/src/docs/compsdocs/form/FormLocation.mdx +64 -0
- package/src/docs/compsdocs/form/FormPhone.mdx +30 -0
- package/src/docs/compsdocs/form/FormRadio.mdx +35 -0
- package/src/docs/compsdocs/form/FormRegion.mdx +30 -0
- package/src/docs/compsdocs/form/FormSelect.mdx +36 -0
- package/src/docs/compsdocs/form/FormSwitch.mdx +30 -0
- package/src/docs/compsdocs/form/FormTextarea.mdx +30 -0
- package/src/docs/compsdocs/form/FormTime.mdx +30 -0
- package/src/docs/compsdocs/form/FormUploadFile.mdx +30 -0
- package/src/docs/compsdocs/form/FormUrl.mdx +30 -0
- package/src/docs/compsdocs/form/_category_.json +1 -0
- package/src/docs/compsdocs/grid/Card.mdx +32 -0
- package/src/docs/compsdocs/grid/Container.mdx +42 -0
- package/src/docs/compsdocs/grid/Footer.mdx +31 -0
- package/src/docs/compsdocs/grid/GridLayout.mdx +32 -0
- package/src/docs/compsdocs/grid/Header.mdx +31 -0
- package/src/docs/compsdocs/grid/Layout.mdx +25 -0
- package/src/docs/compsdocs/grid/List.mdx +31 -0
- package/src/docs/compsdocs/grid/ScrollView.mdx +37 -0
- package/src/docs/compsdocs/grid/Swiper.mdx +58 -0
- package/src/docs/compsdocs/grid/_category_.json +1 -0
- package/src/docs/compsdocs/media/Icon.mdx +31 -0
- package/src/docs/compsdocs/media/Image.mdx +55 -0
- package/src/docs/compsdocs/media/_category_.json +1 -0
- package/src/docs/compsdocs/model/ModelCreate.mdx +20 -0
- package/src/docs/compsdocs/model/ModelDetail.mdx +20 -0
- package/src/docs/compsdocs/model/ModelTable.mdx +24 -0
- package/src/docs/compsdocs/model/ModelUpdate.mdx +21 -0
- package/src/docs/compsdocs/model/PageLayout.mdx +21 -0
- package/src/docs/compsdocs/model/_category_.json +1 -0
- package/src/docs/compsdocs/navmenu/Classification.mdx +38 -0
- package/src/docs/compsdocs/navmenu/NavBar.mdx +43 -0
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +30 -0
- package/src/docs/compsdocs/navmenu/TabBar.mdx +43 -0
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +29 -0
- package/src/docs/compsdocs/navmenu/_category_.json +1 -0
- package/src/docs/compsdocs/senior/Lottery.mdx +48 -0
- package/src/docs/compsdocs/senior/Modal.mdx +58 -0
- package/src/docs/compsdocs/senior/SlotMachine.mdx +52 -0
- package/src/docs/compsdocs/senior/_category_.json +1 -0
- package/src/docs/compsdocs/show/Calendar.mdx +29 -0
- package/src/docs/compsdocs/show/Divider.mdx +31 -0
- package/src/docs/compsdocs/show/GraphicCard.mdx +30 -0
- package/src/docs/compsdocs/show/Item.mdx +32 -0
- package/src/docs/compsdocs/show/ItemList.mdx +47 -0
- package/src/docs/compsdocs/show/Media.mdx +25 -0
- package/src/docs/compsdocs/show/StatusTip.mdx +25 -0
- package/src/docs/compsdocs/show/Swiper.mdx +33 -0
- package/src/docs/compsdocs/show/Tabs.mdx +38 -0
- package/src/docs/compsdocs/show/_category_.json +1 -0
- package/src/docs/compsdocs/show/button.mdx +25 -0
- package/src/docs/compsdocs/text/Link.mdx +43 -0
- package/src/docs/compsdocs/text/RichTextView.mdx +36 -0
- package/src/docs/compsdocs/text/Text.mdx +31 -0
- package/src/docs/compsdocs/text/Title.mdx +32 -0
- package/src/docs/compsdocs/text/_category_.json +1 -0
- package/src/docs/compsdocs/wxOpen/Phone.mdx +60 -0
- package/src/docs/compsdocs/wxOpen/Share.mdx +46 -0
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +60 -0
- package/src/docs/compsdocs/wxOpen/_category_.json +4 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.js +18 -2
- package/src/mp/components/button/index.wxml +7 -4
- package/src/mp/components/chart/bar/index.js +6 -2
- package/src/mp/components/chart/common/core/eChartBar.js +9 -8
- package/src/mp/components/chart/common/core/eChartBase.js +20 -16
- package/src/mp/components/chart/common/core/eChartLine.js +6 -5
- package/src/mp/components/chart/line/index.js +10 -6
- package/src/mp/components/chart/pie/index.js +6 -2
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/dataView/index.json +1 -1
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/form/index.wxml +1 -2
- package/src/mp/components/form/formcell/index.wxml +1 -1
- package/src/mp/components/form/formcell/index.wxss +17 -0
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/input/index.wxss +15 -0
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/location/index.wxss +4 -6
- package/src/mp/components/form/radio/index.js +34 -1
- package/src/mp/components/form/select/index.js +351 -41
- package/src/mp/components/form/select/index.wxml +17 -2
- package/src/mp/components/form/select/index.wxss +4 -0
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.js +1 -1
- package/src/mp/components/form/textarea/index.wxss +4 -0
- package/src/mp/components/form/uploader/index.js +39 -27
- package/src/mp/components/form/uploader/index.json +3 -2
- package/src/mp/components/form/uploader/index.wxml +11 -7
- package/src/mp/components/form/uploader/index.wxss +20 -2
- package/src/mp/components/form/uploader/weui-uploader.js +209 -0
- package/src/mp/components/form/uploader/weui-uploader.json +7 -0
- package/src/mp/components/form/uploader/weui-uploader.wxml +45 -0
- package/src/mp/components/form/uploader/weui-uploader.wxss +1 -0
- package/src/mp/components/form/uploaderFile/index.js +10 -6
- package/src/mp/components/form/uploaderFile/index.wxss +4 -4
- package/src/mp/components/image/index.wxss +3 -2
- package/src/mp/components/listView/index.js +38 -43
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/{internals/listView → lottery}/index.json +0 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +7 -1
- package/src/mp/style/weda-ui.wxss +16 -0
- package/src/mp/utils/constant.js +15 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/lodash.js +2 -0
- package/src/mp/utils/platform.js +10 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +10 -9
- package/src/web/components/calendar/index.jsx +1 -1
- package/src/web/components/carousel/index.tsx +8 -8
- package/src/web/components/chart/bar/index.tsx +40 -39
- package/src/web/components/chart/common/config/line.js +1 -1
- package/src/web/components/chart/common/core/eChartBar.js +7 -6
- package/src/web/components/chart/common/core/eChartBase.ts +20 -16
- package/src/web/components/chart/common/core/eChartLine.js +8 -6
- package/src/web/components/chart/line/index.tsx +40 -39
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +61 -23
- package/src/web/components/form/form/index.css +5 -1
- package/src/web/components/form/form/index.tsx +3 -1
- package/src/web/components/form/formcell/index.css +22 -1
- package/src/web/components/form/formcell/index.tsx +11 -6
- package/src/web/components/form/input/index.css +7 -12
- package/src/web/components/form/location/components/LocationH5/index.css +4 -7
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +1 -1
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +370 -73
- package/src/web/components/form/select/index.css +15 -0
- package/src/web/components/form/select/index.tsx +392 -145
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +89 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/textarea/index.css +4 -0
- package/src/web/components/form/textarea/index.tsx +2 -2
- package/src/web/components/form/tips/index.css +4 -0
- package/src/web/components/form/tips/index.tsx +4 -3
- package/src/web/components/form/uploader/index.css +26 -2
- package/src/web/components/form/uploader/uploader.h5.tsx +89 -57
- package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
- package/src/web/components/form/uploaderFile/index.css +2 -4
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.css +3 -3
- package/src/web/components/image/index.tsx +6 -7
- package/src/web/components/index.js +8 -0
- package/src/web/components/link/index.tsx +7 -4
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +12 -20
- package/src/web/components/lottery/index.css +327 -0
- package/src/web/components/lottery/index.tsx +567 -0
- package/src/web/components/lottery/lotteryUtil.ts +130 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.tsx +2 -2
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +230 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/picker/timePicker.tsx +2 -2
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/slot/index.tsx +1 -1
- package/src/web/components/tabs/index.tsx +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +12 -20
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/{constant.js → constant.ts} +17 -2
- package/src/web/utils/lodash.ts +2 -0
- package/src/web/utils/platform.js +9 -0
- package/src/web/utils/tcb.js +26 -0
- package/src/web/weda-ui.css +7 -1
- package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
- package/src/mp/components/internals/listView/index.js +0 -286
- package/src/mp/components/internals/listView/index.wxml +0 -40
- package/src/mp/components/internals/listView/index.wxss +0 -150
- package/src/mp/components/internals/listView/more-line.svg +0 -3
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as _moment from 'moment';
|
|
3
|
-
|
|
4
2
|
import weui from '../../../utils/weui';
|
|
5
3
|
import classNames from '../../../utils/classnames';
|
|
6
4
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { regionPicker,getRegionTree,getAreaCode } from './region/index';
|
|
6
|
+
import { PropsType , defaultProps , moment } from './index';
|
|
7
|
+
import { timePicker, yearPicker, monthPicker } from './time';
|
|
8
|
+
import { callDataSource, callWedaApi } from '../../../utils/tcb';
|
|
9
|
+
import destr from 'destr';
|
|
10
|
+
import { REL_DICT } from '../../../utils/constant';
|
|
11
|
+
import { isNil } from '../../../utils/lodash';
|
|
11
12
|
|
|
12
|
-
// @ts-expect-error TODO: fix 与plugin构建阶段效果不同
|
|
13
|
-
const moment = (typeof _moment === 'function' ? _moment : _moment.default) as _moment.moment;
|
|
14
13
|
export default function Select({
|
|
15
14
|
// 系统属性
|
|
16
|
-
events,
|
|
15
|
+
events = {change: null },
|
|
17
16
|
// 组件属性
|
|
18
17
|
name,
|
|
19
18
|
placeholder,
|
|
20
19
|
layout,
|
|
21
20
|
mode,
|
|
21
|
+
dateMode = 'day',
|
|
22
22
|
disabled = false,
|
|
23
23
|
// selector mode
|
|
24
24
|
range = defaultProps.range,
|
|
25
|
+
where,
|
|
26
|
+
primaryField,
|
|
27
|
+
tipBlock,
|
|
28
|
+
enumName,
|
|
29
|
+
dataSourceName,
|
|
30
|
+
viewId,
|
|
31
|
+
format,
|
|
25
32
|
defaultValue,
|
|
26
33
|
// date mode
|
|
27
34
|
startDate,
|
|
@@ -33,29 +40,38 @@ export default function Select({
|
|
|
33
40
|
defaultTime,
|
|
34
41
|
// region mode
|
|
35
42
|
defaultRegion,
|
|
43
|
+
defaultMutiRegion,
|
|
44
|
+
regionType,
|
|
36
45
|
separator,
|
|
46
|
+
onChange
|
|
47
|
+
//regionTree,
|
|
37
48
|
}: PropsType) {
|
|
38
49
|
const [date, setDate] = React.useState(
|
|
39
|
-
decodeIsoDatetime(defaultDate, 'date')
|
|
50
|
+
decodeIsoDatetime(defaultDate, 'date', dateMode)
|
|
40
51
|
);
|
|
41
52
|
const [time, setTime] = React.useState(
|
|
42
53
|
decodeIsoDatetime(defaultTime, 'time')
|
|
43
54
|
);
|
|
44
|
-
const [
|
|
45
|
-
|
|
46
|
-
);
|
|
55
|
+
const [regioDepth,setRegionDepth] = React.useState(3);
|
|
56
|
+
const [regionData,setRegionData] = React.useState([]);
|
|
57
|
+
const [regionTree,setRegionTree] = React.useState([]);
|
|
58
|
+
const [region, setRegion] = React.useState(defaultRegion);
|
|
59
|
+
const [mutiRegion,setMutiRegion]=React.useState([]);
|
|
60
|
+
const [typeRegion, setTypeRegion] = React.useState(regionType);
|
|
47
61
|
const [selectedValue, setSelectedValue] = React.useState(defaultValue);
|
|
62
|
+
const [option, setOption] = React.useState([{ label: '', value: '' }]);
|
|
63
|
+
const [records, setRecords] = React.useState([]);
|
|
48
64
|
|
|
49
65
|
// 两次默认值不同, 需要刷新
|
|
50
66
|
const prevDefaultRef = React.useRef<any>({});
|
|
51
|
-
React.useEffect(() => {
|
|
67
|
+
React.useEffect( () => {
|
|
52
68
|
let hasChange = false;
|
|
53
69
|
if (prevDefaultRef.current?.defaultValue !== defaultValue) {
|
|
54
70
|
setSelectedValue(defaultValue);
|
|
55
71
|
hasChange = true;
|
|
56
72
|
}
|
|
57
73
|
if (prevDefaultRef.current?.defaultDate !== defaultDate) {
|
|
58
|
-
setDate(decodeIsoDatetime(defaultDate, 'date'));
|
|
74
|
+
setDate(decodeIsoDatetime(defaultDate, 'date', dateMode));
|
|
59
75
|
hasChange = true;
|
|
60
76
|
}
|
|
61
77
|
if (prevDefaultRef.current?.defaultTime !== defaultTime) {
|
|
@@ -66,14 +82,168 @@ export default function Select({
|
|
|
66
82
|
setRegion(defaultRegion);
|
|
67
83
|
hasChange = true;
|
|
68
84
|
}
|
|
85
|
+
if (!isObjectEqual(prevDefaultRef.current?.defaultMutiRegion, defaultMutiRegion)) {
|
|
86
|
+
|
|
87
|
+
//setMutiRegion((defaultMutiRegion || ".").split(','));
|
|
88
|
+
setMutiRegion(defaultMutiRegion?defaultMutiRegion.split(','):[]);
|
|
89
|
+
hasChange = true;
|
|
90
|
+
}
|
|
91
|
+
if (prevDefaultRef.current?.regionType !== regionType) {
|
|
92
|
+
setTypeRegion(regionType);
|
|
93
|
+
hasChange = true;
|
|
94
|
+
}
|
|
69
95
|
if (hasChange) {
|
|
70
96
|
prevDefaultRef.current = {
|
|
97
|
+
defaultValue,
|
|
71
98
|
defaultDate,
|
|
72
99
|
defaultTime,
|
|
73
100
|
defaultRegion,
|
|
101
|
+
defaultMutiRegion
|
|
74
102
|
};
|
|
75
103
|
}
|
|
104
|
+
|
|
76
105
|
});
|
|
106
|
+
//实现初始值触发change事件
|
|
107
|
+
const defaultMutiRegionChange = function(treeValue,defaultMutiRegion){
|
|
108
|
+
const defaultValue =defaultMutiRegion?defaultMutiRegion.split(','):null;
|
|
109
|
+
const changeValue=[];
|
|
110
|
+
if(Array.isArray(defaultValue)&&defaultValue.length>0){
|
|
111
|
+
defaultValue.forEach(element => {
|
|
112
|
+
treeValue.map((item)=>{
|
|
113
|
+
if(item?.Value == element){
|
|
114
|
+
changeValue.push({
|
|
115
|
+
value:item?.Value,
|
|
116
|
+
code:item?.Code
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
events?.change?.({ value:defaultMutiRegion,result:changeValue });
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const regionTreeMode = React.useMemo(()=>{
|
|
127
|
+
if((mode=='region'|| mode=='mutiRegion')){
|
|
128
|
+
if(regionData.length<1){
|
|
129
|
+
getAreaCode().then((value)=>{
|
|
130
|
+
defaultMutiRegionChange(value,defaultMutiRegion);
|
|
131
|
+
setRegionData(value);
|
|
132
|
+
getRegionTree(value,regionType,mode).then(tree=>{
|
|
133
|
+
setRegionTree(tree);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}else{
|
|
137
|
+
getRegionTree(regionData,regionType,mode).then(tree=>{
|
|
138
|
+
setRegionTree(tree);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
switch(regionType){
|
|
143
|
+
case 'levelOne':{
|
|
144
|
+
setRegionDepth(1);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case 'levelTwo':{
|
|
148
|
+
setRegionDepth(2);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 'levelThree':{
|
|
152
|
+
setRegionDepth(3);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
default: {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
},[regionType,mode,regionData]);
|
|
161
|
+
|
|
162
|
+
React.useEffect(() => {
|
|
163
|
+
// tcb过滤参数
|
|
164
|
+
const whereEffected = [].concat(getWhereList(where));
|
|
165
|
+
if ((format === 'father-son' || format === 'related') && dataSourceName && viewId) {
|
|
166
|
+
fetchData({
|
|
167
|
+
dataSourceName: dataSourceName,
|
|
168
|
+
viewId: viewId,
|
|
169
|
+
methodName: 'wedaGetRecords',
|
|
170
|
+
params: whereEffected
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}, [where]);
|
|
174
|
+
|
|
175
|
+
// 获取数据列表中主列字段,将其作为选项
|
|
176
|
+
React.useEffect(() => {
|
|
177
|
+
if (records && records.length !== 0 && primaryField) {
|
|
178
|
+
const option = records.map(item => {
|
|
179
|
+
return {
|
|
180
|
+
label: item[primaryField],
|
|
181
|
+
value: item._id
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
setOption(option);
|
|
185
|
+
}
|
|
186
|
+
}, [records]);
|
|
187
|
+
|
|
188
|
+
// 获取数据列表
|
|
189
|
+
const fetchData = async (param: {
|
|
190
|
+
dataSourceName?: string,
|
|
191
|
+
viewId?: string,
|
|
192
|
+
methodName?: string,
|
|
193
|
+
params?: any,
|
|
194
|
+
}) => {
|
|
195
|
+
let pageNo = 1;
|
|
196
|
+
let pageSize = 200;
|
|
197
|
+
let records = [];
|
|
198
|
+
let total = 99999;
|
|
199
|
+
for (let index = 0; index < Math.floor(total / pageSize) + 1; index++) {
|
|
200
|
+
let data = await callDataSource({
|
|
201
|
+
dataSourceName: param.dataSourceName,
|
|
202
|
+
viewId: param.viewId,
|
|
203
|
+
methodName: param.methodName,
|
|
204
|
+
params: {
|
|
205
|
+
where: param.params,
|
|
206
|
+
pageNo: pageNo,
|
|
207
|
+
pageSize: pageSize
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
pageNo = pageNo + 1;
|
|
211
|
+
if (data?.records) {
|
|
212
|
+
total = data?.total || 0;
|
|
213
|
+
records = records.concat(data?.records);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (records) {
|
|
219
|
+
setRecords(records);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
React.useEffect(() => {
|
|
224
|
+
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
225
|
+
if (format === 'x-enum' && enumName) {
|
|
226
|
+
fetchEnumData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
|
|
227
|
+
}
|
|
228
|
+
}, [enumName]);
|
|
229
|
+
|
|
230
|
+
// 获取自定义选项集
|
|
231
|
+
const fetchEnumData = async (param:
|
|
232
|
+
{ OptNameList?: object, PageIndex?: number, PageSize?: number }
|
|
233
|
+
) => {
|
|
234
|
+
let data = await callWedaApi({
|
|
235
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
236
|
+
data: param,
|
|
237
|
+
});
|
|
238
|
+
const config = destr(data?.Items[0]?.Config) ?? [];
|
|
239
|
+
const enumOption = config.map(item => {
|
|
240
|
+
return {
|
|
241
|
+
label: item.value,
|
|
242
|
+
value: item.key,
|
|
243
|
+
};
|
|
244
|
+
});
|
|
245
|
+
setOption(enumOption);
|
|
246
|
+
};
|
|
77
247
|
|
|
78
248
|
const isFlex = layout !== 'vertical';
|
|
79
249
|
const subCls = classNames({
|
|
@@ -91,20 +261,26 @@ export default function Select({
|
|
|
91
261
|
!!date && (options.defaultDate = date);
|
|
92
262
|
!!startDate && (options.start = decodeIsoDatetime(startDate, 'date'));
|
|
93
263
|
!!endDate && (options.end = decodeIsoDatetime(endDate, 'date'));
|
|
264
|
+
if (['year', 'month'].includes(dateMode)) {
|
|
265
|
+
!!startDate && (options.startDate = startDate);
|
|
266
|
+
!!endDate && (options.endDate = endDate);
|
|
267
|
+
}
|
|
268
|
+
options.onConfirm = (result) => {
|
|
269
|
+
const value = formatDateModeValue(result, dateMode);
|
|
270
|
+
setDate(value);
|
|
271
|
+
events.change({ value: new Date(value).getTime() });
|
|
272
|
+
};
|
|
94
273
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
...options
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
events.change({ value: new Date(value).getTime() });
|
|
106
|
-
},
|
|
107
|
-
});
|
|
274
|
+
if (dateMode === 'year') {
|
|
275
|
+
// 年,1 列
|
|
276
|
+
yearPicker({ ...options });
|
|
277
|
+
} else if (dateMode === 'month') {
|
|
278
|
+
// 年月,2 列
|
|
279
|
+
monthPicker({ ...options });
|
|
280
|
+
} else {
|
|
281
|
+
// 年月日,3 列
|
|
282
|
+
weui.datePicker({ id: String(Date.now()), ...options });
|
|
283
|
+
}
|
|
108
284
|
};
|
|
109
285
|
|
|
110
286
|
const onTimeClick = function () {
|
|
@@ -121,42 +297,112 @@ export default function Select({
|
|
|
121
297
|
const date = moment().hour(result[0].value).minute(result[1].value);
|
|
122
298
|
const value = date.format('HH:mm');
|
|
123
299
|
setTime(value);
|
|
124
|
-
events
|
|
300
|
+
events?.change({
|
|
125
301
|
value: (date.hour() * 60 * 60 + date.minute() * 60) * 1000,
|
|
126
302
|
});
|
|
127
303
|
},
|
|
128
304
|
});
|
|
129
305
|
};
|
|
130
306
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
307
|
+
const getWhereList = (where) => {
|
|
308
|
+
let result = [];
|
|
309
|
+
Array.isArray(where) &&
|
|
310
|
+
where.forEach((item1) => {
|
|
311
|
+
if (item1?.groupLogic !== 'or' && Array.isArray(item1?.logicData)) {
|
|
312
|
+
item1?.logicData.forEach((item2) => {
|
|
313
|
+
let [rel, val] = [REL_DICT[item2?.rel], item2?.value];
|
|
314
|
+
if ('_begin_with' === rel) {
|
|
315
|
+
rel = 'regex';
|
|
316
|
+
val = `^${val}`;
|
|
317
|
+
}
|
|
318
|
+
if ('_exclude' === rel) {
|
|
319
|
+
rel = 'regex';
|
|
320
|
+
val = `^((?!${val}).)*$`;
|
|
321
|
+
}
|
|
322
|
+
if (item2?.logic !== 'or' && item2?.key && rel && !isNil(val)) {
|
|
323
|
+
result.push({ key: item2.key, rel, val });
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
return result;
|
|
142
329
|
};
|
|
143
330
|
|
|
331
|
+
const onSelect = function () {
|
|
332
|
+
if (format === 'father-son' || format === 'related' || format === 'x-enum') {
|
|
333
|
+
weui.picker(option, {
|
|
334
|
+
id: String(Date.now()),
|
|
335
|
+
defaultValue: [selectedValue || option[0].value],
|
|
336
|
+
onConfirm(result) {
|
|
337
|
+
const item = result[0];
|
|
338
|
+
setSelectedValue(item?.value);
|
|
339
|
+
events.change({ value: item?.value });
|
|
340
|
+
},
|
|
341
|
+
className: 'weda-ui weda-picker',
|
|
342
|
+
});
|
|
343
|
+
} else {
|
|
344
|
+
weui.picker(range, {
|
|
345
|
+
id: String(Date.now()),
|
|
346
|
+
defaultValue: [selectedValue || range[0].value],
|
|
347
|
+
onConfirm(result) {
|
|
348
|
+
const item = result[0];
|
|
349
|
+
setSelectedValue(item?.value);
|
|
350
|
+
events.change({ value: item?.value });
|
|
351
|
+
},
|
|
352
|
+
className: 'weda-ui weda-picker',
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
let regionTimer;
|
|
357
|
+
const momentClick =async () => {
|
|
358
|
+
regionTimer = setInterval(() => {
|
|
359
|
+
setTimeout(()=>{
|
|
360
|
+
if(regionTree.length!=0){
|
|
361
|
+
onRegionClick();
|
|
362
|
+
}
|
|
363
|
+
}, 0);
|
|
364
|
+
}, regionTree.length==0?500:0);
|
|
365
|
+
};
|
|
144
366
|
const onRegionClick = function () {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
367
|
+
clearInterval(regionTimer);
|
|
368
|
+
let defaultValue=[];
|
|
369
|
+
if(mode=='region'){
|
|
370
|
+
defaultRegion && defaultRegion.length <= 0
|
|
371
|
+
? defaultValue=['北京市', '北京市', '东城区']
|
|
372
|
+
: defaultValue= defaultRegion;
|
|
373
|
+
}else{
|
|
374
|
+
mutiRegion && mutiRegion.length <= 0
|
|
375
|
+
? defaultValue=['北京市', '北京市', '东城区']
|
|
376
|
+
: defaultValue= mutiRegion;
|
|
377
|
+
}
|
|
378
|
+
regionPicker(
|
|
379
|
+
{
|
|
380
|
+
defaultValue:defaultValue,
|
|
381
|
+
depth:regioDepth,
|
|
382
|
+
onConfirm(result) {
|
|
383
|
+
const value = result.map((item) => item.value);
|
|
384
|
+
//const value=regionValueSplit(typeRegion,defaultvalue);
|
|
385
|
+
mode=='region'?setRegion(value):setMutiRegion(value);
|
|
386
|
+
const changeValue = mode=='region'?value:value.join(',');
|
|
387
|
+
onChange && onChange(changeValue);
|
|
388
|
+
events?.change?.({ value:changeValue,result:result.map((item)=>{
|
|
389
|
+
return {
|
|
390
|
+
value:item?.value,
|
|
391
|
+
code:item?.code
|
|
392
|
+
};
|
|
393
|
+
}) });
|
|
394
|
+
|
|
395
|
+
},
|
|
396
|
+
onChange(result) {
|
|
397
|
+
},
|
|
398
|
+
className: 'weda-ui weda-picker',
|
|
399
|
+
id: new Date().valueOf(),
|
|
400
|
+
},
|
|
401
|
+
regionTree
|
|
402
|
+
);
|
|
157
403
|
};
|
|
158
404
|
|
|
159
|
-
const onClick = function () {
|
|
405
|
+
const onClick =async function () {
|
|
160
406
|
if (disabled) {
|
|
161
407
|
return;
|
|
162
408
|
}
|
|
@@ -175,7 +421,11 @@ export default function Select({
|
|
|
175
421
|
break;
|
|
176
422
|
}
|
|
177
423
|
case 'region': {
|
|
178
|
-
|
|
424
|
+
momentClick();
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
case 'mutiRegion': {
|
|
428
|
+
momentClick();
|
|
179
429
|
break;
|
|
180
430
|
}
|
|
181
431
|
default: {
|
|
@@ -185,35 +435,42 @@ export default function Select({
|
|
|
185
435
|
};
|
|
186
436
|
|
|
187
437
|
const result = React.useMemo(() => {
|
|
438
|
+
let selectLabel = '';
|
|
439
|
+
if (format === 'father-son' || format === 'related' || format === 'x-enum') {
|
|
440
|
+
selectLabel = (option ?? []).find((item) => item.value === selectedValue)?.label;
|
|
441
|
+
} else {
|
|
442
|
+
selectLabel = (range ?? []).find((item) => item.value === selectedValue)?.label;
|
|
443
|
+
}
|
|
188
444
|
return {
|
|
189
|
-
selector:
|
|
445
|
+
selector: selectLabel,
|
|
190
446
|
date: date,
|
|
191
447
|
time: time,
|
|
192
448
|
region: (region || []).join(separator), // region 有可能是空串
|
|
449
|
+
mutiRegion:mutiRegion
|
|
193
450
|
};
|
|
194
|
-
}, [range, selectedValue, date, time, region, separator]);
|
|
451
|
+
}, [range, selectedValue, date, time, region, separator,mutiRegion]);
|
|
195
452
|
|
|
196
453
|
return (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
454
|
+
<div className={subCls}>
|
|
455
|
+
<div className="weui-cell__bd weui-flex">
|
|
456
|
+
<input
|
|
457
|
+
onClick={onClick}
|
|
458
|
+
className="weui-input"
|
|
459
|
+
type="select"
|
|
460
|
+
name={name}
|
|
461
|
+
placeholder={placeholder}
|
|
462
|
+
value={result[mode] ?? ''}
|
|
463
|
+
disabled={disabled}
|
|
464
|
+
autoComplete={'off'}
|
|
465
|
+
readOnly={true}
|
|
466
|
+
data-testid="form-item-select"
|
|
467
|
+
/>
|
|
211
468
|
</div>
|
|
469
|
+
</div>
|
|
212
470
|
);
|
|
213
471
|
}
|
|
214
472
|
|
|
215
|
-
|
|
216
|
-
export function decodeIsoDatetime(isoStringOrTimesnap, type) {
|
|
473
|
+
export function decodeIsoDatetime(isoStringOrTimesnap, type, dateMode = 'day') {
|
|
217
474
|
if (!isoStringOrTimesnap) {
|
|
218
475
|
return null;
|
|
219
476
|
}
|
|
@@ -249,6 +506,46 @@ export function decodeIsoDatetime(isoStringOrTimesnap, type) {
|
|
|
249
506
|
return moment(isoStringOrTimesnap).format('HH:mm');
|
|
250
507
|
}
|
|
251
508
|
} else {
|
|
252
|
-
return moment(isoStringOrTimesnap).format(
|
|
509
|
+
return moment(isoStringOrTimesnap).format(getDateModeFormat(dateMode));
|
|
253
510
|
}
|
|
254
511
|
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* 根据时间模式,将 picker 返回的值转成对应的 年-月-日
|
|
515
|
+
*/
|
|
516
|
+
export const formatDateModeValue = (result = [], dateMode = 'day') => {
|
|
517
|
+
let [year, month, day] = [
|
|
518
|
+
result[0]?.value,
|
|
519
|
+
result[1]?.value || 1,
|
|
520
|
+
result[2]?.value || 1,
|
|
521
|
+
];
|
|
522
|
+
if (dateMode === 'year') {
|
|
523
|
+
month = 1;
|
|
524
|
+
day = 1;
|
|
525
|
+
}
|
|
526
|
+
if (dateMode === 'month') {
|
|
527
|
+
day = 1;
|
|
528
|
+
}
|
|
529
|
+
const value = moment()
|
|
530
|
+
.year(year)
|
|
531
|
+
.month(month - 1)
|
|
532
|
+
.date(day)
|
|
533
|
+
.format(getDateModeFormat(dateMode));
|
|
534
|
+
return value;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* 不同时间模式对应的展示格式
|
|
539
|
+
*/
|
|
540
|
+
export const getDateModeFormat = (dateMode = 'day') => {
|
|
541
|
+
switch (dateMode) {
|
|
542
|
+
case 'year':
|
|
543
|
+
return 'YYYY';
|
|
544
|
+
case 'month':
|
|
545
|
+
return 'YYYY-MM';
|
|
546
|
+
case 'day':
|
|
547
|
+
return 'YYYY-MM-DD';
|
|
548
|
+
default:
|
|
549
|
+
return 'YYYY-MM-DD';
|
|
550
|
+
}
|
|
551
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.weda-ui .weui-cell.weui-check__label {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
padding-left: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.year-picker__overlay {
|
|
7
|
+
width: 300px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.year-picker__overlay .year-picker__header {
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
align-items: center;
|
|
14
|
+
font-weight: 700;
|
|
15
|
+
}
|