define(function(require, exports, module) {
  'use strict';
  require('bootstrapTable');
  require('bootstrapTableCn');

  var global = require("../../js/global");
  var utils = require("../../js/utils");
  var quickGoneLive = window.require('../../common/js/quickGoneLive');
  var quickGoneFlow = window.require('../../common/js/quickGoneFlow');
  var rac = window.require('../../common/js/racTelnetMng');
  var jsUtil = window.require('../../common/js/jsUtil');

  var keepHandle = null;

  var oneAcUpgradeIns = null;
  var oneAcUpgrade = window.require("../../common/js/oneAcUpgrade");
  var jGlobal = require("../../oneUpgrade/js/oneUpgradeGlobal");

  // 连续MAX_SAME_ONLINE_AP_COUNT+1次点击刷新AP列表后，
  // 在线AP数保存不变，则引导用户进行设备升级
  const MAX_SAME_ONLINE_AP_COUNT = 2;
  let sameOnlineApCount = 0;
  let currentApNum = 0;

  let patchEditMap = {}; //需要下发命令项
  let batchPowerList = []; //批量修改功率项

  function init() {
    tableFormatter();
    initEvent();
    initGlobalEvent(); //离开当前页面事件
    // initDeviceTable();
  }
  function tableFormatter() {
    window.statusFormatter = statusFormatter;
    window.deviceNameFormatter = deviceNameFormatter;
    window.radio1Formatter = radio1Formatter;
    window.radio2Formatter = radio2Formatter;
    window.checkFormatter = checkFormatter;
    window.formatterMac = formatterMac;
  }
  function keepAlive() {
    if (keepHandle) {
      clearInterval(keepHandle);
    }
    keepHandle = setInterval(function() {
      //这里使用keeplive.htm仅仅是因为无内容，返回快，只要有请求session就会保活。
      var params = {
        path: "/keeplive.htm"
      };
      quickGoneLive.keepAlive(params, function(res) {
        console.log('保持会话', res);
      })
    }, 60000);
  }

  function logBoard(type, content) {
    var resultText = '';
    switch (type) {
      case 'success':
        resultText = '<p class="success">' + content + '</p><br>'
        break;
      case 'fail':
        resultText = '<p class="fail">' + content + '</p><br>'
        break;
      case 'warn':
        resultText = '<p class="warn">' + content + '</p><br>'
        break;
      case 'run':
        if (content === '...') {
          resultText = '... ';
        } else {
          resultText = '<p>' + content + '</p>'
        }
        break;
      case 'alert':
        alert(undefined, content);
        return;
      default:
    }
    console.log('---->', content);
    $("#cliResult").append(resultText);
  }

  function initEvent() {
    // var currentApName; // AP名称修改前的值
    logBoard('run', '<span class="spanTitle">操作说明:</span>');
    logBoard('run', '1、路由器正常配置上网，开启路由器上DHCP自动分配地址的功能；判断路由器DHCP是否开启的方法是，电脑连接路由器，看下电脑能不能获取到地址上网');
    logBoard('run', '2、如左边拓扑所示，把路由器、RAP、RAC、电脑通过交换机相互联在一起；默认情况下，RAC和交换机除了Console口以外，任意接口都可以使用');
    logBoard('run', '<span class="spanContent spanWarn">   注意：RAC必须是出厂情况下使用</span>');
    logBoard('run', '3、在左边输入框中填上无线WiFi名字和无线WiFi密码，点击【开始部署】启动部署，等待部署结束');
    logBoard('run', '4、部署成功后，会自动跳到AP列表，可以查看当前上线的AP，可以对RAC和RAP进行升级');
    logBoard('run', ' ');
    logBoard('run', '<span class="spanTitle spanWarn">注意:</span>');
    logBoard('run', '<span class="spanContent spanWarn">1、RAC部署程序会修改电脑的网络配置，导致电脑临时断网，使用完后自动恢复电脑网络</span>');
    logBoard('run', '<span class="spanContent spanWarn">2、修改电脑网络配置的脚本可能会被安全软件（360等）拦截，请允许操作</span>');
    // $("#cliResult").addClass('divAnimation');
    $(".spanTitle").addClass('divAnimation');
    $("#issuedCommand").click(function() {
      if (!check()) {
        return;
      }
      // $("#cliResult").removeClass('divAnimation');
      $(".spanTitle").removeClass('divAnimation');
      $("#cliResult").html('');
      // $(".arrowDOM").hide();
      var ewebPsd = $("#ewebPsd").val();
      var wirelessName = $("#wirelessName").val();
      var wirelessPsd = $("#wirelessPsd").val();
      var deviceLoginIp = $("#deviceLoginIp").val();
      var params = {
        logBoard: logBoard,
        alive: keepAlive,
        ewebPsd: ewebPsd,
        ssidName: wirelessName,
        ssidPwd: wirelessPsd,
        devIp: deviceLoginIp
      };
      $("#issuedCommand").addClass('disabled').prop('disabled', true);
      quickGoneFlow.start(params, function(err, ret) {
        $("#issuedCommand").removeClass('disabled').removeAttr('disabled');
        if (!err) {
          success();
          $("#deviceMangeAP").trigger('click', true); //触发点击管理RAP按钮
          // if (global.racBackFile !== undefined) {
          //     $(".tRight").append('<button id="backups" class="self-btn">查看备份</button>');
          // }
          // if (quickGoneFlow.getRacIP() !== undefined) {
          //     console.log(quickGoneFlow.getRacIP(), "quickGoneFlow.getRacIP")
          //     $(".tRight").append('<button id="goEweb" class="self-btn">前往EWEB</button>');
          // }
        } else {
          error();
        }
        clearInterval(keepHandle);
        console.log(ret);
      });

    })
    $("#wirelessPsd").keyup(function(event) {
      var wirelessPsd = $("#wirelessPsd").val();
      if ($("#wirelessPsd").val() != '') {
        if (/^[a-zA-Z0-9@]{8,}$/.test(wirelessPsd)) {
          $(this).parent('.userinput').removeClass('error').addClass('success');
        } else {
          $(this).parent('.userinput').removeClass('success').addClass('error');
        }
      } else {
        $(this).parent('.userinput').removeClass('error').removeClass('success');
        $(this).next('.hint').hide();
      }
    });
    $("#wirelessPsd").blur(function(event) {
      $(this).parent('.userinput').removeClass('error').removeClass('success');
      $(this).next('.hint').hide();
    });
    $("#wirelessPsd").focus(function(event) {
      $(this).next('.hint').show();
    });

    $("#showAdvanceConfig").click(function() {
      if ($(this).hasClass('show')) {
        $(this).removeClass('show').text("展开高级配置>>");
        $(".advanceConfig").hide();
      } else {
        $(this).addClass('show').text("收起高级配置<<");
        $(".advanceConfig").css('display', 'flex');
        $("#deviceLoginIp").val('');
        $("#ewebPsd").val('');
      }
    })
    $("#showHistoryAcIp").click(function() {
      let racHistoryFile = quickGoneFlow.getRacHistoryFile();
      let gui = window.require('nw.gui');
      gui.Shell.openItem(racHistoryFile);
    });
    $("#openLogDir").click(function() {
      let logDir = quickGoneFlow.getLogDir();
      console.debug('tool log dir:', logDir);
      jsUtil.openDir(logDir);
    });
    //点击前往WEB
    $("#goEweb").click(function(event) {
      var racIP = quickGoneFlow.getRacIP();
      console.log(racIP, "racIP");
      var gui = window.require('nw.gui');
      gui.Shell.openExternal("http://" + racIP + '/index.htm');
    });
    //点击备份
    $("#backups").click(function(event) {
      let racBackFile = quickGoneFlow.getRacBackFile();
      console.log(racBackFile, "racBackFile");
      let gui = window.require('nw.gui');
      if (racBackFile) {
        gui.Shell.openItem(racBackFile);
      } else {
        let backupDir = quickGoneFlow.getRacBackDir();
        console.debug('rac config backup dir:', backupDir);
        jsUtil.openDir(backupDir);
      }
    });
    //（开启/关闭）信道/功率事件
    $(".deviceTableDOM").delegate('.openRadio', 'click', function(event) {
      if ($(this).prop('checked')) {
        $(this).parents(".iosCheck").siblings(".selfSelect").removeAttr('disabled');
        $(this).parents(".iosCheck").siblings(".custom").find(".power").removeAttr('disabled');
        $(this).parents(".iosCheck").siblings(".custom").find(".customPower").removeAttr('disabled');
      } else {
        $(this).parents(".iosCheck").siblings(".selfSelect").prop('disabled', 'disabled');
        $(this).parents(".iosCheck").siblings(".custom").find(".power").prop('disabled', 'disabled');
        $(this).parents(".iosCheck").siblings(".custom").find(".customPower").prop('disabled', 'disabled');
      }
    });
    //登录RAC管理
    $(".btn-ok").on('click', function(e) {
      e.stopPropagation(); //阻止点击按钮默认会关闭弹窗
      e.preventDefault();
      if (!loginDeviceCheck()) { //校验登录
        return;
      }
      var host = $("#racHost").val();
      var password = $("#racPsd").val() == ''
        ? 'admin'
        : $("#racPsd").val();
      $("#loginAPmanage").modal('hide');
      $("#loadShadow").show();
      var params = {
        host: host,
        pwd: password
      }
      // gerUrlCode(params);
      getAPlistAPI(params);
      // $("#deviceManageContent").find('.codeBtn').trigger('click');
    });
    //点击设备管理事件
    $('#deviceMangeAP').click(function(event, isShowQr) {
      console.log("triggerBBB")
      let host = quickGoneFlow.getRacIP();
      let pwd = quickGoneFlow.getRacPwd();
      if (!host) {
        $("#loginAPmanage").modal('show');
        // $('#loginAPmanage').on('shown.bs.modal', function() {
        // });
        $('#loginAPmanage').off('hidden.bs.modal').on('hidden.bs.modal', function() {
          $("#loginAPmanage").find('.hint').hide();
          $("#loginAPmanage").find('.errorHint').hide();
          $("#racPsd").val('').removeClass('error');
          $("#racHost").val('').removeClass('error');
        })
      } else {
        $("#loadShadow").show();
        var params = {
          host: host,
          pwd: pwd
        }
        $("#refreshAP").addClass('divAnimation');
        sameOnlineApCount = 0;
        currentApNum = 0;
        getAPlistAPI(params, isShowQr); //第二个参数表示是否点开二维码
        // gerUrlCode(params);
      }
    });
    //点击刷新AP列表
    $("#refreshAP").click(function(event) {
      $("#loadShadow").show(); //loading；
      refreshAPI(null, function(onlineAps) {
        console.log('temp ap num, refresh ap num:', currentApNum, onlineAps);
        if (currentApNum === onlineAps) {
          sameOnlineApCount++;
        } else {
          currentApNum = onlineAps;
          sameOnlineApCount = 0;
        }
        if (sameOnlineApCount >= MAX_SAME_ONLINE_AP_COUNT) {
          $("#refreshAP").removeClass("divAnimation");
          $("#upgradeVersion").addClass("divAnimation");
        }
      });
    });
    //登录设备管理弹窗 RAC地址输入框键盘事件
    $("#racHost").keyup(function(event) {
      var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
      if (!reg.test($(this).val())) {
        $(this).addClass('error');
      } else {
        $(this).removeClass('error');
      }
    })
    //登录设备管理弹窗 RAC密码输入框键盘事件
    $("#racPsd").keyup(function(event) {
      if ($(this).val() === '') {
        $("#racPsd").removeClass('error').siblings(".hint").hide();
        return;
      }
      if (!/^[a-zA-Z0-9@]+$/.test($(this).val())) {
        $(this).addClass('error');
        $("#racPsd").siblings(".hint").show();
        setTimeout(function() {
          $("#racPsd").siblings(".hint").hide();
        }, 1500)
      } else {
        $(this).removeClass('error');
        $("#racPsd").siblings(".hint").hide();
      }
    });
    // 分页点击事件
    $("#deviceManageContent").delegate(".page-first,.page-pre,.page-number,.page-next,.page-last", "mousedown", function(event) {
      if($('.deviceTableDOM').find('.error').length > 0) {
        alert(undefined,"请修改正确的配置");
        event.preventDefault();
        event.stopPropagation();
        return;
      }
      console.log(patchEditMap, "ssssssssssssss");
      if(patchEditMap && JSON.stringify(patchEditMap) != '{}') {
        alert(undefined,"请保存当前页修改");
        event.preventDefault();
        event.stopPropagation();
        return;
      }
    });

    // //AP名称 键盘输入事件
    $("#apDeviceTable").delegate('.apNameInput', 'keyup', function(event) {
      var _this = $(this);
      var apName = $(this).val();
      if (!/^[\w@.\u4e00-\u9fa5]{1,64}$/.test(apName)) {
        $(this).addClass('error');
        $(this).siblings('.hint').show().text('请输入中文，数字，字母，下划线，.或@,且不可超过64位字符');
        setTimeout(function() {
          _this.siblings('.hint').hide();
        }, 2500);
      } else {
        $(this).removeClass('error');
      }
    })
    //修改AP名称
    $("#apDeviceTable").delegate('.apNameInput', 'change', function(event) {
      var _this = $(this);
      if ($("#apDeviceTable").find('.error').length > 0) { //存在不正确的输入
        console.log("错误啦啦啦啦啦啦")
        return;
      }
      var newApname = $(this).val();
      var filterApName = [] //判断要修改的ap名称是否有重复
      $(".apNameInput").each(function(index, item) {
        if ($(this).val() == newApname) {
          filterApName.push($(this).val())
        }
      })
      if (filterApName.length > 1) { // 大于1，因为自身也遍历了
        $(this).addClass('error');
        $(this).siblings('.hint').show().text('AP名称重复');
        setTimeout(function() {
          _this.siblings('.hint').hide();
        }, 1500);
        return;
      } else {
        $(this).removeClass('error');
      }
      var oldName = $(this).data('oldvalue');
      let apParams = {
        oldName: oldName,
        newName: newApname
      };
      var status = $(this).parents('td').prev('td').text(); //在线状态
      if (status == '在线') {
        apParams.isOffline = false;
      } else {
        apParams.isOffline = true;
      }
      var mac = $(this).parents('td').next('td').next('td').find(".mac").text(); //MAC地址
      if (mac != '-') {
        apParams.oldMac = mac;
      }
      console.log(apParams, "修改AP名称");
      patchEditMap[mac] = patchEditMap[mac]
        ? patchEditMap[mac]
        : {};
      patchEditMap[mac].apName = apParams;
      // rac.setApName(apParams,function (err,rest) {
      //     if (!err) {
      //         console.log('修改AP名称成功', err, rest);
      //         refreshAPI();
      //     } else {
      //         alert(undefined, '修改AP名称失败');
      //         console.log('修改AP名称失败：' + JSON.stringify(err));
      //         refreshAPI();
      //     }
      // });
    });
    //开启/关闭信道功率
    $("#apDeviceTable").delegate('.openRadio', 'change', function(event) {
      var radioId = $(this).parent(".iosCheck").parent(".rateFormater").data('id');
      var apName = $(this).parents("td").siblings('td').find('.apNameInput').data('oldvalue');
      var status = $(this).is(':checked')
        ? 'enable'
        : 'disable';
      var apStatusParams = {
        apName: apName,
        radioId: radioId,
        status: status
      }; // radioId：1-》2.4G,2->5G;status:enable->开启，disable->关闭
      var mac = $(this).parents("td").siblings('td').find('.mac').text();
      patchEditMap[mac] = patchEditMap[mac]
        ? patchEditMap[mac]
        : {};
      if (radioId == 1) {
        patchEditMap[mac].apSwitchOne = apStatusParams;
      } else if (radioId == 2) {
        patchEditMap[mac].apSwitchTwo = apStatusParams;
      }
      // rac.changeApBandStatus(apStatusParams,function (err,rest) {
      //   if(!err) {
      //     var textStatus = status == 'enable' ? '启用' : '关闭';
      //     console.log(`设备 ${apName} ${textStatus}信道/功率成功`,err,rest);
      //     refreshAPI();
      //   } else {
      //     alert(undefined,`设备 ${apName} ${textStatus} 信道/功率失败`);
      //     console.log(`设备 ${apName} ${textStatus}信道/功率失败：`+ JSON.stringify(err));
      //   }
      // });
    })

    //修改信道
    $("#apDeviceTable").delegate('.channel', 'change', function(event) {
      var radioId = $(this).parent(".rateFormater").data('id');
      var apName = $(this).parents("td").siblings('td').find('.apNameInput').data('oldvalue');
      var channel = $(this).val();
      var apChannelParams = {
        apName: apName,
        radioId: radioId,
        channel: channel
      };
      var mac = $(this).parents("td").siblings('td').find('.mac').text();
      patchEditMap[mac] = patchEditMap[mac]
        ? patchEditMap[mac]
        : {};
      if (radioId == 1) {
        patchEditMap[mac].apChannelOne = apChannelParams;
      } else if (radioId == 2) {
        patchEditMap[mac].apChannelTwo = apChannelParams;
      }
      // rac.setApChannel(apChannelParams,function (err,rest) {
      //   if(!err) {
      //     console.log(`设备 ${apName} 修改信道为${channel} 成功`,err,rest);
      //     refreshAPI();
      //   } else {
      //     alert(undefined,`设备 ${apName} 修改信道为${channel} 失败`);
      //     console.log(`设备 ${apName} 修改信道为${channel} 失败：`+ JSON.stringify(err));
      //   }
      // });
    })

    //修改单个功率（选择 节能|标准|增强）
    $("#apDeviceTable").delegate('.power', 'change', function(event) {
      if ($(this).find("option:selected").text() == '自定义') {
        $(this).parent('.custom').append('<input class="form-control customPower" placeholder="1~100"/>');
        $(this).parent('.custom').find(".customPower").focus();
      } else {
        $(this).removeClass('error');
        $(this).siblings('.customPower').remove(); //去除自定义功率输入框
      }
      var radioId = $(this).parents(".rateFormater").data('id');
      var apName = $(this).parents("td").siblings('td').find('.apNameInput').data('oldvalue');
      var power;
      if ($(this).find("option:selected").text() != '自定义') {
        power = $(this).val();
        var apPowerParams = {
          apName: apName,
          radioId: radioId,
          power: power
        };
        var mac = $(this).parents("td").siblings('td').find('.mac').text();
        editPowerAPI(apPowerParams, mac, radioId);
      }
    })
    //表格自定义功率 键盘输入 事件
    $("#apDeviceTable").delegate('.customPower', 'keyup', function(event) {
      var powerValue = $(this).val();
      if (!/^([1-9]\d?|100)$/.test(powerValue)) {
        $(this).siblings('.power').addClass('error');
        return;
      } else {
        $(this).siblings('.power').removeClass('error');
        if ($("#apDeviceTable").find('.error').length > 0) { //存在不正确的输入
          return;
        }
        console.log($("#apDeviceTable").find("tr.selected").length, "KKKKKKKKKKKKKKKKKK");
        var powerValue = $(this).val();
        $(this).siblings('.power').find("option:selected").attr('value', powerValue); //将输入框中自定义的值设为下拉选项“自定义” 的值
        var radioId = $(this).parents(".rateFormater").data('id');
        var apName = $(this).parents("td").siblings( 'td').find('.apNameInput').data('oldvalue');
        var apPowerParams = {
          apName: apName,
          radioId: radioId,
          power: powerValue
        };
        var mac = $(this).parents("td").siblings('td').find('.mac').text();
        editPowerAPI(apPowerParams, mac, radioId);
      }
    })

    //批量修改功率弹窗 下拉选择事件
    $("#batchEditModal").find(".batchPower").change(function() {
      if ($(this).find("option:selected").text() == '自定义') {
        $(this).siblings('.customPower').show().focus();
      } else {
        $(this).siblings('.customPower').hide();
      }
    })
    // 批量修改功率弹窗  2.4G功率自定义键盘输入事件
    $("#batchCustomPower_1").keyup(function(event) {
      var batchPower = $(this).val();
      $(this).siblings('.batchPower').find("option:selected").attr('value', batchPower);
      if (!/^([1-9]\d?|100)$/.test(batchPower)) {
        $(this).siblings(".batchPower").addClass('error');
      } else {
        $(this).siblings('.batchPower').removeClass('error');
      }
    });
    // 批量修改功率弹窗  5G功率自定义键盘输入事件
    $("#batchCustomPower_2").keyup(function(event) {
      var batchPower = $(this).val();
      $(this).siblings('.batchPower').find("option:selected").attr('value', batchPower);
      if (!/^([1-9]\d?|100)$/.test(batchPower)) {
        $(this).siblings('.batchPower').addClass('error');
      } else {
        $(this).siblings('.batchPower').removeClass('error');
      }
    });

    //批量修改勾选
    $("#apDeviceTable").delegate("tr", 'mousedown', function(event) {
      /* Act on the event */
      if(!$(this).hasClass('selected')) {
        var deviceName = $(this).find(".apNameInput").data('oldvalue');
        var hasPowerOne = $(this).find('.rateFormater[data-id=1]').length > 0 ? true : false;
        var hasPowerTwo = $(this).find('.rateFormater[data-id=2]').length > 0 ? true :false;
        var batchPowerInfo = {
          apName:deviceName,
          hasPowerOne:hasPowerOne,
          hasPowerTwo:hasPowerTwo
        }
        batchPowerList.push(batchPowerInfo);
      }
    });
    //批量修改功率
    $("#batchEdit").click(function(event) {
      if ($("#apDeviceTable").find('tr.selected').length == 0) {
        alert(undefined, "请选择需要修改的设备");
        return;
      }
      $("#batchEditModal").modal('show');
      $('#batchEditModal').off('shown.bs.modal').on('shown.bs.modal', function() {
        $(".batch-ok").off().on('click', function(event) {
          if ($("#batchEditModal").find('.error').length > 0) { //存在不正确的输入
            event.stopPropagation();
            event.preventDefault();
            return;
          }
          $("#batchEditModal").modal('hide');
          $("#loadShadow").show(); //loading
          var batchItem = [];
          var editCount = 0;
          batchPowerList.forEach(function(item){
            if(item.hasPowerOne) {
              var powerValue = $("#batchPower_1").val();
              batchItem.push({apName: item.apName, radioId: 1, power: powerValue})
            }
            if(item.hasPowerTwo) {
              var powerValue = $("#batchPower_2").val();
              batchItem.push({apName: item.apName, radioId: 2, power: powerValue})
            }
          })
          batchItem.forEach(function(item){
              rac.setApPower(item, function(err, rest) {
                editCount++;
                var PowerType = item.radioId == 1
                  ? '2.4G'
                  : '5G';
                if (!err) {
                  console.log(`设备 ${item.apName} 修改${PowerType}功率为${item.power} 成功`, err, rest);
                } else {
                  alert(undefined, `设备 ${item.apName} 修改${PowerType}功率为${item.power} 失败`);
                  console.log(`设备 ${item.apName} 修改${PowerType}功率为${item.power} 失败：` + JSON.stringify(err));
                }
                if (editCount == batchItem.length) {
                  editCount = 0;
                  batchPowerList = [];
                  var msg = "批量修改成功";
                  refreshAPI(msg);
                }
              });
          })

        })
      })
      $('#batchEditModal').off('hidden.bs.modal').on('hidden.bs.modal', function() {
        $('#batchEditModal').find(".batchPower").removeClass('error');
        $("#batchCustomPower_1").hide();
        $("#batchCustomPower_2").hide();
        $("#batchPower_1").find('option:first-child').prop("selected", "selected");
        $("#batchPower_2").find('option:first-child').prop("selected", "selected");
      })
    });
    //关闭二维码
    $("#deviceManageCode").find(".close-code").click(function(event) {
      $("#deviceManageCode").hide();
    });
    //显示二维码
    $("#deviceManageContent").find('.codeBtn').hover(function(event) {
      $("#deviceManageCode").show();
    });

    // 版本升级
    $("#upgradeVersion").click(function() {
      $("#refreshAP").removeClass("divAnimation");
      $("#upgradeVersion").removeClass("divAnimation");

      sameOnlineApCount = 0;
      currentApNum = 0;

      // 初始化下载进度条显示
      $("#progress_download").text('0%');
      $("#progressBar_download").css('width', '0%');
      $("#dlg_downloadProgress").modal('show');

      rac.getApVersionList({}, function(err, info) {
        if (err != null) {
          $("#dlg_downloadProgress").modal('hide');
          alert(undefined, "获取版本信息失败，原因：" + JSON.stringify(err));
          return;
        }
        console.log('ap product list', info);

        var sessionId = global.userMgrIns.getUserInfo().sessionId;
        var params = [];
        params.push({deviceType: info.acType, hardwareVersion: info.acHardVer, versionType: "normal", softwareVersion: "11.x"});
        for (var i = 0; i < info.apList.length; i++) {
          params.push({deviceType: info.apList[i].deviceType, hardwareVersion: info.apList[i].hardwareVersion, versionType: "normal", softwareVersion: "11.x"});
        }
        oneAcUpgradeIns = new oneAcUpgrade(global.devicesIns, false);

        oneAcUpgradeIns.batchDownloadBinFile(sessionId, params, function(err, res) {
          // 有版本下载失败，err不为null
          if (err != null) {
            $("#dlg_downloadProgress").modal('hide');
            alert(undefined, '下载推荐版本出错，出错原因：' + err);
            return;
          }

          if (res.code == 7) {
            $("#dlg_downloadProgress").modal('hide');
            alert(undefined, '检测到本地已存在推荐版本。点击确定开始升级！', function() {
              rac.addAcToDevLinkMgr(global.devicesIns, function(err, ret) {
                if (!err) {
                  info.deviceName = ret;
                  formatUpgradeParams(info);
                  gotoUpgradePage();
                }
              });
            }, true, function() {});
            return;
          }

          // 更新进度条
          if (res.code == -1) {
            var percent = Math.floor((res.downloadLen / res.totalLen) * 100);
            $("#progress_download").text(percent + '%');
            $("#progressBar_download").css('width', percent + '%');
          }

          // 某一个文件下载完成
          if (res.code == 2) {
            console.log('下载完成: ', res.path);
          }

          // 全部下载完成
          if (res.code == 0) {
            $("#progress_download").text('100%');
            $("#progressBar_download").css('width', '100%');
            $("#dlg_downloadProgress").modal('hide');

            alert(undefined, '全部推荐版本都已下载完成。点击确定开始升级！', function() {
              rac.addAcToDevLinkMgr(global.devicesIns, function(err, ret) {
                if (!err) {
                  info.deviceName = ret;
                  formatUpgradeParams(info);
                  gotoUpgradePage();
                }
              });

            }, true, function() {});
          }
        });
      });
    });

    //点击修改按钮
    $("#editConfig").click(function(event) {
      if($('.deviceTableDOM').find('.error').length > 0) {
        alert(undefined, '请修改正确的配置');
        return ;
      }
      console.log(patchEditMap, "哈拉");
      var EditItem = Object.keys(patchEditMap);
      if(EditItem.length == 0) {
        return;
      }
      $("#loadShadow").show(); //loading
      var pathList = []
      EditItem.forEach(function(item, index) {
        (function(item, index) {
          pathList[index] = 0;
          //2.4G开关
          if (patchEditMap[item].apSwitchOne) {
            console.log(`第 ${index} 设备：2.4G开关修改`);
            var apSwitchOne = patchEditMap[item].apSwitchOne;
            rac.changeApBandStatus(apSwitchOne, function(err, rest) {
              if (!err) {
                var textStatus = apSwitchOne.status == 'enable'
                  ? '启用'
                  : '关闭';
                console.log(`设备 ${apSwitchOne.apName} ${textStatus}信道/功率成功`, err, rest);
                pathList[index] += 1;
                // refreshAPI();
              } else {
                alert(undefined, `设备 ${apSwitchTwo.apName} ${textStatus} 信道/功率失败`);
                console.log(`设备 ${apSwitchTwo.apName} ${textStatus}信道/功率失败：` + JSON.stringify(err));
                $("#loadShadow").hide();
                return
              }
            });
          }
          //5G开关
          if (patchEditMap[item].apSwitchTwo) {
            console.log(`第 ${index} 设备：5G开关修改`);
            var apSwitchTwo = patchEditMap[item].apSwitchTwo;
            rac.changeApBandStatus(apSwitchTwo, function(err, rest) {
              if (!err) {
                var textStatus = apSwitchTwo.status == 'enable'
                  ? '启用'
                  : '关闭';
                console.log(`设备 ${apSwitchTwo.apName} ${textStatus}信道/功率成功`, err, rest);
                pathList[index] += 1;
                // refreshAPI();
              } else {
                alert(undefined, `设备 ${apSwitchTwo.apName} ${textStatus} 信道/功率失败`);
                console.log(`设备 ${apSwitchTwo.apName} ${textStatus}信道/功率失败：` + JSON.stringify(err));
                $("#loadShadow").hide();
                return;
              }
            });
          }

          //2.4G信道
          if (patchEditMap[item].apChannelOne) {
            var apChannelOne = patchEditMap[item].apChannelOne;
            console.log(`第 ${index} 设备：2.4G信道修改`);
            rac.setApChannel(apChannelOne, function(err, rest) {
              if (!err) {
                console.log(`设备 ${apChannelOne.apName} 修改信道为${apChannelOne.channel} 成功`, err, rest);
                pathList[index] = pathList[index] + 1;

                // refreshAPI();
              } else {
                alert(undefined, `设备 ${apChannelOne.apName} 修改信道为${apChannelOne.channel} 失败`);
                console.log(`设备 ${apChannelOne.apName} 修改信道为${apChannelOne.channel} 失败：` + JSON.stringify(err));
                $("#loadShadow").hide();
                return;
              }
            });
          }

          //5G信道
          if (patchEditMap[item].apChannelTwo) {
            var apChannelTwo = patchEditMap[item].apChannelTwo;
            console.log(`第 ${index} 设备：5G信道修改`);
            rac.setApChannel(apChannelTwo, function(err, rest) {
              if (!err) {
                console.log(`设备 ${apChannelTwo.apName} 修改信道为${apChannelTwo.channel} 成功`, err, rest);
                pathList[index] += 1;
                // refreshAPI();
              } else {
                alert(undefined, `设备 ${apChannelTwo.apName} 修改信道为${apChannelTwo.channel} 失败`);
                console.log(`设备 ${apChannelTwo.apName} 修改信道为${apChannelTwo.channel} 失败：` + JSON.stringify(err));
                $("#loadShadow").hide();
                return;
              }
            });
          }

          //2.4G功率
          if (patchEditMap[item].apPowerOne) {
            var apPowerOne = patchEditMap[item].apPowerOne;
            console.log(`第 ${index} 设备：2.4G功率修改`);
            rac.setApPower(apPowerOne, function(err, rest) {
              var powerType = apPowerOne.radioId == 1
                ? '2.4G'
                : '5G';
              if (!err) {
                console.log(`设备 ${apPowerOne.apName} 修改${powerType}功率为${apPowerOne.power} 成功`, err, rest);
                pathList[index] += 1;
                // refreshAPI();
              } else {
                alert(undefined, `设备 ${apPowerOne.apName} 修改${powerType}功率为${apPowerOne.power} 失败`);
                console.log(`设备 ${apPowerOne.apName} 修改${powerType}功率为${apPowerOne.power} 失败：` + JSON.stringify(err));
                $("#loadShadow").hide();
                return;
              }
            });
          }

          //5G功率
          if (patchEditMap[item].apPowerTwo) {
            var apPowerTwo = patchEditMap[item].apPowerTwo;
            console.log(`第 ${index} 设备：5G功率修改`);
            rac.setApPower(apPowerTwo, function(err, rest) {
              var powerType = apPowerTwo.radioId == 1
                ? '2.4G'
                : '5G';
              if (!err) {
                console.log(`设备 ${apPowerTwo.apName} 修改${powerType}功率为${apPowerTwo.power} 成功`, err, rest);
                pathList[index] += 1;
                // refreshAPI();
              } else {
                alert(undefined, `设备 ${apPowerTwo.apName} 修改${powerType}功率为${apPowerTwo.power} 失败`);
                console.log(`设备 ${apPowerTwo.apName} 修改${powerType}功率为${apPowerTwo.power} 失败：` + JSON.stringify(err));
                $("#loadShadow").hide();
                return;
              }
            });
          }

          let line = setInterval(function() {
            if (patchEditMap[item] && patchEditMap[item].apName) {
              if (Object.keys(patchEditMap[item]).length - 1 == pathList[index]) { //判断其他项是否都修改完成， （Object.keys(patchEditMap[item]).length-1） 去除apName的修改,因为apName要最后修改
                clearInterval(line);
                var apNameParams = patchEditMap[item].apName;
                console.log(`第 ${index} 设备：设备名称修改`);
                rac.setApName(apNameParams, function(err, rest) {
                  if (!err) {
                    console.log('修改AP名称成功', err, rest);
                    console.log(`第 ${index} 设备修改完成`);
                    if (EditItem.length == pathList.length) { //全部修改完成，刷新表格
                      patchEditMap = {};
                      refreshAPI('保存修改成功');
                      return;
                    }
                  } else {
                    clearInterval(line);
                    alert(undefined, '修改设备 '+apNameParams.oldName+' 名称失败');
                    console.log('修改设备'+ apNameParams.oldName +'名称失败：' + JSON.stringify(err));
                    $("#loadShadow").hide();
                    return;
                  }
                });
              }
            } else {
              // if(!patchEditMap[item]){
              //   clearInterval(line);
              //   refreshAPI();
              //   return;
              // }
              if (Object.keys(patchEditMap[item]).length == pathList[index]) {
                console.log(`第 ${index} 设备修改完成`);
                clearInterval(line);
                if (EditItem.length -1 == index) { //全部修改完成，刷新表格
                  patchEditMap = {};
                  refreshAPI('保存修改成功');
                  return;
                }
              }
            }
          }, 500)
        })(item, index);
      })
    });
  }

  // 构造升级页面需要的参数
  function formatUpgradeParams(info) {
    jGlobal.oneUpgrade.originAcVersion = "11.";
    jGlobal.oneUpgrade.onlyUpgradeAc = false;
    jGlobal.oneUpgrade.onlyUpgradeAp = false;
    jGlobal.oneUpgrade.upgradeAcFor11x = [];
    jGlobal.oneUpgrade.upgradeApFor11x = [];
    jGlobal.oneUpgrade.upgradeAcFor10x = [];
    jGlobal.oneUpgrade.upgradeApFor10x = [];

    jGlobal.oneUpgrade.upgradeAcFor11x.push({deviceName: info.deviceName, unzipDir: "cloud-11x-ac-bin"});

    var apType = [];
    for (var i = 0; i < info.apList.length; i++) {
      var apTypeTmp = {
        cnt: info.apList[i].count,
        hw_ver: info.apList[i].hardwareVersion,
        name: info.apList[i].deviceType
      };
      apType.push(apTypeTmp);
    }
    jGlobal.oneUpgrade.upgradeApFor11x.push({deviceName: info.deviceName, apType: apType, unzipDir: ["cloud-11x-ap-bin"]});

    jGlobal.oneUpgrade.upgradeAcFor10x.push({deviceName: info.deviceName, unzipDir: "cloud-10x-mid-bin"});

    jGlobal.oneUpgrade.upgradeApFor10x.push({deviceName: info.deviceName, apType: [], unzipDir: ["cloud-10x-mid-bin"]});

    console.log("待升级的11.xac参数： ", jGlobal.oneUpgrade.upgradeAcFor11x);
    console.log("待升级的11.xap参数： ", jGlobal.oneUpgrade.upgradeApFor11x);
    console.log("待升级的10.xac参数： ", jGlobal.oneUpgrade.upgradeAcFor10x);
    console.log("待升级的10.xap参数： ", jGlobal.oneUpgrade.upgradeApFor10x);
  }

  // 进入升级页面升级
  function gotoUpgradePage() {
    //进入升级页面
    var curElement = ".main_content",
      nextPageUrl = "./oneUpgrade/html/acUpgrading.html";
    global.enterPageCallback(curElement, nextPageUrl);
  }

  // 登录设备管理校验
  function loginDeviceCheck() {
    var loginRacHost = $("#racHost").val();
    var loginPsd = $("#racPsd").val();
    var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
    if (!reg.test(loginRacHost)) {
      $("#racHost").addClass('error');
      $("#racHost").siblings(".hint").show();
      setTimeout(function() {
        $("#racHost").siblings(".hint").hide();
      }, 1500);
      return false;
    }
    if (loginPsd != '') {
      if (!/^[a-zA-Z0-9@]+$/.test(loginPsd)) {
        $("#racPsd").addClass('error');
        $("#racPsd").siblings(".hint").show();
        setTimeout(function() {
          $("#racPsd").siblings(".hint").hide();
        }, 1500);
        return false;
      }
    }
    return true;
  }
  //修改功率API
  function editPowerAPI(params, mac, radioId) {
    console.log(radioId)
    patchEditMap[mac] = patchEditMap[mac]
      ? patchEditMap[mac]
      : {};
    if (radioId == 1) {
      patchEditMap[mac].apPowerOne = params;
    } else if (radioId == 2) {
      patchEditMap[mac].apPowerTwo = params;
    }

    // rac.setApPower(params,function (err,rest) {
    //   var powerType = params.radioId  == 1 ? '2.4G' : '5G';
    //   if(!err) {
    //     console.log(`设备 ${params.apName} 修改${powerType}功率为${params.power} 成功`,err,rest);
    //     refreshAPI();
    //   } else{
    //     alert(undefined,`设备 ${params.apName} 修改${powerType}功率为${params.power} 失败`);
    //     console.log(`设备 ${params.apName} 修改${powerType}功率为${params.power} 失败：`+ JSON.stringify(err));
    //   }
    // });
  }
  //获取AP设备列表API
  function getAPlistAPI(params, isOpenCode) {
    console.log("triggerCCC")
    console.log("设备列表");
    var params = {
      host: params.host,
      pwd: params.pwd
    }
    console.log(params, "params");
    rac.getApList(params, function(err, rest) {
      $("#loadShadow").hide(); //去除loading
      if (!err) {
        var result = typeof(rest) === 'object'
          ? rest
          : JSON.parse(rest);
        console.log(result, "LIST");
        $("#manageIP").text(params.host);
        gerUrlCode(params, isOpenCode); //第二个参数，表示都否打开二维码框
        goPageManage(rest);
        quickGoneFlow.setRacPwd(params.pwd)
      } else {
        setTimeout(function() { //（有bug（导致界面什么都点不了），感觉太快，导致boostrap模态层有点问题。使用延时发现不会）
          $("#loginAPmanage").modal('show'); //登录错误，重新显示登录弹窗
        }, 300);
        // $("#loginAPmanage").modal('show');//登录错误，重新显示登录弹窗
        $("#loginAPmanage").find(".errorHint").show();
        $("#racHost").val(err.host);
        $("#racPsd").val(err.password)
        console.log('登录失败：' + JSON.stringify(err));

      }
    })
  }
  //刷新ap列表
  function refreshAPI(msg, cb) {
    rac.getApList({}, function(err, rest) {
      $("#loadShadow").hide();
      if (!err) {
        console.log('the AP list', err, rest);
        var result = typeof(rest) === 'object'
          ? rest
          : JSON.parse(rest);
        initDeviceTable(result.apList);
        // $("#loadShadow").hide();
        if (msg)
          alert(undefined, msg);
        cb && cb(result.onlineAp);
      } else {
        alert(undefined, '更新AP列表失败');
      }
    });
  }
  //校验用户输入
  function check() {
    var wirelessName = $("#wirelessName").val();
    var wirelessPsd = $("#wirelessPsd").val();
    var deviceLoginIp = $("#deviceLoginIp").val();
    var ewebPsd = $("#ewebPsd").val();
    if (wirelessName == '') {
      alert(undefined, '请填写无线网络名称');
      return false;
    }
    if (wirelessPsd != '') {
      if (!/^[a-zA-Z0-9@]{8,}$/.test(wirelessPsd)) {
        // alert(undefined, '无线网络密码格式错误，请输入除中文外的任意字符，且密码长度必须大于或等于8位');
        $("#wirelessPsd").parent('.userinput').addClass('error');
        $("#wirelessPsd").next(".hint").show();
        // $("#cliResult").find(".commanding").remove();
        return false;
      }
    }
    if (deviceLoginIp != '') {
      var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
      if (!reg.test(deviceLoginIp)) {
        alert(undefined, 'IP地址格式不对');
        return false;
      }
    }
    if (ewebPsd != '') {
      if (!/^[a-zA-Z0-9@]+$/.test(ewebPsd)) {
        alert(undefined, 'RAC登录密码 仅限输入字母，数字和@符号');
        return false;
      }
      return true;
    }
    return true;
  }

  function error() {
    // $("#cliResult").find(".commanding").remove();
    if ($("#cliResult").find(".commandResult").length == 0) {
      $("#cliResult").prepend('<div class="commandResult"><i class="icon-fail"></i><span>部署失败</span></div>');
    }
  }

  function success() {
    // $("#cliResult").find(".commanding").remove();
    if ($("#cliResult").find(".commandResult").length == 0) {
      $("#cliResult").prepend('<div class="commandResult"><i class="icon-success"></i><span>部署成功</span></div>');
    }
  }

  // 初始化设备管理页面（部署成功跳转到设备管理）

  function initDeviceTable(data) {
    $('#apDeviceTable').bootstrapTable('load', data);
    var client_h = document.documentElement.clientHeight;
    var head_h = $(".main_menu").height();
    var body_h = client_h - head_h;
    $('#apDeviceTable').bootstrapTable('resetView', {
      height: body_h - 55 - 65
    });
  }
  //格式化在线状态列
  function statusFormatter(value, row, index) {
    if (value == 'ON') {
      return '在线';
    } else {
      return '离线';
    }
  }
  //格式化AP名称列
  function deviceNameFormatter(value, row, index) {
    return '<div class="apNameDOM"><input type="text" class=" apNameInput" value="' + value + '" data-oldvalue="' + value + '"/><div class="hint">请输入字符，字母，下划线或@</div></div>'
  }

  //格式化2.4G信道/功率列
  function radio1Formatter(value, row, index) {
    var radio1Info = value.filter(function(item) {
      return item.id == 1;
    });
    if (radio1Info.length == 0) {
      return '--';
    }
    var radio1DOM = '';
    var isOpen = false; //标识是否开启2.4G信号
    switch (radio1Info[0].status) {
      case 'E':
        radio1DOM += '<div class="rateFormater" data-id="1"><label class="iosCheck"><input type="checkbox" class="openRadio selfCheckbox" checked="checked"/><i></i></label>';
        isOpen = true;
        break;
      case 'D':
        radio1DOM += '<div class="rateFormater" data-id="1"><label class="iosCheck"><input type="checkbox" class="openRadio selfCheckbox"/><i></i></label>';
        isOpen = false;
        break;
      case 'N':
        return '不支持';
      default:
    }
    if (isOpen) {
      radio1DOM += '信道：<select class="form-control selfSelect channel" style="margin-right:5px">';
    } else {
      radio1DOM += '信道：<select disabled class="form-control selfSelect channel" style="margin-right:5px">';
    }
    for (var i = 1; i <= 13; i++) {
      if (i == radio1Info[0].channel) {
        radio1DOM += '<option value="' + i + '"selected="selected">' + i + '</option>';
      } else {
        radio1DOM += '<option value="' + i + '">' + i + '</option>';
      }
    }
    if (isOpen) {
      radio1DOM += '</select>功率：<div class="custom"><select class="form-control selfSelect power" style="width:70px">';
    } else {
      radio1DOM += '</select>功率：<div class="custom"><select disabled class="form-control selfSelect power" style="width:70px">';
    }
    var customPowe = undefined; //自定义功率值
    if ([30, 80, 100].indexOf(+ radio1Info[0].power) == -1) {
      customPowe = +radio1Info[0].power;
    }
    var rate1Type = [
      {
        name: '节能',
        value: 30,
        title: '节能---功率值为30'
      }, {
        name: '标准',
        value: 80,
        title: '标准---功率值为80'
      }, {
        name: '增强',
        value: 100,
        title: '增强---功率值为100'
      }, {
        name: '自定义',
        value: customPowe
      }
    ]
    rate1Type.forEach(function(item) { //构建2.4G功率下拉选项
      var title = item.title
        ? item.title
        : '';
      if (item.value == radio1Info[0].power) {
        radio1DOM += '<option value="' + item.value + '" selected="selected" title="' + title + '">' + item.name + '</option>'
      } else {
        radio1DOM += '<option value="' + item.value + '" title="' + title + '">' + item.name + '</option>'
      }
    })
    if ([30, 80, 100].indexOf(+ radio1Info[0].power) == -1) { //说明是自定义的功率(输入框显示自定义的值)
      if (isOpen) {
        radio1DOM += '</select><input class="form-control customPower" placeholder="1~100" value="' + radio1Info[0].power + '"></div></div>';
      } else {
        radio1DOM += '</select><input class="form-control customPower" placeholder="1~100" value="' + radio1Info[0].power + '" disabled></div></div>';
      }
    } else {
      radio1DOM += '</select></div></div>';
    }
    return radio1DOM;
  }
  //格式化5G信道/功率列
  function radio2Formatter(value, row, index) {
    var radio2Info = value.filter(function(item) {
      return item.id == 2;
    });
    if (radio2Info.length == 0) {
      return '--';
    }
    var radio2DOM = '';
    var isOpen = false; //标识是否开启2.4G信号
    switch (radio2Info[0].status) {
      case 'E':
        radio2DOM += '<div class="rateFormater" data-id="2"><label class="iosCheck"><input type="checkbox" class="openRadio selfCheckbox" checked="checked"/><i></i></label>';
        isOpen = true;
        break;
      case 'D':
        radio2DOM += '<div class="rateFormater" data-id="2"><label class="iosCheck"><input type="checkbox" class="openRadio selfCheckbox"/><i></i></label>';
        isOpen = false;
        break;
      case 'N':
        return '不支持';
      default:
    }
    if (isOpen) {
      radio2DOM += '信道：<select class="form-control selfSelect channel" style="margin-right:5px;width:70px;">';
    } else {
      radio2DOM += '信道：<select disabled class="form-control selfSelect channel" style="margin-right:5px;width:70px;">';
    }
    var radio2Type = [149, 153, 157, 161, 165];
    radio2Type.forEach(function(item) { //构建5G功率下拉选项
      if (item == radio2Info[0].channel) {
        radio2DOM += '<option value="' + item + '"selected="selected">' + item + '</option>';
      } else {
        radio2DOM += '<option value="' + item + '">' + item + '</option>';
      }
    })
    if (isOpen) {
      radio2DOM += '</select>功率：<div class="custom"><select class="form-control selfSelect power" style="width:70px">';
    } else {
      radio2DOM += '</select>功率：<div class="custom"><select disabled class="form-control selfSelect power" style="width:70px">';
    }
    var rate2Type = [
      {
        name: '节能',
        value: 30,
        title: '节能---功率值为30'
      }, {
        name: '标准',
        value: 80,
        title: '标准---功率值为80'
      }, {
        name: '增强',
        value: 100,
        title: '增强---功率值为100'
      }, {
        name: '自定义'
      }
    ]
    rate2Type.forEach(function(item) {
      var title = item.title
        ? item.title
        : '';
      if (item.value == radio2Info[0].power) {
        radio2DOM += '<option value="' + item.value + '" selected="selected" title="' + title + '">' + item.name + '</option>'
      } else {
        radio2DOM += '<option value="' + item.value + '" title="' + title + '">' + item.name + '</option>'
      }
    })
    if ([30, 80, 100].indexOf(+ radio2Info[0].power) == -1) { //说明是自定义的功率(输入框显示自定义的值)
      if (isOpen) {
        radio2DOM += '</select><input class="form-control customPower" placeholder="1~100" value="' + radio2Info[0].power + '"></div></div>';
      } else {
        radio2DOM += '</select><input class="form-control customPower" placeholder="1~100" value="' + radio2Info[0].power + '" disabled></div></div>';
      }
    } else {
      radio2DOM += '</select></div></div>';
    }

    return radio2DOM;
  }
  function checkFormatter(value, row, index) {
    if (row.status == 'OFF') {
      return {disabled: true}
    }
  }

  function formatterMac(value, row, index) {
    return '<div class="mac">' + value + '</div>'
  }
  //获取二维码url
  function gerUrlCode(params, isOpenCode) {
    console.log('二维码');
    params.usingTime = quickGoneFlow.getDeployInterval();
    rac.getDeviceQrcode(params, function(err, rest) {
      console.log('the qrcode url:', rest);
      if (rest && rest != '') {
        $("#deviceManageContent").find(".codeBtn").show(); // 存在url 显示二维码
        $("#codeDOM").html(''); // 清空二维码容器，防止出现多个二维码
        $("#codeDOM").qrcode({
          render: "table", //table方式
          width: 200, //宽度
          height: 200, //高度
          text: rest //任意内容
        });
        if (isOpenCode) { //判断进入RAC管理页面是否就开打二维码框
          $("#deviceManageCode").show();
        }
      }
    });
  }
  //跳转到设备管理
  function goPageManage(result) {
    $('#apDeviceTable').bootstrapTable({data: []})
    console.log(result, "APlist");
    $("#quickGoneLiveContent").hide();
    $("#deviceManageContent").show();

    $(".onlineAP").text(result.onlineAp);
    $(".offlineAP").text(result.offlineAp);
    $("#deviceSnNum").text(result.acSn);
    // $(".deviceTableDOM").find(".search input").prop("placeholder",'搜索：AP名称、IP地址、MAC地址');
    console.error(result);
    initDeviceTable(result.apList);
  }
  function initGlobalEvent() {
    global.exitPageCallback.exitFun = function() {
      console.log("清除绘画")
      clearInterval(keepHandle);
      return true;
    }
  }

  exports.init = init;
})
