前台js代码
function destroyExcelout(){
//返回选中多行
var row = $('#dg').datagrid('getSelections');
//判断是否选中行
if (row.length==0){
$.messager.alert("提示", "请选择要删除的行!", "info");
return;
}else{
var temID="";
//批量获取选中行的评估模板ID
$.messager.confirm('提示', '是否删除选中数据?', function (r){
if (!r) {
return;
}
//将id字符串连在一起
for (i = 0; i < row.length;i++) {
if (temID =="") {
temID = row[i].id;
} else {
temID = row[i].id + "," + temID;
}
}
$.post('__ROOT__/index.php/Comprehensive/deleteComprehensive/','id='+temID,function(result){
if (!result==false){
$.messager.show({ // show error message
title: '成功',
msg: '删除条目成功!'
});
$('#dg').datagrid('reload'); // reload the user data
$('#dg').datagrid('clearSelections');
} else {
$.messager.show({ // show error message
title: '失败',
msg: '操作失败!!'
});
}
},'json');
});
}
$('#fm').form('load',row);
}
后台代码
public function deleteComprehensive(){
$sjcj=M('Sjcj');
$strTemId=I('post.id');
$strid=explode(',',$strTemId);
$value="";
foreach ($strid as $val){
$value.=",'".$val."'";
}
$result=$sjcj->where("id IN (".substr($value, 1).")")->delete();
// $result=$sjcj->where('id='.I('post.id'))->delete();
if($result==true){
//写入日志
$log=M('Log');
$logData['operate']='删除';
$logData['object']='t_sjcj';
$logData['items']=I('post.tybh');
$logData['time']=date('Y-m-d H:i:s');
$logData['user']=session('user');
$log->add($logData);
}
echo $result;
}
}