1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// 自定义field中间件
func NewCustomizedFieldMiddlewares() form_context.FormMiddlewares {
return new(customizedFieldMiddlewares)
}
type customizedFieldMiddlewares struct{}
func (r *customizedFieldMiddlewares) Register(ctx form_context.FormContext) {
ctx.GetResponsePipeline().Add(r.HandleResponse)
}
// ctx的metadataApi可以加一个field(主表子表)
func (r *customizedFieldMiddlewares) HandleResponse(ctx form_context.FormContext, res *context.BizFormConfigResponse) *context.BizFormConfigResponse {
isMobile := ctx.GetSolution().FormTemplate.IsMobile
if isMobile == true {
return res
}
addMasterFields(ctx)
return res
}
// 定义field
func addMasterFields(ctx form_context.FormContext) {
api := ctx.GetMetadataApi()
item := form_context.FormMasterFieldParams{
MetadataField: metadata.Field{
Path: "project",
DisplayName: "项目编码",
IsContextField: true,
Required: true,
Readonly: false,
IsExtend: true,
IsExtendField: true,
ExtendInfo: &metadata.ExtendInfo{
Type: "String",
ReferType: "Project",
EnumType: "",
IsMulti: false,
IsSubmit: false,
Precision: 0,
},
},
TemplateField: template.Field{
FieldBase: template.FieldBase{
Extended: true,
Path: "project",
Required: true,
DisplayName: "项目编码",
},
Colspan: 1,
Rowspan: 1,
},
SectionIndex: 0,
InsertIndex: 6,
}
api.AddMasterField(item)
}
|