Greasy Fork

00-公共函数

公共函数

目前为 2023-07-01 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.cloud/scripts/469866/1213770/00-%E5%85%AC%E5%85%B1%E5%87%BD%E6%95%B0.js

//备注包含CNAS的行就标个颜色
function 公共_CNAS订单加急(html,搜索信息){
	//先运行一遍
	html.find('table').find('tr').each(function(){
		备注信息=$(this).find(搜索信息)
		备注=$(this).find(搜索信息).text()
		if(备注.toUpperCase().indexOf('CNAS')!==-1){
			//设置背景颜色
			$(this).find('td').attr('Bgcolor','#24B2C8')
		}
	})
	//当table出现数据改变的时候
	$(html).find('#list').on('DOMNodeInserted',function(e) {
		//$(e.target)代表的每一行
		备注信息=$(e.target).find(搜索信息)[0].innerText
		if(备注信息.toUpperCase().indexOf('CNAS')!==-1){
			//设置背景颜色
			$(e.target).find(搜索信息).parent().children().attr('Bgcolor','#24B2C8')
		}
	});
}

//查询年月日的函数
function getday_y_n(d){
	var myDate = new Date();
	if(d=="yestday" || d==="hecheng_zuotian_riqi" || d=="zuori---"){myDate.setTime(myDate.getTime()-24*60*60*1000);}
	var year = (myDate.getFullYear()).toString(); //获取当前年
	var mon = (myDate.getMonth() + 1).toString(); //获取当前月
	var date = (myDate.getDate()).toString(); //获取当前日
	if(mon.length==1){
		mon="0"+mon
	}
	if(date.length==1){
		date="0"+date
	}
	if(d==="hecheng_zuotian_riqi"){
		return year+mon+date
	}else if(d=="---"){   //---指的格式为XXXX-XX-XX
		return year+"-"+mon+"-"+date
	}else if(d=="zuori---"){
		//返回昨天的日期 比如 2022-05-13
		return year+"-"+mon+"-"+date
	}else{
		return year+mon+date
	}
}
	
//延时函数
var sleep = function(time) {
	var startTime = new Date().getTime() + parseInt(time, 10);
	while(new Date().getTime() < startTime) {}
};


//设定 页面的高度
function gaodu(html){
		console.log(111)
	//function zhongjian_gonggong(html){
		//下面几行是重新设置 测序样品 页面的高度
		table_div=html.find('.ui-jqgrid-bdiv').eq(0)  // 找到了样品的table的上一级div  用于设置高度
		table_height=table_div.css('height')  //测序样品 页面的高度
		offset_1=$('.footer').eq(0).offset().top
		offset_2=html.find('#pager').eq(0).offset().top
		if(offset_1-offset_2<=120){
			table_div.css('height',table_height.slice(0,-2)-20+"px")  //重新设置  页面的高度
		}else if(offset_1-offset_2>=160){
			table_div.css('height',parseInt(table_height.slice(0,-2))+20+"px")  //重新设置 页面的高度
		}
	//}
}