
layui.use(['table', 'jquery'], function () {
  var table = layui.table;
  var form = layui.form,
    layer = parent.layer === undefined ? layui.layer : parent.layer,
    $ = layui.jquery;
  //监听表格复选框选择
  table.on('checkbox(demo)', function (obj) {
    console.log(obj);
  });
  //监听工具条
  table.on('tool(demo)', function (obj) {
    var data = obj.data;
    if (obj.event === 'view') {
      layer.open({
        type: 2,
        anim: 4,
        scrollbar: false,
        content: '/WorkOrder/ViewMyOrder/?orderKeyId=' + data.F_WORKORDERID,
        area: ['90%', '90%'],
        id: 'ViewMyOrder',
        title: '服务监督热线系统业务工单'

      });
    }
  });
  $ = layui.$, active = {
    //查询按钮
    reload: function () {
      //执行重载
      table.reload('recordtable', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        , where: {
          dateParty: $("#test10").val()
          , NowDateTime: new Date()
          , CallHour: $("#CallHour").val()
          , linkman: $("#linkman").val()
          , calltype: $("#calltype").val()
          , ywtype: $("#ywtype").val()
        }
      });
    }
  };

  $('.searchfilter .layui-btn').on('click', function () {
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
  function saveAs (blob, filename) {
    var type = blob.type;
    var force_saveable_type = 'application/octet-stream';
    if (type && type !== force_saveable_type) { // 强制下载，而非在浏览器中打开
      var slice = blob.slice || blob.webkitSlice || blob.mozSlice;
      blob = slice.call(blob, 0, blob.size, force_saveable_type);
    }

    var url = URL.createObjectURL(blob);
    var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
    save_link.href = url;
    save_link.download = filename;

    var theevent = document.createEvent('MouseEvents');
    theevent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    save_link.dispatchEvent(theevent);
    URL.revokeObjectURL(url);
  }
  //回车执行
  document.onkeydown = function (event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if (e && e.keyCode === 13) {
      //执行重载
      table.reload('recordtable', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        , where: {
          types: 0,
          dateParty: $("#test10").val()
          , NowDateTime: new Date()
          , CallHour: $("#CallHour").val()
          , linkman: $("#linkman").val()
        }
      });
    }
  };
  function Init () {
    //执行重载
    table.reload('recordtable', {
      page: {
        curr: 1 //重新从第 1 页开始
      }
      , where: {
        dateParty: $("#test10").val()
        , NowDateTime: new Date()
        , CallHour: $("#CallHour").val()
        , linkman: $("#linkman").val()
        , calltype: $("#calltype").val()
        , ywtype: $("#ywtype").val()
      }
    });
  }
  Init();
});