<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body layui-table-body layui-table-main">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="排风温度设定"
                                       name="temp_set" id="L_exhaustTemperature" lay-verify="Temp_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="排风湿度设定"
                                       name="humi_set" id="L_exhaustHumidity" lay-verify="Humi_set">
                            </div>
                        </div>
<!--                        <div class="layui-inline layui-show-xs-block">-->
<!--                            <div class="layui-input-inline">-->
<!--                                <input type="text" class="layui-input" autocomplete="off" placeholder="停机延时设定"-->
<!--                                       name="unit_delay_stop" id="L_stopDelaySetting" lay-verify="unit_delay_stop">-->
<!--                            </div>-->
<!--                        </div>-->
                        <div class="layui-inline layui-show-xs-block">
                            <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">设定温湿度</i>
                            </a>
                        </div>
                    </form>
                    <form class="layui-form layui-col-space5" style="padding-top: 20px">
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="缺风报警延时时间"
                                       name="delayed_wind_alarm" id="L_delayed_wind_alarm" lay-verify="Temp_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="机组停止延时时间"
                                       name="unit_delay_stop" id="L_unit_delay_stop" lay-verify="Humi_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="送风机延时启动时间"
                                       name="blower_delay" id="L_blower_delay" lay-verify="unit_delay_stop">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="排风机延时启动时间"
                                       name="exhaust_fan_delay" id="L_exhaust_fan_delay" lay-verify="unit_delay_stop">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">设置延时、启动时间</i>
                            </a>
                        </div>
                    </form>
                    <form class="layui-form layui-col-space5" style="padding-top: 20px">
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时开机星期"
                                       name="open_week" id="L_open_week" lay-verify="Temp_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时开机时"
                                       name="open_hour" id="L_open_hour" lay-verify="Humi_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时开机分"
                                       name="open_min" id="L_open_min" lay-verify="unit_delay_stop">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时开机秒"
                                       name="open_sec" id="L_open_sec" lay-verify="unit_delay_stop">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">设置定时开机</i>
                            </a>
                        </div>
                    </form>
                    <form class="layui-form layui-col-space5" style="padding-top: 20px">
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时关机星期"
                                       name="stop_week" id="L_stop_week" lay-verify="Temp_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时关机时"
                                       name="stop_hour" id="L_stop_hour" lay-verify="Humi_set">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时关机分"
                                       name="stop_min" id="L_stop_min" lay-verify="unit_delay_stop">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" autocomplete="off" placeholder="定时关机秒"
                                       name="stop_sec" id="L_stop_sec" lay-verify="unit_delay_stop">
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">设置定时关机</i>
                            </a>
                        </div>
                    </form>
                    <div class="layui-inline layui-show-xs-block" style="padding-top: 20px">
                        <label class="layui-form-label">
                            控制选择模式
                        </label>
                        <div class="layui-input-inline">
                            <button class="layui-btn" th:text="${deviceData.M_bit1BinStr.charAt(6)} == '0' ? 'CK1' : 'CK2'">CK-1</button>
                        </div>
                    </div>
                    <div class="layui-inline layui-show-xs-block" style="padding-top: 20px">
                        <label class="layui-form-label">
                            控制选择复位
                        </label>
                        <div class="layui-input-inline">
                            <div class="layui-input-inline">
                                <button class="layui-btn" th:text="${deviceData.M_bit1BinStr.charAt(7)} == '0' ? '主用' : '备用模式'">控制选择复位</button>
                            </div>
                        </div>
                    </div>
                    <table class="layui-table">
                        <colgroup>
                            <col width="150">
                            <col width="200">
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>设备名称</th>
                            <th>控制模式</th>
                            <th>手动命令</th>
                            <th>实时反馈</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>空调送风机</td>
                            <td >
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(14)} == '0' ? 2 : -2" lay-verify="">
<!--                                               th:value="2" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(14)} == '0' ? '手动' : '自动'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(13)} == '0' ? 4 : -4" lay-verify="">
<!--                                               th:value="4" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(13)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(5)} == '0' ? '关' : '开'">运行</td>
                        </tr>
                        <tr>
                            <td>空调排风机</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(13)} == '0' ? 8 : -8" lay-verify="">
<!--                                               th:value="8" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(13)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(11)} == '0' ? 16 : -16" lay-verify="">
<!--                                               th:value="16" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(11)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(4)} == '0' ? '关' : '开'">运行</td>
                        </tr>
                        <tr>
                            <td>一级电加热</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(8)} == '0' ? 128 : -128" lay-verify="">
<!--                                               th:value="128" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(8)} == '0' ? '手动' : '自动'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(7)} == '0' ? 256 : -256" lay-verify="">
<!--                                               th:value="256" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(7)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(3)} == '0' ? '关' : '开'">开启</td>
                        </tr>
                        <tr>
                            <td>二级电加热</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(6)} == '0' ? 512 : -512" lay-verify="">
