forked from hjqhezgh/lessgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
comp_custom_formpanel.go
80 lines (63 loc) · 1.9 KB
/
comp_custom_formpanel.go
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Title:自定义表单
//
// Description:
//
// Author:black
//
// Createtime:2013-08-09 16:48
//
// Version:1.0
//
// 修改历史:版本号 修改日期 修改人 修改说明
//
// 1.0 2013-08-09 16:48 black 创建文档
package lessgo
import (
"bytes"
"text/template"
)
type customFormPanel struct {
Load string `xml:"load,attr"`
LoadUrl string `xml:"loadUrl,attr"`
SaveUrl string `xml:"saveUrl,attr"`
Id string `xml:"id,attr"`
PageId string `xml:"pageId,attr"`
Title string `xml:"title,attr"`
Elements []element `xml:"element"`
FormButtons []formButton `xml:"formButton"`
BeforeSave string `xml:"beforeSave"`
AfterRender string `xml:"afterRender"`
AfterSave string `xml:"afterSave"`
Inwindow string `xml:"inwindow,attr"`
HideSaveButton string `xml:"hideSaveButton,attr"`
HideResetButton string `xml:"hideResetButton,attr"`
}
func (formpanel customFormPanel) generate(terminal, packageName string, employee Employee) []byte {
var t *template.Template
var buf bytes.Buffer
formpanel.Id = packageName + "." + formpanel.Id
runtimeComponentContain[formpanel.Id] = formpanel
t = template.New("customformpanel.html")
t = t.Funcs(template.FuncMap{
"getComponentId": getComponentId,
"compareInt": CompareInt,
"compareString": CompareString,
"getPropValue": GetPropValue,
"dealHTMLEscaper": DealHTMLEscaper,
})
t, err := t.ParseFiles("../lessgo/template/component/" + terminal + "/customformpanel.html")
if err != nil {
Log.Error(err.Error())
return []byte{}
}
data := make(map[string]interface{})
data["CustomFormPanel"] = formpanel
data["Terminal"] = terminal
data["Employee"] = employee
err = t.Execute(&buf, data)
if err != nil {
Log.Error(err.Error())
return []byte{}
}
return buf.Bytes()
}