config.blade.php 4.1 KB


<div class="fields-group">
    <div class="fields-group">
        <div class="form-group col-md-6 row ">
            <label for="mobile" class="col-sm-2 col-form-label">参数值</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input type="checkbox" name="type{{$option}}[]" value="{{$option}}" class="minimal type"/>&nbsp;&nbsp;{{$label}}&nbsp;&nbsp;
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $(".type").iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '100%' // optional
        });

        $(".short_term_time").iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '100%' // optional
        });



        // $("input:radio[name='short_term_time']").iCheck({
        //     checkboxClass: 'icheckbox_square-blue',
        //     radioClass: 'iradio_square-blue',
        //     increaseArea: '100%' // optional
        // });

        // $("input:radio[name='type']").eq(2).iCheck('check');
        // 设置长期的选中
        $("input[name='type'][value='2']").iCheck("check");


        $("input:radio[name='type']").on('ifChecked', function () {
            if($(this).val()=="1"){
                // 短期密码
                $(this).closest('.fields-group').find('.long-div').hide();
                $(this).closest('.fields-group').find('.short-div').show();
                $(this).closest('.fields-group').find('.password').val("{{optional($short_term)->password}}");
                var short_term_time= "{{$short_term_time}}";
                $(this).closest('.fields-group').find("input[name='short_term_time'][value='" + short_term_time+ "']").iCheck("check");
                // var date = new Date();
                // $('.enabled_at_short').datetimepicker({
                //     "format":"YYYY-MM-DD HH:mm","locale":"zh-CN","allowInputToggle":true,
                //     // minDate: date,
                // });
                //
                // $('.expired_at_short').datetimepicker({
                //     "format":"YYYY-MM-DD HH:m","locale":"zh-CN","allowInputToggle":true,
                //     // minDate: date,
                // });
                // 设置选中
            }if($(this).val()=="2"){

                // 长期密码
                $(this).closest('.fields-group').find('.long-div').show();
                $(this).closest('.fields-group').find('.short-div').hide();
                $(this).closest('.fields-group').find('.password').val("{{optional($long_term)->password}}");

            }
            // $(this).attr("checked",false);

            $(this).iCheck('update');
        });

        $('.enabled_at').datetimepicker({
            "format":"YYYY-MM-DD","locale":"zh-CN","allowInputToggle":true,
        });

        $('.expired_at').datetimepicker({
            "format":"YYYY-MM-DD","locale":"zh-CN","allowInputToggle":true
        });
    });

    function check() {
        let $form = $("form");
        let ok = true;
        let msg = '';
        // 获取密码
        let password = $("#password").val();
        if (!password) {
            swal_error('请输入密码!');
            return false;
        }

        // 获取选中的状态
        var type = $("input[name='type']:checked").val();
        let password_id = $("#long_term_id").val();
        if (type==1) {
            password_id = $("#short_term_id").val();
            var short_term_time = $("input[name='short_term_time']:checked").val();
            if (!short_term_time) {
                swal_error('请选择有效期!');
                return false;
            }

        } else {
            let enabled_at = $("#enabled_at").val();
            let expired_at = $("#expired_at").val();
            if (!enabled_at) {
                swal_error('请选择生效日期!');
                return false;
            }
            if (!expired_at) {
                swal_error('请选择失效日期!');
                return false;
            }
        }



    }
</script>