
<link rel="stylesheet" href="<?php echo base_url();?>public/js/bootstrap/bootstrap.min.css">
<script src="<?php echo base_url();?>public/js/vendor/jquery.min.js"></script>
<link rel="stylesheet" href="/public/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css">
<script src="/public/node_modules/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<!-- 引入 layui 组件 -->
<link rel="stylesheet" href="/static/layer/dist/theme/default/layer.css">
<script src="/static/layer/dist/layer.js"></script>


<!-- Select2 -->
<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">
<script src="<?php echo base_url();?>public/js/vendor/select2/select2.full.min.js"></script>

<div class="content_wrapper">
    <div class="container-fluid">

        <input name="id" class="form-control col-sm-8 " type="hidden" value="<?=$groups['id']?>">
        <div class="form-group">
            <label class="col-cm-2" style="text-align: right">分组名</label>
            <input name="name" class="form-control col-sm-8 " value="<?=$groups['name']?>">
        </div>
        <div class="form-group">
            <label class="col-cm-2" style="text-align: right">数数分组</label>
            <select name="gids[]" class="select2 form-control" multiple>
                <?php foreach ($shushuGroups as $gid => $group){?>
                    <option <?php if(in_array($gid, $groups['gids'])){echo 'selected';}?> value="<?=$gid?>"><?=$group?></option>
                <?php } ?>
            </select>
        </div>
        <div class="form-group" style="text-align: center">
            <button type="button" onclick="submitForm()" class=" btn btn-info" style="text-align: right">提交</button>
        </div>
    </div>
</div>
<script>
    $('.select2').select2({})
    function submitForm() {
        parent.showLoading()
        var data = {
            id:$('input[name=id]').val(),
            name:$('input[name=name]').val(),
            gids:$('select[name="gids[]"]').val()
        };
        if(!data.name){
            parent.hideLoading()
            layer.alert('分组名必填')
            return;
        }
        if(!data.gids){
            parent.hideLoading()
            layer.alert('数数分组必选')
            return;
        }
        $.post('/luckyDice/winWeightGroupSave',data, function(res ){
            parent.hideLoading()
            console.log(res)
            if(typeof res == 'string')res = JSON.parse(res)
            layer.alert(res.msg,function(){
                if(res.ret == 1){
                    parent.location.reload()
                }
            })

        })
    }
</script>