1 // 批量刪除功能 2 // 1.得到table選中行內容 3 // 2.得到刪除需要的唯一值,一般是id; 4 // 3.將所要刪除的項加入到數組中; 5 // 4.判斷是否選中; 6 // 5.發送ajax請求,並附帶參數id; 7 var $=layui.$,active={ 8 deLink:function () { 9 var checkStatus=table.checkStatus('idTest'), 10 data=checkStatus.data, 11 deList=[]; 12 data.forEach(function(n,i){ 13 delList.push(n.id); 14 }); 15 if(delList!=''){ 16 layer.comfirm('確定刪除所選項嗎?',function (index) { 17 $.ajax({ 18 url: '/cd/workPlatform/tool/remove.afca', 19 type:'post', 20 dataType:'json', 21 data:"id="+delList, 22 success:function (data,statusText) { 23 if(data.code==='0'){ 24 layer.msg('刪除成功'); 25 table.reload('idTest',{}); 26 }else{ 27 layer.msg('刪除失敗'); 28 } 29 }, 30 'error':function () { 31 layer.msg('系統錯誤'); 32 } 33 }) 34 }) 35 }else{ 36 layer.tips('請選擇需要刪除的行',$('#batchDel'),{ 37 tips:[3,'#5fb878'] 38 }) 39 } 40 } 41 }
