liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
    <title>票务代理管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        var validateForm;
        function doSubmit(){//回调函数,在编辑和保存动作时,供openDialog调用提交表单。
          if(validateForm.form()){
              $("#inputForm").submit();
              return true;
          }
    
          return false;
        }
        $(document).ready(function() {
            validateForm = $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交,请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误,请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
            
                    laydate({
                        elem: '#inDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎,因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                        event: 'focus' //响应事件。如果没有传入event,则按照默认的click
                    });
        });
        function addRow(list, idx, tpl, row){
            $(list).append(Mustache.render(tpl, {
                idx: idx, delBtn: true, row: row
            }));
            $(list+idx).find("select").each(function(){
                $(this).val($(this).attr("data-value"));
            });
            $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
                var ss = $(this).attr("data-value").split(',');
                for (var i=0; i<ss.length; i++){
                    if($(this).val() == ss[i]){
                        $(this).attr("checked","checked");
                    }
                }
            });
        }
        function delRow(obj, prefix){
            var id = $(prefix+"_id");
            var delFlag = $(prefix+"_delFlag");
            if (id.val() == ""){
                $(obj).parent().parent().remove();
            }else if(delFlag.val() == "0"){
                delFlag.val("1");
                $(obj).html("&divide;").attr("title", "撤销删除");
                $(obj).parent().parent().addClass("error");
            }else if(delFlag.val() == "1"){
                delFlag.val("0");
                $(obj).html("&times;").attr("title", "删除");
                $(obj).parent().parent().removeClass("error");
            }
        }
    </script>
