2.18-样品补送

样品补送

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/496569/1390082/218-%E6%A0%B7%E5%93%81%E8%A1%A5%E9%80%81.js

function 样品补送(src){
	console.log('新的样品补送界面')
	var local_打印样品标签=localStorage.getItem('打印样品标签');
	var html=$('iframe[src="'+src+'"]')//页面
	html=html.contents().find('body').eq(0)
	var toolbar=html.find('.toolbar').eq(0)  // 找到了toolbar工具栏
	var table=html.find('.ui-jqgrid-btable').eq(0)  // 找到了样品的table
	//添加toolbar工具栏按钮
	添加toolbar按钮(html)
	//添加toolbar工具栏按钮
	function 添加toolbar按钮(html){
		if (toolbar.find('.weiyiyici').length==0){
			//添加标记
			toolbar.addClass('weiyiyici')
			//点击 打印样品标签 按钮
			if (local_打印样品标签 == 'true'){
				toolbar.append('<button id="button_print_ypbq" onclick="return false">打印样品标签</button>')
			}
			//点击按钮
			toolbar.find('#button_print_ypbq').click(function(){
				打印样品标签()
			})
		}
	}
	
	//打印样品标签
	function 打印样品标签(){
		selecteds=table.find('tbody').find("[aria-selected='true']")
		if (selecteds.size()==0){return false}
		res="<NewDataSet>"
		selecteds.each(function(){
			shengchanbianhao=$(this).find('[aria-describedby=list_undefined]').text() //生产编号
			kehu_xingming=$(this).find('[aria-describedby=list_seqo_cust_name]').text()  //客户姓名
			yangpinbianhao=$(this).find('[aria-describedby=list_seqs_sam_num]').text() //样品编号
			yangpinleixing=$(this).find('[aria-describedby=list_seqs_sam_type]').text() //样品类型
			res+="<Table1>"
			res+="<seqs_prod_id>"+shengchanbianhao+"</seqs_prod_id>"
			res+="<seqo_cust_name>"+kehu_xingming+"</seqo_cust_name>"
			res+="<seqs_sam_num>"+yangpinbianhao+"</seqs_sam_num>"
			res+="<seqs_ant_type />"
			res+="<seqs_sam_type>"+'质粒'+"</seqs_sam_type>"
			res+="<seqs_fragment_size />"
			当天日期=getday_y_n('---')
			console.log(当天日期)
			res+="<seqo_send_sample_time>"+当天日期+"T18:47:08+08:00</seqo_send_sample_time>"
			res+="</Table1>"
		})
		res+="</NewDataSet>"
		保存文本到本地(res,'down.html')
		
	}
	
	//保存文本到本地
	function 保存文本到本地(text, filename){
		// 创建一个Blob实例,类型为纯文本
		    var blob = new Blob([text], { type: 'text/plain' });
		 
		    // 创建一个指向Blob对象的URL
		    var url = URL.createObjectURL(blob);
		 
		    // 创建一个a标签
		    var a = document.createElement("a");
		 
		    // 设置a标签属性
		    a.href = url;
		    a.download =filename;
		 
		    // 模拟a标签点击,触发下载
		    document.body.appendChild(a);
		    a.click();
		 
		    // 清理临时DOM和对象URL
		    document.body.removeChild(a);
		    URL.revokeObjectURL(url);
			window.open('http://localhost//打印/print.html')
	}
	
}