批量删除1

//html


                {foreach $res as $row} 
                    
               {/foreach}
                
ID 商品名 货号 数量 商家ID 单价 上架时间 状态 操作
{$row.good_id} {$row.good_name}{if condition="($row.virtual==1)"}(虚拟商品){/if} {$row.good_art_no} {$row.good_num} {$row.myself} {$row.good_marketprice}元 {:date("Y/m/d H:i:s",$row.create_time)} {if condition="($row.not_sell==1)"} 未上架 {else /} 已上架 {/if}
//js //controller 1.wode public function delAll(){ $ids = input('post.ids'); $ids=rtrim($ids, ","); // $res=db('goods')->where['id'] =array->('in',$ids)->delete(); $res=\think\Db::table('goods')->delete([$ids]); if($res){ $arr = array( 'error'=>0, 'info'=>'删除成功' ); echo json_encode($arr); exit; }else{ $arr = array( 'error'=>1, 'info'=>'删除失败' ); echo json_encode($arr); exit; } } 2.master public function ajaxReturn($message='', $data=[], $jumpUrl='', $statusCode=1) { // 第二参数直接传url if (!is_array($data)) { $jumpUrl = $data; } return json([ 'message' => $message, 'data' => $data, 'url' => $jumpUrl, 'code' => $statusCode, ]); } public function deleteByIds($table) { $ids = trim(input('ids'), ','); $ids = explode(',', $ids); if (empty($ids)) { return $this->ajaxReturn('请选择要操作的数据'); } else { $success = Db::table($table)->whereIn('id', $ids)->delete(); if ($table === 'menu') { $this->getAllMenu(true); } if ($success) { return $this->ajaxSuccess('删除成功'); } else { return $this->ajaxFail('删除失败'); } } }

你可能感兴趣的:(批量删除1)