layui中table表格的操作列(删除,编辑)等按钮的操作
Posted Carina
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了layui中table表格的操作列(删除,编辑)等按钮的操作相关的知识,希望对你有一定的参考价值。
1 //编辑,删除,发布申请 2 table.on(‘tool(demo)‘, function(obj){ 3 var data = obj.data; 4 // console.log(data) 5 if(obj.event === ‘check‘){ 6 // console.log(data.id); 7 $(‘.textCon‘).val(""); 8 layer.open({ 9 title: ‘发布申请‘ 10 ,type: 1 11 ,maxmin:true 12 ,area: [‘700px‘,‘570px‘] 13 ,content: $(‘#toExamine‘) 14 ,btn: [‘申请‘, ‘取消‘] 15 ,yes: function(index, layero) { 16 var userName = $(‘#userRadio‘).val(); 17 if(userName == null || userName == ‘‘){ 18 layer.msg("请选择用户", {icon: 2, time: 2000}); 19 return; 20 } 21 var describe = $(‘.textCon‘).val(); 22 if(describe == null || describe == ‘‘){ 23 layer.msg("请输入内容", {icon: 2, time: 2000}); 24 return; 25 } 26 $.ajax({ 27 type: "post", 28 url: "/approval/application/save.afca", 29 dataType:‘json‘, 30 data: { 31 name: data.toolName, 32 targerId: data.id, 33 status: 0, 34 type: ‘script‘, 35 describe: $(‘.textCon‘).val(), 36 key: ‘script‘, 37 supUser:userName 38 }, 39 success: function (data) { 40 var message = data.msg; 41 if(data.code === ‘0‘){ 42 obj.del(); 43 layer.close(index); 44 layer.msg(message,{icon: 1,time:2000}); 45 tableObj.reload({ 46 url:‘/cd/workPlatform/tool/queryTools.afca‘ 47 }); 48 } else { 49 layer.alert(message, { 50 icon: 2,title:‘提示‘ 51 }); 52 return; 53 } 54 }, 55 error: function () { 56 } 57 }) 58 } 59 }); 60 getAllUser(); 61 $(‘.laytable-cell-checkbox‘).eq(0).empty(); 62 } else if(obj.event === ‘del‘){ 63 layer.confirm(‘确认删除么‘, function(index) { 64 $.ajax({ 65 type: "post", 66 url: "/cd/workPlatform/tool/remove.afca", 67 dataType:‘json‘, 68 data: "id="+data.id, 69 dataType: "json", 70 success: function (data) { 71 // console.log(data); 72 var message = data.msg; 73 var code = data.code; 74 // console.log(message); 75 // console.log(code); 76 if(data.code === ‘0‘){ 77 //obj.del(); 78 layer.close(index); 79 layer.alert(message,{icon: 1,time:2000}); 80 tableObj.reload({ 81 url:‘/cd/workPlatform/tool/queryTools.afca‘ 82 }); 83 } else { 84 layer.alert(message, { 85 icon: 2,title:‘提示‘ 86 }); 87 return; 88 } 89 }, 90 error: function () { 91 } 92 93 }) 94 }); 95 //编辑脚本定义 96 }else if(obj.event === ‘edit‘){ 97 //之前版本 98 // window.location.href=‘workToolEdit.html?toolSceneId=‘+data.toolSceneId+‘&‘+‘id=‘+data.id; 99 //脚本编辑弹出层 100 var name = encodeURIComponent(data.toolName); 101 // console.log(data.toolName); 102 parent.layer.open({ 103 type: 2, 104 title: ‘编辑脚本定义‘, 105 // title:data.to, 106 shadeClose: true, 107 shade: 0.8, 108 // maxmin: true, 109 area: [‘100%‘, ‘100%‘], 110 content: ‘html/taskManagement/scriptManagement/workToolEdit.html?toolSceneId=‘+data.toolSceneId+‘&‘+‘id=‘+data.id 111 }); 112 }else if(obj.event === ‘showInformation‘){ 113 //脚本展示弹出层 114 var name = encodeURIComponent(data.toolName); 115 // console.log(data.toolName); 116 parent.layer.open({ 117 type: 2, 118 title: ‘展示脚本定义‘, 119 // title:data.to, 120 shadeClose: true, 121 shade: 0.8, 122 // maxmin: true, 123 area: [‘100%‘, ‘100%‘], 124 content: ‘html/taskManagement/scriptManagement/showScriptInformation.html?id=‘+data.id 125 }); 126 } 127 else if(obj.event ===‘jump‘){ 128 // window.location.href=‘openScriptParaVerManagement.html?toolId=‘+data.id; 129 var name = encodeURIComponent(data.toolName); 130 // console.log(data.toolName); 131 parent.layer.open({ 132 type: 2, 133 title: ‘参数版本管理‘, 134 // title:data.to, 135 shadeClose: true, 136 shade: 0.8, 137 // maxmin: true, 138 area: [‘100%‘, ‘100%‘], 139 content: ‘html/taskManagement/scriptManagement/openScriptParaVerManagement.html?toolId=‘+data.id+"&jiaoben="+name+"&banben="+data.version+"&scriptLanguage="+data.scriptLanguage+"&categoryName="+data.categoryName+"&=status"+data.status 140 }); 141 } 142 });
1 //html代码 2 <script type="text/html" id="barDemo"> 3 <!--操作工具--> 4 <a href="" lay-event="edit">编辑</a> 5 <a href="" lay-event="jump">参数管理</a> 6 <a href="" lay-event="del">删除</a> 7 {{# if (d.status !="1"){}} 8 <a href="" lay-event="check">发布申请</a> 9 {{#}}} 10 </script>
以上是关于layui中table表格的操作列(删除,编辑)等按钮的操作的主要内容,如果未能解决你的问题,请参考以下文章