SocialPcAppManager.jsp 17.1 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
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ page import="net.sf.json.JSONArray"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="java.util.regex.*"%> 
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%
Pattern pattern = Pattern.compile("[0-9]*");
String id = request.getParameter("id");
if(id==null||id.equals("")){
    id = "";
}
String isOpenDisk = weaver.file.Prop.getPropValue("network2Emessage", "openDisk");
%>
<!DOCTYPE html 
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html>
    <head>
    	<script type="text/javascript" src="/js/select/script/jquery-1.8.3.min_wev8.js"></script>
    	<script> $.fn.jquery="1.8.3";</script>
        <link rel="stylesheet" href="/social/css/im_pcmodels_wev8.css" type="text/css" />
        <link rel="stylesheet" href="/js/ecology8/jNice/jNice/jNice_wev8.css" type="text/css" />
		<script type="text/javascript" src="/js/ecology8/jNice/jNice/jquery.jNice_wev8.js"></script>
		<script type="text/javascript" src="/js/ecology8/base/jquery-ui_wev8.js"></script>
		<script>
			jQuery(document).ready(function(){
				$('#pc-appmanager').perfectScrollbar();
				//绑定拖动时间
				registerDragEvent();
				//绑定按钮点击
				registerMouseEvent();
				delIdAry = new Array();
				addIcoIdAry = new Array();
				//绑定关闭事件
				saveTimer = null;
			});
			
			function registerMouseEvent() {
				 $(document).on("mouseover mouseout",'#pc-appmanager .item',function(e){
				 	e = e || window.event;
				 	if(event.type == "mouseover"){
					  $(this).find('.itembtnblock').css('display', 'block');
					}else if(event.type == "mouseout"){
					  $(this).find('.itembtnblock').css('display', 'none');
					}
				 });
				 //删除
				 $(document).on('click','#content .btnStyleBlue',function(e){
				 	doDel(this, e);
				 	e = e || window.event;
				 	e.preventDefault();
				 });
				 //添加
				 $(document).on('click','#content2 .btnStyleBlue',function(e){
				 	doAdd(this, e);
				 });
			}
			
			function doClose(){
			    $('.newWindow-close').click();
			}
			
			function doSave() {
				window.clearTimeout(saveTimer);
				saveTimer = setTimeout(function(){
					var delids = delIdAry.join(",");
					var addids = addIcoIdAry.join(",");
					var showindexs = getShowIndexs();
					$("input[name='readyToDelIds']").val(delids);
					$("input[name='readyToAddIds']").val(addids);
					$("input[name='showindexs']").val(showindexs);
					var userId = $("input[name='userId']").val();
					$.post("/social/im/SocialIMOperation.jsp?operation=saveUserAppSetting", {
						"readyToDelIds": delids,
						"readyToAddIds": addids,
						"showindexs": showindexs,
						"userId": userId
					}, function(ret){
						ret = $.trim(ret);
						if(ret == "1"){
							//window.location.href=window.location.href;
							delIdAry = [];
							addIcoIdAry = [];
						}
						closeWidthData();
						
						var id = "<%= id %>";
						if(id!==''){
						   doClose();
						}
						
					});
					//$("#mainform").submit();
				}, 200);
			}
			
			function getShowIndexs(){
				var items = $("#content .item");
				var indexAry = new Array();
				for(var i = 0; i < items.length; ++i){
					var id = $(items[i]).attr("id");
					if(id){
						indexAry.push(id+"_"+i);
					}else{
						indexAry.push("0_"+i+"_"+($(items[i]).attr("tempId")));
					}
				}
				return indexAry.join(",");
			}
			
			function checkRange(tag) {
				var itemcount = $("#content .item:visible").length;
				if(tag > 0 && itemcount >= 9){
					top.Dialog.alert("超出最多9个限制!");
					throw new Error("over maxmums!");
				}
				console.log("tag:"+tag,"itemcount:"+itemcount);
				if(tag < 0 && itemcount <= 1){
					top.Dialog.alert("至少显示一个按钮!");
					throw new Error("over minmums!");
				}
			}
			function doDel(btnObj, evt){
				try{
					checkRange(-1);
					var itemObj = $(btnObj).parents('.item');
					if(itemObj.attr("isTemp")){
						var tempId = itemObj.attr("tempId");
						for (var i = 0; i < addIcoIdAry.length; i++) {
							if (addIcoIdAry[i] == tempId){
								addIcoIdAry.splice(i, 1);
							}
						}
						$("#"+tempId).show();
						itemObj.remove();
					}else{
						var readyToDelId = itemObj.attr('id');
						var addObj = $("#item-template-1").children().clone();
						addObj.find(".itemico img").attr("src", itemObj.find(".itemico img").attr("src"));
						addObj.find(".itemtitle").text(itemObj.find(".itemtitle").text());
						addObj.attr({"isTemp": "isTemp", "tempId": readyToDelId});
						$("#content2").append(addObj);
						itemObj.hide();
						delIdAry.push(readyToDelId);
					}
					//doSave();
				}catch(err) {
					console.log("删除报错", err);
				}
			}
			
			function doAdd(btnObj, evt){
				try{
					checkRange(1);
					var itemObj = $(btnObj).parents('.item');
					if(itemObj.attr("isTemp")){
						var tempId = itemObj.attr("tempId");
						for (var i = 0; i < delIdAry.length; i++) {
							if (delIdAry[i] == tempId){
								delIdAry.splice(i, 1);
							}
						}
						$("#"+tempId).show();
						itemObj.remove();
					}else{
						var readyToAddIcoId = $(itemObj).attr("id");
						var linkuri = $(itemObj).attr("_linkuri");
						var uritype = $(itemObj).attr("_uritype");
						var linkuri = $(itemObj).attr("_linkuri");
						var linktitle = $(itemObj).attr("_linktitle");
						var icouri = itemObj.find(".itemico img").attr("src");
						var hoticouri = itemObj.find(".itemico img").attr("_srchot");
						
						var addObj = $("#item-template-0").children().clone();
						addObj.find(".itemico img").attr({"src": icouri, "_srchot":hoticouri});
						addObj.find(".itemtitle").text(itemObj.find(".itemtitle").text());
						addObj.attr({"isTemp": "isTemp", "tempId": readyToAddIcoId, "_linkuri": linkuri, "_uritype":uritype, "_linktitle":linktitle });
						$("#content").append(addObj);
						itemObj.hide();
						addIcoIdAry.push(readyToAddIcoId);
					}
					//doSave();
				}catch(err){
					console.log("添加报错", err);
				}
			}
			
			function registerDragEvent(){
				 var fixHelper = function(e, ui) {
			        ui.children().each(function() {  
			            jQuery(this).width(jQuery(this).width());     
			            jQuery(this).height("30");						
			        });  
			        return ui;  
			    }; 
			    $("#content").sortable({
		            revert: true,
		            axis: "y",
		            handle: ".movebtn",
		            stop : function () {
		                var itemcount = $("#content .item").length;
		                $("#content .item").each(function (i, e) {
		                    if (i < itemcount - 1) {
		                        //$(this).addClass("itemborder"); 
		                        $(this).find(".inrsplitline").addClass("inrsplitline-dis");
		                    } else {
		                        //$(this).removeClass("itemborder");
		                        $(this).find(".inrsplitline").removeClass("inrsplitline-dis");
		                    }
		                });
		                //doSave();
		            }
		        });
			}
			
			function closeWidthData(){
				var datas = new Array();
				var itemList = $("#content .item:visible"), item;
				var icouri, hoticouri, linkuri, uritype, icotitle;
				for(var i = 0; i < itemList.length; ++i){
					item = $(itemList[i]);
					icouri = item.find(".itemicoblock img").attr('src');
					icohoturi = item.find(".itemicoblock img").attr('_srchot');
					linkuri = item.attr("_linkuri");
					uritype = item.attr("_uritype");
					icotitle = item.attr("_linktitle");
					//应用数不多余9个
					if(i>=9){
					   break;
					}
					datas.push({"icouri": icouri, "icohoturi": icohoturi, "linkuri":linkuri, "uritype": uritype, "icotitle": icotitle});
				}
				
				var id = "<%= id %>";
                if(id===''){
                    top.getDialog(window).close(datas);
                }else{
                    window.Electron.ipcRenderer.send('plugin-pcAppManager-cb',datas);
                }
				
			}
		</script>
    </head>
    <body>
		<div id="pc-appmanager" class="appmanager">
			<div class="title">
		      <span class="margin-left-12"><%=SystemEnv.getHtmlLabelName(130706, user.getLanguage())%></span><!-- 已添加应用 -->
		    </div>
		    
		    <form action="" method="post" id="mainform" target="targetframe">
		    	<input type="hidden" name="readyToDelIds" value=""/> 
		    	<input type="hidden" name="readyToAddIds" value=""/> 
		    	<input type="hidden" name="showindexs" value=""/> 
		    	<input type="hidden" name="userId" value="<%=user.getUID() %>"/> 
		    	<div id="content">
			      	<!-- item -->
			      	<%
				      	RecordSet recordSet = new RecordSet();
						String querySql = "select t1.id id, t1.showindex showindex, t2.labelindexid labelindexid, t2.labeltemp labeltemp, " +
						"t2.uritype uritype, t2.linkuri linkuri, t2.icouri icouri, t2.hoticouri hoticouri " +
						"from SocialPcUserApps t1 " +
						"inner join Social_Pc_UrlIcons t2 " +
						"on t1.icoid = t2.id " +
						"where t2.icotype = '1' and t2.ifshowon = '1' and t1.userid = '"+user.getUID()+"' " +
						"order by t1.showindex ";
						recordSet.execute(querySql);
			      		String icouri = "", icotitle = "", hoticouri = "", uritype = "", linkuri = "";
			      		String defaultPicPath = "/social/images/pcmodels/htb_default_wev8.png";
						String defaultPicHotPath = "/social/images/pcmodels/htb_default_h_wev8.png";
			      		int labelindexid;
			      		while(recordSet.next()){
			      			icouri = recordSet.getString("icouri");
			      			icouri = pattern.matcher(icouri).matches()?"/weaver/weaver.file.FileDownload?fileid="+icouri:icouri;
			      			hoticouri = recordSet.getString("hoticouri");
			      			hoticouri = pattern.matcher(hoticouri).matches()?"/weaver/weaver.file.FileDownload?fileid="+hoticouri:hoticouri;
			      			uritype = recordSet.getString("uritype");
			      			linkuri = recordSet.getString("linkuri");
			      			labelindexid = recordSet.getInt("labelindexid");
			      			if(labelindexid != 0 && labelindexid != -1){
			      				icotitle = SystemEnv.getHtmlLabelName(labelindexid, user.getLanguage());
			      			}else{
			      				icotitle = recordSet.getString("labeltemp");
			      			}
			      			if (!isOpenDisk.equals("1") && "/rdeploy/chatproject/doc/index.jsp".equals(linkuri)) continue;
			      	%>
			      	<div class="item" id="<%=recordSet.getString("id") %>" _linkuri="<%=linkuri %>" _uritype="<%=uritype %>" _linktitle="<%=icotitle %>">
				        <div class="itembtnblock">
				          <span class="btnStyleBlue"><%=SystemEnv.getHtmlLabelName(131200, user.getLanguage())%></span> <!-- 删除 -->
				          <span class="movebtn" title="<%=SystemEnv.getHtmlLabelName(131189, user.getLanguage())%>"></span> <!-- 移动 -->
				        </div>
				        <table width="100%" height="52px" cellpadding="0" cellspacing="0">
				          <colgroup><col width="60px"><col width="*"></colgroup>
				          <tr>
				            <td class="itemico">
				            	<div class="itemicoblock">
				            		<img onerror="javascript:this.src='<%=defaultPicPath %>';this.setAttribute('_srchot', '<%=defaultPicHotPath %>');" src="<%=icouri%>" _srchot="<%=hoticouri %>" width="18px" height="18px">
				            	</div>
				            </td>
				            <td>
				                <span class="itemtitle">
				                  	<%=icotitle %>
				                </span>
				            </td>
				          </tr>
				        </table>
			        	<div class="inrsplitline"></div>
			        </div> <!-- item end -->
			        <%} %>
			     </div>
		   </form>
		   <div class="title">
		      <span class="margin-left-12"><%=SystemEnv.getHtmlLabelName(130707, user.getLanguage())%></span><!-- 可添加应用 -->
		   </div>
		   <div id="content2">
		      <!-- item -->
		      <%
			      	recordSet = new RecordSet();
					querySql = "select id, showindex, labelindexid, labeltemp, uritype, linkuri, icouri, hoticouri  " +
					"from Social_Pc_UrlIcons " +
					"where ifshowon = '1' and not exists (select 1 from SocialPcUserApps where SocialPcUserApps.icoid = Social_Pc_UrlIcons.id and userid = '"+user.getUID()+"') " +
					"and icotype = '1' " +
					"order by showindex";
					System.err.println(querySql);
					recordSet.execute(querySql);
		      		while(recordSet.next()){
		      			icouri = recordSet.getString("icouri");
		      			icouri = pattern.matcher(icouri).matches()?"/weaver/weaver.file.FileDownload?fileid="+icouri:icouri;
		      			hoticouri = recordSet.getString("hoticouri");
		      			hoticouri = pattern.matcher(hoticouri).matches()?"/weaver/weaver.file.FileDownload?fileid="+hoticouri:hoticouri;
		      			uritype = recordSet.getString("uritype");
		      			linkuri = recordSet.getString("linkuri");
		      			labelindexid = recordSet.getInt("labelindexid");
		      			if(labelindexid != 0 && labelindexid != -1){
		      				icotitle = SystemEnv.getHtmlLabelName(labelindexid, user.getLanguage());
		      			}else{
		      				icotitle = recordSet.getString("labeltemp");
		      			}
						if (!isOpenDisk.equals("1") && "/rdeploy/chatproject/doc/index.jsp".equals(linkuri)) continue;
		      	%>
		      <div class="item" id="<%=recordSet.getString("id") %>" _linkuri="<%=linkuri %>" _uritype="<%=uritype %>" _linktitle="<%=icotitle %>">
		        <table width="100%" height="52px" cellpadding="0" cellspacing="0">
		          <colgroup><col width="60px"><col width="*"><col width="100px"></colgroup>
		          <tr>
		            <td class="itemico">
		            	<div class="itemicoblock">
		              		<img onerror="javascript:this.src='<%=defaultPicPath %>';this.setAttribute('_srchot', '<%=defaultPicHotPath %>');" src="<%=icouri%>" _srchot="<%=hoticouri %>" width="18px" height="18px">
		            	</div>
		            </td>
		            <td>
		                <span class="itemtitle">
		                  	<%=icotitle %>
		                </span>
		            </td>
		            <td>
		            	<div class="itembtnblock">
		                	<span class="btnStyleBlue"><%=SystemEnv.getHtmlLabelName(131201, user.getLanguage())%></span><!-- 添加 -->
		                </div>
		            </td>
		          </tr>
		        </table>
		      <div class="inrsplitline" style=""></div>
		    </div> <!-- item end -->
		     <%} %>
		</div>
		<!-- item template -->
		<div id="item-template-0" style="display:none;">
			<div class="item">
		        <div class="itembtnblock">
		          <span class="btnStyleBlue"><%=SystemEnv.getHtmlLabelName(131200, user.getLanguage())%></span> <!-- 删除 -->
		          <span class="movebtn" title="<%=SystemEnv.getHtmlLabelName(131189, user.getLanguage())%>"></span> <!-- 移动 -->
		        </div>
		        <table width="100%" height="52px" cellpadding="0" cellspacing="0">
		          <colgroup><col width="60px"><col width="*"></colgroup>
		          <tr>
		            <td class="itemico">
		            	<div class="itemicoblock">
		            		<img src="" width="18px" height="18px">
		            	</div>
		            </td>
		            <td>
		                <span class="itemtitle">
		                  	<!-- 按钮标题 -->
		                </span>
		            </td>
		          </tr>
		        </table>
	        	<div class="inrsplitline"></div>
	        </div> <!-- item end -->
		</div>
		<div id="item-template-1" style="display:none;">
			<div class="item">
		        <table width="100%" height="52px" cellpadding="0" cellspacing="0">
		          <colgroup><col width="60px"><col width="*"><col width="100px"></colgroup>
		          <tr>
		            <td class="itemico">
		            	<div class="itemicoblock">
		              		<img src="" width="18px" height="18px">
		            	</div>
		            </td>
		            <td>
		                <span class="itemtitle">
		                  	<!-- 按钮标题 -->
		                </span>
		            </td>
		            <td>
		            	<div class="itembtnblock">
		                	<span class="btnStyleBlue"><%=SystemEnv.getHtmlLabelName(611, user.getLanguage())%></span><!-- 添加 -->
		                </div>
		            </td>
		          </tr>
		        </table>
		      <div class="inrsplitline" style=""></div>
		    </div> <!-- item end -->
		</div>
		<!-- 底部按钮组 -->
	    <div id="zDialog_div_bottom" class="zDialog_div_bottom">	
	     	<wea:layout>
	     		<wea:group context="" attributes="{groupDisplay:none}">
	     			<wea:item type="toolbar">
	     				 <input type="button" value="<%=SystemEnv.getHtmlLabelName(826, user.getLanguage())%>" id="zd_btn_confirm" class="zd_btn_cancle" onclick="doSave();"><!-- 确定 -->
	     				 <% 
	     				 if(id.equals("")){
	     				 %>
	                     <input type="button" value="<%=SystemEnv.getHtmlLabelName(309, user.getLanguage())%>" id="zd_btn_cancle" class="zd_btn_cancle" onclick="top.getDialog(window).close()"> <!-- 关闭 -->
	     			     <% 
	     				 }else{
                         %>
                         <input type="button" value="<%=SystemEnv.getHtmlLabelName(309, user.getLanguage())%>" id="zd_btn_cancle" class="zd_btn_cancle" onclick="doClose()"> <!-- 关闭 -->
                         <% 
                         }
                         %>
	     			</wea:item>
	     		</wea:group>
	     	</wea:layout>
	     </div>
	</body>
	</html>