jquery之杂记
??
//選中事件,放在初始化方法里面,toolbar下面 onSelect : function(rowIndex, rowData) {queryChannelFloor(rowIndex, rowData);}//圖片展示 {field : 'adImg',title : '廣告圖片',width : 200,sortable : true,align : 'center',formatter:function(value){return "<img src='"+value+"' width='60px' height='30px' />";}}//圖片操作 $("#addAdImg").val("");$("#addAdImg").val(data.adImg);//初始化時間var appPath = getAppPath(); $(function(){var d = new Date();var vYear = d.getFullYear();var vMon = d.getMonth() + 1;var vDay = d.getDate() - 1;var date = vYear+"-"+vMon+"-"+vDay;$('#searchTime').datebox("setValue",date);$('#searchTimeEd').datebox("setValue",date);logGrid(); });function logGrid(){$('#queryLogGrid').datagrid({url:appPath+'/page/portalSearchLog/logList',method:'post',queryParams:getQueryParam(),//或者是 $("#bgCommitTime").datebox("setValue", getTimeString()+" 00:00:00"); $("#endCommitTime").datebox("setValue", getTimeString()+" 23:59:59");/*** 初始化時間* @returns {String}*/ function getTimeString(){var day = new Date();var Year = 0;var Month = 0;var Day = 0;var CurrentDate = "";Year = day.getFullYear();Month = day.getMonth() + 1;Day = day.getDate();CurrentDate += Year + "-";if (Month >= 10) {CurrentDate += Month + "-";} else {CurrentDate += "0" + Month + "-";}if (Day >= 10) {CurrentDate += Day;} else {CurrentDate += "0" + Day;}return CurrentDate; } //特殊編輯器的使用,首先要引入<script src="${ctx }/js/lib/ckeditor/ckeditor.js"></script>這個文件<tr><td class="queryTitle" width="80px">分類代碼</td><td class="queryContent" colspan="3"><textarea id="headCode" class="ckeditor"></textarea></td></tr>//賦予空值(初始化) CKEDITOR.instances.headCode.setData('');//編輯展示 CKEDITOR.instances.headCode.setData(data.headCode);//取值 ecChannelPage.headCode = CKEDITOR.instances.headCode.getData();if(seoWordName==""){$("#seoWordNameFont").html("seoWord名稱不能為空!");return;}else{$("#seoWordNameFont").html("*");}<td class="queryTitle" width="100">SeoWord名稱</td><td class="queryContent" width="100"><input type="text" id="addseoWordName" name="addseoWordName"/><font id="seoWordNameFont" color="red">*</font></td><td class="queryTitle" width="100">SeoWordUrl</td><td class="queryContent" width="100"><input type="text" id="addseoWordUrl" name="addseoWordUrl"/> <font id="seoWordUrlFont" color="gray">格式:http://www.***.com</font> </td>var seoWordUrl=$.trim($("#addseoWordUrl").val());var strRegex = "^http://(([a-zA-z0-9]|-){1,}\\.){1,}[a-zA-z0-9]{1,}-*" ;var re=new RegExp(strRegex);if (!re.test(seoWordUrl) && seoWordUrl.length>0){ $("#seoWordUrlFont").css('color','red');$("#seoWordUrlFont").html("URL格式不正確");return;}else{$("#seoWordUrlFont").css('color','gray');$("#seoWordUrlFont").html("格式:http://www.***.com");}//限數字var numC=/^\d+$/;if(!numC.test(priority) && priority.length>0){$('#priorityFont').css('color','red');return;}else{$('#priorityFont').css('color','gray');}//checkbox?
//選中事件,放在初始化方法里面,toolbar下面onSelect : function(rowIndex, rowData) {queryChannelFloor(rowIndex, rowData);}//圖片展示{field : 'adImg',title : '廣告圖片',width : 200,sortable : true,align : 'center',formatter:function(value){return "<img src='"+value+"' width='60px' height='30px' />";}}//圖片操作$("#addAdImg").val("");$("#addAdImg").val(data.adImg);//初始化時間var appPath = getAppPath(); $(function(){var d = new Date();var vYear = d.getFullYear();var vMon = d.getMonth() + 1;var vDay = d.getDate() - 1;var date = vYear+"-"+vMon+"-"+vDay;$('#searchTime').datebox("setValue",date);$('#searchTimeEd').datebox("setValue",date);logGrid(); });function logGrid(){$('#queryLogGrid').datagrid({url:appPath+'/page/portalSearchLog/logList',method:'post',queryParams:getQueryParam(),//或者是$("#bgCommitTime").datebox("setValue", getTimeString()+" 00:00:00"); $("#endCommitTime").datebox("setValue", getTimeString()+" 23:59:59");/*** 初始化時間* @returns {String}*/ function getTimeString(){var day = new Date();var Year = 0;var Month = 0;var Day = 0;var CurrentDate = "";Year = day.getFullYear();Month = day.getMonth() + 1;Day = day.getDate();CurrentDate += Year + "-";if (Month >= 10) {CurrentDate += Month + "-";} else {CurrentDate += "0" + Month + "-";}if (Day >= 10) {CurrentDate += Day;} else {CurrentDate += "0" + Day;}return CurrentDate; } //特殊編輯器的使用,首先要引入<script src="${ctx }/js/lib/ckeditor/ckeditor.js"></script>這個文件<tr><td class="queryTitle" width="80px">分類代碼</td><td class="queryContent" colspan="3"><textarea id="headCode" class="ckeditor"></textarea></td></tr>//賦予空值(初始化)CKEDITOR.instances.headCode.setData('');//編輯展示CKEDITOR.instances.headCode.setData(data.headCode);//取值ecChannelPage.headCode = CKEDITOR.instances.headCode.getData();if(seoWordName==""){$("#seoWordNameFont").html("seoWord名稱不能為空!");return;}else{$("#seoWordNameFont").html("*");}<td class="queryTitle" width="100">SeoWord名稱</td><td class="queryContent" width="100"><input type="text" id="addseoWordName" name="addseoWordName"/><font id="seoWordNameFont" color="red">*</font></td><td class="queryTitle" width="100">SeoWordUrl</td><td class="queryContent" width="100"><input type="text" id="addseoWordUrl" name="addseoWordUrl"/> <font id="seoWordUrlFont" color="gray">格式:http://www.***.com</font> </td>var seoWordUrl=$.trim($("#addseoWordUrl").val());var strRegex = "^http://(([a-zA-z0-9]|-){1,}\\.){1,}[a-zA-z0-9]{1,}-*" ;var re=new RegExp(strRegex);if (!re.test(seoWordUrl) && seoWordUrl.length>0){ $("#seoWordUrlFont").css('color','red');$("#seoWordUrlFont").html("URL格式不正確");return;}else{$("#seoWordUrlFont").css('color','gray');$("#seoWordUrlFont").html("格式:http://www.***.com");}//限數字var numC=/^\d+$/;if(!numC.test(priority) && priority.length>0){$('#priorityFont').css('color','red');return;}else{$('#priorityFont').css('color','gray');}//checkbox?
?
/*** @description 去往商品維護*/@RequestMapping(value="/gotoExpand")public String gotoExpand(HttpServletRequest request){List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();for (ProductShowField p : ProductShowField.values()) {Map<String,Object> map = new HashMap<String,Object>();map.put("name", p.name());map.put("code", p.getCode()); // System.out.println(p.name()); //得到枚舉的名字 // System.out.println(p.getCode()); //得到枚舉的code list.add(map);}request.setAttribute("productShowFieldList", list);return "/jsp/seo/productExpand.jsp";} var productShowField = document.getElementsByName("productShowField");for ( var i = 0; i < productShowField.length; i++) {if(productShowField[i].checked){productExpand.showfield += productShowField[i].value + ',';}}if(productExpand.showfield!=null&&productExpand.showfield!=''){productExpand.showfield = productExpand.showfield.substring(0, productExpand.showfield.length-1);}//checkbox 初始化 $("#productIdPHidden").val(productIdP);$("#canHdfk").attr("selected","selected");var title="添加信息";var iconC="icon-add";var productShowField = document.getElementsByName("productShowField");for ( var i = 0; i < productShowField.length; i++) {productShowField[i].checked = false;}if(data.showfield!=null&&data.showfield!=''){var showField = data.showfield.split(",");for ( var i = 0; i < productShowField.length; i++) {for ( var j = 0; j < showField.length; j++) {if(showField[j] == productShowField[i].value){productShowField[i].checked = true;}}}} //枚舉/*** 商品顯示字段**/ public enum ProductShowField {pCode("商品編碼"),referPrice("參考價"),pEvaluationn("商品評價"),pSpecif("規格"),paymentType("支付方式"),j1Service("健一服務");private String i;private ProductShowField(String n){this.i = n;}public String getCode(){return this.i;}public static NAdNo resolve(String i){try {return NAdNo.valueOf(i);} catch (Exception e) {return null;}}public static String getNoName(String no){try {return NAdNo.resolve(no).getCode();} catch (Exception e) {return "";}} }?
//微信 @RequestMapping(value = "/toPageWeixin")public String toPageWeixin(HttpServletRequest request) {request.setAttribute("weixinStatusList", NWeixinStatus.values());return "/jsp/weixin/weixinActivity.jsp";}?
?
<td class="queryTitle" width="80px">活動狀態</td><td class="queryContent"><select class="inputText easyui-combobox" id="isStatus" style="width: 150px" panelHeight="auto"><option value="">請選擇</option><c:forEach var="weixinStatus" items="${weixinStatusList }"><option value="${weixinStatus }">${weixinStatus.code }</option></c:forEach></select></td><!-- 查詢 --> <table class="queryTable"><tr><td class="queryContent"><input class="inputText searchText" type="text" id="queryParam" placeholder="商品編號/商品名稱/工號/用戶名"/></td><td class="queryBtnTd"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQuery()">查 詢</a></td></tr> </table>?
?
//js
function chooseRadio(n) {$("input:radio[name='addcategory']").eq(n).attr("checked",'checked'); if(n==0){$("#productSpan").css("display","none");$("#catalogSpan").css("display","block");}else{$("#productSpan").css("display","block");$("#catalogSpan").css("display","none");} }?
?
//jsp
?
<tr><td class="queryTitle" width="100">類別</td> <td class="queryContent" ><input checked="checked" name="addcategory" type="radio" value="catalog" onclick="chooseRadio(0)" />類目<input name="addcategory" type="radio" value="product" onclick="chooseRadio(1)" />商品</td><td class="queryContent" colspan="2"><span id="productSpan" style="display:none;">商品編碼<input type="text" id="addproductCode" name="addproductCode" /></span><span id="catalogSpan" >類目ID<input type="text" id="addcatalogId" name="addcatalogId" /></span> <font id="categoryFont" color="grey">商品編碼或者類目ID不允許出現重復記錄</font> </td></tr>?
var category=$("input[name='addcategory']:checked").val();//類別if(category=="catalog"){if(catalogId==null || catalogId.length==0){$("#categoryFont").html("類目ID不能為空");$("#categoryFont").css("color","red");return;}}else{if(productCode==null || productCode.length==0){$("#categoryFont").html("商品編碼不能為空");$("#categoryFont").css("color","red");return;}}//排序 {field : 'orderNum',title : '排序',width : 100,align : 'center',sortable : true,formatter:function(value,rowData,rowIndex){var obj=JSON.stringify(rowData); return "<input type='text' id='orderNum"+rowIndex+"' style='width: 76px;' value='"+value+"' οnchange='onblus(this,"+obj+")'/>";} },//填寫順序 后實時保存 function onblus (obj,data){var orderNum = $(obj).attr("value");if(orderNum==null || orderNum==''){$(obj).attr("value",data.orderNum);return;}var flag2=validateNum(orderNum);if(!flag2){$.messager.alert('提示信息','排序請填寫正確的0~99之間的自然數','info',function(){$(obj).attr("value",data.orderNum);$(obj).focus();});return;}var pageIndexImg = new Object();pageIndexImg.orderNum=orderNum;pageIndexImg.imageType=Number($("#imgType").val());pageIndexImg.id=data.id;doAjax({url : appPath + '/page/pageIndexMrgAct/update',type : 'post',data : pageIndexImg,success : function(data) {if (data.code != 0) {$.messager.alert('提示信息', data.msg + ',操作失敗', 'error');}},error : function(XMLHttpRequest, textStatus, errorThrown) {$.messager.alert('提示信息', '排序保存失敗' + textStatus, 'error');}});}?
?
/*** 根據Id更新圖片信息* * @param request* @param response*/@RequestMapping(value = "/update")@ResponseBodypublic Map<String,Object> updateOrderNum(HttpServletRequest request,HttpServletResponse response,PageIndexImg pageIndexImg) {Map<String,Object> mapRes=new HashMap<String,Object>();String userId = request.getSession().getAttribute("userId").toString();try{if (pageIndexImg==null || pageIndexImg.getId()==null) {mapRes.put("code", -1);mapRes.put("msg", "參數不全");return mapRes;}pageIndexImg.setEditTime(StringUtil.returnDateFormat(new Date(),"yyyy-MM-dd HH:mm:ss"));pageIndexImg.setEditUserId(Integer.parseInt(userId));ServiceMessage<?> res=pageIndexImgService.update(pageIndexImg);if(res.getStatus().getCode().equals("0")){mapRes.put("code", 0);mapRes.put("msg", "ok");}else{mapRes.put("code", -1);mapRes.put("msg",res.getMessage());}}catch(Exception e){mapRes.put("code", -1);mapRes.put("msg", "處理異常");logger.error(e.getMessage());}return mapRes;}?
?
===============================================
//鼠標事件 {field : 'imageUrl',title : '圖片',width : 80,align : 'center',sortable : false,formatter : function(value, rowData,rowIndex) {if (value == null || value == '') {return "<img border='0' src='"+ appPath+ "/js/lib/jquery-easyui/themes/icons/blank.gif"+ "' />";} else {return "<img title='顯示圖片' onMousemove=\"mouseOn(event)\" οnmοuseοut='mouseOff()' rel='"+ rowData.imageUrl+ "' src='"+ appPath+ "/js/lib/jquery-easyui/themes/icons/search.png"+ "' />";}}},// 圖片顯示,鼠標移入事件 function mouseOn(e) {if ($("#showImgDetail").not(":visible")) {var dom = e.srcElement || e.target;var tp = $(dom).offset().top;var lf = $(dom).offset().left + $(dom).width() + 10;$("#showImgDetail").attr("src", $(dom).attr("rel"));$("#showImgDetail").css("top", tp);$("#showImgDetail").css("left", lf);$("#showImgDetail").show();} }// 圖片顯示,鼠標移出事件 function mouseOff() {$("#showImgDetail").hide(); }<img id="showImgDetail"style="position: absolute; display: none; border: 1px #EEEEFF solid;"alt="" src="" />//關閉窗口之廢話連篇function closeWin(id) {if(id='addDlg'){if($("#addUrl").val()=='' && $("#addKeywords1").val()=='' && $("#addLinkUrl1").val()==''){$('#'+id).window('close');}else{$.messager.defaults = { ok: "是", cancel: "否,繼續填寫" };$.messager.confirm('提示信息','將丟失已經填寫的內容,是否繼續關閉?',function(r){if(r){$('#'+id).window('close');}});}}else{$('#'+id).window('close');} }?
轉載于:https://www.cnblogs.com/wangchuanfu/p/5848410.html
總結
- 上一篇: (转)Schema
- 下一篇: Log4net 日志使用介绍