/
comp_tab_formpanel.go
executable file
·90 lines (72 loc) · 2.16 KB
/
comp_tab_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
81
82
83
84
85
86
87
88
89
90
// Title:多表编辑表单
//
// Description: 可以同时录入多表数据的表单控件,目前只支持添加
//
// Author:black
//
// Createtime:2013-08-19 11:55
//
// Version:1.0
//
// 修改历史:版本号 修改日期 修改人 修改说明
//
// 1.0 2013-08-19 11:55 black 创建文档
package lessgo
import (
"bytes"
"net/http"
"text/template"
)
type tabFormPanel struct {
Id string `xml:"id,attr"`
PageId string `xml:"pageId,attr"`
FormTabs []formTab `xml:"formtab"`
Load string `xml:"load,attr"`
LoadUrl string `xml:"loadUrl,attr"`
SaveUrl string `xml:"saveUrl,attr"`
Title string `xml:"title,attr"`
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"`
}
type formTab struct {
Elements []element `xml:"element"`
Desc string `xml:"desc,attr"`
}
func (tabFormPanel tabFormPanel) generate(terminal, packageName string, r *http.Request, employee Employee) []byte {
var t *template.Template
var buf bytes.Buffer
tabFormPanel.Id = packageName + "." + tabFormPanel.Id
runtimeComponentContain[tabFormPanel.Id] = tabFormPanel
t = template.New("tabformpanel.html")
t = t.Funcs(template.FuncMap{
"getComponentId": getComponentId,
"compareInt": CompareInt,
"compareString": CompareString,
"getPropValue": GetPropValue,
"dealHTMLEscaper": DealHTMLEscaper,
})
t, err := t.ParseFiles("../lessgo/template/component/" + terminal + "/tabformpanel.html")
if err != nil {
Log.Error(err.Error())
return []byte{}
}
if err != nil {
Log.Error(err.Error())
return []byte{}
}
data := make(map[string]interface{})
data["TabFormPanel"] = tabFormPanel
data["Terminal"] = terminal
data["Employee"] = employee
err = t.Execute(&buf, data)
if err != nil {
Log.Error(err.Error())
return []byte{}
}
return buf.Bytes()
}