欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Layui 行点击追加元素效果

程序员文章站 2024-01-13 19:52:52
/** * 单击事件 * @param obj */var dom;var state;WarningIllegalIntime.onRowClick=function(obj) { console.log(obj.data.id,"6666666") var data = obj.data; co ......
/**
* 单击事件
* @param obj
*/
var dom;
var state;
warningillegalintime.onrowclick=function(obj) {
console.log(obj.data.id,"6666666")
var data = obj.data;
console.log(data.id);
if (state != 1) {
if(state==0){
if(dom==null){//state 0
bbb(obj);
state=1;
}else{//state 0
bbb(obj)
state=1;
}
}else{
bbb(obj);
state=1;
}
}else{//state 1 打开状态
if(dom!=null){
if(data.id==dom){
var ids = document.getelementbyid(dom);
ids.remove();
state = 0;
}else if(data.id==null){
var ids = document.getelementbyid(dom);
ids.remove();
state = 0;
}else{
var ids = document.getelementbyid(dom);
ids.remove();
bbb(obj);
state = 1;
}
}else{
bbb(obj);
state = 1;
}
}
}

function bbb(obj){
var assayname=[];
var standardvalue=[];
var assayvalue=[];
var value=obj.data.assaydetaillist;
for(var i=0;i<value.length;i++){
assayname[i]=value[i].assayname;
standardvalue[i]=value[i].standardvalue;
assayvalue[i]=value[i].assayvalue;
}
var data = obj.data;
var html = "<tr id=" + data.id + "><td colspan='18' align='center' valign='middle'>"
html+="<table>"
html+="<tr><td>指标项</td>"
for(a in assayname){
html+="<td style='width: 90px;text-align: center' >"+assayname[a]+"</td>"
}
html+="</tr>"
html+="<tr><td>标准值</td>"
for(b in standardvalue){
html+="<td style='width: 90px;text-align: center'>"+standardvalue[b]+"</td>"
}
html+="</tr>"
html+="<tr><td>化验值</td>"
for(c in assayvalue){
html+="<td style='width: 90px;text-align: center'>"+assayvalue[c]+"</td>"
}
html+="</tr>"
html+="</table>"
html+="<table><tr>"
html+='<td data-role="fieldcontain"><a class="aaa" id="zoom8" style="max-width:200px;display: block" href='+data.storageinimg.roughfront+' data-gallery=""><img onclick="ab(this)" class="img-thumbnail" src="'+data.storageinimg.roughfront+'" style="max-width:200px;height: 120px;"></a></td>'
html+='<td data-role="fieldcontain"><a class="aaa" id="zoom9" style="max-width:200px;display: block" href='+data.storageinimg.roughback+' data-gallery=""><img onclick="ab(this)" class="img-thumbnail" src='+data.storageinimg.roughback+' style="max-width:200px;height: 120px;"></a></td>'
html+='<td data-role="fieldcontain"><a class="aaa" id="zoom10" style="max-width:200px;display: block" href='+data.storageinimg.tarefront+' data-gallery=""><img onclick="ab(this)" class="img-thumbnail" src='+data.storageinimg.tarefront+' style="max-width:200px;height: 120px;"></a></td>'
html+='<td data-role="fieldcontain"><a class="aaa" id="zoom11" style="max-width:200px;display: block" href='+data.storageinimg.tareback+' data-gallery=""><img onclick="ab(this)" class="img-thumbnail" src='+data.storageinimg.tareback+' style="max-width:200px;height: 120px;"></a></td>'
html+='<td data-role="fieldcontain"><a class="aaa" id="zoom12" style="max-width:200px;display: block" href='+data.storageinimg.settlementpic+' data-gallery=""><img onclick="ab(this)" class="img-thumbnail" src='+data.storageinimg.settlementpic+' style="max-width:200px;height: 120px;"></a></td></tr><table>'
html+="</td></tr>"
dom =data.id;
obj.tr.after(html)
}