zndd.html 8.84 KB
<div id="nav-zndd_config-modal" class="uk-modal">
    <div class="uk-modal-dialog" style="width: 530px;">
        <a href="" class="uk-modal-close uk-close"></a>
        <div class="uk-modal-header">
            <h2>智能调度检测</h2></div>
        
        <div  style="margin: auto;width: 100%;display: flex;">
            <div style="width: 49%;">
                <ul>
                    <li>
                        <input id="s1" name="s1" value="DJG" type="checkbox" class="switch" >
                        <label for="s1">车辆大间隔</label>
                    </li>
                    <li>
                        <input id="s2" name="s1"  value="YCSF"  type="checkbox" class="switch">
                        <label for="s2">异常实发</label>
                    </li>
                    <li>
                        <input id="s3"  name="s1" value="SFTZ"   type="checkbox" class="switch">
                        <label for="s3">实发未发</label>
                    </li>
                    <li>
                        <input id="s4" name="s1"  value="WD"  type="checkbox" class="switch">
                        <label for="s4">误点</label>
                    </li>
                </ul>
            </div>
            <div style="width: 49%;">
                <ul>
                    <li>
                        <input id="ss1" type="checkbox" class="switch" checked>
                        <label for="ss1">指令重发</label>
                    </li>
                    <li>
                        <input id="ss2" value="FCJG" type="checkbox" class="switch">
                        <label for="ss2">发车间隔</label>
                    </li>
                    <li>
                        <input id="ss5" type="checkbox" class="switch" disabled>
                        <label for="ss5">大客流-未启用</label>
                    </li>
                    <li>
                        <input id="ss6" value="MZ" type="checkbox" class="switch" >
                        <label for="ss6">满载-未启用</label>
                    </li>
                </ul>
            </div>
        </div>

        <div id ="hoverBox1" class="hoverBox">
            
        </div>
        
        
        <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;">
            <button type="button" class="uk-button uk-modal-close">取消</button>
            <button type="submit" class="uk-button uk-button-primary" id="submiton"><i class="uk-icon-check"></i> &nbsp;保存</button>
        </div>
    </div>
    <script>
        var storage = window.localStorage;
        var switchmap = storage.getItem("switchmap") != null ? JSON.parse(storage.getItem("switchmap")) : null; //智能调度开关  0 关闭 1 开启

        var modal = '#nav-zndd_config-modal';

        checkboxes =$(".uk-modal-dialog input[type='checkbox']");

        checkboxes.each(function(){
            $(this).click(function(){
                var ischecked=$(this).prop("checked");
                let type = $(this).val();
                //null的情况下
                if (switchmap == null){
                    k();
                }

                for(let tm in switchmap){
                    if (tm == type){
                        if (ischecked){
                            switchmap[tm] = 1;
                        }else {
                            switchmap[tm] = 0;
                        }
                    }
                }
            });

            $(this).mouseover(function(){
                debugger
                let type = $(this).val();
                
                $("#hoverBox1").css({
                    'background-image': 'url(/real_control_v2/zndd/img/'+type+'.png)',
                    'position': 'absolute',
                    'top': $(this).position().top,
                    //'left': $(this).position().left,
                    'right': '550px',
                    'width': "500px",
                    'height': "500px",
                    'display': 'block',
                    'transition':'opacity .5s ease',
                });
            })
            $(this).mouseleave(function(){
                $("#hoverBox1").css({
                    'display': 'none'
                });
            })
        });
        
        function k (){
            switchmap= {};
            switchmap.DJG = 0;
            switchmap.YCSF = 0;
            switchmap.SFTZ = 0;
            switchmap.WD = 0;
            switchmap.FCJG = 0;
            switchmap.MZ = 0;
        }
        
        on_off(switchmap);
        //0是关 1是开
        function on_off(switchmap){
            debugger
            for(let i in checkboxes){
                for(let tm in switchmap){
                    if (tm == checkboxes[i].value){
                        if (switchmap[tm] == 0){
                            checkboxes[i].checked = "";
                        }else {
                            checkboxes[i].checked = "checked";
                        }
                    }
                }
            }
        }

        // 获取表单并提交.
        $('#submiton').on('click',function() {
            debugger
            storage.setItem("switchmap", JSON.stringify(switchmap));
            UIkit.modal(modal).hide();
            notify_succ('修改成功!');
        });
        
        
        
    
    </script>

    <style>
        @supports (-webkit-appearance: none) or (-moz-appearance: none) {
            input[type=checkbox] {
                --active: #275EFE;
                --active-inner: #fff;
                --focus: 2px rgba(39, 94, 254, .3);
                --border: #BBC1E1;
                --border-hover: #275EFE;
                --background: #fff;
                --disabled: #F6F8FF;
                --disabled-inner: #E1E6F9;
                -webkit-appearance: none;
                -moz-appearance: none;
                height: 21px;
                outline: none;
                display: inline-block;
                vertical-align: top;
                position: relative;
                margin: 0;
                cursor: pointer;
                border: 1px solid var(--bc, var(--border));
                background: var(--b, var(--background));
                transition: background 0.3s, border-color 0.3s, box-shadow 0.2s;
            }
            input[type=checkbox]:after {
                content: "";
                display: block;
                left: 0;
                top: 0;
                position: absolute;
                transition: transform var(--d-t, 0.3s) var(--d-t-e, ease), opacity var(--d-o, 0.2s);
            }
            input[type=checkbox]:checked {
                --b: var(--active);
                --bc: var(--active);
                --d-o: .3s;
                --d-t: .6s;
                --d-t-e: cubic-bezier(.2, .85, .32, 1.2);
            }
            input[type=checkbox]:disabled {
                --b: var(--disabled);
                cursor: not-allowed;
                opacity: 0.9;
            }
            input[type=checkbox]:disabled:checked {
                --b: var(--disabled-inner);
                --bc: var(--border);
            }
            input[type=checkbox]:disabled + label {
                cursor: not-allowed;
            }
            input[type=checkbox]:hover:not(:checked):not(:disabled) {
                --bc: var(--border-hover);
            }
            input[type=checkbox]:focus {
                box-shadow: 0 0 0 var(--focus);
            }

            input[type=checkbox] + label {
                font-size: 14px;
                line-height: 21px;
                display: inline-block;
                vertical-align: top;
                cursor: pointer;
                margin-left: 4px;
            }


            input[type=checkbox].switch {
                width: 38px;
                border-radius: 11px;
            }
            input[type=checkbox].switch:after {
                left: 2px;
                top: 2px;
                border-radius: 50%;
                width: 15px;
                height: 15px;
                background: var(--ab, var(--border));
                transform: translateX(var(--x, 0));
            }
            input[type=checkbox].switch:checked {
                --ab: var(--active-inner);
                --x: 17px;
            }
            input[type=checkbox].switch:disabled:not(:checked):after {
                opacity: 0.6;
            }

        }
        .uk-modal-dialog ul {
            margin: 12px;
            padding: 0;
            list-style: none;
            width: 100%;
            max-width: 320px;
        }
        .uk-modal-dialog ul li {
            margin: 16px 0;
            position: relative;
        }
        @media (max-width: 800px) {
            body {
                flex-direction: column;
            }
        }
        .hoverBox{
            display: none; /* 初始状态隐藏 */
        }
    </style> 
</div>