在專案中用到的一些公共方法

2022-02-17 06:43:17 字數 3035 閱讀 1953

1.通過路徑傳值,得到值:

function getquerystring(name) 

2.數字保留n位小數

//統計分析保留小數函式(四捨五入)

function round2(number, fractiondigits)

}

3.以日期生成主鍵

//生成主鍵規則:字首+中綴+字尾

// prefix表示字首可傳可為空,infix中綴分為年月日、年月、年的格式因此只需要傳"yyyymmdd","yyyymm","yyyy",postfix字尾可能為時分秒、隨機數因此需要傳"hhmmss","rnd"

function setdefaultcode(prefix, infix, postfix)

switch (postfix)

return id;

}

4.匯出excel

/// /// 用於web匯出

///

/// 源datatable

/// 表頭文字

/// 需要匯出的列的列頭

/// 需要匯出的對應的列欄位

/// 檔名

public static void exportbyweb(datatable dtsource, string strheadertext, string headers, string cellkes, string strfilename)

/// /// 用於web匯出

///

/// 源datatable

/// 表頭文字

/// 需要匯出的列的列頭

/// 需要匯出的對應的列欄位

/// 檔名

///特殊欄位json字串

public static void exportbyweb(datatable dtsource, string strheadertext, string headers, string cellkes, string strfilename, string excelvaluesjson)

5.對於時間戳的處理

$.fn.extend(

return value;

};for (var start = 0; start < 13; start++)

}oneselftime = oneselftime.join('') * 1;

var diffvalue = new date().gettime() - oneselftime;

// 如果本地時間反而小於變數時間

if (diffvalue < 0)

// 計算差異時間的量級

var arrtimediff = ;

// 使用

if (arrtimediff.monthc > 12) )();

} else if (arrtimediff.monthc >= 1) else if (arrtimediff.weekc >= 1) else if (arrtimediff.dayc >= 1) else if (arrtimediff.hourc >= 1) else if (arrtimediff.minc >= 1)

return '剛剛';

},/*

** author:lttr

** day:2018-02-05

** 首頁訊息時間戳顯示為【不同顏色處理】的處理

** eg.

** $('1517451000000').indexmestimestamp(); // 2023年02月01日

** $(new date('2018-02-01 15:10:00').gettime()).indexmestimestamp(); // 1分鐘前

** $("/date(1517469000000)/".replace(/[^0-9]/ig, "")).indexmestimestamp(); // 1分鐘前

*/"indexmestimestamp": function ()

return value;

};for (var start = 0; start < 13; start++)

}oneselftime = oneselftime.join('') * 1;

var diffvalue = new date().gettime() - oneselftime;

// 如果本地時間反而小於變數時間

if (diffvalue < 0)

// 計算差異時間的量級

var arrtimediff = ;

// 使用

if (arrtimediff.monthc > 12) )();

} else if (arrtimediff.monthc >= 1) else if (arrtimediff.weekc >= 1) else if (arrtimediff.dayc >= 1) else if (arrtimediff.hourc >= 1) else if (arrtimediff.minc >= 1)

return '';

},/*

** author:lttr

** day:2018-02-01

** 時間戳顯示為【今天 上午10:10,今天 下午15:10,昨天 上午10:10,昨天 下午15:10,上午10:10,下午15:10】的處理

** eg.

** $('1517451000000').specifictimestamp(); // 今天 上午10:10

** $(new date('2018-02-01 15:10:00').gettime()).specifictimestamp(); // 今天 下午15:10

** $("/date(1517469000000)/".replace(/[^0-9]/ig, "")).specifictimestamp(); // 今天 下午15:10

*/"specifictimestamp": function ()

});

專案中用到mobiscroll的一些心得

我所負責的專案要求的效果是 1.顯示的日期格式是2017 11 20 星期一 2.初始化的預設值是後台傳過來的乙個日期值,後台傳過來的是昨日日期值 3.最大日期值也是這個日期,即只能選擇昨日以前的日期 4.這篇部落格的最後,給大家附帶說下只顯示年月的實現方法 1.效果1 顯示的日期格式是2017 1...

專案中用到的一些函式,9 26份

這裡的list函式 list 函式用於在一次操作中給一組變數賦值。作用 userservice getsmsrecordlist query,offset,pagesize 的返回值是乙個陣列 含有兩個元素 list獲取第乙個元素,totalcount獲取第二個元素 list list,totalc...

專案中用到的python

import scipy.io as scio 資料輸入輸出,載入和儲存matlab檔案,例如下面 train norm scio.loadmat train norm file 這裡面包含兩個矩陣 train datan train labeln test norm scio.loadmat te...