@cloudbase/weda-ui 0.2.16 → 1.0.24
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 +41 -169
- package/package.json +23 -11
- package/src/configs/components/calendar.json +4 -1
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +21 -6
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/graphicCard.json +84 -73
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +19 -3
- package/src/configs/components/listView.json +65 -18
- package/src/configs/components/lottery.json +151 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +87 -75
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +4 -1
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- 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 +20 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.wxml +1 -2
- package/src/mp/components/chart/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- 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/input/index.js +1 -1
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +348 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +76 -44
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +61 -29
- package/src/mp/components/graphicCard/index.js +26 -28
- package/src/mp/components/listView/index.js +52 -64
- package/src/mp/components/listView/index.wxml +2 -2
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/lottery/index.json +4 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/navLayout/index.js +3 -3
- 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 +10 -1
- package/src/mp/style/weda-ui.wxss +2 -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 +25 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/chart/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- 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/formcell/index.tsx +10 -5
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +371 -72
- package/src/web/components/form/select/index.css +10 -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 +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- 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/uploader.h5.tsx +28 -19
- package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
- package/src/web/components/graphicCard/index.css +1 -5
- package/src/web/components/graphicCard/index.tsx +4 -3
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +13 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +10 -18
- 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/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 +231 -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/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/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 +6 -14
- 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 +10 -1
- package/src/web/utils/tcb.js +20 -6
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- 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,40 +1,131 @@
|
|
|
1
|
-
// 暂时把地区信息打包在本地, 后续移到COS桶内
|
|
2
|
-
import {provinces} from './provinces';
|
|
3
|
-
import {cities} from './cities';
|
|
4
|
-
import {regions} from './regions';
|
|
5
1
|
import weui from '../../../../utils/weui';
|
|
2
|
+
import { callWedaApi } from '../../../../utils/tcb';
|
|
6
3
|
|
|
7
4
|
let tree;
|
|
8
5
|
|
|
9
|
-
export function getRegionTree() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
6
|
+
export async function getRegionTree(regionData,regionType,regionMode) {
|
|
7
|
+
tree = [];
|
|
8
|
+
tree = formatTreeData(regionData,regionType,regionMode);
|
|
9
|
+
return tree;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function regionPicker(options,regionTree:any[]) {
|
|
13
|
+
const weRegionTree =regionTree.length==0?[{label:'地区数据加载中,请关闭弹窗后重试',value:null,children:null}]:regionTree;
|
|
14
|
+
weui.picker(weRegionTree, options);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 获取运行态地区数据
|
|
18
|
+
*/
|
|
19
|
+
export async function getAreaCode() {
|
|
20
|
+
try {
|
|
21
|
+
const res = await callWedaApi({
|
|
22
|
+
action: 'QueryRuntimeAreaCode',
|
|
23
|
+
data: {Mask: "11100"},
|
|
32
24
|
});
|
|
25
|
+
return res?.AreaCodeList;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('错误', error);
|
|
28
|
+
return {};
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
return tree;
|
|
36
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* 构建树形结构
|
|
33
|
+
*/
|
|
34
|
+
function formatTreeData(arr,regionType,regionMode) {
|
|
35
|
+
let provicesData = [];
|
|
36
|
+
arr.forEach(item=>{
|
|
37
|
+
//省数据集合
|
|
38
|
+
if(item?.Type==1&&item?.Deprecated==false){
|
|
39
|
+
provicesData.push({
|
|
40
|
+
label: item.Value,
|
|
41
|
+
value: item.Value,
|
|
42
|
+
code:item.Code,
|
|
43
|
+
type:item.Type,
|
|
44
|
+
centralCity:item.CentralCity,
|
|
45
|
+
children: regionType!= 'levelOne'||regionMode=='region'?[{
|
|
46
|
+
label: item.Value,
|
|
47
|
+
value: item.Value,
|
|
48
|
+
code:item.Code,
|
|
49
|
+
type:item.Type,
|
|
50
|
+
children: regionType!= 'levelTwo'||regionMode=='region'?[{
|
|
51
|
+
label: item.Value,
|
|
52
|
+
value: item.Value,
|
|
53
|
+
code:item.Code,
|
|
54
|
+
type:item.Type,
|
|
55
|
+
centralCity:item.CentralCity,
|
|
56
|
+
}]:null
|
|
57
|
+
}]:null
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if(regionType!= 'levelOne'||regionMode=='region'){
|
|
62
|
+
arr.forEach(item=>{
|
|
63
|
+
//市数据集合
|
|
64
|
+
if(item?.Type==2&&item?.Deprecated==false){
|
|
65
|
+
provicesData.map(provice=>{
|
|
66
|
+
if(provice.code.substr(0, 2) == item.Code.substr(0,2)){
|
|
67
|
+
if(provice['children'][0].type==1){
|
|
68
|
+
provice['children']=[];
|
|
69
|
+
}
|
|
70
|
+
provice['children'].push({
|
|
71
|
+
label: item.Value,
|
|
72
|
+
value: item.Value,
|
|
73
|
+
code:item.Code,
|
|
74
|
+
type:item.Type,
|
|
75
|
+
centralCity:item.CentralCity,
|
|
76
|
+
children: regionType!= 'levelTwo'||regionMode=='region'?[{
|
|
77
|
+
label: item.Value,
|
|
78
|
+
value: item.Value,
|
|
79
|
+
code:item.Code,
|
|
80
|
+
type:item.Type,
|
|
81
|
+
centralCity:item.CentralCity,
|
|
82
|
+
}]:null
|
|
83
|
+
});
|
|
37
84
|
|
|
38
|
-
|
|
39
|
-
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if(regionType != 'levelTwo'||regionMode=='region'){
|
|
90
|
+
arr.forEach(item=>{
|
|
91
|
+
//区数据集合
|
|
92
|
+
if(item?.Type==3&&item?.Deprecated==false){
|
|
93
|
+
provicesData.map(provice=>{
|
|
94
|
+
if(provice.centralCity){
|
|
95
|
+
provice.children.map(city=>{
|
|
96
|
+
if(city.code.substr(0, 2) == item.Code.substr(0,2)){
|
|
97
|
+
if(city['children'][0].type==1){
|
|
98
|
+
city['children']=[];
|
|
99
|
+
}
|
|
100
|
+
city['children'].push({
|
|
101
|
+
label: item.Value,
|
|
102
|
+
value: item.Value,
|
|
103
|
+
code:item.Code,
|
|
104
|
+
//type:item.Type
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
}});
|
|
108
|
+
}else{
|
|
109
|
+
provice.children.map(city=>{
|
|
110
|
+
if(city.code.substr(0, 4) == item.Code.substr(0,4)){
|
|
111
|
+
if(city['children'][0].type==2){
|
|
112
|
+
city['children']=[];
|
|
113
|
+
}
|
|
114
|
+
city['children'].push({
|
|
115
|
+
label: item.Value,
|
|
116
|
+
value: item.Value,
|
|
117
|
+
code:item.Code,
|
|
118
|
+
//type:item.Type
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
}});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
return provicesData;
|
|
40
131
|
}
|
|
@@ -48,8 +48,98 @@ export function timePicker(options) {
|
|
|
48
48
|
];
|
|
49
49
|
weui.picker(hours, {
|
|
50
50
|
...options,
|
|
51
|
+
id: String(Date.now()),
|
|
51
52
|
start: [startHour, startMin],
|
|
52
53
|
end: [endHour, endMin],
|
|
53
54
|
defaultValue,
|
|
54
55
|
});
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 年选择器
|
|
60
|
+
*/
|
|
61
|
+
export function yearPicker(options) {
|
|
62
|
+
const { startDate, endDate, defaultDate } = options;
|
|
63
|
+
if (startDate > endDate) {
|
|
64
|
+
throw 'startDate is bigger then endDate';
|
|
65
|
+
}
|
|
66
|
+
// 当前年
|
|
67
|
+
const currentYear = new Date().getFullYear();
|
|
68
|
+
// 默认传入年
|
|
69
|
+
const defaultYear = defaultDate
|
|
70
|
+
? new Date(defaultDate).getFullYear()
|
|
71
|
+
: currentYear;
|
|
72
|
+
// 最小年份
|
|
73
|
+
const minYear = startDate
|
|
74
|
+
? new Date(startDate).getFullYear()
|
|
75
|
+
: currentYear - 100;
|
|
76
|
+
// 最大年份
|
|
77
|
+
const maxYear = endDate ? new Date(endDate).getFullYear() : currentYear + 100;
|
|
78
|
+
const years = Array.from({ length: maxYear - minYear + 1 }).map(
|
|
79
|
+
(item, index) => ({
|
|
80
|
+
label: `${minYear + index}年`,
|
|
81
|
+
value: minYear + index,
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
weui.picker(years, {
|
|
85
|
+
...options,
|
|
86
|
+
defaultValue: [defaultYear],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 年月选择器
|
|
92
|
+
*/
|
|
93
|
+
export function monthPicker(options) {
|
|
94
|
+
const { startDate, endDate, defaultDate } = options;
|
|
95
|
+
if (startDate > endDate) {
|
|
96
|
+
throw 'startDate is bigger then endDate';
|
|
97
|
+
}
|
|
98
|
+
const _getYear = (d) => d.getFullYear();
|
|
99
|
+
const _getMonth = (d) => d.getMonth() + 1;
|
|
100
|
+
// 当前年月
|
|
101
|
+
const now = new Date();
|
|
102
|
+
const [currentYear, currentMonth] = [_getYear(now), _getMonth(now)];
|
|
103
|
+
// 默认传入年月
|
|
104
|
+
const def = defaultDate ? new Date(defaultDate) : now;
|
|
105
|
+
const [defaultYear, defaultMonth] = [_getYear(def), _getMonth(def)];
|
|
106
|
+
// 最小年月
|
|
107
|
+
const min = startDate && new Date(startDate);
|
|
108
|
+
const [minYear, minMonth] = [
|
|
109
|
+
min ? _getYear(min) : currentYear - 100,
|
|
110
|
+
min ? _getMonth(min) : 1,
|
|
111
|
+
];
|
|
112
|
+
// 最大年月
|
|
113
|
+
const max = endDate && new Date(endDate);
|
|
114
|
+
const [maxYear, maxMonth] = [
|
|
115
|
+
max ? _getYear(max) : currentYear + 100,
|
|
116
|
+
max ? _getMonth(max) : 12,
|
|
117
|
+
];
|
|
118
|
+
// 年份月份
|
|
119
|
+
const years = Array.from({ length: maxYear - minYear + 1 }).map((item, i) => {
|
|
120
|
+
const year = i + minYear;
|
|
121
|
+
let months = [];
|
|
122
|
+
let [minMonthWithYear, maxMonthWithYear] = [1, 12];
|
|
123
|
+
if (year === minYear) {
|
|
124
|
+
minMonthWithYear = Math.max(minMonth, 1);
|
|
125
|
+
}
|
|
126
|
+
if (year === maxYear) {
|
|
127
|
+
maxMonthWithYear = Math.min(maxMonth, 12);
|
|
128
|
+
}
|
|
129
|
+
months = Array.from({
|
|
130
|
+
length: maxMonthWithYear - minMonthWithYear + 1,
|
|
131
|
+
}).map((item, i) => ({
|
|
132
|
+
label: `${i + minMonthWithYear}月`,
|
|
133
|
+
value: i + minMonthWithYear,
|
|
134
|
+
}));
|
|
135
|
+
return {
|
|
136
|
+
label: `${i + minYear}年`,
|
|
137
|
+
value: i + minYear,
|
|
138
|
+
children: months,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
weui.picker(years, {
|
|
142
|
+
...options,
|
|
143
|
+
defaultValue: [defaultYear, defaultMonth],
|
|
144
|
+
});
|
|
145
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Popover,
|
|
4
|
+
ConfigProvider,
|
|
5
|
+
useConfig,
|
|
6
|
+
Input,
|
|
7
|
+
Icon,
|
|
8
|
+
Button,
|
|
9
|
+
} from 'tea-component';
|
|
10
|
+
import classNames from '../../../utils/classnames';
|
|
11
|
+
import { moment } from './index';
|
|
12
|
+
import './index.css';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* pc 版简易年份选择器
|
|
16
|
+
* 传参与 DatePicker 保持一致
|
|
17
|
+
*/
|
|
18
|
+
export default function YearPicker(props) {
|
|
19
|
+
const {
|
|
20
|
+
range = [],
|
|
21
|
+
disabled,
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
className,
|
|
25
|
+
placeholder,
|
|
26
|
+
...rest
|
|
27
|
+
} = props;
|
|
28
|
+
const { classPrefix } = useConfig();
|
|
29
|
+
const inputRef = React.useRef(null);
|
|
30
|
+
const [show, setShow] = React.useState(false);
|
|
31
|
+
const [page, setPage] = React.useState(0);
|
|
32
|
+
const [inputValue, setInputValue] = React.useState(transValueToYear(value));
|
|
33
|
+
const { pageYears, pageStart, pageEnd } = getYears(inputValue, page);
|
|
34
|
+
const [min, max] = [
|
|
35
|
+
transValueToYear(range?.[0]),
|
|
36
|
+
transValueToYear(range?.[1]),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
setInputValue(transValueToYear(value));
|
|
41
|
+
}, [value]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
45
|
+
<Popover
|
|
46
|
+
trigger="click"
|
|
47
|
+
visible={show}
|
|
48
|
+
onVisibleChange={(v) => !v && setShow(v)}
|
|
49
|
+
overlay={
|
|
50
|
+
<div
|
|
51
|
+
className={classNames(
|
|
52
|
+
`${classPrefix}-dropdown-box`,
|
|
53
|
+
'year-picker__overlay'
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
className={classNames(
|
|
58
|
+
`${classPrefix}-calendar__caption`,
|
|
59
|
+
'year-picker__header'
|
|
60
|
+
)}
|
|
61
|
+
>
|
|
62
|
+
<div className="year-picker__header-title">
|
|
63
|
+
{pageStart}-{pageEnd}
|
|
64
|
+
</div>
|
|
65
|
+
<div className="year-picker__header-actions">
|
|
66
|
+
<Button
|
|
67
|
+
type="link"
|
|
68
|
+
icon="arrowleft"
|
|
69
|
+
title="上二十年"
|
|
70
|
+
onClick={() => setPage((d) => d - 1)}
|
|
71
|
+
/>
|
|
72
|
+
<Button
|
|
73
|
+
type="link"
|
|
74
|
+
icon="cur-active"
|
|
75
|
+
title="当前二十年"
|
|
76
|
+
onClick={() => setPage(0)}
|
|
77
|
+
/>
|
|
78
|
+
<Button
|
|
79
|
+
type="link"
|
|
80
|
+
icon="arrowright"
|
|
81
|
+
title="下二十年"
|
|
82
|
+
onClick={() => setPage((d) => d + 1)}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
<div
|
|
87
|
+
className={classNames(
|
|
88
|
+
`${classPrefix}-calendar__type--year`,
|
|
89
|
+
'year-picker__body'
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{pageYears.map((list) => (
|
|
93
|
+
<div
|
|
94
|
+
key={list.join()}
|
|
95
|
+
className={classNames(`${classPrefix}-calendar__row`)}
|
|
96
|
+
>
|
|
97
|
+
{list.map((item) => {
|
|
98
|
+
const isSelected = item === inputValue;
|
|
99
|
+
const isDisabled =
|
|
100
|
+
(min && Number(item) < Number(min)) ||
|
|
101
|
+
(max && Number(item) > Number(max));
|
|
102
|
+
return (
|
|
103
|
+
<div
|
|
104
|
+
key={item}
|
|
105
|
+
className={classNames(
|
|
106
|
+
`${classPrefix}-calendar__cell`,
|
|
107
|
+
'year-picker__cell',
|
|
108
|
+
{
|
|
109
|
+
'is-selected': isSelected,
|
|
110
|
+
'is-disabled': isDisabled,
|
|
111
|
+
}
|
|
112
|
+
)}
|
|
113
|
+
onClick={() => {
|
|
114
|
+
if (isDisabled) return;
|
|
115
|
+
setShow(false);
|
|
116
|
+
setInputValue(item);
|
|
117
|
+
onChange?.(moment(item));
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
<span>{item}</span>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
})}
|
|
124
|
+
</div>
|
|
125
|
+
))}
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
}
|
|
129
|
+
>
|
|
130
|
+
<div
|
|
131
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
132
|
+
{...rest}
|
|
133
|
+
onClick={() => !disabled && setShow(true)}
|
|
134
|
+
className={classNames(`${classPrefix}-datepicker`, className)}
|
|
135
|
+
>
|
|
136
|
+
<div className={classNames(`${classPrefix}-datepicker__input`)}>
|
|
137
|
+
<Input
|
|
138
|
+
ref={inputRef}
|
|
139
|
+
disabled={disabled}
|
|
140
|
+
placeholder={placeholder}
|
|
141
|
+
value={inputValue}
|
|
142
|
+
onFocus={() => inputRef.current.blur()}
|
|
143
|
+
/>
|
|
144
|
+
<Icon type="dismiss" />
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</Popover>
|
|
148
|
+
</ConfigProvider>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 获取当前20年,page 表示分页,1表示下一页,-1表示上一页
|
|
154
|
+
* @returns [][]
|
|
155
|
+
*/
|
|
156
|
+
const getYears = (currentYear, page = 0, range = []) => {
|
|
157
|
+
currentYear = currentYear || new Date().getFullYear();
|
|
158
|
+
const startYear = (Math.floor(parseInt(currentYear) / 20) + page) * 20;
|
|
159
|
+
const pageYears = Array.from({ length: 5 }).map((item, i1) =>
|
|
160
|
+
Array.from({ length: 4 }).map((item, i2) => i1 * 4 + i2 + startYear + '')
|
|
161
|
+
);
|
|
162
|
+
return { pageYears, pageStart: startYear, pageEnd: startYear + 20 - 1 };
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 输入 moment 值转 string 年份
|
|
167
|
+
*/
|
|
168
|
+
const transValueToYear = (val) => {
|
|
169
|
+
return moment.isMoment(val) ? val.format('YYYY') : '';
|
|
170
|
+
};
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from '../../../utils/classnames';
|
|
4
4
|
import { CommonPropsType } from '../../../types';
|
|
5
|
+
import './index.css';
|
|
5
6
|
|
|
6
7
|
export default function Tips({
|
|
7
8
|
// 系统属性
|
|
@@ -10,7 +11,7 @@ export default function Tips({
|
|
|
10
11
|
tips = '表单提示',
|
|
11
12
|
type = 'normal',
|
|
12
13
|
id,
|
|
13
|
-
style
|
|
14
|
+
style,
|
|
14
15
|
}: PropsType) {
|
|
15
16
|
const cls = classNames({
|
|
16
17
|
'weda-ui': true,
|
|
@@ -21,7 +22,7 @@ export default function Tips({
|
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
return (
|
|
24
|
-
<div className={cls} id={id} style={style}
|
|
25
|
+
<div className={cls} id={id} style={style}>
|
|
25
26
|
{tips}
|
|
26
27
|
</div>
|
|
27
28
|
);
|
|
@@ -30,4 +31,4 @@ export default function Tips({
|
|
|
30
31
|
export interface PropsType extends CommonPropsType {
|
|
31
32
|
tips?: string;
|
|
32
33
|
type?: 'warn' | 'normal';
|
|
33
|
-
}
|
|
34
|
+
}
|
|
@@ -7,7 +7,7 @@ import { useSyncValue } from '../../../utils/useSyncValue';
|
|
|
7
7
|
import { isCloudFileID } from '../../../utils/platform';
|
|
8
8
|
import { IMAGE_TYPES } from './uploader.pc';
|
|
9
9
|
import { CommonFormPropsType } from '../types';
|
|
10
|
-
import
|
|
10
|
+
import { v4 } from 'uuid';
|
|
11
11
|
|
|
12
12
|
const uploadPath = 'weda-uploader';
|
|
13
13
|
/**
|
|
@@ -40,7 +40,12 @@ export function ImageUploaderH5({
|
|
|
40
40
|
//上传进度
|
|
41
41
|
const [progress, setProgress] = React.useState(0);
|
|
42
42
|
const [inputValue, setInputValue] = useSyncValue(defaultValue, isObjectEqual);
|
|
43
|
+
|
|
43
44
|
const fileIdList = React.useMemo(() => {
|
|
45
|
+
//兼容h5默认值为空时情况
|
|
46
|
+
if (inputValue === null) {
|
|
47
|
+
setInputValue('');
|
|
48
|
+
}
|
|
44
49
|
if (typeof inputValue === 'string') {
|
|
45
50
|
// single = true 传入的是字符串
|
|
46
51
|
return [inputValue].filter((i) => i.length > 0); // 排除空串
|
|
@@ -67,7 +72,7 @@ export function ImageUploaderH5({
|
|
|
67
72
|
React.useEffect(() => {
|
|
68
73
|
if (single) {
|
|
69
74
|
const file = fileIdList[0] || '';
|
|
70
|
-
|
|
75
|
+
onChange && onChange(file);
|
|
71
76
|
events.change && events.change({ value: file });
|
|
72
77
|
} else {
|
|
73
78
|
onChange && onChange(fileIdList);
|
|
@@ -88,22 +93,20 @@ export function ImageUploaderH5({
|
|
|
88
93
|
setUploading(true);
|
|
89
94
|
getCloudInstance().then(async (tcb) => {
|
|
90
95
|
try {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
fileID && setInputValue((list) => [...list, fileID]);
|
|
104
|
-
fileID && events.success && events.success({ value: fileID, file });
|
|
105
|
-
};
|
|
96
|
+
const fileType = file.type.split('/')?.[1];
|
|
97
|
+
const cloudPath = `${uploadPath}/${v4().replaceAll('-', '')}-${
|
|
98
|
+
file?.name
|
|
99
|
+
}`;
|
|
100
|
+
const { fileID } = await tcb.uploadFile({
|
|
101
|
+
cloudPath,
|
|
102
|
+
filePath: file,
|
|
103
|
+
onUploadProgress: onProgress,
|
|
104
|
+
});
|
|
105
|
+
// @ts-expect-error TODO
|
|
106
|
+
fileID && setInputValue((list) => [...list, fileID]);
|
|
107
|
+
fileID && events.success && events.success({ value: fileID, file });
|
|
106
108
|
} catch (err) {
|
|
109
|
+
weui.alert(`${err}` || '上传失败');
|
|
107
110
|
events.error && events.error(err);
|
|
108
111
|
} finally {
|
|
109
112
|
setUploading(false);
|
|
@@ -118,6 +121,13 @@ export function ImageUploaderH5({
|
|
|
118
121
|
: Array.from(new Set(acceptTypes));
|
|
119
122
|
}, [acceptTypes]);
|
|
120
123
|
|
|
124
|
+
const showAdd = React.useMemo(() => {
|
|
125
|
+
if(single) {
|
|
126
|
+
// single 模式时,仅当数组为空时显示
|
|
127
|
+
return fileIdList.length < 1;
|
|
128
|
+
}
|
|
129
|
+
return fileIdList.length < maxUploadCount;
|
|
130
|
+
}, [fileIdList, single, maxUploadCount]);
|
|
121
131
|
return (
|
|
122
132
|
<div className={cls} id={id} style={style}>
|
|
123
133
|
<div className="weui-cell">
|
|
@@ -146,8 +156,7 @@ export function ImageUploaderH5({
|
|
|
146
156
|
</li>
|
|
147
157
|
)}
|
|
148
158
|
</ul>
|
|
149
|
-
{
|
|
150
|
-
(single && fileIdList.length < 1)) && ( // single 模式时,仅当数组为空时显示
|
|
159
|
+
{showAdd && (
|
|
151
160
|
<div className="weui-uploader__input-box">
|
|
152
161
|
<input
|
|
153
162
|
id="uploaderInput"
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
ImagePreview,
|
|
9
9
|
ConfigProvider,
|
|
10
10
|
} from 'tea-component';
|
|
11
|
+
import { v4 } from 'uuid';
|
|
11
12
|
import classNames from '../../../utils/classnames';
|
|
12
13
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
13
14
|
import { isCloudFileID } from '../../../utils/platform';
|
|
14
15
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
15
16
|
import { H5UploaderProps } from './uploader.h5';
|
|
16
|
-
import SparkMD5 from 'spark-md5';
|
|
17
17
|
// 默认组件类前缀
|
|
18
18
|
export const CLASS_PREFIX = 'weda-uploader-pc';
|
|
19
19
|
// 默认图片类型
|
|
@@ -80,7 +80,6 @@ export function UploaderPCInner(props) {
|
|
|
80
80
|
// 文件列表
|
|
81
81
|
const [fileIDList, setfileIDList] = React.useState([]);
|
|
82
82
|
const fileRef = React.useRef(fileIDList);
|
|
83
|
-
|
|
84
83
|
React.useEffect(() => {
|
|
85
84
|
let initialValue = []
|
|
86
85
|
.concat(defaultValue)
|
|
@@ -89,14 +88,14 @@ export function UploaderPCInner(props) {
|
|
|
89
88
|
initialValue = initialValue[0] ? [initialValue[0]] : [];
|
|
90
89
|
}
|
|
91
90
|
setfileIDList(initialValue);
|
|
92
|
-
}, []);
|
|
91
|
+
}, [defaultValue]);
|
|
93
92
|
|
|
94
93
|
// 值变化事件
|
|
95
94
|
React.useEffect(() => {
|
|
96
95
|
if (!isObjectEqual(fileRef.current, fileIDList)) {
|
|
97
96
|
if (single) {
|
|
98
97
|
const file = fileIDList[0] || '';
|
|
99
|
-
|
|
98
|
+
onChange && onChange(file);
|
|
100
99
|
events.change && events.change({ value: file });
|
|
101
100
|
} else {
|
|
102
101
|
onChange && onChange(fileIDList);
|
|
@@ -130,22 +129,20 @@ export function UploaderPCInner(props) {
|
|
|
130
129
|
setUploading(true);
|
|
131
130
|
getCloudInstance().then(async (tcb) => {
|
|
132
131
|
try {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} catch (e) {
|
|
148
|
-
events.error && events.error({ value: e, file });
|
|
132
|
+
const fileType = file.type.split('/')?.[1];
|
|
133
|
+
const cloudPath = `${uploadPath}/${v4().replaceAll('-', '')}-${
|
|
134
|
+
file?.name
|
|
135
|
+
}`;
|
|
136
|
+
const { fileID } = await tcb.uploadFile({
|
|
137
|
+
cloudPath,
|
|
138
|
+
filePath: file,
|
|
139
|
+
onUploadProgress: onProgress,
|
|
140
|
+
});
|
|
141
|
+
fileID && setfileIDList((list) => [...list, fileID]);
|
|
142
|
+
fileID && events.success && events.success({ value: fileID, file });
|
|
143
|
+
} catch (err) {
|
|
144
|
+
message.error({ content: `${err}` || '上传失败' });
|
|
145
|
+
events.error && events.error(err);
|
|
149
146
|
} finally {
|
|
150
147
|
setUploading(false);
|
|
151
148
|
setProgress(0);
|