@@ -19,10 +19,20 @@ const ColumnChartEdit = (props: Props) => {
19
19
const config = props . data ?. config ;
20
20
// 历史数据:数据量、时间范围
21
21
// 聚合数据:数据量、时间范围、聚合类型、时间周期
22
+ const getData = ( ) => {
23
+ let data : any ;
24
+ form . validateFields ( ( err , fileValue ) => {
25
+ if ( err ) {
26
+ return ;
27
+ }
28
+ data = fileValue ;
29
+ } ) ;
30
+ return data ;
31
+ }
22
32
useEffect ( ( ) => {
23
33
// 加载后执行
24
34
if ( props . save ) {
25
- props . save ( ( ) => form . getFieldsValue ( ) )
35
+ props . save ( ( ) => getData ( ) )
26
36
}
27
37
if ( props . data ) {
28
38
setType ( props . data ?. config ?. dimension ) ;
@@ -40,7 +50,8 @@ const ColumnChartEdit = (props: Props) => {
40
50
label = "数据量"
41
51
>
42
52
{ getFieldDecorator ( 'history' , {
43
- initialValue : config ?. history || 30
53
+ initialValue : config ?. history || 30 ,
54
+ rules : [ { required : true , message : '请输入数据量' } ]
44
55
} ) (
45
56
< InputNumber style = { { width : '100%' } } />
46
57
) }
@@ -51,7 +62,9 @@ const ColumnChartEdit = (props: Props) => {
51
62
label = "时间格式"
52
63
>
53
64
{ getFieldDecorator ( 'timeFormat' , {
54
- initialValue : config ?. timeFormat
65
+ initialValue : config ?. timeFormat || 'yyyy-MM-dd' ,
66
+ rules : [ { required : true , message : '请输入时间格式' } ]
67
+
55
68
} ) (
56
69
< Input />
57
70
) }
@@ -68,7 +81,9 @@ const ColumnChartEdit = (props: Props) => {
68
81
style = { { display : 'inline-block' , width : 'calc(50% - 12px)' } }
69
82
>
70
83
{ getFieldDecorator ( 'from' , {
71
- initialValue : config ?. from
84
+ initialValue : config ?. from || 'now-7d' ,
85
+ rules : [ { required : true } ]
86
+
72
87
} ) (
73
88
< Input />
74
89
) }
@@ -80,7 +95,7 @@ const ColumnChartEdit = (props: Props) => {
80
95
style = { { display : 'inline-block' , width : 'calc(50% - 12px)' } }
81
96
>
82
97
{ getFieldDecorator ( 'to' , {
83
- initialValue : config ?. to
98
+ initialValue : config ?. to ,
84
99
} ) (
85
100
< Input />
86
101
) }
@@ -98,7 +113,9 @@ const ColumnChartEdit = (props: Props) => {
98
113
label = "数据量"
99
114
>
100
115
{ getFieldDecorator ( 'limit' , {
101
- initialValue : config ?. limit || 30
116
+ initialValue : config ?. limit || 30 ,
117
+ rules : [ { required : true , message : '请输入数据量' } ]
118
+
102
119
} ) (
103
120
< InputNumber style = { { width : '100%' } } />
104
121
) }
@@ -109,7 +126,9 @@ const ColumnChartEdit = (props: Props) => {
109
126
label = "聚合类型"
110
127
>
111
128
{ getFieldDecorator ( 'agg' , {
112
- initialValue : config ?. agg || 'avg'
129
+ initialValue : config ?. agg || 'avg' ,
130
+ rules : [ { required : true } ]
131
+
113
132
} ) (
114
133
< Select >
115
134
< Select . Option value = "avg" > AVG</ Select . Option >
@@ -133,7 +152,7 @@ const ColumnChartEdit = (props: Props) => {
133
152
style = { { display : 'inline-block' , width : 'calc(50% - 12px)' } }
134
153
>
135
154
{ getFieldDecorator ( 'from' , {
136
- initialValue : config ?. from || 'now-30d'
155
+ initialValue : config ?. from || 'now-30d' ,
137
156
} ) (
138
157
< Input />
139
158
) }
@@ -157,7 +176,9 @@ const ColumnChartEdit = (props: Props) => {
157
176
< Tooltip title = "M:月、d:天、h:小时、m:分钟、" >
158
177
< Form . Item label = "时间间隔" >
159
178
{ getFieldDecorator ( 'time' , {
160
- initialValue : config ?. time || '1d'
179
+ initialValue : config ?. time || '1d' ,
180
+ rules : [ { required : true , message : '请输入时间间隔' } ]
181
+
161
182
} ) (
162
183
< Input />
163
184
) }
@@ -169,7 +190,9 @@ const ColumnChartEdit = (props: Props) => {
169
190
label = "时间格式"
170
191
>
171
192
{ getFieldDecorator ( 'format' , {
172
- initialValue : config ?. format || 'yyyy-MM-dd'
193
+ initialValue : config ?. format || 'yyyy-MM-dd' ,
194
+ rules : [ { required : true , message : '请输入时间格式' } ]
195
+
173
196
} ) (
174
197
< Input />
175
198
) }
@@ -189,7 +212,9 @@ const ColumnChartEdit = (props: Props) => {
189
212
label = "名称"
190
213
>
191
214
{ getFieldDecorator ( 'name' , {
192
- initialValue : config ?. name
215
+ initialValue : config ?. name ,
216
+ rules : [ { required : true , message : '请输入名称' } ]
217
+
193
218
} ) (
194
219
< Input /> ) }
195
220
</ Form . Item >
@@ -199,7 +224,9 @@ const ColumnChartEdit = (props: Props) => {
199
224
label = "X轴"
200
225
>
201
226
{ getFieldDecorator ( 'x' , {
202
- initialValue : config ?. x || '时间'
227
+ initialValue : config ?. x || '时间' ,
228
+ rules : [ { required : true , message : '请输入X轴名称' } ]
229
+
203
230
} ) (
204
231
< Input placeholder = "X轴名称" />
205
232
) }
@@ -210,7 +237,9 @@ const ColumnChartEdit = (props: Props) => {
210
237
label = "Y轴"
211
238
>
212
239
{ getFieldDecorator ( 'y' , {
213
- initialValue : config ?. y || '值'
240
+ initialValue : config ?. y || '值' ,
241
+ rules : [ { required : true , message : '请输入Y轴名称' } ]
242
+
214
243
} ) (
215
244
< Input placeholder = "Y轴名称" />
216
245
) }
@@ -221,7 +250,9 @@ const ColumnChartEdit = (props: Props) => {
221
250
label = "属性"
222
251
>
223
252
{ getFieldDecorator ( 'measurement' , {
224
- initialValue : config ?. measurement
253
+ initialValue : config ?. measurement ,
254
+ rules : [ { required : true , message : '请选择属性' } ]
255
+
225
256
} ) (
226
257
< Select style = { { width : "100%" } } >
227
258
{ properties . map ( ( i : any ) => < Select . Option key = { i . id } value = { i . id } > { i . name } </ Select . Option > ) }
@@ -234,7 +265,9 @@ const ColumnChartEdit = (props: Props) => {
234
265
label = "类型"
235
266
>
236
267
{ getFieldDecorator ( 'dimension' , {
237
- initialValue : config ?. dimension
268
+ initialValue : config ?. dimension ,
269
+ rules : [ { required : true , message : '请选择数据类型' } ]
270
+
238
271
} ) (
239
272
< Select onChange = { ( e : string ) => setType ( e ) } >
240
273
< Select . Option value = 'history' > 历史数据</ Select . Option >
0 commit comments