addfield_selectItemDiv.jsp
23.7 KB
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
int rowsum=0;
%>
<style type="text/css">
.childItemDiv .e8_outScroll,.childItemDiv .e8_innerShowMust{
display:none;
}
.childItemDiv .e8_innerShow_button{
float:left;
}
.childItemDiv .e8_os{
float:left;
}
.childItemDiv .e8_browflow{
background-image:url("/images/ecology8/workflow/setting_wev8.png") !important;
width:20px !important;
}
#childfieldNotesSpan{
margin-left:10px;
}
</style>
<div id="selectdiv" <%if(fieldhtmltype.equals("5")){%>style="display:''" <%} else {%>style="display:none"<%}%>>
<script type="text/javascript">
var js_label127136 = '<%=SystemEnv.getHtmlLabelName(127136,user.getLanguage())%>';
var js_label127139 = '<%=SystemEnv.getHtmlLabelName(127139,user.getLanguage())%>';
var js_label127141 = '<%=SystemEnv.getHtmlLabelName(127141,user.getLanguage())%>';
var js_label22878 = '<%=SystemEnv.getHtmlLabelName(22878,user.getLanguage())%>';
</script>
<script type="text/javascript" src="/js/workflow/selectItemEdit_wev8.js"></script>
<wea:layout type="2col" attributes="{'expandAllGroup':'true'}">
<wea:group context='<%=SystemEnv.getHtmlLabelName(124984,user.getLanguage()) %>'>
<wea:item type="thead"></wea:item>
<wea:item type="groupHead">
<button type="button" class="e8_btn_top" style="float: left;margin-top:5px;margin-right:10px;" onclick="batchAddOpen('addRow')"/><%=SystemEnv.getHtmlLabelName(127019, user.getLanguage()) %></button>
<button type="button" class="addbtn" id="btnaddRow" style="margin-left:10px;margin-top:5px;float: left;" name=btnaddRow onclick="addRow()" title="<%=SystemEnv.getHtmlLabelName(611,user.getLanguage())%>"></button>
<button type="button" class="delbtn" id="btnsubmitClear" style="margin-left:10px;margin-top:5px;float: left;" name=btnsubmitClear onclick="submitClear()" title="<%=SystemEnv.getHtmlLabelName(23777,user.getLanguage())%>"></button>
</wea:item>
<wea:item attributes="{'isTableList':'true','samePair':'itemShow','display':''}">
<table class="ListStyle" id="oTable" style="width:100%" >
<%-- 表示列表开始 (如果空格太多,页面可能会出现错乱,此处缩进特殊处理)--%>
<colgroup>
<col width="10%">
<col width="5%">
<col width="20%">
<col width="7%">
<col width="35%">
<col width="15%">
<% if(fieldid!=0){%>
<col width="10%">
<%} %>
</colgroup>
<tr class="header notMove">
<th><%=SystemEnv.getHtmlLabelName(1426,user.getLanguage())%></th>
<th><%=SystemEnv.getHtmlLabelName(32011,user.getLanguage())%></th>
<th ><%=SystemEnv.getHtmlLabelName(15442,user.getLanguage())%></th>
<th class="colspanTD" <%if(htmltypeid==2){%> colspan="3" <%}%>><%=SystemEnv.getHtmlLabelName(19206,user.getLanguage())%></th>
<th class="needhideTD" <%if(htmltypeid==2){%> style="display:none" <%}%>><%=SystemEnv.getHtmlLabelName(19207,user.getLanguage())%></th>
<th class="needhideTD" <%if(htmltypeid==2){%> style="display:none" <%}%>><%=SystemEnv.getHtmlLabelName(22663,user.getLanguage())%></th>
<th style="min-width:60px;"><%=SystemEnv.getHtmlLabelName(22151,user.getLanguage())%></th>
</tr>
<%if(fieldid==0){
%>
<tr class="DataLight movingtr" style="cursor:move;" onmouseover="showMoveIcon(this)" onmouseout="hideMoveIcon(this, event)">
<td height="23">
<div>
<input type='checkbox' name='check_select' value="<%=rowsum%>" >
<span movingicon class="movingicon" style="display:inline-block;width:20px;">
<img src='/proj/img/move_wev8.png' title='<%=SystemEnv.getHtmlLabelName(82783,user.getLanguage()) %>'/>
</span>
</div>
</td>
<td>
</td>
<td >
<div style="float:left; display:inline;width:165px;">
<input type=text class="Inputstyle detailInput" id="field_name_<%=rowsum%>_name" name="field_name_<%=rowsum%>_name" style="width:150px!important;" onchange="checkinput('field_name_<%=rowsum%>_name','field_name_<%=rowsum%>_span')">
<span id="field_name_<%=rowsum%>_span"><IMG src="/images/BacoError_wev8.gif" align=absMiddle></span>
</div>
</td>
<td class="colspanTD" <%if(htmltypeid==2){%> colspan="3" <%}%>><input type='checkbox' name='field_checked_<%=rowsum%>_name' value='1'></td>
<td class="needhideTD" <%if(htmltypeid==2){%> style="display:none" <%}%>>
<div style="float:left; display:inline;width:100%;">
<input type='checkbox' name='isAccordToSubCom<%=rowsum%>' id='isAccordToSubCom<%=rowsum%>' value='1' style="float: left;"><%=SystemEnv.getHtmlLabelName(22878,user.getLanguage())%>
<input type='hidden' name='selectvalue<%=rowsum%>' id='selectvalue<%=rowsum%>' value='0' >
<input type='hidden' name='field_count_<%=rowsum%>_name' id='field_count_<%=rowsum%>_name' value='0' >
<brow:browser viewType="0" name='<%="maincategory"+rowsum%>' browserValue="<%=maincategory%>" browserBtnID='<%="maincategory"+rowsum%>'
getBrowserUrlFn="onShowCatalog" getBrowserUrlFnParams='<%=""+rowsum%>'
idKey="id" nameKey="path"
_callback="afterSelect"
_callbackParams='<%=""+rowsum%>'
hasInput="true" isSingle="true" hasBrowser = "true" isMustInput='1'
completeUrl="/data.jsp?type=categoryBrowser&onlySec=true" linkUrl="#" width="60%"
browserSpanValue="<%=docPath%>"></brow:browser>
<span id=mypath<%=rowsum%>><%=docPath%></span>
<input type=hidden id='pathcategory<%=rowsum%>' name='pathcategory<%=rowsum%>' value="<%=docPath%>">
</div>
</td>
<td class="needhideTD" <%if(htmltypeid==2){%> style="display:none" <%}%>>
<%
String selectName = "selectChildItem" + rowsum;
String selectChild = "childItem" + rowsum;
%>
<div style="float:left; display:inline;width:25px;" class="childItemDiv">
<brow:browser viewType="0" name='<%="childItem"+rowsum%>' browserValue=""
getBrowserUrlFn="showChildSelectItem" getBrowserUrlFnParams='<%=""+rowsum%>'
_callback="selectChildSelectItem"
_callbackParams='<%=""+rowsum%>'
hasInput="false" isSingle="false" hasBrowser = "true" isMustInput='1' width="25px"
browserSpanValue=""></brow:browser>
</div>
<span name='<%="childItemSpan"+rowsum%>' class='childItemSpan' id='<%="childItemSpan"+rowsum%>'></span>
</td>
<td style="width:60px;">
<input type='checkbox' name='cancel_<%=rowsum%>_name' value="0" onclick="if(this.checked){this.value=1;}else{this.value=0}">
</td>
</tr>
<% rowsum+=1; %>
<%}else{
int colorcount=0;
String sql="select * from workflow_SelectItem where fieldid="+fieldid+" and isbill=0 order by listorder,selectvalue";//xwj for td2977 20051107 //"id" is added to "order by" by xwj for td3297 20051130
RecordSet RecordSetSelItem = new RecordSet();
RecordSetSelItem.executeSql(sql);
while(RecordSetSelItem.next()){
String selectname=RecordSetSelItem.getString("selectname");
String selectvalue=RecordSetSelItem.getString("selectvalue");
String listorder=RecordSetSelItem.getString("listorder");//xwj for td2977 20051107
String isdefault=RecordSetSelItem.getString("isdefault");//xwj for td2977 20051107
String selectid=RecordSetSelItem.getString("id");//xwj for td3286 20051129
String docspath = "";
String docscategory = RecordSetSelItem.getString("docCategory");
String isAccordToSubCom = Util.null2String(RecordSetSelItem.getString("isAccordToSubCom"));
String childitemid = Util.null2String(RecordSetSelItem.getString("childitemid"));
String cancel=RecordSetSelItem.getString("cancel");//td31072
if(!"".equals(docscategory) && null != docscategory)
//根据路径ID得到路径名称
{
List nameList = Util.TokenizerString(docscategory, ",");
try{
String mainCategory = (String)nameList.get(0);
String subCategory = (String)nameList.get(1);
String secCategory = (String)nameList.get(2);
docspath = secCategoryComInfo.getAllParentName(secCategory,true);
}catch(Exception e){
docspath = secCategoryComInfo.getAllParentName(docscategory,true);
}
}
String childitemidStr = "";
if(!"".equals(childitemid)){
if(childitemid.startsWith(",")) childitemid = childitemid.substring(1);
String[] itemid_sz = Util.TokenizerString2(childitemid, ",");
for(int cx=0; cx<itemid_sz.length; cx++){
String itemid_tmp = itemid_sz[cx];
try{
String[] checktmp_sz = Util.TokenizerString2(itemid_tmp, "a");
String itemidStr_tmp = Util.null2String((String)selectitem_sh.get("si_"+checktmp_sz[0]));
if(!"".equals(itemidStr_tmp)){
childitemidStr += (itemidStr_tmp + ",");
}
}catch(Exception e){}
}
if(!"".equals(childitemidStr)){
childitemidStr = childitemidStr.substring(0, childitemidStr.length()-1);
if(childitemidStr.length() > 10){
childitemidStr = childitemidStr.substring(0,8)+"...";
}
}
}
%>
<tr class="DataLight movingtr" style="cursor:move;" onmouseover="showMoveIcon(this)" onmouseout="hideMoveIcon(this, event)">
<td height="23">
<div>
<input <% if(tof) out.println("disabled");%> type='checkbox' name='check_select' value="<%=selectvalue%>" <%if(fieldCommon.isOptionUsed(String.valueOf(fieldid),type2,selectvalue,0)){%> disabled = "true" <%}//xwj for td3297 20051201 %>>
<span movingicon class="movingicon" style="display:inline-block;width:20px;">
<img src='/proj/img/move_wev8.png' title='<%=SystemEnv.getHtmlLabelName(82783,user.getLanguage()) %>'/>
</span>
</div>
</td>
<td>
<%=""+selectvalue%>
</td>
<td >
<div style="float:left; display:inline;width:165px;">
<input <% if(tof) out.println("disabled");%> class="Inputstyle detailInput" type=text name="field_name_<%=rowsum%>_name" value="<%=Util.toScreen(selectname,user.getLanguage())%>" style="width:150px!important;" onchange="checkinput('field_name_<%=rowsum%>_name','field_name_<%=rowsum%>_span')">
<input type="hidden" value="<%=selectid%>" name="field_id_<%=rowsum%>_name"><!--added by xwj for td3286 20051129-->
<input type='hidden' name='field_count_<%=rowsum%>_name' id='field_count_<%=rowsum%>_name' value='<%=rowsum%>' >
<!--xwj for td2977 20051107 begin-->
<span id="field_name_<%=rowsum%>_span"></span>
</div>
</td>
<td class="colspanTD" <%if(htmltypeid==2){%> colspan="3" <%}%>><input <% if(tof) out.println("disabled");%> type='checkbox' name='field_checked_<%=rowsum%>_name' value='1' <%if("y".equals(isdefault)){%>checked<%}%>>
</td>
<td class="needhideTD" <%if(htmltypeid==2){%> style="display:none" <%}%>>
<div style="float:left; display:inline;width:100%;">
<input type='hidden' name='selectvalue<%=rowsum%>' id='selectvalue<%=rowsum%>' value='<%=selectvalue%>' >
<input <% if(tof) out.println("disabled");%> type='checkbox' name='isAccordToSubCom<%=rowsum%>' id='isAccordToSubCom<%=rowsum%>' value='1' <%if("1".equals(isAccordToSubCom)){%>checked<%}%>><%=SystemEnv.getHtmlLabelName(22878,user.getLanguage())%>
<brow:browser viewType="0" name='<%="maincategory"+rowsum%>' browserValue="<%=docscategory%>"
getBrowserUrlFn="onShowCatalog" getBrowserUrlFnParams='<%=""+rowsum%>'
idKey="id" nameKey="path"
_callback="afterSelect"
_callbackParams='<%=""+rowsum%>'
hasInput="true" isSingle="true" hasBrowser = "true" isMustInput='1'
completeUrl="/data.jsp?type=categoryBrowser&onlySec=true" linkUrl="#" width="60%"
browserSpanValue="<%=docspath%>"></brow:browser>
<input type=hidden id='pathcategory<%=rowsum%>' name='pathcategory<%=rowsum%>' value="<%=docspath%>">
</div>
</td>
<td class="needhideTD" <%if(htmltypeid==2){%> style="display:none" <%}%>>
<div style="float:left; display:inline;width:25px;" class="childItemDiv">
<brow:browser viewType="0" name='<%="childItem"+rowsum%>' browserValue="<%=childitemid%>"
getBrowserUrlFn="showChildSelectItem" getBrowserUrlFnParams='<%=""+rowsum%>'
_callback="selectChildSelectItem"
_callbackParams='<%=""+rowsum%>'
hasInput="false" isSingle="false" hasBrowser = "true" isMustInput='1' width="25px"
browserSpanValue="<%=childitemidStr%>"></brow:browser>
</div>
<span name='<%="childItemSpan"+rowsum%>' class='childItemSpan' id='<%="childItemSpan"+rowsum%>' title='<%=childitemidStr%>'><%=childitemidStr%></span>
</td>
<td><input <% if(tof) out.println("disabled");%> type='checkbox' name='cancel_<%=rowsum%>_name' value="<%=cancel%>" onclick="if(this.checked){this.value=1;}else{this.value=0}" <%if("1".equals(cancel)){%>checked<%}%>>
</tr>
<% rowsum++;
}
}%>
<%-- 表示列表结束 --%>
</table>
</wea:item>
</wea:group>
</wea:layout>
<script type="text/javascript">
//禁止文字选中
/*document.getElementById("oTable").onselectstart = document.getElementById("oTable").ondrag = function(){
return false;
}
*/
rowindex = <%=rowsum%>;
function showMoveIcon(me, e){
e = e || window.event;
var o = e.relatedTarget || e.toElement;
if( o.tagName != 'IMG'){
jQuery(me).find('span[movingicon]').html("<img src='/proj/img/move-hot_wev8.png' title='<%=SystemEnv.getHtmlLabelName(82783,user.getLanguage()) %>'/>");
}
}
function hideMoveIcon(me, e){
e = e || window.event;
var o = e.relatedTarget || e.toElement;
if( o == null || o.tagName != 'IMG'){
jQuery(me).find('span[movingicon]').html("<img src='/proj/img/move_wev8.png' title='<%=SystemEnv.getHtmlLabelName(82783,user.getLanguage()) %>'/>");
}
}
function showChildSelectItem(choicerowindex){
var cfid = $G("childfieldid").value;
var resourceids = jQuery("#childItem" + choicerowindex).val();
var url = "/systeminfo/BrowserMain.jsp?url=" + escape("/workflow/field/SelectItemBrowser.jsp?isbill=0&isdetail=<%=isdetail%>&childfieldid=" + cfid + "&resourceids=" + resourceids);
return url;
}
function selectChildSelectItem(e,rt,name,choicerowindex){
if (rt != null) {
var rid = rt.id;
var rname = rt.name;
if (rid != "") {
var resourceids = rid.substr(1);
var resourcenames = rname.substr(1);
jQuery("#childItem" + choicerowindex).val(resourceids);
jQuery("#childItemSpan" + choicerowindex).html(resourcenames);
jQuery("#childItemSpan" + choicerowindex).attr("title",resourcenames);
} else {
jQuery("#childItem" + choicerowindex).val("");
jQuery("#childItemSpan" + choicerowindex).html("");
jQuery("#childItemSpan" + choicerowindex).removeAttr("title");
}
}
}
//行追加
function addRow(objValue) {
var oTable = $G("oTable");
rowColor = getRowBg();
ncol = oTable.rows[0].cells.length;
oRow = oTable.insertRow(-1);
oRow.style.cursor="move";
jQuery(oRow).addClass("DataLight");
jQuery(oRow).addClass("movingtr");
jQuery(oRow).bind("mouseover",function(event){
showMoveIcon(this);
});
jQuery(oRow).bind("mouseout",function(event){
hideMoveIcon(this, event);
});
for(j=0; j<ncol; j++) {
oCell = oRow.insertCell(-1);
switch(j) {
case 0:
var oDiv = document.createElement("div");
var sHtml = "<input type='checkbox' name='check_select' value='0'><span movingicon class='movingicon ui-sortable-handle' style='display:inline-block;width:20px;'><img src='/proj/img/move_wev8.png' title='<%=SystemEnv.getHtmlLabelName(82783,user.getLanguage()) %>'/></span>";
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
oCell.height = "23px";
break;
<%--xwj for td2977 20051107 begin--%>
case 1:
var oDiv = document.createElement("div");
oDiv.style.display="inline-block";
var sHtml = "";
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
break;
case 2:
var oDiv = document.createElement("div");
oDiv.style.display="inline-block";
var sHtml = "<div style='float:left; display:inline;width:165px;'><input class=\"Inputstyle detailInput\" type='text' style='width:150px!important;float:left;' id='field_name_"+rowindex+"_name' name='field_name_"+rowindex+"_name' ";
if(objValue != undefined && objValue != null && objValue != ""){
sHtml += " value= '" + objValue + "'";
}
sHtml += " onchange=checkinput('field_name_"+rowindex+"_name','field_name_"+rowindex+"_span')>";
if(objValue != undefined && objValue != null && objValue != ""){
sHtml += " <span id='field_name_"+rowindex+"_span'></span></div>";
}else{
sHtml += " <span id='field_name_"+rowindex+"_span'><IMG src='/images/BacoError_wev8.gif' align=absMiddle></span> </div>";
}
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
break;
case 3:
jQuery(oCell).addClass("colspanTD");
if(jQuery("#selectItemType").val() == 2){
jQuery(oCell).attr("colspan","3");
}
var oDiv = document.createElement("div");
var sHtml = " <input type='checkbox' name='field_checked_"+rowindex+"_name' value='1'>";
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
break;
break;
case 4:
jQuery(oCell).addClass("needhideTD");
if(jQuery("#selectItemType").val() == 2){
oCell.style.display = "none";
}
var oDiv = document.createElement("div");
var sHtml = "<div style='float:left; display:inline;width:100%;'><input type='checkbox' name='isAccordToSubCom"+rowindex+"' id='isAccordToSubCom"+rowindex+"' value='1' ><%=SystemEnv.getHtmlLabelName(22878,user.getLanguage())%> "
+ "\r\n<span id='maincategory"+rowindex+"' name='maincategory"+rowindex+"' ></span>"
+ "\r\n<input type='hidden' id='selectvalue"+rowindex+"' name='selectvalue"+rowindex+"' value='" + rowindex + "' />"
+ "\r\n<input type='hidden' name='field_count_" + rowindex + "_name' id='field_count_" + rowindex + "_name' value='" + rowindex + "' >"
+ "\r\n<input type=hidden id='pathcategory" + rowindex + "' name='pathcategory" + rowindex + "' value='<%=docPath%>'>"
+ "\r\n</div>";
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
jQuery("#maincategory"+rowindex).e8Browser({
name:"maincategory"+rowindex,
viewType:"0",
browserValue:"",
isMustInput:"1",
browserSpanValue:"",
hasInput:true,
linkUrl:"#",
isSingle:true,
completeUrl:"/data.jsp?type=categoryBrowser&onlySec=true",
getBrowserUrlFn:'onShowCatalog',
getBrowserUrlFnParams:''+rowindex,
_callback:"afterSelect",
_callbackParams:rowindex,
width:"60%",
hasAdd:false,
isSingle:true
});
break;
<%--xwj for td2977 20051107 end--%>
case 5:
jQuery(oCell).addClass("needhideTD");
if(jQuery("#selectItemType").val() == 2){
oCell.style.display = "none";
}
var oDiv = document.createElement("div");
var sHtml = "<div style='float:left; display:inline;width:25px;' class='childItemDiv'>"
+ "\r\n<span id='childItem"+rowindex+"' name='childItem"+rowindex+"' ></span>"
+ "\r\n</div><span id=\"childItemSpan"+rowindex+"\" class=\"childItemSpan\" name=\"childItemSpan"+rowindex+"\"></span>";
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
jQuery("#childItem"+rowindex).e8Browser({
name:"childItem"+rowindex,
viewType:"0",
browserValue:"",
isMustInput:"1",
browserSpanValue:"",
getBrowserUrlFn:"showChildSelectItem",
getBrowserUrlFnParams:''+rowindex,
_callback:"selectChildSelectItem",
_callbackParams:rowindex,
hasInput:false,
isSingle:false,
hasBrowser:true,
width:"25px",
hasAdd:false
});
break;
case 6:
var oDiv = document.createElement("div");
var sHtml = "<input type='checkbox' name='cancel_"+rowindex+"_name' id='cancel_"+rowindex+"_name' value='1'>";
oDiv.innerHTML = sHtml;
oCell.appendChild(oDiv);
break;
}
}
rowindex += 1;
jQuery("body").jNice();
jQuery("#oTable td").each(function() {
$(this).width($(this).width()); // 在拖动时,拖动行的cell(单元格)宽度会发生改变。在这里做了处理就没问题了
$(this).attr("style",$(this).attr("style"));
$(this).height(30);
});
}
</script>
<link href="/page/element/imgSlide/resource/js/jquery-ui-1.11.4.custom/jquery-ui.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/page/element/imgSlide/resource/js/jquery-ui-1.11.4.custom/jquery-ui.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
registerDragEvent();
jQuery("tr.notMove").bind("mousedown", function() {
return false;
});
$(".field").find("#btnaddRow").remove();
$(".field").find("#btnsubmitClear").remove();
});
function registerDragEvent() {
var fixHelper = function(e, ui) {
ui.children().each(function() {
$(this).width($(this).width()); // 在拖动时,拖动行的cell(单元格)宽度会发生改变。在这里做了处理就没问题了
$(this).height($(this).height());
});
return ui;
};
var copyTR = null;
var startIdx = 0;
var idStr = "#oTable";
jQuery(idStr + " tbody tr").bind("mousedown", function(e) {
copyTR = jQuery(this).next("tr.Spacing");
});
jQuery(idStr + " tbody").sortable({ // 这里是talbe tbody,绑定 了sortable
helper: fixHelper, // 调用fixHelper
axis: "y",
start: function(e, ui) {
ui.helper.addClass("e8_hover_tr") // 拖动时的行,要用ui.helper
if(ui.item.hasClass("notMove")) {
e.stopPropagation && e.stopPropagation();
e.cancelBubble = true;
}
if(copyTR) {
copyTR.hide();
}
startIdx = ui.item.get(0).rowIndex;
return ui;
},
stop: function(e, ui) {
ui.item.removeClass("e8_hover_tr"); // 释放鼠标时,要用ui.item才是释放的行
if(ui.item.get(0).rowIndex < 1) { // 不能拖动到表头上方
if(copyTR) {
copyTR.show();
}
return false;
}
if(copyTR) {
/* if(ui.item.get(0).rowIndex > startIdx) {
ui.item.before(copyTR.clone().show());
}else {
ui.item.after(copyTR.clone().show());
} */
if(ui.item.prev("tr").attr("class") == "Spacing") {
ui.item.after(copyTR.clone().show());
}else {
ui.item.before(copyTR.clone().show());
}
copyTR.remove();
copyTR = null;
}
return ui;
}
});
}
</script>
</div>