【多选 】批量处理 input

来源:互联网 发布:csgo a卡优化 编辑:程序博客网 时间:2024/06/04 19:24


//批量处理<script type="text/javascript">         function recordSend(){            var ids='';            $("input[name^=ids").each(function() {                              if ($(this).attr("checked")) {                      ids += ","+$(this).val();                  }                          });            if($.trim(ids)!='' && confirm('确认要进行批量发货吗?')){                $.getJSON("{:U('order/updateSendIdsP')}&ids="+ids+"&callback=?",function(data){                                        if(data.code==1){                        location.reload();                    }else{                        alert(data.message);                    }                });            }        }</script>

/**     * 批量发货( 只能发货,不可取消发货)     */    public function updateSendIdsP(){$ids= trim(trim(I("ids")),',');$idsArr=explode(',',$ids);foreach($idsArr as $k=>$id){if((int)$id<1){$return = array('message' => '参数有误','code' =>2);$this->ajaxReturn($return, 'JSONP');exit;}}$sqlWhere="id in (".$ids.") and virtual=1";$count = $this->model->where($sqlWhere)->count();if(count($idsArr)!=$count){$return = array('message' => '参数有误,有不是实物的id','code' =>3);$this->ajaxReturn($return, 'JSONP');}$data['send']=1;               $rst = $this->model->where($sqlWhere)->save($data);if( $rst>=0){$return = array('message' => '更新成功','code' =>1);}else{$return = array('message' => '更新失败','code' =>4);}$this->ajaxReturn($return, 'JSONP');}


0 0
原创粉丝点击