@@ -68,6 +68,8 @@ const TemplateForm: React.FC<TemplateFormProps> = ({
6868 const values = await form . validateFields ( ) ;
6969 setLoading ( true ) ;
7070
71+ console . log ( "Form values:" , values ) ;
72+
7173 const requestData = {
7274 name : values . name ,
7375 description : values . description ,
@@ -81,6 +83,8 @@ const TemplateForm: React.FC<TemplateFormProps> = ({
8183 } ,
8284 } ;
8385
86+ console . log ( "Request data:" , requestData ) ;
87+
8488 let response ;
8589 if ( mode === "create" ) {
8690 response = await createAnnotationTemplateUsingPost ( requestData ) ;
@@ -287,42 +291,70 @@ const TemplateForm: React.FC<TemplateFormProps> = ({
287291 key = { field . key }
288292 size = "small"
289293 style = { { marginBottom : 12 } }
290- title = { `控件 ${ fields . indexOf ( field ) + 1 } ` }
294+ title = {
295+ < Space >
296+ < span > 控件 { fields . indexOf ( field ) + 1 } </ span >
297+ < Form . Item noStyle shouldUpdate >
298+ { ( ) => {
299+ const controlType = form . getFieldValue ( [ "labels" , field . name , "type" ] ) ;
300+ const fromName = form . getFieldValue ( [ "labels" , field . name , "fromName" ] ) ;
301+ if ( controlType || fromName ) {
302+ return (
303+ < span style = { { fontSize : 12 , fontWeight : 'normal' , color : '#999' } } >
304+ ({ fromName || '未命名' } - { controlType || '未设置类型' } )
305+ </ span >
306+ ) ;
307+ }
308+ return null ;
309+ } }
310+ </ Form . Item >
311+ </ Space >
312+ }
291313 extra = {
292314 < MinusCircleOutlined
293315 style = { { color : "red" } }
294316 onClick = { ( ) => remove ( field . name ) }
295317 />
296318 }
297319 >
298- < Space direction = "vertical" style = { { width : "100%" } } >
299- < Space style = { { width : "100%" } } >
320+ < Space direction = "vertical" style = { { width : "100%" } } size = "middle" >
321+ { /* Row 1: 控件名称, 标注目标对象, 控件类型 */ }
322+ < div style = { { display : 'grid' , gridTemplateColumns : '180px 220px 1fr auto' , gap : 12 , alignItems : 'flex-end' } } >
300323 < Form . Item
301324 { ...field }
302325 label = "来源名称"
303326 name = { [ field . name , "fromName" ] }
304327 rules = { [ { required : true , message : "必填" } ] }
305- style = { { marginBottom : 0 , width : 150 } }
328+ style = { { marginBottom : 0 } }
329+ tooltip = "此控件的唯一标识符"
306330 >
307331 < Input placeholder = "例如:choice" />
308332 </ Form . Item >
309333
310334 < Form . Item
311335 { ...field }
312- label = "目标名称 "
336+ label = "标注目标对象 "
313337 name = { [ field . name , "toName" ] }
314338 rules = { [ { required : true , message : "必填" } ] }
315- style = { { marginBottom : 0 , width : 150 } }
339+ style = { { marginBottom : 0 } }
340+ tooltip = "选择此控件将标注哪个数据对象"
341+ dependencies = { [ 'objects' ] }
316342 >
317- < Input placeholder = "例如:image" />
343+ < Select placeholder = "选择数据对象" >
344+ { ( form . getFieldValue ( "objects" ) || [ ] ) . map ( ( obj : any , idx : number ) => (
345+ < Option key = { idx } value = { obj ?. name || '' } >
346+ { obj ?. name || `对象 ${ idx + 1 } ` } ({ obj ?. type || '未知类型' } )
347+ </ Option >
348+ ) ) }
349+ </ Select >
318350 </ Form . Item >
319351
320352 < Form . Item
321353 { ...field }
322354 label = "控件类型"
323355 name = { [ field . name , "type" ] }
324356 rules = { [ { required : true , message : "必填" } ] }
325- style = { { marginBottom : 0 , width : 250 } }
357+ style = { { marginBottom : 0 } }
326358 >
327359 < Select placeholder = "选择控件类型" >
328360 { controlTypes . map ( ( t ) => (
@@ -335,39 +367,45 @@ const TemplateForm: React.FC<TemplateFormProps> = ({
335367
336368 < Form . Item
337369 { ...field }
338- label = "必填 "
370+ label = " "
339371 name = { [ field . name , "required" ] }
340372 valuePropName = "checked"
341373 style = { { marginBottom : 0 } }
342374 >
343- < Checkbox / >
375+ < Checkbox > 必填 </ Checkbox >
344376 </ Form . Item >
345- </ Space >
377+ </ div >
346378
379+ { /* Row 2: 取值范围定义(添加选项) - Conditionally rendered based on type */ }
347380 < Form . Item
348- { ...field }
349- label = "描述"
350- name = { [ field . name , "description" ] }
351- style = { { marginBottom : 0 } }
381+ noStyle
382+ shouldUpdate = { ( prevValues , currentValues ) => {
383+ const prevType = prevValues . labels ?. [ field . name ] ?. type ;
384+ const currType = currentValues . labels ?. [ field . name ] ?. type ;
385+ return prevType !== currType ;
386+ } }
352387 >
353- < Input placeholder = "标注人员的帮助文本" />
354- </ Form . Item >
388+ { ( { getFieldValue } ) => {
389+ const controlType = getFieldValue ( [ "labels" , field . name , "type" ] ) ;
390+ const fieldName = controlType === "Choices" ? "options" : "labels" ;
355391
356- < Form . Item noStyle shouldUpdate >
357- { ( ) => {
358- const controlType = form . getFieldValue ( [ "labels" , field . name , "type" ] ) ;
359392 if ( needsOptions ( controlType ) ) {
360393 return (
361394 < Form . Item
362395 { ...field }
363396 label = { controlType === "Choices" ? "选项" : "标签" }
364- name = { [ field . name , controlType === "Choices" ? "options" : "labels" ] }
397+ name = { [ field . name , fieldName ] }
365398 rules = { [ { required : true , message : "至少需要一个选项" } ] }
366399 style = { { marginBottom : 0 } }
367400 >
368401 < Select
369402 mode = "tags"
370- placeholder = "输入后按回车添加"
403+ open = { false }
404+ placeholder = {
405+ controlType === "Choices"
406+ ? "输入选项内容,按回车添加。例如:是、否、不确定"
407+ : "输入标签名称,按回车添加。例如:人物、车辆、建筑物"
408+ }
371409 style = { { width : "100%" } }
372410 />
373411 </ Form . Item >
@@ -376,6 +414,17 @@ const TemplateForm: React.FC<TemplateFormProps> = ({
376414 return null ;
377415 } }
378416 </ Form . Item >
417+
418+ { /* Row 3: 描述 */ }
419+ < Form . Item
420+ { ...field }
421+ label = "描述"
422+ name = { [ field . name , "description" ] }
423+ style = { { marginBottom : 0 } }
424+ tooltip = "向标注人员显示的帮助信息"
425+ >
426+ < Input placeholder = "为标注人员提供此控件的使用说明" maxLength = { 200 } />
427+ </ Form . Item >
379428 </ Space >
380429 </ Card >
381430 ) ) }
0 commit comments