</head>
<body>
    <form:form id="inputForm" modelAttribute="testDataMain" action="${ctx}/test/onetomany/testDataMain/save" method="post" class="form-horizontal">
        <form:hidden path="id"/>
        <sys:message content="${message}"/>    
        <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
           <tbody>
                <tr>
                    <td class="width-15 active"><label class="pull-right"><font color="red">*</font>归属用户:</label></td>
                    <td class="width-35">
                        <sys:treeselect id="user" name="user.id" value="${testDataMain.user.id}" labelName="user.name" labelValue="${testDataMain.user.name}"
                            title="用户" url="/sys/office/treeData?type=3" cssClass="form-control required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    <td class="width-15 active"><label class="pull-right"><font color="red">*</font>归属部门:</label></td>
                    <td class="width-35">
                        <sys:treeselect id="office" name="office.id" value="${testDataMain.office.id}" labelName="office.name" labelValue="${testDataMain.office.name}"
                            title="部门" url="/sys/office/treeData?type=2" cssClass="form-control required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                </tr>
                <tr>
                    <td class="width-15 active"><label class="pull-right"><font color="red">*</font>归属区域:</label></td>
                    <td class="width-35">
                        <sys:treeselect id="area" name="area.id" value="${testDataMain.area.id}" labelName="area.name" labelValue="${testDataMain.area.name}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    <td class="width-15 active"><label class="pull-right"><font color="red">*</font>名称:</label></td>
                    <td class="width-35">
                        <form:input path="name" htmlEscape="false" maxlength="100" class="form-control required"/>
                    </td>
                </tr>
                <tr>
                    <td class="width-15 active"><label class="pull-right"><font color="red">*</font>性别:</label></td>
                    <td class="width-35">
                        <form:radiobuttons path="sex" items="${fns:getDictList('sex')}" itemLabel="label" itemValue="value" htmlEscape="false" class="i-checks required"/>
                    </td>
                    <td class="width-15 active"><label class="pull-right"><font color="red">*</font>加入日期:</label></td>
                    <td class="width-35">
                        <input id="inDate" name="inDate" type="text" maxlength="20" class="laydate-icon form-control layer-date required"
                            value="<fmt:formatDate value="${testDataMain.inDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
                    </td>
                </tr>
                <tr>
                    <td class="width-15 active"><label class="pull-right">备注信息:</label></td>
                    <td class="width-35">
                        <form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="form-control "/>
                    </td>
                    <td class="width-15 active"></td>
                       <td class="width-35" ></td>
                  </tr>
             </tbody>
        </table>
        
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">火车票:</a>
                </li>
                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">飞机票:</a>
                </li>
                <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">汽车票:</a>
                </li>
            </ul>
            <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
            <a class="btn btn-white btn-sm" onclick="addRow('#testDataChildList', testDataChildRowIdx, testDataChildTpl);testDataChildRowIdx = testDataChildRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
            <table id="contentTable" class="table table-striped table-bordered table-condensed">
                <thead>
                    <tr>
                        <th class="hide"></th>
                        <th>出发地</th>
                        <th>目的地</th>
                        <th>代理价格</th>
                        <th>备注信息</th>
                        <th width="10">&nbsp;</th>
                    </tr>
                </thead>
                <tbody id="testDataChildList">
                </tbody>
            </table>
            <script type="text/template" id="testDataChildTpl">//<!--
                <tr id="testDataChildList{{idx}}">
                    <td class="hide">
                        <input id="testDataChildList{{idx}}_id" name="testDataChildList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                        <input id="testDataChildList{{idx}}_delFlag" name="testDataChildList[{{idx}}].delFlag" type="hidden" value="0"/>
                    </td>
                    
                    <td  class="max-width-250">
                        <sys:treeselect id="testDataChildList{{idx}}_start" name="testDataChildList[{{idx}}].start.id" value="{{row.start.id}}" labelName="testDataChildList{{idx}}.start.name" labelValue="{{row.start.name}}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control  required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    
                    
                    <td  class="max-width-250">
                        <sys:treeselect id="testDataChildList{{idx}}_end" name="testDataChildList[{{idx}}].end.id" value="{{row.end.id}}" labelName="testDataChildList{{idx}}.end.name" labelValue="{{row.end.name}}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control  required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    
                    
                    <td>
                        <input id="testDataChildList{{idx}}_price" name="testDataChildList[{{idx}}].price" type="text" value="{{row.price}}" class="form-control required number"/>
                    </td>
                    
                    
                    <td>
                        <textarea id="testDataChildList{{idx}}_remarks" name="testDataChildList[{{idx}}].remarks" rows="4" maxlength="255" class="form-control ">{{row.remarks}}</textarea>
                    </td>
                    
                    <td class="text-center" width="10">
                        {{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChildList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
                    </td>
                </tr>//-->
            </script>
            <script type="text/javascript">
                var testDataChildRowIdx = 0, testDataChildTpl = $("#testDataChildTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                $(document).ready(function() {
                    var data = ${fns:toJson(testDataMain.testDataChildList)};
                    for (var i=0; i<data.length; i++){
                        addRow('#testDataChildList', testDataChildRowIdx, testDataChildTpl, data[i]);
                        testDataChildRowIdx = testDataChildRowIdx + 1;
                    }
                });
            </script>
            </div>
                <div id="tab-2" class="tab-pane">
            <a class="btn btn-white btn-sm" onclick="addRow('#testDataChild2List', testDataChild2RowIdx, testDataChild2Tpl);testDataChild2RowIdx = testDataChild2RowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
            <table id="contentTable" class="table table-striped table-bordered table-condensed">
                <thead>
                    <tr>
                        <th class="hide"></th>
                        <th>出发地</th>
                        <th>目的地</th>
                        <th>代理价格</th>
                        <th>备注信息</th>
                        <th width="10">&nbsp;</th>
                    </tr>
                </thead>
                <tbody id="testDataChild2List">
                </tbody>
            </table>
            <script type="text/template" id="testDataChild2Tpl">//<!--
                <tr id="testDataChild2List{{idx}}">
                    <td class="hide">
                        <input id="testDataChild2List{{idx}}_id" name="testDataChild2List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                        <input id="testDataChild2List{{idx}}_delFlag" name="testDataChild2List[{{idx}}].delFlag" type="hidden" value="0"/>
                    </td>
                    
                    <td  class="max-width-250">
                        <sys:treeselect id="testDataChild2List{{idx}}_start" name="testDataChild2List[{{idx}}].start.id" value="{{row.start.id}}" labelName="testDataChild2List{{idx}}.start.name" labelValue="{{row.start.name}}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control  required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    
                    
                    <td  class="max-width-250">
                        <sys:treeselect id="testDataChild2List{{idx}}_end" name="testDataChild2List[{{idx}}].end.id" value="{{row.end.id}}" labelName="testDataChild2List{{idx}}.end.name" labelValue="{{row.end.name}}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control  required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    
                    
                    <td>
                        <input id="testDataChild2List{{idx}}_price" name="testDataChild2List[{{idx}}].price" type="text" value="{{row.price}}" class="form-control  number"/>
                    </td>
                    
                    
                    <td>
                        <textarea id="testDataChild2List{{idx}}_remarks" name="testDataChild2List[{{idx}}].remarks" rows="4" maxlength="255" class="form-control ">{{row.remarks}}</textarea>
                    </td>
                    
                    <td class="text-center" width="10">
                        {{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild2List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
                    </td>
                </tr>//-->
            </script>
            <script type="text/javascript">
                var testDataChild2RowIdx = 0, testDataChild2Tpl = $("#testDataChild2Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                $(document).ready(function() {
                    var data = ${fns:toJson(testDataMain.testDataChild2List)};
                    for (var i=0; i<data.length; i++){
                        addRow('#testDataChild2List', testDataChild2RowIdx, testDataChild2Tpl, data[i]);
                        testDataChild2RowIdx = testDataChild2RowIdx + 1;
                    }
                });
            </script>
            </div>
                <div id="tab-3" class="tab-pane">
            <a class="btn btn-white btn-sm" onclick="addRow('#testDataChild3List', testDataChild3RowIdx, testDataChild3Tpl);testDataChild3RowIdx = testDataChild3RowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
            <table id="contentTable" class="table table-striped table-bordered table-condensed">
                <thead>
                    <tr>
                        <th class="hide"></th>
                        <th>出发地</th>
                        <th>目的地</th>
                        <th>代理价格</th>
                        <th>备注信息</th>
                        <th width="10">&nbsp;</th>
                    </tr>
                </thead>
                <tbody id="testDataChild3List">
                </tbody>
            </table>
            <script type="text/template" id="testDataChild3Tpl">//<!--
                <tr id="testDataChild3List{{idx}}">
                    <td class="hide">
                        <input id="testDataChild3List{{idx}}_id" name="testDataChild3List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                        <input id="testDataChild3List{{idx}}_delFlag" name="testDataChild3List[{{idx}}].delFlag" type="hidden" value="0"/>
                    </td>
                    
                    <td  class="max-width-250">
                        <sys:treeselect id="testDataChild3List{{idx}}_start" name="testDataChild3List[{{idx}}].start.id" value="{{row.start.id}}" labelName="testDataChild3List{{idx}}.start.name" labelValue="{{row.start.name}}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control  required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    
                    
                    <td  class="max-width-250">
                        <sys:treeselect id="testDataChild3List{{idx}}_end" name="testDataChild3List[{{idx}}].end.id" value="{{row.end.id}}" labelName="testDataChild3List{{idx}}.end.name" labelValue="{{row.end.name}}"
                            title="区域" url="/sys/area/treeData" cssClass="form-control  required" allowClear="true" notAllowSelectParent="true"/>
                    </td>
                    
                    
                    <td>
                        <input id="testDataChild3List{{idx}}_price" name="testDataChild3List[{{idx}}].price" type="text" value="{{row.price}}" class="form-control  number"/>
                    </td>
                    
                    
                    <td>
                        <textarea id="testDataChild3List{{idx}}_remarks" name="testDataChild3List[{{idx}}].remarks" rows="4" maxlength="255" class="form-control ">{{row.remarks}}</textarea>
                    </td>
                    
                    <td class="text-center" width="10">
                        {{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild3List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
                    </td>
                </tr>//-->
            </script>
            <script type="text/javascript">
                var testDataChild3RowIdx = 0, testDataChild3Tpl = $("#testDataChild3Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                $(document).ready(function() {
                    var data = ${fns:toJson(testDataMain.testDataChild3List)};
                    for (var i=0; i<data.length; i++){
                        addRow('#testDataChild3List', testDataChild3RowIdx, testDataChild3Tpl, data[i]);
                        testDataChild3RowIdx = testDataChild3RowIdx + 1;
                    }
                });
            </script>
            </div>
        </div>
        </div>
    </form:form>
</body>
</html>