@cloudbase/weda-ui 0.2.15 → 1.0.21
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 +28 -15
- package/src/configs/components/calendar.json +78 -0
- package/src/configs/components/carousel.json +273 -0
- 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 +379 -0
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +154 -0
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +410 -0
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +20 -4
- package/src/configs/components/listView.json +277 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +362 -0
- 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 +6 -3
- 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 +34 -0
- package/src/mp/components/button/index.js +12 -13
- package/src/mp/components/button/index.wxml +1 -1
- package/src/mp/components/calendar/arrowright--line.svg +11 -0
- package/src/mp/components/calendar/index.js +238 -0
- package/src/mp/components/calendar/index.json +4 -0
- package/src/mp/components/calendar/index.wxml +37 -0
- package/src/mp/components/calendar/index.wxss +178 -0
- package/src/mp/components/carousel/index.js +88 -0
- package/src/mp/components/carousel/index.json +7 -0
- package/src/mp/components/carousel/index.wxml +6 -0
- 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 +253 -0
- package/src/mp/components/chart/statisticsCard/index.json +4 -0
- package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
- package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
- package/src/mp/components/dataView/index.js +34 -0
- package/src/mp/components/dataView/index.json +7 -0
- package/src/mp/components/dataView/index.wxml +15 -0
- package/src/mp/components/dataView/index.wxss +0 -0
- 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/input/index.js +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
- package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
- package/src/mp/components/form/location/index.js +382 -0
- package/src/mp/components/form/location/index.json +6 -0
- package/src/mp/components/form/location/index.wxml +25 -0
- package/src/mp/components/form/location/index.wxss +91 -0
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +84 -48
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +106 -27
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +203 -0
- package/src/mp/components/graphicCard/index.json +4 -0
- package/src/mp/components/graphicCard/index.wxml +29 -0
- package/src/mp/components/graphicCard/index.wxss +157 -0
- package/src/mp/components/image/index.js +0 -1
- package/src/mp/components/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/listView/index.js +285 -0
- package/src/mp/components/listView/index.json +4 -0
- package/src/mp/components/listView/index.wxml +40 -0
- package/src/mp/components/listView/index.wxss +155 -0
- package/src/mp/components/listView/more-line.svg +3 -0
- package/src/mp/components/navLayout/index.js +123 -0
- package/src/mp/components/navLayout/index.json +7 -0
- package/src/mp/components/navLayout/index.wxml +25 -0
- package/src/mp/components/navLayout/index.wxss +1193 -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/swiper/index.wxml +2 -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 +18 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
- package/src/mp/utils/spark-md5.js +776 -0
- package/src/mp/utils/tcb.js +62 -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/calendar/index.css +382 -0
- package/src/web/components/calendar/index.jsx +312 -0
- package/src/web/components/calendar/util.js +90 -0
- package/src/web/components/carousel/index.css +119 -0
- package/src/web/components/carousel/index.tsx +417 -0
- 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.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +307 -0
- package/src/web/components/chart/statisticsCard/interface.ts +14 -0
- package/src/web/components/dataView/index.tsx +20 -0
- package/src/web/components/dataView/interface.ts +6 -0
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/location/common/mapChoose.css +178 -0
- package/src/web/components/form/location/common/mapChoose.jsx +343 -0
- package/src/web/components/form/location/common/mapView.jsx +190 -0
- package/src/web/components/form/location/common/propsConfig.js +54 -0
- package/src/web/components/form/location/common/selectModal.css +44 -0
- package/src/web/components/form/location/common/selectModal.jsx +82 -0
- package/src/web/components/form/location/common/useLocationInfo.js +100 -0
- package/src/web/components/form/location/components/LocationH5/index.css +243 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
- package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
- package/src/web/components/form/location/components/LocationPC/index.css +44 -0
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
- package/src/web/components/form/location/constants.js +4 -0
- package/src/web/components/form/location/index.css +0 -0
- package/src/web/components/form/location/index.jsx +25 -0
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +389 -71
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +404 -144
- 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/uploader/uploader.h5.tsx +19 -4
- package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
- package/src/web/components/graphicCard/index.css +159 -0
- package/src/web/components/graphicCard/index.tsx +310 -0
- package/src/web/components/image/image.tsx +1 -2
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +24 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +143 -0
- package/src/web/components/listView/index.tsx +359 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- 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 +4 -2
- package/src/web/components/tabs/tabs.h5.tsx +50 -37
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +40 -0
- package/src/web/utils/tcb.js +49 -0
- package/src/web/utils/tmap.js +4 -0
- 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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as echarts from '../common/lib/echarts.min';
|
|
2
|
+
import EchartPie from '../common/core/eChartPie';
|
|
3
|
+
Component({
|
|
4
|
+
options: {
|
|
5
|
+
virtualHost: true,
|
|
6
|
+
multipleSlots: true,
|
|
7
|
+
},
|
|
8
|
+
properties: {
|
|
9
|
+
id: {
|
|
10
|
+
type: String,
|
|
11
|
+
value: '',
|
|
12
|
+
},
|
|
13
|
+
className: {
|
|
14
|
+
type: String,
|
|
15
|
+
value: '',
|
|
16
|
+
},
|
|
17
|
+
style: {
|
|
18
|
+
type: String,
|
|
19
|
+
value: '',
|
|
20
|
+
},
|
|
21
|
+
chartType: {
|
|
22
|
+
// 图形类型
|
|
23
|
+
type: String,
|
|
24
|
+
value: 'bight',
|
|
25
|
+
},
|
|
26
|
+
title: {
|
|
27
|
+
// 图表标题
|
|
28
|
+
type: String,
|
|
29
|
+
},
|
|
30
|
+
isTitle: {
|
|
31
|
+
// 是否显示标题
|
|
32
|
+
type: Boolean,
|
|
33
|
+
value: false,
|
|
34
|
+
},
|
|
35
|
+
titleLocation: {
|
|
36
|
+
type: String,
|
|
37
|
+
value: 'top',
|
|
38
|
+
},
|
|
39
|
+
dataSource: {
|
|
40
|
+
// 数据源
|
|
41
|
+
type: Object,
|
|
42
|
+
},
|
|
43
|
+
filterData: {
|
|
44
|
+
// 数据筛选
|
|
45
|
+
type: Array,
|
|
46
|
+
value: [],
|
|
47
|
+
},
|
|
48
|
+
setColor: {
|
|
49
|
+
// 设置颜色
|
|
50
|
+
type: Array,
|
|
51
|
+
value: [],
|
|
52
|
+
},
|
|
53
|
+
xField: {
|
|
54
|
+
// x轴字段选择
|
|
55
|
+
type: Object,
|
|
56
|
+
value: {
|
|
57
|
+
format: '',
|
|
58
|
+
type: '', // 数据源字段 类型
|
|
59
|
+
title: '', // 字段名中文
|
|
60
|
+
name: '', // 字段名英文
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
xStatistics: {
|
|
64
|
+
// x轴统计维度
|
|
65
|
+
type: String,
|
|
66
|
+
value: '', // 统计纬度, 只有选择时间类型才有,y 年,m月,d 日,w周,h时,min 分,s秒
|
|
67
|
+
},
|
|
68
|
+
xIsCountEmpty: {
|
|
69
|
+
// x轴 是否统计空值
|
|
70
|
+
type: Boolean,
|
|
71
|
+
value: false,
|
|
72
|
+
},
|
|
73
|
+
yField: {
|
|
74
|
+
// Y轴字段,分组字段,是否分组
|
|
75
|
+
type: Object,
|
|
76
|
+
value: {
|
|
77
|
+
numValue: [{ key: '', operationType: '' }],
|
|
78
|
+
groupKey: '',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
isLegend: {
|
|
82
|
+
// 是否显示图例
|
|
83
|
+
type: Boolean,
|
|
84
|
+
value: false,
|
|
85
|
+
},
|
|
86
|
+
legend: {
|
|
87
|
+
// 图例
|
|
88
|
+
type: String,
|
|
89
|
+
value: 'bottom', // 左 left 右right, 上top,下 bottom
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
// 高级属性
|
|
93
|
+
isSeriesShowSymbol: {
|
|
94
|
+
// 是否显示数据标签 开启后 属性 series.label.show 要同时设置为true
|
|
95
|
+
type: Boolean,
|
|
96
|
+
value: true,
|
|
97
|
+
},
|
|
98
|
+
isPercent: {
|
|
99
|
+
// 百分比
|
|
100
|
+
type: Boolean,
|
|
101
|
+
value: false,
|
|
102
|
+
},
|
|
103
|
+
isUnit: {
|
|
104
|
+
// 显示单位
|
|
105
|
+
type: Boolean,
|
|
106
|
+
value: false,
|
|
107
|
+
},
|
|
108
|
+
unit: {
|
|
109
|
+
// 数字显示的单位 百分比,千分比,千,万,百万,亿,十亿
|
|
110
|
+
type: String,
|
|
111
|
+
value: '%',
|
|
112
|
+
},
|
|
113
|
+
decimalDigits: {
|
|
114
|
+
// 小数位数
|
|
115
|
+
type: Number,
|
|
116
|
+
value: 0,
|
|
117
|
+
},
|
|
118
|
+
suffix: {
|
|
119
|
+
// 后缀
|
|
120
|
+
type: String,
|
|
121
|
+
value: '',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
data: {
|
|
125
|
+
ec: {},
|
|
126
|
+
canvas_id: {
|
|
127
|
+
type: String,
|
|
128
|
+
value: `canvas_pie_${Date.now()}_${Math.random() * 100}`,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
lifetimes: {
|
|
132
|
+
attached() {
|
|
133
|
+
// 在组件实例进入页面节点树时执行
|
|
134
|
+
this.initData();
|
|
135
|
+
},
|
|
136
|
+
detached() {
|
|
137
|
+
// 在组件实例被从页面节点树移除时执行
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
// 以下是旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
|
|
141
|
+
attached() {
|
|
142
|
+
// 在组件实例进入页面节点树时执行
|
|
143
|
+
this.initData();
|
|
144
|
+
},
|
|
145
|
+
detached() {
|
|
146
|
+
// 在组件实例被从页面节点树移除时执行
|
|
147
|
+
},
|
|
148
|
+
observers: {
|
|
149
|
+
// 当参数变化时
|
|
150
|
+
'**': async function() {
|
|
151
|
+
const objEChartPie = new EchartPie();
|
|
152
|
+
await objEChartPie.setOptions(this.properties);
|
|
153
|
+
const options = await objEChartPie.getOptions();
|
|
154
|
+
this._chart && this._chart.setOption(options);
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
methods: {
|
|
158
|
+
initData() {
|
|
159
|
+
this.setData({
|
|
160
|
+
ec: {
|
|
161
|
+
onInit: this.initChart.bind(this),
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
async initChart(canvas, width, height, dpr) {
|
|
166
|
+
const objEchart = echarts.init(canvas, null, {
|
|
167
|
+
width,
|
|
168
|
+
height,
|
|
169
|
+
devicePixelRatio: dpr,
|
|
170
|
+
});
|
|
171
|
+
canvas.setChart(objEchart);
|
|
172
|
+
const objEChartPie = new EchartPie();
|
|
173
|
+
await objEChartPie.setOptions(this.properties);
|
|
174
|
+
const options = await objEChartPie.getOptions();
|
|
175
|
+
// objEchart.clear();
|
|
176
|
+
console.log('设置前参数pie', options);
|
|
177
|
+
objEchart.setOption(options);
|
|
178
|
+
this._chart = objEchart;
|
|
179
|
+
return objEchart;
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { callDataSource, callWedaApi } from '../../../utils/tcb';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_VAL = 1000;
|
|
4
|
+
|
|
5
|
+
Component({
|
|
6
|
+
properties: {
|
|
7
|
+
className: {
|
|
8
|
+
type: String,
|
|
9
|
+
value: '',
|
|
10
|
+
},
|
|
11
|
+
style: {
|
|
12
|
+
type: String,
|
|
13
|
+
value: '',
|
|
14
|
+
},
|
|
15
|
+
dataSource: {
|
|
16
|
+
// 数据源
|
|
17
|
+
type: Object,
|
|
18
|
+
},
|
|
19
|
+
filterData: {
|
|
20
|
+
// 数据筛选
|
|
21
|
+
type: Array,
|
|
22
|
+
value: [],
|
|
23
|
+
},
|
|
24
|
+
field: {
|
|
25
|
+
// 字段选择
|
|
26
|
+
type: Object,
|
|
27
|
+
},
|
|
28
|
+
operationType: {
|
|
29
|
+
// 统计方式
|
|
30
|
+
type: String,
|
|
31
|
+
},
|
|
32
|
+
label: {
|
|
33
|
+
// 字段展示名称
|
|
34
|
+
type: String,
|
|
35
|
+
value: '今日活跃用户数',
|
|
36
|
+
},
|
|
37
|
+
isCountEmpty: {
|
|
38
|
+
// 是否统计空值
|
|
39
|
+
type: Boolean,
|
|
40
|
+
value: false,
|
|
41
|
+
},
|
|
42
|
+
isShowUnit: {
|
|
43
|
+
// 是否显示单位
|
|
44
|
+
type: Boolean,
|
|
45
|
+
value: true,
|
|
46
|
+
},
|
|
47
|
+
unit: {
|
|
48
|
+
// 单位
|
|
49
|
+
type: Number,
|
|
50
|
+
value: 1,
|
|
51
|
+
},
|
|
52
|
+
decimalDigits: {
|
|
53
|
+
// 小数位数
|
|
54
|
+
type: Number,
|
|
55
|
+
value: 0,
|
|
56
|
+
},
|
|
57
|
+
suffix: {
|
|
58
|
+
// 后缀
|
|
59
|
+
type: String,
|
|
60
|
+
value: '个',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
data: {
|
|
64
|
+
count: DEFAULT_VAL,
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
scientificToNumber: function (num) {
|
|
68
|
+
const str = num;
|
|
69
|
+
const reg = /^([-]?\d+\.?\d*)(e)([-|+]?\d+)$/;
|
|
70
|
+
let zero = '';
|
|
71
|
+
if (!reg.test(str)) {
|
|
72
|
+
return num;
|
|
73
|
+
}
|
|
74
|
+
const arr = reg.exec(str);
|
|
75
|
+
const len = Math.abs(arr[3]) - 1;
|
|
76
|
+
for (let i = 0; i < len; i += 1) {
|
|
77
|
+
zero += '0';
|
|
78
|
+
}
|
|
79
|
+
if (arr[1].indexOf('-') === 0) {
|
|
80
|
+
return `-0.${zero}${arr[1].replace('-', '').replace('.', '')}`;
|
|
81
|
+
}
|
|
82
|
+
return `0.${zero}${arr[1].replace('.', '')}`;
|
|
83
|
+
},
|
|
84
|
+
padEnd: function (source, targetLength) {
|
|
85
|
+
targetLength = Math.floor(targetLength); //floor if number or convert non-number to 0;
|
|
86
|
+
if (source.length > targetLength) {
|
|
87
|
+
return source;
|
|
88
|
+
} else {
|
|
89
|
+
targetLength = targetLength - source.length;
|
|
90
|
+
return source + '0'.repeat(targetLength);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
customToFixed: function (num, digit = 0) {
|
|
94
|
+
const pow = Math.pow(10, digit);
|
|
95
|
+
let value = `${num}`;
|
|
96
|
+
// 如果是小数,四舍五入进行转化处理确保精度正确
|
|
97
|
+
if (!Number.isInteger(num)) {
|
|
98
|
+
if (num > 0) {
|
|
99
|
+
value = (Math.round((num + Number.EPSILON) * pow) / pow).toString();
|
|
100
|
+
} else if (num < 0) {
|
|
101
|
+
value = (Math.round((num - Number.EPSILON) * pow) / pow).toString();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
value = this.scientificToNumber(value);
|
|
105
|
+
const [integer, decimal = ''] = value.split('.');
|
|
106
|
+
if (digit > 0) {
|
|
107
|
+
return `${integer}.${this.padEnd(decimal, digit)}`;
|
|
108
|
+
}
|
|
109
|
+
return integer;
|
|
110
|
+
},
|
|
111
|
+
addDelimiter: function (fixedString, digit) {
|
|
112
|
+
let len = fixedString.length;
|
|
113
|
+
let result = '';
|
|
114
|
+
const decimalPoint = digit > 0 ? digit + 1 : 0;
|
|
115
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
116
|
+
let stepFromTail = len - 1 - i;
|
|
117
|
+
let char = fixedString.charAt(i);
|
|
118
|
+
|
|
119
|
+
if (stepFromTail <= decimalPoint) {
|
|
120
|
+
// 小数部分不处理
|
|
121
|
+
result = char + result;
|
|
122
|
+
} else {
|
|
123
|
+
if ((stepFromTail - decimalPoint) % 3 === 0) {
|
|
124
|
+
if (char !== '-') {
|
|
125
|
+
result = ',' + result;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
result = char + result;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
},
|
|
133
|
+
formatNumber: function (val, digits = 0) {
|
|
134
|
+
return isNaN(val)
|
|
135
|
+
? val
|
|
136
|
+
: this.addDelimiter(this.customToFixed(val, digits), digits);
|
|
137
|
+
},
|
|
138
|
+
getSourceData: async function (
|
|
139
|
+
dataSource,
|
|
140
|
+
filterData,
|
|
141
|
+
field,
|
|
142
|
+
operationType,
|
|
143
|
+
isCountEmpty
|
|
144
|
+
) {
|
|
145
|
+
const where = filterData?.map
|
|
146
|
+
? filterData.map((val) => {
|
|
147
|
+
let arrLogicData = val.logicData;
|
|
148
|
+
if (val.logicData && val.logicData.length > 0) {
|
|
149
|
+
arrLogicData = val.logicData.map((mval) => {
|
|
150
|
+
return {
|
|
151
|
+
Key: mval.key,
|
|
152
|
+
Rel: mval.rel,
|
|
153
|
+
Value: mval.value,
|
|
154
|
+
Logic: mval.logic,
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
GroupLogic: val.groupLogic,
|
|
160
|
+
LogicData: arrLogicData,
|
|
161
|
+
};
|
|
162
|
+
})
|
|
163
|
+
: [];
|
|
164
|
+
const params = {
|
|
165
|
+
dataSourceName: dataSource?.name,
|
|
166
|
+
where,
|
|
167
|
+
value: [
|
|
168
|
+
{
|
|
169
|
+
Key: field?.name,
|
|
170
|
+
OperationType: operationType,
|
|
171
|
+
IsCountEmpty: isCountEmpty,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
try {
|
|
176
|
+
if (dataSource?.type === 'database') {
|
|
177
|
+
return await callWedaApi({
|
|
178
|
+
action: 'DescribeChartCardData',
|
|
179
|
+
data: params,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return await callDataSource({
|
|
183
|
+
dataSourceName: dataSource?.name,
|
|
184
|
+
methodName: dataSource?.methodName,
|
|
185
|
+
});
|
|
186
|
+
} catch {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
_fetchData: async function () {
|
|
191
|
+
if (
|
|
192
|
+
(this.properties.dataSource?.type === 'database' &&
|
|
193
|
+
this.properties.field &&
|
|
194
|
+
this.properties.operationType) ||
|
|
195
|
+
(this.properties.dataSource &&
|
|
196
|
+
this.properties.dataSource?.type !== 'database')
|
|
197
|
+
) {
|
|
198
|
+
let data = await this.getSourceData(
|
|
199
|
+
this.properties.dataSource,
|
|
200
|
+
this.properties.filterData,
|
|
201
|
+
this.properties.field,
|
|
202
|
+
this.properties.operationType,
|
|
203
|
+
this.properties.isCountEmpty
|
|
204
|
+
);
|
|
205
|
+
// 自定义连接器 返回处理
|
|
206
|
+
if (this.properties.dataSource?.type !== 'database' && data?.result) {
|
|
207
|
+
data = data?.result;
|
|
208
|
+
}
|
|
209
|
+
if (data?.length) {
|
|
210
|
+
const val = isNaN(data[0]?.Value) ? 0 : data[0]?.Value;
|
|
211
|
+
this.setData({
|
|
212
|
+
count: this.properties.isShowUnit
|
|
213
|
+
? this.formatNumber(
|
|
214
|
+
val / this.properties.unit,
|
|
215
|
+
this.properties.decimalDigits
|
|
216
|
+
)
|
|
217
|
+
: val,
|
|
218
|
+
});
|
|
219
|
+
} else {
|
|
220
|
+
// 返回数据为空 使用 0
|
|
221
|
+
this.setData({
|
|
222
|
+
count: this.formatNumber(0, this.properties.decimalDigits),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
// 没有配置数据使用默认数据
|
|
227
|
+
this.setData({
|
|
228
|
+
count: this.setData({
|
|
229
|
+
count: this.formatNumber(
|
|
230
|
+
DEFAULT_VAL,
|
|
231
|
+
this.properties.decimalDigits
|
|
232
|
+
),
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
lifetimes: {
|
|
239
|
+
attached() {
|
|
240
|
+
this._fetchData();
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
attached() {
|
|
244
|
+
this._fetchData();
|
|
245
|
+
},
|
|
246
|
+
observers: {
|
|
247
|
+
// 当参数变化时
|
|
248
|
+
'datasource,filterData,field,operationType,label,isCountEmpty,isShowUnit,unit,decimalDigits,suffix':
|
|
249
|
+
function () {
|
|
250
|
+
this._fetchData();
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<view class="weda-statistics-card weda-ui {{className}}" style="{{style}}" bind:tap="tap">
|
|
2
|
+
<view class="weda-statistics-card__wrapper">
|
|
3
|
+
<view class="weda-statistics-card__title">{{label}}</view>
|
|
4
|
+
<view class="weda-statistics-card__detail">
|
|
5
|
+
<text class="weda-statistics-card__count">{{count}}</text>
|
|
6
|
+
<text class="weda-statistics-card__unit">{{suffix}}</text>
|
|
7
|
+
</view>
|
|
8
|
+
</view>
|
|
9
|
+
</view>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.weda-statistics-card {
|
|
2
|
+
background: #ffffff;
|
|
3
|
+
border: 1px solid #f1f2f5;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1);
|
|
6
|
+
border-radius: 6px;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
max-width: 100%;
|
|
9
|
+
min-height: 140px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.weda-statistics-card .weda-statistics-card__wrapper {
|
|
13
|
+
width: 100%;
|
|
14
|
+
padding: 40px 24px;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.weda-statistics-card .weda-statistics-card__title {
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
line-height: 22px;
|
|
21
|
+
color: rgba(0, 0, 0, 0.6);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.weda-statistics-card .weda-statistics-card__detail {
|
|
25
|
+
margin-top: 4px;
|
|
26
|
+
font-size: 28px;
|
|
27
|
+
line-height: 34px;
|
|
28
|
+
color: rgba(0, 0, 0, 0.9);
|
|
29
|
+
word-break: break-all;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.weda-statistics-card .weda-statistics-card__count {
|
|
33
|
+
font-size: 28px;
|
|
34
|
+
line-height: 34px;
|
|
35
|
+
color: rgba(0, 0, 0, 0.9);
|
|
36
|
+
word-break: break-all;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.weda-statistics-card .weda-statistics-card__unit {
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
line-height: 22px;
|
|
42
|
+
color: rgba(0, 0, 0, 0.4);
|
|
43
|
+
margin-left: 4px;
|
|
44
|
+
vertical-align: middle;
|
|
45
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
options: {
|
|
3
|
+
virtualHost: true,
|
|
4
|
+
},
|
|
5
|
+
properties: {
|
|
6
|
+
className: {
|
|
7
|
+
type: String,
|
|
8
|
+
value: '',
|
|
9
|
+
},
|
|
10
|
+
style: {
|
|
11
|
+
type: String,
|
|
12
|
+
value: '',
|
|
13
|
+
},
|
|
14
|
+
datasource: {
|
|
15
|
+
type: Object,
|
|
16
|
+
value: {},
|
|
17
|
+
},
|
|
18
|
+
where: {
|
|
19
|
+
type: Array,
|
|
20
|
+
value: [],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
data: {
|
|
24
|
+
innerBeforeDataChange: function (values) {
|
|
25
|
+
return values?.[0];
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
handleEvent: function (params) {
|
|
30
|
+
const { type, detail } = params || {};
|
|
31
|
+
type && this.triggerEvent(type, detail);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<list-view
|
|
2
|
+
className="weda-data-view__containor {{className}}"
|
|
3
|
+
style="{{style}}"
|
|
4
|
+
datasource="{{datasource}}"
|
|
5
|
+
where="{{where}}"
|
|
6
|
+
pageSize="{{1}}"
|
|
7
|
+
pagination="none"
|
|
8
|
+
beforeDataChange="{{innerBeforeDataChange}}"
|
|
9
|
+
bindonDataChange="handleEvent"
|
|
10
|
+
bindqueryFail="handleEvent"
|
|
11
|
+
bindqueryEmpty="handleEvent"
|
|
12
|
+
bindquerySuccess="handleEvent"
|
|
13
|
+
>
|
|
14
|
+
<slot></slot>
|
|
15
|
+
</list-view>
|
|
File without changes
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import classNames from '../../../utils/classnames';
|
|
2
|
+
import destr from '../../../utils/destr';
|
|
2
3
|
import handleEvents from '../../../utils/handleEvents';
|
|
4
|
+
import { callWedaApi } from '../../../utils/tcb';
|
|
3
5
|
|
|
4
6
|
Component({
|
|
5
7
|
options: {
|
|
@@ -41,15 +43,24 @@ Component({
|
|
|
41
43
|
type: Boolean,
|
|
42
44
|
value: false,
|
|
43
45
|
},
|
|
46
|
+
format: {
|
|
47
|
+
type: String,
|
|
48
|
+
value: '',
|
|
49
|
+
},
|
|
50
|
+
enumName: {
|
|
51
|
+
type: String,
|
|
52
|
+
value: '',
|
|
53
|
+
}
|
|
44
54
|
},
|
|
45
55
|
data: {
|
|
46
56
|
cls: '',
|
|
47
57
|
subCls: '',
|
|
48
58
|
isFlex: true,
|
|
59
|
+
defaultRange: []
|
|
49
60
|
},
|
|
50
61
|
lifetimes: {
|
|
51
62
|
attached() {
|
|
52
|
-
const { className, layout, disabled } = this.properties;
|
|
63
|
+
const { className, layout, disabled, range } = this.properties;
|
|
53
64
|
const isFlex = layout !== 'vertical';
|
|
54
65
|
const cls = classNames({
|
|
55
66
|
'weda-ui': true,
|
|
@@ -63,10 +74,26 @@ Component({
|
|
|
63
74
|
'weui-cell_disabled': disabled,
|
|
64
75
|
});
|
|
65
76
|
|
|
66
|
-
this.setData({ cls, subCls, isFlex });
|
|
77
|
+
this.setData({ cls, subCls, isFlex, defaultRange: range });
|
|
67
78
|
},
|
|
68
79
|
},
|
|
69
80
|
methods: {
|
|
81
|
+
_fetchData: async function () {
|
|
82
|
+
let data = await callWedaApi({
|
|
83
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
84
|
+
data: { OptNameList: [this.properties.enumName], PageIndex: 1, PageSize: 10 },
|
|
85
|
+
});
|
|
86
|
+
const config = destr(data?.Items?.[0]?.Config) ?? [];
|
|
87
|
+
const option = config.map(item => {
|
|
88
|
+
return {
|
|
89
|
+
label: item.value,
|
|
90
|
+
value: item.key,
|
|
91
|
+
checked: false
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
this.setData({ defaultRange: option });
|
|
95
|
+
},
|
|
96
|
+
|
|
70
97
|
...handleEvents([
|
|
71
98
|
{
|
|
72
99
|
name: 'change',
|
|
@@ -74,4 +101,16 @@ Component({
|
|
|
74
101
|
},
|
|
75
102
|
]),
|
|
76
103
|
},
|
|
104
|
+
observers: {
|
|
105
|
+
range: function (range) {
|
|
106
|
+
if (this.properties.format !== 'x-enum') {
|
|
107
|
+
this.setData({ defaultRange: range });
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
format: function (format) {
|
|
111
|
+
if (format === 'x-enum' && this.properties.enumName) {
|
|
112
|
+
this._fetchData();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
77
116
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
requiredFlag="{{requiredFlag}}"
|
|
8
8
|
>
|
|
9
9
|
<checkbox-group class="{{isFlex ? 'weui-flex__item' : ''}}" bindchange="change">
|
|
10
|
-
<label class="{{subCls}}" wx:for="{{
|
|
10
|
+
<label class="{{subCls}}" wx:for="{{defaultRange}}" wx:key="value">
|
|
11
11
|
<view class="weui-cell__hd">
|
|
12
12
|
<checkbox
|
|
13
13
|
class="weui-check"
|