IntelligentRecognition/ah-jjsp-web/.svn/pristine/1f/1f70a0583969c4492776d0e7a4e...

383 lines
12 KiB
Plaintext
Raw Permalink Normal View History

2024-05-24 16:09:40 +08:00
// 判空
function strNull(str) {
if (str == null || str == '' || str === undefined) {
return "暂无数据";
} else {
return str;
}
}
// 二级页面背景弹框动态高度、宽度
let getDefaultWidth = () => {
return $(top.window).width() * 0.714583;
};
let getNewDefaultWidth = () => {
return $(top.window).width() * 0.6713541;
};
let getMoreWidth = () => {
return $(top.window).width() * 0.310416;
};
let getChooseWidth = () => {
return $(top.window).width() * 0.345833;
};
let getSecondaryWidth = () => {
return $(top.window).width() * 0.2864583;
};
let getComfrimWidth = () => {
return $(top.window).width() * 0.2213541;
};
let getImportComfrimWidth = () => {
return $(top.window).width() * 0.3125;
};
let autoResizeWidth = (index) => {
layer.style(index, {width: getDefaultWidth().toFixed(0) + 'px'});
};
let autoNewResizeWidth = (index) => {
layer.style(index, {width: getNewDefaultWidth().toFixed(0) + 'px'});
};
let autoMoreResizeWidth = (index) => {
layer.style(index, {width: getMoreWidth().toFixed(0) + 'px'});
};
let autoChooseResizeWidth = (index) => {
layer.style(index, {width: getChooseWidth().toFixed(0) + 'px'});
};
let autoSecondaryResizeWidth = (index) => {
layer.style(index, {width: getSecondaryWidth().toFixed(0) + 'px'});
};
let autoComfrimResizeWidth = (index) => {
layer.style(index, {width: getComfrimWidth().toFixed(0) + 'px'});
};
let autoImportComfrimResizeWidth = (index) => {
layer.style(index, {width: getImportComfrimWidth().toFixed(0) + 'px'});
};
let getDefaultHeight = () => {
return $(top.window).height() * 0.7759259;
};
let getNewDefaultHeight = () => {
return $(top.window).height() * 0.7851851;
};
let getMoreHeight = () => {
return $(top.window).height() * 0.259259;
};
let getChooseHeight = () => {
return $(top.window).height() * 0.4111111;
};
let getSecondaryHeight = () => {
return $(top.window).height() * 0.3796296;
};
let getConfirmHeight = () => {
return $(top.window).height() * 0.2592592;
};
let getImportConfirmHeight = () => {
return $(top.window).height() * 0.4694444;
};
let autoResizeHeight = (index) => {
layer.style(index, {height: getDefaultHeight().toFixed(0) + 'px'});
};
let autoNewResizeHeight = (index) => {
layer.style(index, {height: getNewDefaultHeight().toFixed(0) + 'px'});
};
let autoMoreResizeHeight = (index) => {
layer.style(index, {height: getMoreHeight().toFixed(0) + 'px'});
};
let autoChooseResizeHeight = (index) => {
layer.style(index, {height: getChooseHeight().toFixed(0) + 'px'});
};
let autoSecondaryResizeHeight = (index) => {
layer.style(index, {height: getSecondaryHeight().toFixed(0) + 'px'});
};
let autoConfrimResizeHeight = (index) => {
layer.style(index, {height: getConfirmHeight().toFixed(0) + 'px'});
};
let autoImportConfrimResizeHeight = (index) => {
layer.style(index, {height: getImportConfirmHeight().toFixed(0) + 'px'});
};
let autoParentResizeWidth = (index) => {
parent.layer.style(index, {width: getDefaultWidth().toFixed(0) + 'px'});
};
let autoParentResizeHeight = (index) => {
parent.layer.style(index, {height: getDefaultHeight().toFixed(0) + 'px'});
};
// 根据身份证获取年龄
function getAge(identityCard) {
let len = (identityCard + "").length;
if (len == 0) {
return '';
} else {
if ((len != 15) && (len != 18)) //身份证号码只能为15位或18位其它不合法
{
return '';
}
}
let strBirthday = "";
if (len === 18) //处理18位的身份证号码从号码中得到生日和性别代码
{
strBirthday = identityCard.substr(6, 4) + "/" + identityCard.substr(10, 2) + "/" + identityCard.substr(12, 2);
}
if (len === 15) {
strBirthday = "19" + identityCard.substr(6, 2) + "/" + identityCard.substr(8, 2) + "/" + identityCard.substr(10, 2);
}
//时间字符串里,必须是“/”
let birthDate = new Date(strBirthday);
let nowDateTime = new Date();
let age = nowDateTime.getFullYear() - birthDate.getFullYear();
//再考虑月、天的因素;.getMonth()获取的是从0开始的这里进行比较不需要加1
if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
// 根据身份证获取性别
function getSex(IdCard) {
//获取性别
if (parseInt(IdCard.substr(16, 1)) % 2 === 1) {
return "男"
} else {
return "女"
}
}
function backLogin() {
let url = "/ahsfs/login.html";
top.layer.confirm('您的登录已过期,请点击确定后重新登录!', {
btn: ['确认', '取消'],
cancel: function (index, layero) {
top.location.href = url;
}
}, function () {
top.location.href = url;
}, function () {
top.location.href = url;
});
}
// 获取日期区间所有的日期
function getAllDate(startTime, endTime) {
//初始化日期列表,数组
let allDate = new Array();
let i = 0;
//开始日期小于等于结束日期,并循环
while (startTime <= endTime) {
allDate[i] = startTime;
//获取开始日期时间戳
let startTime_ts = new Date(startTime).getTime();
//增加一天时间戳后的日期
let next_date = startTime_ts + 24 * 60 * 60 * 1000;
//拼接年月日这里的月份会返回0-11所以要+1
let next_dates_y = new Date(next_date).getFullYear() + "-";
let next_dates_m =
new Date(next_date).getMonth() + 1 < 10
? "0" + (new Date(next_date).getMonth() + 1) + "-"
: new Date(next_date).getMonth() + 1 + "-";
let next_dates_d =
new Date(next_date).getDate() < 10
? "0" + new Date(next_date).getDate()
: new Date(next_date).getDate();
startTime = next_dates_y + next_dates_m + next_dates_d;
//增加数组key
i++;
}
return allDate;
}
function getBeforeDate(n) {
let d = new Date();
let year = d.getFullYear();
let mon = d.getMonth() + 1;
let day = d.getDate();
if (day <= n) {
if (mon > 1) {
mon = mon - 1;
} else {
year = year - 1;
mon = 12;
}
}
d.setDate(d.getDate() - n);
year = d.getFullYear();
mon = d.getMonth() + 1;
day = d.getDate();
s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
return s;
}
function setDate(strTime) {
let d = new Date(Date.parse(strTime.replace(/-/g, "/")));
return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日";
}
// 判断是否是手机号
function isPhone(value) {
if (value.length === 11) {
return value;
}
return '';
}
// 格式化日对象
const getNowDate = () => {
var date = new Date();
var sign2 = "-";
var year = date.getFullYear() // 年
var month = date.getMonth() + 1; // 月
var day = date.getDate(); // 日
var hour = date.getHours(); // 时
var minutes = date.getMinutes(); // 分
var seconds = date.getSeconds() //秒
var weekArr = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'];
var week = weekArr[date.getDay()];
// 给一位数的数据前面加 “0”
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (day >= 0 && day <= 9) {
day = "0" + day;
}
if (hour >= 0 && hour <= 9) {
hour = "0" + hour;
}
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
return year + "-" + month + "-" + day + "-" + hour + sign2 + minutes + sign2 + seconds;
}
const getNowDate2 = () => {
var date = new Date();
var sign2 = ":";
var year = date.getFullYear() // 年
var month = date.getMonth() + 1; // 月
var day = date.getDate(); // 日
var hour = date.getHours(); // 时
var minutes = date.getMinutes(); // 分
var seconds = date.getSeconds() //秒
var weekArr = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'];
var week = weekArr[date.getDay()];
// 给一位数的数据前面加 “0”
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (day >= 0 && day <= 9) {
day = "0" + day;
}
if (hour >= 0 && hour <= 9) {
hour = "0" + hour;
}
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
return year + "-" + month + "-" + day + " " + hour + sign2 + minutes + sign2 + seconds;
}
/**
* 获取当日时间
*/
function getNowTime() {
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) :
nowDate.getMonth() + 1;
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
var dateStr = year + "-" + month + "-" + day;
return dateStr;
}
function getyesDay(){
var nowDate = new Date( new Date().setHours(0)-24*60*60*1000);
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) :
nowDate.getMonth() + 1;
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
var dateStr = year + "-" + month + "-" + day;
return dateStr;
}
/*获取当前月的第一天*/
function getStartTime() {
let date = new Date()
date.setDate(1) // 将当前时间的日期设置成第一天
let year= date.getFullYear() // 得到当前年份
let month = date.getMonth() + 1 // 得到当前月份0-11月份+1是当前月份
month = month > 10 ? month :'0' + month // 补零
let day = date.getDate() // 得到当前天数实际是本月第一天因为前面setDate(1) 设置过了
day = day > 10 ? day :'0' + day // 补零
return year +'-'+ month +'-'+ day // 这里传入的是字符串
};
/*获取当前月的最后一天*/
function getEndTime(){
let date = new Date()
let year = date.getFullYear()
let month = date.getMonth() +1
month = month > 10 ? month :'0' + month // 补零
// 这里传入的是整数时间返回的是下个月的第一天因为月份是0-11
let nextMonthFirthDay = new Date(year,month,1) // 下个月的第一天
let oneDay = 1000*60 * 60 * 24 // 一天的时间毫秒数
let endDay = new Date(nextMonthFirthDay - oneDay)
let day = endDay.getDate() // 本月最后一天
day = day > 10 ? day :'0' + day // 补零
// 这里传入的是字符串格式的时间,返回的是传入字符串的时间
return year + '-' + month + '-' + day
};
/**
* 获取链接中的参数
* @returns {Object}
* @constructor
*/
function GetRequest() {
let url = filterJS(location.search); //获取url中"?"符后的字串
console.log(url)
let theRequest = {};
let str = url.substr(1);
let parameter = str.split("&");
for (let i = 0; i < parameter.length; i++) {
theRequest[parameter[i].split("=")[0]] = (parameter[i].split("=")[1]);
}
return theRequest;
}
/**
* @param {Object} param
*/
function filterJS(param) {
if (param == null || param == "") {
return null;
}
let filteArr = 'script,alert,console';
let splitArr = filteArr.split(',');
for (let i = 0; i < splitArr.length; i++) {
console.log(splitArr[i]);
if (param.indexOf(splitArr[i]) == -1) {
return param
} else {
return '*****';
}
}
}
function setValue(value) {
if (!value) {
return "暂无数据"
}
return value;
}
function setValue2(value) {
if (!value) {
return '';
}
return value;
}