|
|
本帖最后由 purple 于 2012-12-28 09:48 编辑
函数格式:
getSeq(countLabel,num,isYear,isMonth,isDay)
函数说明:
countLabel :字母
num :流水数几位
isYear : 年
isMonth : 月
isDay : 天
示例:
实现getSeq(countLabel,num,isYear,isMonth,isDay)函数的应用
function getSeq(countLabel,num,isYear,isMonth,isDay){
var process = new Packages.cn.myapps.core.counter.ejb.CounterProcessBean($WEB.getApplication());
var dateUtil = $BEANFACTORY.createObject("cn.myapps.util.DateUtil");
var prefix = countLabel;
var year = "";
var month = "";
var day = "";
if(isYear){
year = dateUtil.format(dateUtil.getToday(), "yy");
prefix = prefix + year;
}
if(isMonth){
month = dateUtil.format(dateUtil.getToday(), "MM");
prefix = prefix + month;
}
if(isDay){
day = dateUtil.format(dateUtil.getToday(), "DD");
prefix = prefix + day;
}
var count = process.getNextValue(prefix, $WEB.getApplication(), $WEB.getDomainid());
var val = "";
if (count < 10) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else if (count < 100) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else if (count < 1000) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else if (count < 10000) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else if (count < 100000) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else if (count < 1000000) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else if (count < 10000000) {
for (var temp = 1; temp <= num - count.toString().length; temp++) {
val += "0";
}
val += count;
} else val += count;
if(isDay){
val = day + val;
}
if(isMonth){
val = month + val;
}
if(isYear){
val = year + val;
}
return val;
}
调用
#include " actionlib";
getSeq("countLabel","num","isYear","isMonth,isDay"); |
|