批量修改功能,弹窗功能,ajax

layer框架下的,不懂可以查一下layer框架弹出层怎么玩。

前端按钮:

<button class="btn btn-blue" οnclick="javascript:deliverunit('sale')">批量修改单位</button>

弹出层:

<!-- 批量修改单位 -->
<div id='deliverBox4' style='display:none'>
  <form id='deliverForm4' autocomplete='off'>
    <table class='wst-form wst-box-top'>
      <tr>
        <th>商品单位:</th>
        <td><input type='text' id='expressNo4' name=""  style='width:240px;'></td>
      </tr>
    </table>
  </form>

</div>


js部分:

//批量修改商品单位
function deliverunit(src){
var ids = WST.getChks('.chk');
if(ids==''){
WST.msg('请先选择商品!', {icon: 5});
return;
}
// console.log(ids);
var params = {};
params.ids = ids;
// console.log(params);
    WST.open({type: 1,title:"批量修改商品单位",shade: [0.6, '#000'], border: [0],
    content: $('#deliverBox4'),area: ['400px', '250px'],btn: ['提交','取消'],
    yes:function(index, layero){
    if($('#expressNo4').val()==''){
    WST.msg('商品单位不能为空!', {icon: 5});
    return;
    }
        var ll = WST.load({msg:'正在提交信息,请稍候...'});
        params.unit=$('#expressNo4').val();
        $.post(WST.U('admin/goods/deliverunit'),params,function(data,textStatus){
        var json = WST.toAdminJson(data);
        if(json.status=='1'){
        $('#all').prop('checked',false);
            $('#deliverForm4')[0].reset();
            WST.msg(json.msg,{icon:1});
            layer.close(index);//关闭特定层
            layer.close(ll);
            switch(src){//提交成功后刷新,
    case 'store':loadStoreGrid(0);break;
    case 'sale':loadSaleGrid(0);break;
    }
        }else{
            WST.msg(json.msg,{icon:5});
        }
      });
    }
    });

}

WST.open = function(options){
var opts = {};
opts = $.extend(opts, {offset:'100px'}, options);
return layer.open(opts);

}

WST.msg = function(msg, options, func){
var opts = {};
if(options){
if(options.icon==1){
options.icon='wst1';
}else if(options.icon==2 || options.icon==5){
options.icon='wst2';
}else if(options.icon==3){
options.icon='wst3';
}else if(options.icon==16){
options.icon='wstloading';
options.time = 0;
}
}
//有抖動的效果,第二位是函數
if(typeof(options)!='function'){
opts = $.extend(opts,{time:2000,shade: [0.4, '#000000']},options);
return layer.msg(msg, opts, func);
}else{
return layer.msg(msg, options);
}

}

WST.load = function(options){
var opts = {};
opts = $.extend(opts,{time:0,icon:'wstloading',shade: [0.4, '#000000'],offset: '200px'},options);
return layer.msg(opts.msg, opts);

}

WST.toAdminJson = function(str){
var json = {};
try{
if(typeof(str )=="object"){
json = str;
}else{
json = eval("("+str+")");
}
if(json.status && json.status=='-999'){
WST.msg('对不起,您已经退出系统!请重新登录',{icon:5},function(){
if(window.parent){
window.parent.location.reload();
}else{
location.reload();
}
});
}else if(json.status && json.status=='-998'){
WST.msg('对不起,您没有操作权限,请与管理员联系');
return;
}
}catch(e){
WST.msg("系统发生错误:"+e.getMessage,{icon:5});
json = {};
}
return json;

}




控制层:

    /**
    *   批量修改商品单位
    */
    public function deliverunit(){
        $m = new M();
        return $m->deliverunit();

    }


模型层:

public function deliverunit(){
$unit = input('post.unit');
        $ids = input('post.ids/a');
        $result=Db::name('goods')->where(['goodsId'=>['in',$ids]])->setField('goodsUnit', $unit);
        if ($result) {
            return WSTReturn('修改成功',1);
        }else{
            return WSTReturn('修改失败',-1);
        }

}




仅供参考!!!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值