開發(fā)常用代碼記錄
一、前臺方法
1、Supp.Util.getSystemUrl();??說明:獲取系統(tǒng)服務(wù)路徑,如:http://127.0.0.1:8080/bmv6/
2、Supp.Util.getUrlParams();??說明:獲取url中的參數(shù),以json格式返回,如果沒有則返回{}
3、console.log(resp);??說明:在控制臺打印
4、$("#"+Supp.Util.transferSpecialStr("jqGrid_prjRisk_list_investAnalysis.fixedTotalInvestment"));??說明:獲取頁面中的元素
5、setTimeout(function(){$(".form-validate").valid();},500);??說明:定時器,延遲0.5秒
6、$("#prjCategoryId").removeAttr("disabled");? $('#prjCategoryId').selectpicker('refresh');??說明:重新加載下拉框
7、$("#investmentDeptIdShow")、$("select[name='prjType']")、$('input[name="score"]');??說明:獲取元素的幾種寫法
8、$("select[name='prjCategoryId']").selectpicker('val', json.prjCategoryId);??說明:給下拉框賦值
9、Supp.showWarning("該項目已經(jīng)生成填報數(shù)據(jù),不能刪除!");??說明:提示信息
10、$("#planYearFixed").html(""+planYear+"年固定資產(chǎn)投資計劃明細表");??說明:拼接元素內(nèi)容
11、window.location.reload();??說明:刷新當前頁面
12、var ids = getJqgridAllIds(JQGRID_ID);? ? var ids1 = getJqgridSelectIds(JQGRID_ID);??說明:獲取所有記錄的ID、獲取選擇的記錄的ID
13、reloadGrid(JQGRID_ID);??說明:重新加載表格
14、$("input[name='loanFund']:eq(" + i + ")").val() || 0;??說明:選取帶有指定 index 值的元素
15、window.location.hash = "#main_bg";??說明:頁面滾動至指定位置
16、new Date() > new Date(endDate.replace(/-/g,"\/"))??說明:年份比較
二、前臺樣式
1、errorDisplayPosition:"elementInner"??說明:校驗錯誤提示語顯示在輸入框內(nèi)
2、$("select[name='prjType']").attr("readonly", "true");??說明:給元素添加屬性
3、$('input[name="score"]').css('text-align', 'right');??說明:給元素增加樣式
4、className : "thousandth"??說明:顯示千分位
5、data-precision="2"??說明:保留兩位小數(shù)
6、formatter:'date',formatoptions: {srcformat:'yyyy-mm-dd', newformat:'yyyy-mm-dd'}
??說明:列表時間格式化,如{ label: '訂單日期', name: 'orderDate', width:120,formatter:'date',formatoptions: {srcformat:'yyyy-mm-dd', newformat:'yyyy-mm-dd'}}
7、data-date-format="yyyy-mm-dd"??說明:查看頁面時間格式化
8、displayInSet:false??說明:不顯示在操作列中,如{ label: 'id', name: 'orderId',key:true,displayInSet:false,hidden:true}
三、后臺
1、CollectionUtils.isEmpty(id);? StringUtils.isBlank(id);??說明:判斷字段是否為空
2、String prjNo = EIPService.getSerialNumberService().generateNumber(2018, 12, "Library", "libraryTwoNo", projectLibrary, user);??說明:獲取編碼規(guī)則
3、select max(cast(t.number as int)) from test t;??說明:hql中to_number函數(shù)的寫法
4、EIPService.getComCodeTableService().getCodetableItem("codeTableName");??說明:獲取碼表信息
5、JSONArray json=JSONArray.fromObject(jsonStr);??說明:將字符轉(zhuǎn)換為json
6、String reportUrl = EIPService.getRegistryService().get("REPORT_URL");??說明:獲取系統(tǒng)業(yè)務(wù)參數(shù)設(shè)置的值
7、com.supporter.util.UUIDHex.newId();??說明:生成ID
8、NumberFormat numberFormat=new DecimalFormat("0.000");? ? System.out.println(numberFormat.format(time/1000));??說明:測試開始結(jié)束時間