继续编辑index方法: ~~~ public function index($ap=0){ } ~~~ 编辑界面: ![](https://box.kancloud.cn/2016-07-10_5781bda0503c5.png) 添加代码如下: ~~~ if($this->request->method()=='POST') { $postdata = $this->request->only(['moderate','operation']); if($postdata['operation']=='delete'){ foreach($postdata['moderate'] as $aid) { $this->destroy($aid); } return $this->success('删除成功'); }else if($postdata['operation']=='pay'){ foreach($postdata['moderate'] as $aid) { $this->updatepay($aid); } return $this->success('更新成功'); } else{ echo 'none'; } } ~~~ 添加编辑方法: ~~~ protected function destroy($aid=0) { AcctModel::destroy($aid); } protected function updatepay($aid=0) { $record = AcctModel::get($aid); // getData $record->pstatus = !$record->getData('pstatus'); if($record->save()){ return $this->success('更新成功'); }else{ return $this->error('更新失败'); } } ~~~ 这里 ~~~ $record->pstatus = !$record->getData('pstatus'); ~~~ 没有使用 ~~~ $record->pstatus = !$record->pstatus; ~~~ 是因为在结算模型中定义了获取器 ~~~ protected function getPstatusAttr($value) { $status = [-1 => '删除', 0 => '未支付', 1 => '已支付', 2 => '待定']; return $status[$value]; } ~~~ 直接使用会报错。