function 测序样品(){
console.log('新的测序样品界面')
var local_修改样品名称=localStorage.getItem('修改样品名称');
var local_批量添加反应=localStorage.getItem('批量添加反应');
var local_显示订单号=localStorage.getItem('显示订单号');
var local_显示样品名称=localStorage.getItem('显示样品名称');
var html=$('iframe[src="/seq/SeqSampleList.aspx"]')//测序样品页面
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('<span style="position:relative;z-index:2;"><button id="button_xiugai_yangpin" onclick="return false">修改样品名称◇</button><div id="div_xiugai_yangpin" style="position:absolute;width:230px;height:95px;border:1px solid orange;background-color: #1B211D;display:none"></div></span>')
var div_show_yincang=toolbar.find('#div_xiugai_yangpin').eq(0)
div_show_yincang.append('<input type="text" id="text_qianzhui" placeholder="样品前缀" size="10"/><button id="button_qianzhui" onclick="return false">添加样品前缀</button>')
div_show_yincang.append('<input type="text" id="text_houzhui" placeholder="样品后缀" size="10"/><button id="button_houzhui" onclick="return false">添加样品后缀</button>')
div_show_yincang.append('<input type="text" id="text_gaiqian" placeholder="需要改的部分" size="15"/><input type="text" id="text_gaihou" placeholder="改成的部分" size="10"/><button id="button_genggai" onclick="return false">更改部分样品名称</button>')
//点击修改样品名称按钮 显示或者隐藏DIV
toolbar.find('#button_xiugai_yangpin').click(function(){
显示隐藏DIV('#div_xiugai_yangpin',"button_xiugai_yangpin")
})
//点击添加样品前缀按钮执行如下函数
toolbar.find('#button_qianzhui').click(function(){
添加前后缀('前缀','#text_qianzhui')
})
//点击添加样品后缀按钮执行如下函数
toolbar.find('#button_houzhui').click(function(){
添加前后缀('后缀','#text_houzhui')
})
//点击 更改部分 执行如下函数
toolbar.find('#button_genggai').click(function(){
更改部分()
})
//给文本框绑定回车键的函数
toolbar.find('#text_houzhui').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
});
toolbar.find('#text_qianzhui').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
});
toolbar.find('#text_gaiqian').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
});
toolbar.find('#text_gaihou').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
});
}
//添加批量添加反应按钮
if (local_批量添加反应=='true'){
toolbar.append('<span style="position:relative;z-index:2;"><button id="button_piliang" onclick="return false"><font color="red">批量添加反应◇</font></button><div id="div_piliang" style="position:absolute;left:-250px;height:100px;width:430px;height:105px;border:1px solid orange;background-color: #1B211D;display:none"></div></span>')
div_piliang=toolbar.find('#div_piliang').eq(0)
div_piliang.append('<input type="text" id="text_piliang_duotiaodai" placeholder="添加多条带" size="10" value="1"/><button id="button_duotiaodai" onclick="return false">批量添加多条带,默认双条带(带引物)</button><br/><br/>')
div_piliang.append('<input type="text" id="text_piliang_tongming" placeholder="添加同名反应" size="10" value="1"/><button id="button_tongming" onclick="return false">批量添加同名反应(不带引物,一个名字只能选一次)</button><br/><br/>')
div_piliang.append('<input type="text" id="text_jiace" placeholder="默认1个" value="1" size="10"/><button id="button_jiace" onclick="return false"><font color="red">加测</font></button>')
//点击批量添加反应按钮 显示或者隐藏DIV
toolbar.find('#button_piliang').click(function(){
显示隐藏DIV('#div_piliang',"button_piliang")
})
//给批量多条带文本框绑定回车键的函数
toolbar.find('#text_piliang_duotiaodai').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
//如果输入的字符不是数字 那么不允许输入
if(event.keyCode !==48 && event.keyCode !==49 && event.keyCode !==50 && event.keyCode !==51 && event.keyCode !==52 && event.keyCode !==53 && event.keyCode !==54 && event.keyCode !==55 && event.keyCode !==56 && event.keyCode !==57 ){
return false
}
});
//给批量同名文本框绑定回车键的函数
toolbar.find('#text_piliang_tongming').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
//如果输入的字符不是数字 那么不允许输入
if(event.keyCode !==48 && event.keyCode !==49 && event.keyCode !==50 && event.keyCode !==51 && event.keyCode !==52 && event.keyCode !==53 && event.keyCode !==54 && event.keyCode !==55 && event.keyCode !==56 && event.keyCode !==57 ){
return false
}
});
//给加测文本框绑定回车键的函数
toolbar.find('#text_jiace').eq(0).keypress(function(event){
if(event.keyCode ==13){
return false
}
});
//点击多条带批量添加按钮
toolbar.find('#button_duotiaodai').click(function(){
批量_添加多条带()
})
//点击批量添加同名反应按钮
toolbar.find('#button_tongming').click(function(){
批量_添加同名反应()
})
//点击加测 按钮
toolbar.find('#button_jiace').click(function(){
加测('jiace');
})
}
//添加显示订单号按钮
if (local_显示订单号=='true'){
toolbar.append('<button id="button_show_order" onclick="return false">显示订单号</button>')
//点击按钮
toolbar.find('#button_show_order').click(function(){
显示选择行所属的订单号()
})
}
//添加 显示样品名称 按钮
if (local_显示样品名称=='true'){
toolbar.append('<button id="button_show_yp" onclick="return false">显示样品名称</button>')
//点击按钮
toolbar.find('#button_show_yp').click(function(){
显示选择行的样品名称()
})
}
}
}
//显示或者隐藏DIV
function 显示隐藏DIV(div_id,button_id){
div=toolbar.find(div_id).eq(0)
div.toggle()
//改变背景颜色
if (div.css('display')==="none"){
toolbar.find(button_id).css('background-color','')
}else{
toolbar.find(button_id).css('background-color','#B7A0AA')
//如果是修改样品名称的div 把已填的数据清除
if (div_id=='#div_xiugai_yangpin'){
toolbar.find(div_id).eq(0).find(":input").val('')
}
//如果是批量添加反应的div 把已填的数据改为1
if (div_id=='#div_piliang'){
toolbar.find(div_id).eq(0).find(":input").val('1')
}
}
}
//添加前后缀
function 添加前后缀(前后缀,id){
//如果没有选择的行,那么退出
if(table.find('tbody').find("[aria-selected='true']").size()==0){return false}
if(html.find(id).eq(0).val()===""){return false}
selecteds=table.find('tbody').find("[aria-selected='true']")
selecteds.each(function(){
ids=$(this).find('[aria-describedby=list_undefined]').text() //获取生产编号
product_number=$(this).find('[aria-describedby=list_seqs_sam_num]').text() //获取最开始的样品编号
if (前后缀=='前缀'){
new_product_number=toolbar.find('#text_qianzhui').eq(0).val()+product_number //获取最新的样品编号
}
if (前后缀=='后缀'){
new_product_number=product_number+toolbar.find('#text_houzhui').eq(0).val() //获取最新的样品编号
}
//post请求 更改样品编号
$.post("/seq/ashx/SeqSampleHandler.ashx",
{action:"piliang_edit",ids:ids.slice(2),newValue:"seqs_sam_num="+new_product_number,rules_txt:"样品编号"},
function (data,status) {console.log(data);}
);
html.find('.ui-pg-input').eq(0).focus()
alert('修改了 '+table.find('tbody').find("[aria-selected='true']").size()+' 条反应的样品名称,光标自动定位在页数,直接按回车或更改页数可以查看更改结果')
return false
})
}
//更改部分样品名称
function 更改部分(){
//如果没有选择的行,那么退出
if(table.find('tbody').find("[aria-selected='true']").size()==0){return false}
if(html.find('#text_gaiqian').eq(0).val()===""){return false}
selecteds=table.find('tbody').find("[aria-selected='true']")
//做个标记,只有所有的样品都只匹配到一次才可以
var is_goon=true
selecteds.each(function(){
ids=$(this).find('[aria-describedby=list_undefined]').text() //获取生产编号
product_number=$(this).find('[aria-describedby=list_seqs_sam_num]').text() //获取最开始的样品编号
old_part=toolbar.find('#text_gaiqian').eq(0).val() //获取需要更改的部分名称 前
new_part=toolbar.find('#text_gaihou').eq(0).val() //获取需要更改的部分名称 后
num=product_number.split(old_part).length-1 //存在多少遍要更改的部分,只有1遍才可以
if (num!=1){is_goon=false; alert('只有每个样品都能匹配一次,才能修改');return false}
})
if (is_goon==true){
selecteds.each(function(){
ids=$(this).find('[aria-describedby=list_undefined]').text() //获取生产编号
product_number=$(this).find('[aria-describedby=list_seqs_sam_num]').text() //获取最开始的样品编号
old_part=toolbar.find('#text_gaiqian').eq(0).val() //获取需要更改的部分名称
new_part=toolbar.find('#text_gaihou').eq(0).val() //获取需要更改的部分名称
var reg = new RegExp(old_part,"g");
new_product_number=product_number.replace(reg,new_part); //改成最新的样品编号
//post请求 更改样品编号
$.post("/seq/ashx/SeqSampleHandler.ashx",
{action:"piliang_edit",ids:ids.slice(2),newValue:"seqs_sam_num="+new_product_number,rules_txt:"样品编号"},
function (data,status) {console.log("成功" + data);});
})
html.find('.ui-pg-input').eq(0).focus()
alert('修改了 '+table.find('tbody').find("[aria-selected='true']").size()+' 条反应的样品名称,光标自动定位在页数,直接按回车或更改页数可以查看更改结果')
return false
}
}
//添加多条带
function 批量_添加多条带(){
var geshu=toolbar.find('#text_piliang_duotiaodai').eq(0).val()
res=文本是否是1到20(geshu)
if(!res){ //说明输入的不符合要求
alert('输入的不符合要求,需要输入1到20')
return false
}
geshu=parseInt(geshu)
//判断是否选择了反应,且选择的是否是同一个订单号
selecteds=is_one_order(html)
if(selecteds===false){//如果返回的是false 那么要不没有选择反应,要不选择的不是同一个订单号
return false
}
yp_all_array=[] //生产编号
ypmc_all_array=[] //样品名称
new_ypmc_all_array=[] //新的样品名称
yinwu_all_array=[] //引物名称
new_yinwu_all_array=[] //新的引物名称
yinwu_weizhi_array=[] //引物位置
new_yinwu_weizhi_array=[] //新的引物位置
yinwu_nong_all_array=[] //引物浓度
new_yinwu_nong_all_array=[] //新的引物浓度
yplx_all_array=[] //样品类型
new_yplx_all_array=[] //新的样品类型
zaiti_array=[] //载体
new_zaiti_array=[] //新的载体
pianduan_array=[] //片段
new_pianduan_array=[] //新的片段
kangshengsu_array=[] //抗生素
new_kangshengsu_array=[] //新的抗生素
beizhu_array=[] //备注
new_beizhu_array=[] //新的备注
is_cetong_array=[] //是否测通
new_is_cetong_array=[] //新的是否测通
//公共函数 生产编号需要降序排序
是否排好序=生产编号需要降序排序(selecteds)
if(是否排好序===false){//如果返回的是false 那么没有排好序
return false
}
//倒序把样品对应号放进数组
tags=0
$(selecteds.toArray().reverse()).each(function(){
ypdyh_name=$(this).find('[aria-describedby=list_seqs_plus_prod_id]').html()
if(ypdyh_name!=="" && ypdyh_name!==" "){
tags=1
}
})
if(tags===1){
alert('有的反应带有"样品对应号",不能添加多条带')
return false
}
$(selecteds.toArray().reverse()).each(function(){
//倒序把样品名称放进数组
ypmc_all_array.push($(this).find('[aria-describedby=list_seqs_sam_num]').text())
//倒序把引物名称放进数组
yinwu_name=$(this).find('[aria-describedby=list_seqs_primer]').html()
if(yinwu_name=="" || yinwu_name==" "){
yinwu_all_array.push("")
}else{yinwu_all_array.push(yinwu_name)}
//倒序把引物位置放进数组
yinwu_weizhi_array.push($(this).find('[aria-describedby=list_seqs_primer_id_2_kind]').text())
//倒序把引物浓度放进数组
nongdu_name=$(this).find('[aria-describedby=list_seqs_observe]').html()
if(nongdu_name=="" || nongdu_name==" "){ //如果载体为空 或者 空格
yinwu_nong_all_array.push("")
}else{yinwu_nong_all_array.push(nongdu_name)}
//倒序把样品类型放进数组
yplx_name=$(this).find('[aria-describedby=list_seqs_sam_type]').text()
yplx_all_array.push(yplx_name)
//倒序把载体放进数组
zaiti_name=$(this).find('[aria-describedby=list_seqs_carry]').html()
if(zaiti_name=="" || zaiti_name==" "){ //如果载体为空 或者 空格
zaiti_array.push("")
}else{zaiti_array.push(zaiti_name)}
//倒序把片段放进数组
pianduan_name=$(this).find('[aria-describedby=list_seqs_fragment_size]').html()
if(pianduan_name=="" || pianduan_name==" "){ //如果片段为空 或者 空
pianduan_array.push("")
}else{pianduan_array.push(pianduan_name)}
//倒序把抗生素放进数组
kangshengsu_name=$(this).find('[aria-describedby=list_seqs_ant_type]').html()
if(kangshengsu_name=="" || kangshengsu_name==" "){ //如果为空 或者 空格
kangshengsu_array.push("")
}else{kangshengsu_array.push(kangshengsu_name)}
//倒序把备注放进数组
beizhu_name=$(this).find('[aria-describedby=list_remark]').html()
if(beizhu_name=="" || beizhu_name==" "){
beizhu_array.push("")
}else{beizhu_array.push(beizhu_name)}
//倒序把是否测通放进数组
cetong_is=$(this).find('[aria-describedby=list_seqs_istest_pass]').text()
if(cetong_is=="是" || cetong_is=="true"){
is_cetong_array.push(true)
}else{is_cetong_array.push(false)}
})
//对多条带进行重新赋值
quchong_ypm=quchong_arr(ypmc_all_array)
for(var i=0;i<quchong_ypm.length;i++){ //去重后的数组
for(var j=1;j<=geshu;j++){ // 多条带 这是为了方便样品的多条带加上后缀
for(var z=0;z<ypmc_all_array.length;z++){ //原数组
if(quchong_ypm[i]===ypmc_all_array[z]){
new_ypmc_all_array.push(ypmc_all_array[z]+'-'+(j+1).toString()) //把样品名加上多条带的后缀push到新的样品数组里面
new_yinwu_all_array.push(yinwu_all_array[z]) //push到新的引物数组里面
new_yinwu_weizhi_array.push(yinwu_weizhi_array[z]) //push到新的引物位置数组里面
new_yinwu_nong_all_array.push(yinwu_nong_all_array[z]) //push到新的引物浓度数组里面
new_yplx_all_array.push(yplx_all_array[z]) //push到新的样品类型数组里面
new_zaiti_array.push(zaiti_array[z])//push到新的载体数组里面
new_pianduan_array.push(pianduan_array[z])//push到新的片段数组里面
new_kangshengsu_array.push(kangshengsu_array[z]) //push到新的抗生素数组里面
new_beizhu_array.push(beizhu_array[z]) //push到新的备注数组里面
new_is_cetong_array.push(is_cetong_array[z]) //push到新的是否测通数组里面
}
}
}
}
order_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_order_id]').eq(0).text() //查找订单号
kehu_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_cust_id]').eq(0).text() //查找客户ID
kehu_name=selecteds.eq(0).find('[aria-describedby=list_seqo_cust_name]').eq(0).text() //查找客户姓名
ketizu_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_ketizu_id]').eq(0).text() //查找课题组ID
ketizu_name=selecteds.eq(0).find('[aria-describedby=list_seqo_ketizu]').eq(0).text() //查找课题组姓名
company_ID=selecteds.eq(0).find('[aria-describedby=list_seqs_product_company_id]').eq(0).text() // 公司ID 比如昌平的是38
company_name=selecteds.eq(0).find('[aria-describedby=list_seqs_product_company_name]').eq(0).text() // 生产分公司名字 比如北京分公司
var r = confirm("确定要给"+kehu_name+"添加"+(geshu+1).toString()+"条带吗?总共 "+(selecteds.size()*geshu).toString()+" 条反应");
if (r == false) {
return false;
} else{
html.find('#button_duotiaodai').eq(0).attr('disabled',true)
}
josn_str=''
$.each(new_ypmc_all_array,function(index){ //对数组 多条反应,需要结合成josn_str index是从0开始的
weizhi_split_array=new_yinwu_weizhi_array[index].split("-") //位置用split分隔,如果不能分隔,那么长度为1,如果能分隔,那么长度为2
if(weizhi_split_array.length==1){
yinwu_weizhi_kind="";
yinwu_weizhi_primerid=""
}else{
yinwu_weizhi_kind=weizhi_split_array[1]
yinwu_weizhi_primerid=weizhi_split_array[0]
}
josn_str=josn_str+'{"seqs_vip_platestyle":"纵向提交","seqs_vip_platename":"1","seqs_vip_plate":1,"seqs_vip_hole":'+(index+1)+',"seqs_vip_number":'+(index+1)+',"seqs_vip_sam_num":"'+new_ypmc_all_array[index]+'","seqs_vip_sam_kind":"'+new_yplx_all_array[index]+'","seqs_vip_fragment_size":"","seqs_vip_seqs_carry":"'+new_zaiti_array[index]+'","seqs_vip_ant_type":"'+new_kangshengsu_array[index]+'","seqs_vip_seqs_primer":"'+new_yinwu_all_array[index]+'","seqs_vip_seqsprime_kind":"'+yinwu_weizhi_kind+'","seqs_vip_seqs_primer_id":"'+yinwu_weizhi_primerid+'","seqs_vip_istest_pass":'+new_is_cetong_array[index]+',"seqs_vip_return_sample":false,"seqs_vip_sample_remark":"'+new_beizhu_array[index]+'"},'
if(new_ypmc_all_array.length==index+1){ //如果是最后一项,那么把最后的逗号去掉
josn_str=josn_str.slice(0,-1);
}
})
josn_str='['+josn_str+'],'+'"orderid":"'+order_ID+'","companyid":"'+company_ID+'"}'
josn_str='{"action":"AddSeqOrder","seqHighPhoto":"","seqscreenshot":[],"cust_id":'+kehu_ID+',"cust_name":"'+kehu_name+'","ketizu_id":"'+ketizu_ID+'","ketizu_name":"'+ketizu_name+'","ordersort":"","linkToGeneNo":"","seqo_product_company_id":"'+company_ID+'","seqo_product_company_name":"'+company_name+'","seqo_settlement_company_id":"","seqo_settlement_company_name":"","order":{"vip_order_name":"","vip_order_kind":"PCR切胶","vip_order_platestyle":"2","vip_order_remark":"","vip_order_state":0,"vip_order_ketizuid":"'+ketizu_ID+'","vip_order_ketizuname":"'+ketizu_name+'","vip_order_isurgent":"false"},"seqo_id":"'+order_ID+'","seqs":'+josn_str
$.ajax({
type:"POST",
url:"/ajax/PostErpUseVipPageHandler.ashx",
contentType: "application/json", //必须这样写
dataType:"json",
data: JSON.stringify(jQuery.parseJSON(josn_str)), //josn_str是你要提交是json字符串
success:function (data) {
html.find('.ui-pg-input').eq(0).focus()
alert('修改成功 ,光标自动定位在页数,直接按回车或更改页数可以查看更改结果')
html.find('#button_duotiaodai').eq(0).attr('disabled',false)
}
})
}
//批量添加同名反应
function 批量_添加同名反应(){
var geshu=toolbar.find('#text_piliang_tongming').eq(0).val()
res=文本是否是1到20(geshu)
if(!res){ //说明输入的不符合要求
alert('输入的不符合要求,需要输入1到20')
return false
}
geshu=parseInt(geshu)
//公共函数 判断是否选择了反应,且选择的是否是同一个订单号
selecteds=is_one_order(html)
if(selecteds===false){//如果返回的是false 那么要不没有选择反应,要不选择的不是同一个订单号
return false
}
yp_all_array=[] //生产编号
ypdyh_all_array=[] //样品对应号
new_ypdyh_all_array=[] //新的样品对应号
ypmc_all_array=[] //样品名称
new_ypmc_all_array=[] //新的样品名称
yplx_all_array=[] //样品类型
new_yplx_all_array=[] //新的样品类型
zaiti_array=[] //载体
new_zaiti_array=[] //新的载体
pianduan_array=[] //片段
new_pianduan_array=[] //新的片段
kangshengsu_array=[] //抗生素
new_kangshengsu_array=[] //新的抗生素
beizhu_array=[] //备注
new_beizhu_array=[] //新的备注
is_cetong_array=[] //是否测通
new_is_cetong_array=[] //新的是否测通
//公共函数 生产编号需要降序排序
是否排好序=生产编号需要降序排序(selecteds)
if(是否排好序===false){//如果返回的是false 那么没有排好序
return false
}
$(selecteds.toArray().reverse()).each(function(){
//倒序把样品名称放进数组
ypmc_all_array.push($(this).find('[aria-describedby=list_seqs_sam_num]').text())
//倒序把样品对应号放进数组
ypdyh_name=$(this).find('[aria-describedby=list_seqs_plus_prod_id]').html()
if(ypdyh_name=="" || ypdyh_name==" "){
ypdyh_all_array.push("")
}else{ypdyh_all_array.push(ypdyh_name)}
//倒序把样品类型放进数组
yplx_name=$(this).find('[aria-describedby=list_seqs_sam_type]').text()
yplx_all_array.push(yplx_name)
//倒序把载体放进数组
zaiti_name=$(this).find('[aria-describedby=list_seqs_carry]').html()
if(zaiti_name=="" || zaiti_name==" "){ //如果载体为空 或者 空格
zaiti_array.push("")
}else{zaiti_array.push(zaiti_name)}
//倒序把片段放进数组
pianduan_name=$(this).find('[aria-describedby=list_seqs_fragment_size]').html()
if(pianduan_name=="" || pianduan_name==" "){ //如果片段为空 或者 空
pianduan_array.push("")
}else{pianduan_array.push(pianduan_name)}
//倒序把抗生素放进数组
kangshengsu_name=$(this).find('[aria-describedby=list_seqs_ant_type]').html()
if(kangshengsu_name=="" || kangshengsu_name==" "){ //如果为空 或者 空格
kangshengsu_array.push("")
}else{kangshengsu_array.push(kangshengsu_name)}
//倒序把备注放进数组
beizhu_name=$(this).find('[aria-describedby=list_remark]').html()
if(beizhu_name=="" || beizhu_name==" "){
beizhu_array.push("")
}else{beizhu_array.push(beizhu_name)}
//倒序把是否测通放进数组
cetong_is=$(this).find('[aria-describedby=list_seqs_istest_pass]').text()
if(cetong_is=="是" || cetong_is=="true"){
is_cetong_array.push(true)
}else{is_cetong_array.push(false)}
})
//对同名数组进行重新赋值
quchong_ypm=quchong_arr(ypmc_all_array)
//如果去重后的长度和原先的长度不一致,代表有重复的
if(ypmc_all_array.length!==quchong_ypm.length){
alert('不要选择重复的样品名,一个样品名只允许选择一次')
return false
}
for(var i=0;i<ypmc_all_array.length;i++){ //去重后的数组
for(var j=1;j<=geshu;j++){ // 多条带 这是为了方便样品的多条带加上后缀
new_ypmc_all_array.push(ypmc_all_array[i]) //把样品名push到新的样品数组里面
new_ypdyh_all_array.push(ypdyh_all_array[i])//把样品对应号push到新的样品数组里面
new_yplx_all_array.push(yplx_all_array[i]) //push到新的样品类型数组里面
new_zaiti_array.push(zaiti_array[i])//push到新的载体数组里面
new_pianduan_array.push(pianduan_array[i])//push到新的片段数组里面
new_kangshengsu_array.push(kangshengsu_array[i]) //push到新的抗生素数组里面
new_beizhu_array.push(beizhu_array[i]) //push到新的备注数组里面
new_is_cetong_array.push(is_cetong_array[i]) //push到新的是否测通数组里面
}
}
order_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_order_id]').eq(0).text() //查找订单号
kehu_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_cust_id]').eq(0).text() //查找客户ID
kehu_name=selecteds.eq(0).find('[aria-describedby=list_seqo_cust_name]').eq(0).text() //查找客户姓名
ketizu_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_ketizu_id]').eq(0).text() //查找课题组ID
ketizu_name=selecteds.eq(0).find('[aria-describedby=list_seqo_ketizu]').eq(0).text() //查找课题组姓名
company_ID=selecteds.eq(0).find('[aria-describedby=list_seqs_product_company_id]').eq(0).text() // 公司ID 比如昌平的是38
company_name=selecteds.eq(0).find('[aria-describedby=list_seqs_product_company_name]').eq(0).text() // 生产分公司名字 比如北京分公司
var r = confirm("确定要给"+kehu_name+"添加"+(selecteds.size()*geshu).toString()+"条同名反应吗?");
if (r == false) {
return false;
} else{
html.find('#button_tongming').eq(0).attr('disabled',true)
}
josn_str=''
$.each(new_ypmc_all_array,function(index){ //对数组 多条反应,需要结合成josn_str index是从0开始的
josn_str=josn_str+'{"seqs_vip_platestyle":"纵向提交","seqs_vip_platename":"1","seqs_vip_plate":1,"seqs_vip_hole":'+(index+1)+',"seqs_vip_number":'+(index+1)+',"seqs_vip_sam_num":"'+new_ypmc_all_array[index]+'","seqs_vip_sam_kind":"'+new_yplx_all_array[index]+'","seqs_vip_fragment_size":"'+new_pianduan_array[index]+'","seqs_vip_seqs_carry":"'+new_zaiti_array[index]+'","seqs_vip_ant_type":"'+new_kangshengsu_array[index]+'","seqs_vip_seqs_primer":"","seqs_vip_seqsprime_kind":"","seqs_vip_seqs_primer_id":"","seqs_vip_istest_pass":'+new_is_cetong_array[index]+',"seqs_vip_return_sample":false,"seqs_vip_sample_remark":"'+new_beizhu_array[index]+'","seqs_plus_prod_id":"'+new_ypdyh_all_array[index]+'"},'
if(new_ypmc_all_array.length==index+1){ //如果是最后一项,那么把最后的逗号去掉
josn_str=josn_str.slice(0,-1);
}
})
josn_str='['+josn_str+'],'+'"orderid":"'+order_ID+'","companyid":"'+company_ID+'"}'
josn_str='{"action":"AddSeqOrder","seqHighPhoto":"","seqscreenshot":[],"cust_id":'+kehu_ID+',"cust_name":"'+kehu_name+'","ketizu_id":"'+ketizu_ID+'","ketizu_name":"'+ketizu_name+'","ordersort":"","linkToGeneNo":"","seqo_product_company_id":"'+company_ID+'","seqo_product_company_name":"'+company_name+'","seqo_settlement_company_id":"","seqo_settlement_company_name":"","order":{"vip_order_name":"","vip_order_kind":"PCR切胶","vip_order_platestyle":"2","vip_order_remark":"","vip_order_state":0,"vip_order_ketizuid":"'+ketizu_ID+'","vip_order_ketizuname":"'+ketizu_name+'","vip_order_isurgent":"false"},"seqo_id":"'+order_ID+'","seqs":'+josn_str
$.ajax({
type:"POST",
url:"/ajax/PostErpUseVipPageHandler.ashx",
contentType: "application/json", //必须这样写
dataType:"json",
data: JSON.stringify(jQuery.parseJSON(josn_str)), //josn_str是你要提交是json字符串
success:function (data) {
html.find('.ui-pg-input').eq(0).focus()
alert('修改成功 ,光标自动定位在页数,直接按回车或更改页数可以查看更改结果')
html.find('#button_tongming').eq(0).attr('disabled',false)
}
})
}
//加测
function 加测(){
//公共函数 判断是否选择了反应,且选择的是否是同一个订单号
selecteds=is_one_order(html)
if(selecteds===false){//如果返回的是false 那么要不没有选择反应,要不选择的不是同一个订单号
return false
}
//公共函数 生产编号需要降序排序
是否排好序=生产编号需要降序排序(selecteds)
if(是否排好序===false){//如果返回的是false 那么没有排好序
return false
}
//获取选择的行的所有数据
[scbh_arr,ypdyh_arr,ypmc_arr,yinwu_arr,yinwu_weizhi_arr,yinwu_nong_arr,yplx_arr,zaiti_arr,pianduan_arr,kangshengsu_arr,beizhu_arr,is_cetong_arr]=获取选择的行的所有数据(selecteds)
console.log([scbh_arr,ypdyh_arr,ypmc_arr,yinwu_arr,yinwu_weizhi_arr,yinwu_nong_arr,yplx_arr,zaiti_arr,pianduan_arr,kangshengsu_arr,beizhu_arr,is_cetong_arr])
return false
yp_all_array=[] //生产编号
ypdyh_all_array=[] //样品对应号
ypmc_all_array=[] //样品名称
yplx_all_array=[] //样品类型
zaiti_array=[] //载体
pianduan_array=[] //片段
kangshengsu_array=[] //抗生素
beizhu_array=[] //备注
is_cetong_array=[] //是否测通
$(selecteds.toArray().reverse()).each(function(){ //倒序把样品对应号放进数组
ypdyh_name=$(this).find('[aria-describedby=list_seqs_plus_prod_id]').html()
if(ypdyh_name=="" || ypdyh_name==" "){
ypdyh_all_array.push($(this).find('[aria-describedby=list_undefined]').text())//如果没有样品对应号,则把生产编号放进数组
}else{ypdyh_all_array.push(ypdyh_name)}
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把样品名称放进数组
ypmc_all_array.push($(this).find('[aria-describedby=list_seqs_sam_num]').text())
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把样品类型放进数组
yplx_name=$(this).find('[aria-describedby=list_seqs_sam_type]').text()
if(yplx_name=="质粒" || yplx_name.search("菌")!= -1){
yplx_all_array.push("质粒")
}else if( yplx_name.search("胶")!= -1 || yplx_name=="PCR已纯化" || yplx_name=="PCR单一"){
yplx_all_array.push("PCR已纯化")
}else{yplx_all_array.push("质粒")}
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把载体放进数组
zaiti_name=$(this).find('[aria-describedby=list_seqs_carry]').html()
if(zaiti_name=="" || zaiti_name==" "){ //如果载体为空 或者 空格
zaiti_array.push("")
}else{zaiti_array.push(zaiti_name)}
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把片段放进数组
pianduan_name=$(this).find('[aria-describedby=list_seqs_fragment_size]').html()
if(pianduan_name=="" || pianduan_name==" "){ //如果片段为空 或者 空
pianduan_array.push("")
}else{pianduan_array.push(pianduan_name)}
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把抗生素放进数组
kangshengsu_name=$(this).find('[aria-describedby=list_seqs_ant_type]').html()
if(kangshengsu_name=="" || kangshengsu_name==" "){ //如果为空 或者 空格
kangshengsu_array.push("")
}else{kangshengsu_array.push(kangshengsu_name)}
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把备注放进数组
beizhu_name=$(this).find('[aria-describedby=list_remark]').html()
if(beizhu_name=="" || beizhu_name==" "){
beizhu_array.push("")
}else{beizhu_array.push(beizhu_name)}
})
$(selecteds.toArray().reverse()).each(function(){ //倒序把是否测通放进数组
cetong_is=$(this).find('[aria-describedby=list_seqs_istest_pass]').text()
if(cetong_is=="是" || cetong_is=="true"){
is_cetong_array.push(true)
}else{is_cetong_array.push(false)}
})
order_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_order_id]').eq(0).text() //查找订单号
kehu_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_cust_id]').eq(0).text() //查找客户ID
kehu_name=selecteds.eq(0).find('[aria-describedby=list_seqo_cust_name]').eq(0).text() //查找客户姓名
ketizu_ID=selecteds.eq(0).find('[aria-describedby=list_seqo_ketizu_id]').eq(0).text() //查找课题组ID
ketizu_name=selecteds.eq(0).find('[aria-describedby=list_seqo_ketizu]').eq(0).text() //查找课题组姓名
company_ID=selecteds.eq(0).find('[aria-describedby=list_seqs_product_company_id]').eq(0).text() // 公司ID 比如昌平的是38
company_name=selecteds.eq(0).find('[aria-describedby=list_seqs_product_company_name]').eq(0).text() // 生产分公司名字 比如北京分公司
if(what=="jiace"){
riqi=getday_y_n('---')
jihang=toolbar.find("#text_jiace").eq(0).val() //确定加测几行,
if(jihang=="" || jihang==" "){jihang="1"}
jihang=parseInt(jihang)
if(!jihang){jihang="1"}
josn_str=''
var r = confirm("确定要给"+kehu_name+"加测吗?总共 "+jihang*selecteds.size()+" 条加测反应");
if (r == false) {
return false;
} else{
html.find('#button_jiace').eq(0).attr('disabled',true)
}
$(selecteds.toArray().reverse()).each(function(index){ //多条反应,需要结合成josn_str index是从0开始的
qian='{"seqs_vip_platestyle":"纵向提交","seqs_vip_platename":"1","seqs_vip_plate":1,"seqs_vip_hole":'
zhong=index*jihang+1
hou=',"seqs_vip_number":'+(index+1)+',"seqs_vip_sam_num":"'+ypmc_all_array[index]+'","seqs_vip_sam_kind":"'+yplx_all_array[index]+'","seqs_vip_fragment_size":"'+pianduan_array[index]+'","seqs_vip_seqs_carry":"'+zaiti_array[index]+'","seqs_vip_ant_type":"'+kangshengsu_array[index]+'","seqs_vip_seqs_primer":"","seqs_vip_seqsprime_kind":"","seqs_vip_seqs_primer_id":"","seqs_vip_spec_require":"","seqs_vip_istest_pass":'+is_cetong_array[index]+',"seqs_vip_return_sample":false,"seqs_vip_sample_remark":"'+beizhu_array[index]+'","seqs_plus_prod_id":"'+ypdyh_all_array[index]+'"},'
josn_str=josn_str+qian+zhong+hou
for(var i=2;i<=jihang;i++){
zhong=index*jihang+i
josn_str=josn_str+qian+zhong+hou
}
if(selecteds.size()==index+1){ //如果是最后一项,那么把最后的逗号去掉
josn_str=josn_str.slice(0,-1);
}
})
josn_str='['+josn_str+'],'+'"orderid":null,"companyid":null}'
josn_str='{"action":"AddSeqOrder","seqHighPhoto":"","seqscreenshot":[],"cust_id":'+kehu_ID+',"cust_name":"'+kehu_name+'","ketizu_id":"'+ketizu_ID+'","ketizu_name":"'+ketizu_name+'","ordersort":"","linkToGeneNo":"","seqo_product_company_id":"'+company_ID+'","seqo_product_company_name":"'+company_name+'","seqo_settlement_company_id":"","seqo_settlement_company_name":"","order":{"vip_order_name":"'+riqi+'","vip_order_kind":"PCR切胶","vip_order_platestyle":"2","vip_order_remark":"","vip_order_state":0,"vip_order_ketizuid":"'+ketizu_ID+'","vip_order_ketizuname":"'+ketizu_name+'","vip_order_isurgent":"false"},"seqo_id":null,"seqs":'+josn_str
$.ajax({
type:"POST",
url:"/ajax/PostErpUseVipPageHandler.ashx",
contentType: "application/json", //必须这样写
dataType:"json",
data: JSON.stringify(jQuery.parseJSON(josn_str)), //josn_str是你要提交是json字符串
success:function (data) {
html.find('.ui-pg-input').eq(0).focus()
alert('修改成功 ,光标自动定位在页数,直接按回车或更改页数可以查看更改结果')
html.find('#button_jiace').eq(0).attr('disabled',false)
}
})
}
}
//显示选择行所属的订单号
function 显示选择行所属的订单号(){
if(table.find('tbody').find("[aria-selected='true']").size()==0){return false}
var dingdanhao=table.find('tbody').find("[aria-selected='true']").eq(0).find('[aria-describedby=list_seqo_order_id]').text() //查询订单号
toolbar.find('#a_search').eq(0).find('.l-btn-left').eq(0).click(); //点击 查询按钮
$('#searchForm').eq(0).find("option[value='seqo_order_id']").attr('selected','selected') //把找到的第一个查询条件改成 订单号
$('#searchForm').eq(0).find("[class='txt02 searchString']").eq(0).val(dingdanhao)
$("#AB").click()
}
//显示选择行的样品名称 查询这个样品在这个客户名下所有的记录
function 显示选择行的样品名称(){
if(table.find('tbody').find("[aria-selected='true']").size()==0){return false}
kehu_id=table.find('tbody').find("[aria-selected='true']").eq(0).find('[aria-describedby=list_seqo_cust_id]').text() //查询客户id
yp_name=table.find('tbody').find("[aria-selected='true']").eq(0).find('[aria-describedby=list_seqs_sam_num]').text() //查询样品名称
toolbar.find('#a_search').eq(0).find('.l-btn-left').eq(0).click(); //点击 查询按钮
$('#searchForm').eq(0).find("option[value='seqo_cust_id']").eq(0).attr('selected','selected') //把找到的第一个查询条件改成 客户ID
$('#searchForm').eq(0).find("[class='txt02 searchString']").eq(0).val(kehu_id)
$('#searchForm').eq(0).find("option[value='seqs_sam_num']").eq(1).attr('selected','selected') //把找到的第二个查询条件改成 样品编号
$('#searchForm').eq(0).find("[class='txt02 searchString']").eq(1).val(yp_name)
$("#AB").click()
}
//公共函数 判断选择的是否是同一个订单号
function is_one_order(html){
//如果没有选择行则退出
if(table.find('tbody').find("[aria-selected='true']").size()==0){return false}
panduan=0
selecteds=table.find('tbody').find("[aria-selected='true']")
selecteds.find('[aria-describedby=list_seqo_order_id]').each(function(){
if(selecteds.find('[aria-describedby=list_seqo_order_id]').eq(0).text()!=$(this).text()){
alert('需要选择同一个订单号!')
panduan=1
return false;
}
})
if(panduan==1){ //如果 不是同一个订单号,就退出
return false;
}else{
return selecteds;
}
}
//公共函数 生产编号需要降序排序
function 生产编号需要降序排序(selecteds){
new_scbh_arr=[]
old_scbh_arr=[]
$(selecteds.toArray().reverse()).each(function(){ //倒序把生产编号放进数组
new_scbh_arr.push($(this).find('[aria-describedby=list_undefined]').text())
})
old_scbh_arr=new_scbh_arr.slice()
new_scbh_arr.sort() //对 生产编号排序,如果和 old_scbh_arr的顺序一样,那么继续,如果不一样,那么退出
for (var i=0;i<old_scbh_arr.length;i++){
if(old_scbh_arr[i]!=new_scbh_arr[i]){
alert('生产编号需要降序排序')
return false;
}
}
return true
}
//公共函数 获取选择的行的所有数据
function 获取选择的行的所有数据(selecteds){
scbh_arr=[] //生产编号
ypdyh_arr=[] //样品对应号
new_ypdyh_arr=[] //新的样品对应号
ypmc_arr=[] //样品名称
new_ypmc_arr=[] //新的样品名称
yinwu_arr=[] //引物名称
new_yinwu_arr=[] //新的引物名称
yinwu_weizhi_arr=[] //引物位置
new_yinwu_weizhi_arr=[] //新的引物位置
yinwu_nong_arr=[] //引物浓度
new_yinwu_nong_arr=[] //新的引物浓度
yplx_arr=[] //样品类型
new_yplx_arr=[] //新的样品类型
zaiti_arr=[] //载体
new_zaiti_arr=[] //新的载体
pianduan_arr=[] //片段
new_pianduan_arr=[] //新的片段
kangshengsu_arr=[] //抗生素
new_kangshengsu_arr=[] //新的抗生素
beizhu_arr=[] //备注
new_beizhu_arr=[] //新的备注
is_cetong_arr=[] //是否测通
new_is_cetong_arr=[] //新的是否测通
$(selecteds.toArray().reverse()).each(function(){
//倒序把生产编号放进数组
scbh_arr.push($(this).find('[aria-describedby=list_undefined]').text())
//倒序把样品对应号放进数组
ypdyh_arr.push($(this).find('[aria-describedby=list_seqs_plus_prod_id]').text())
//倒序把样品名称放进数组
ypmc_arr.push($(this).find('[aria-describedby=list_seqs_sam_num]').text())
//倒序把引物名称放进数组
yinwu_name=$(this).find('[aria-describedby=list_seqs_primer]').html()
yinwu_arr.push(yinwu_name)
//倒序把引物位置放进数组
yinwu_weizhi_arr.push($(this).find('[aria-describedby=list_seqs_primer_id_2_kind]').text())
//倒序把引物浓度放进数组
nongdu_name=$(this).find('[aria-describedby=list_seqs_observe]').html()
yinwu_nong_arr.push(nongdu_name)
// if(nongdu_name=="" || nongdu_name==" "){ //如果载体为空 或者 空格
// yinwu_nong_arr.push("")
// }else{yinwu_nong_arr.push(nongdu_name)}
//倒序把样品类型放进数组
yplx_arr.push($(this).find('[aria-describedby=list_seqs_sam_type]').text())
//倒序把载体放进数组
zaiti_name=$(this).find('[aria-describedby=list_seqs_carry]').html()
zaiti_arr.push(zaiti_name)
// if(zaiti_name=="" || zaiti_name==" "){ //如果载体为空 或者 空格
// zaiti_array.push("")
// }else{zaiti_array.push(zaiti_name)}
//倒序把片段放进数组
pianduan_name=$(this).find('[aria-describedby=list_seqs_fragment_size]').html()
pianduan_arr.push(pianduan_name)
// if(pianduan_name=="" || pianduan_name==" "){ //如果片段为空 或者 空
// pianduan_array.push("")
// }else{pianduan_array.push(pianduan_name)}
//倒序把抗生素放进数组
kangshengsu_name=$(this).find('[aria-describedby=list_seqs_ant_type]').html()
kangshengsu_arr.push(kangshengsu_name)
// if(kangshengsu_name=="" || kangshengsu_name==" "){ //如果为空 或者 空格
// kangshengsu_array.push("")
// }else{kangshengsu_array.push(kangshengsu_name)}
//倒序把备注放进数组
beizhu_name=$(this).find('[aria-describedby=list_remark]').html()
beizhu_arr.push(beizhu_name)
// if(beizhu_name=="" || beizhu_name==" "){
// beizhu_array.push("")
// }else{beizhu_array.push(beizhu_name)}
//倒序把是否测通放进数组
cetong_is=$(this).find('[aria-describedby=list_seqs_istest_pass]').text()
is_cetong_arr.push(cetong_is)
// if(cetong_is=="是" || cetong_is=="true"){
// is_cetong_array.push(true)
// }else{is_cetong_array.push(false)}
})
console.log(scbh_arr) //生产编号
console.log(ypdyh_arr) //样品对应号
console.log(ypmc_arr) //样品名称
console.log(yinwu_arr) //引物名称
console.log(yinwu_weizhi_arr) //引物位置
console.log(yinwu_nong_arr) //引物浓度
console.log(yplx_arr) //样品类型
console.log(zaiti_arr) //载体
console.log(pianduan_arr) //片段
console.log(kangshengsu_arr) //抗生素
console.log(beizhu_arr) //备注
console.log(is_cetong_arr) //是否测通
return [scbh_arr,ypdyh_arr,ypmc_arr,yinwu_arr,yinwu_weizhi_arr,yinwu_nong_arr,yplx_arr,zaiti_arr,pianduan_arr,kangshengsu_arr,beizhu_arr,is_cetong_arr]
}
}