Blame view

src/main/resources/templates/vm/html/add.html.vm 14 KB
tangying authored
1
<!DOCTYPE HTML>
mahuandong authored
2
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
tangying authored
3
<meta charset="utf-8">
mahuandong authored
4
5
6
7
8
9
10
11
12
<head>
    <th:block th:include="include :: header"/>
    #foreach($column in $columns)
        #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
            <th:block th:include="include :: datetimepicker-css"/>
            #break
        #end
    #end
</head>
tangying authored
13
<body class="white-bg">
mahuandong authored
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-${businessName}-add">
        #if($table.sub)
            <h4 class="form-header h4">${functionName}信息</h4>
        #end
        #foreach($column in $columns)
            #set($field=$column.javaField)
            #if($column.insert && !$column.pk)
                #if(($column.usableColumn) || (!$column.superColumn))
                    #set($parentheseIndex=$column.columnComment.indexOf("("))
                    #if($parentheseIndex != -1)
                        #set($comment=$column.columnComment.substring(0, $parentheseIndex))
                    #else
                        #set($comment=$column.columnComment)
                    #end
                    #set($dictType=$column.dictType)
                    #if("" != $treeParentCode && $column.javaField == $treeParentCode)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    #set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
                                    #set($treeId = "${className}?.${treeCode}")
                                    <input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${treeId}}"/>
                                    <input class="form-control" type="text" onclick="select${BusinessName}Tree()"
                                           id="treeName" readonly="true" th:value="${${treeName}}"#if($column.required)
                                           required#end>
                                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                                </div>
                            </div>
                        </div>
                    #elseif($column.htmlType == "input")
                        <div class="form-group">
                            <label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}
</label>
                            <div class="col-sm-8">
                                <input name="${field}" class="form-control" type="text"#if($column.required)
                                       required#end>
                            </div>
                        </div>
                    #elseif($column.htmlType == "select" && "" != $dictType)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <select name="${field}" class="form-control m-b"
                                        th:with="type=${@dict.getType('${dictType}')}"#if($column.required)
                                        required#end>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </div>
                    #elseif($column.htmlType == "select" && $dictType)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <select name="${field}" class="form-control m-b"#if($column.required) required#end>
                                    <option value="">所有</option>
                                </select>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                            </div>
                        </div>
                    #elseif($column.htmlType == "checkbox" && "" != $dictType)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8" th:with="type=${@dict.getType('${dictType}')}">
                                <label th:each="dict : ${type}" class="check-box">
                                    <input name="${field}" type="checkbox" th:value="${dict.dictValue}"
                                           th:text="${dict.dictLabel}"#if($column.required) required#end>
                                </label>
                            </div>
                        </div>
                    #elseif($column.htmlType == "checkbox" && $dictType)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <label class="check-box">
                                    <input name="${field}" type="checkbox"#if($column.required) required#end>
                                </label>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                            </div>
                        </div>
                    #elseif($column.htmlType == "radio" && "" != $dictType)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
                                    <input type="radio" th:id="${'${field}_' + dict.dictCode}" name="${field}"
                                           th:value="${dict.dictValue}"
                                           th:checked="${dict.default}"#if($column.required) required#end>
                                    <label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                                </div>
                            </div>
                        </div>
                    #elseif($column.htmlType == "radio" && $dictType)
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <div class="radio-box">
                                    <input type="radio" name="${field}" value=""#if($column.required) required#end>
                                    <label th:for="${field}" th:text="未知"></label>
                                </div>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                            </div>
                        </div>
                    #elseif($column.htmlType == "datetime")
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <div class="input-group date">
                                    <input name="${field}" class="form-control" placeholder="yyyy-MM-dd"
                                           type="text"#if($column.required) required#end>
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                </div>
                            </div>
                        </div>
                    #elseif($column.htmlType == "textarea")
                        <div class="form-group">
                            <label class="col-sm-3 control-label">${comment}:</label>
                            <div class="col-sm-8">
                                <textarea name="${field}" class="form-control"#if($column.required)
                                          required#end></textarea>
                            </div>
                        </div>
                    #end
                #end
            #end
        #end
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">提交</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
    #foreach($column in $columns)
        #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
        <th:block th:include="include :: datetimepicker-js"/>
            #break
        #end
    #end
<script type="text/javascript">
    var prefix = ctx + "${moduleName}/${businessName}"
        #if($table.sub)
            #foreach($column in $subTable.columns)
                #if(${column.dictType} != '')
                var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
                #end
            #end
        #end
    $("#form-${businessName}-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
        }
    }
        #foreach($column in $columns)
            #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")

            $("input[name='$column.javaField']").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });
            #end
        #end
        #if($table.tree)

        /*${functionName}-新增-选择父部门树*/
        function select${BusinessName}Tree() {
            var options = {
                title: '${functionName}选择',
                width: "380",
                url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
        #end
        #if($table.sub)

        $(function () {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
            	columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                        var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                        return columnIndex + $.table.serialNumber(index);
                    }
                },
                #foreach($column in $subTable.columns)
                    #set($dictType=$column.dictType)
                    #set($javaField=$column.javaField)
                    #set($parentheseIndex=$column.columnComment.indexOf("("))
                    #if($parentheseIndex != -1)
                        #set($comment=$column.columnComment.substring(0, $parentheseIndex))
                    #else
                        #set($comment=$column.columnComment)
                    #end
                    #if($column.pk || $javaField == ${subTableFkclassName})
                    #elseif($column.list && "" != $dictType)
                    {
                        field: '${javaField}',
                        align: 'center',
                        title: '${comment}',
                        formatter: function (value, row, index) {
                            var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
                            return $.common.dictToSelect(${javaField}Datas, value, name);
                        }
                        #if($velocityCount != $subTable.columns.size())},#end

                    #else
                    {
                        field: '${javaField}',
                        align: 'center',
                        title: '${comment}',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
                            return html;
                        }
                        #if($velocityCount != $subTable.columns.size())},#end

                    #end
                #end
            }
        ]
        };
        $.table.init(options);
        })
        ;

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();

            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
            #foreach($column in $subTable.columns)
                #set($javaField=$column.javaField)
                #if($column.pk || $javaField == ${subTableFkclassName})
                #else
                    ${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end

                #end
            #end
        }
        })
            ;
        }
        #end
</script>
tangying authored
289
290
</body>
</html>