<!--                                               th:value="512" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(6)} == '0' ? '手动' : '自动'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(5)} == '0' ? 1024 : -1024" lay-verify="">
<!--                                               th:value="1024" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(5)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(2)} == '0' ? '关' : '开'">开启</td>
                        </tr>
                        <tr>
                            <td>三级电加热</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(4)} == '0' ? 2048 : -2048" lay-verify="">
<!--                                               th:value="2048" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(4)} == '0' ? '手动' : '自动'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td >
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(3)} == '0' ? 4096 : -4096" lay-verify="">
<!--                                               th:value="4096" lay-verify="">-->
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(3)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(1)} == '0' ? '关' : '开'">关闭</td>
                        </tr>
                        <tr>
                            <td>空调送风阀</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(2)} == '0' ? 8192 : -8192" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(2)} == '0' ? '手动' : '自动'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(1)} == '0' ? 16384 : -16384" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(1)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(0)} == '0' ? '关' : '开'">开启</td>
                        </tr>
                        <tr>
                            <td>空调排风阀</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(0)} == '0' ? 32768 : -32768" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(0)} == '0' ? '手动' : '自动'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td >
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit1" class="layui-input"
                                               th:value="${deviceData.M_bit1BinStr.charAt(15)} == '0' ? 1 : -1" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit1BinStr.charAt(15)} == '0' ? '开' : '关'">
                                            修改
                                        </i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.Q_bit3BinStr.charAt(15)} == '0' ? '关' : '开'">开启</td>
                        </tr>
                        <tr>
                            <td>空调热水阀</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(2)} == '0' ? 8192 : -8192" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(2)} == '0' ? '按照手动设置值' : '自动按照PID'">
                                            自动
                                        </i>
                                    </a>
                                </form>
                            </td>
<!--                            <td th:text="${deviceData.M_bit2.charAt(2)} == '0' ? '自动按照PID' : '按照手动设置值'">自动</td>-->
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input id="hot_water_valve_value" name="hot_water_valve_set" class="layui-input"
                                               th:value="${deviceData.hot_water_valve_set}" lay-verify="zeroToHundred">
                                    </div>
                                    % &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">修改</i>
                                    </a>
                                </form>
                                <!--<button class="layui-btn">修改</button>-->
                            </td>
                            <td th:text="${deviceData.hot_water_valve_value} + '%'">87%</td>
                        </tr>
                        <tr>

                            <td>空调冷水阀</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(1)} == '0' ? 16384 : -16384" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(1)} == '0' ? '按照手动设置值' : '自动按照PID'">
                                            自动
                                        </i>
                                    </a>
                                </form>
                            </td>
<!--                            <td th:text="${deviceData.M_bit2.charAt(1)} == '0' ? '自动按照PID' : '按照手动设置值'">自动</td>-->
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input id="cold_water_valve_value" name="cold_water_valve_set"
                                               class="layui-input" th:value="${deviceData.cold_water_valve_set}">
                                    </div>
                                    % &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">修改</i>
                                    </a>
                                </form>
                            </td>

                            <td th:text="${deviceData.cold_water_valve_value} + '%'">94%</td>
                        </tr>

                        <tr>
                            <td>空调加湿器</td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="m_bit2" class="layui-input"
                                               th:value="${deviceData.M_bit2BinStr.charAt(0)} == '0' ? 32768 : -32768" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update">
                                        <i class="layui-icon" th:text="${deviceData.M_bit2BinStr.charAt(0)} == '0' ? '按照手动设置值' : '自动按照PID'">
                                            自动
                                        </i>
                                    </a>
                                </form>
                            </td>
<!--                            <td th:text="${deviceData.M_bit2.charAt(0)} == '0' ? '自动按照PID' : '按照手动设置值'">自动</td>-->
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input id="humidification_set" name="humidification_set" class="layui-input"
                                               th:value="${deviceData.humidification_set}" lay-verify="zeroToHundred">
                                    </div>
                                    % &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">修改</i>
                                    </a>
                                </form>
                                <!--<button class="layui-btn">修改</button>-->
                            </td>
                            </td>
                            <td th:text="${deviceData.humidification_value} + '%'">0%</td>
                        </tr>
                        <tr>
                            <td>风冷主机故障状态</td>
                            <td></td>
                            <td></td>
                            <td th:text="${deviceData.M_bit2BinStr.charAt(11)} == '0' ? '正常' : '故障'">开启</td>
                        </tr>
                        <tr>
                            <td>时间表控制开关</td>
                            <td></td>
                            <td>
                                <form class="layui-form layui-col-space5">
                                    <div class="layui-input-inline">
                                        <input type="hidden" id="" name="m_bit1" class="layui-input"
                                               th:value="2048" lay-verify="">
                                    </div>
                                    <a class="layui-btn" lay-submit lay-filter="update"><i class="layui-icon">修改</i>
                                    </a>
                                </form>
                            </td>
                            <td th:text="${deviceData.M_bit1BinStr.charAt(4)} == '0' ? '定时关' : '定时开'">开启</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form;

        form.verify({
            Temp_set: function (value) {
                if (value < 0 || value > 50) {
                    return '排风温度只能在0-50℃之间';
                }
            },
            Humi_set: function (value) {
                if (value < 0 || value > 100) {
                    return '排风湿度只能在0-100%之间';
                }
            },
            zeroToHundred: function (value) {
                if (value < 0 || value > 100) {
                    return '只能在0-100%之间';
                }
            },
            unit_delay_stop: function (value) {
                if (value < 0 || value > 9999) {
                    return '停机延时只能在0-9999秒之间';
                }
            }
        });


        // 监听全选
        form.on('checkbox(checkall)', function (data) {

            if (data.elem.checked) {
                $('tbody input').prop('checked', true);
            } else {
                $('tbody input').prop('checked', false);
            }
            form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });


        form.on('submit(update)',
            function (data) {
                console.log(JSON.stringify(data.field))
                layer.confirm('确认要设置吗？', function () {
                    $.ajax({
                        url: "[[${#request.contextPath}]]" + "/parameterSetting/update",
                        method: "post",
                        data: JSON.stringify(data.field),
                        contentType: "application/json;charset=UTF-8" //定义数据格式为JSON
                    });
                    layer.msg('设置成功', {icon: 1, time: 500}, function () {
                        location.reload();
                    });
                })
            });
    });

    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function (index) {

            if ($(obj).attr('title') == '启用') {

                //发异步把用户状态进行更改
                $(obj).attr('title', '停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!', {icon: 5, time: 1000});

            } else {
                $(obj).attr('title', '启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!', {icon: 5, time: 1000});
            }

        });
    }

    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }


    function delAll(argument) {
        var ids = [];

        // 获取选中的id
        $('tbody input').each(function (index, el) {
            if ($(this).prop('checked')) {
                // console.log($(this).val())
                ids.push($(this).val())
            }
        });

        layer.confirm('确认要删除吗？' + ids.toString(), function (index) {
            console.log(JSON.stringify(ids))
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $.ajax({
                url: "[[${#request.contextPath}]]" + "/operator/batch",
                method: "delete",
                data: JSON.stringify(ids),
                contentType: "application/json;charset=UTF-8" //定义数据格式为JSON
            });
            $(".layui-form-checked").not('.header').parents('tr').remove();

            //表单重载
            tableReload.reload('tableId', {
                where: {},
                page: {
                    curr: 1
                }
            });
        });
    }

    //用于表单重载
    var tableReload;

    layui.use('table', function () {
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#table',
            url: '/operatorPage', //数据接口
            page: true, //开启分页
            id: 'tableId',
            cols: [
                [ //表头
                    {type: 'checkbox', title: 'ID'},
                    {field: 'id', title: 'id', width: 100, sort: true},
                    {field: 'username', title: '账号', width: 160},
                    {field: 'companyName', title: '公司名称', width: 250, sort: true},
                    {field: 'district', title: '地区', width: 250},
                    {field: 'detailedAddress', title: '具体地址', width: 250},
                    {field: 'contact', title: '联系人', width: 160, sort: true},
                    {field: 'phone', title: '联系电话', width: 180, sort: true},
                    {field: 'tool', toolbar: '#barDemo', title: '操作', width: 200}
                ]
            ],
            done: function () {
                $("tbody td[data-field='id'] div").each(function () {
                    var id = $(this).text();
                    // console.log(id)
                    $(this).parent().prev().children().find("input").attr("value", id);
                })
            }
        });


        //工具条事件
        table.on('tool(table)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

            if (layEvent === 'del') { //删除
                layer.confirm('真的删除行么', function (index) {
                    obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                    layer.close(index);
                    //向服务端发送删除指令
                    console.log(data)
                    $.ajax({
                        url: "[[${#request.contextPath}]]" + '/operator',
                        data: JSON.stringify(data),
                        method: "delete",
                        contentType: "application/json;charset=UTF-8" //定义数据格式为JSON
                    });
                    //表单重载
                    tableReload.reload('tableId', {
                        where: {},
                        page: {
                            curr: 1
                        }
                    });
                });
            } else if (layEvent === 'edit') { //编辑
                //do something
                // console.log(data)
                xadmin.open('编辑运营商', '/operator-edit?id=' + data.id, 600, 550);
                //同步更新缓存对应的值
                obj.update({
                    username: '123'
                    , title: 'xxx'
                });
            } else if (layEvent === 'LAYTABLE_TIPS') {
                layer.alert('Hi，头部工具栏扩展的右侧图标。');
            }
        });

        tableReload = table;
    });


</script>
<!-- 工具条 -->
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
</html>