Blame view

topages/topagesTmp.js 1.54 KB
726eb6d7   Andy   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  /**
   * Created by mac on 18/7/24.
   */
  function Router(){
      this.routes = {};
      this.curUrl = '';
  
      this.route = function(path, callback){
          this.routes[path] = callback || function(){};
      };
  
      this.refresh = function(){
          this.curUrl = location.hash.slice(1) || '/index';
          console.log(this.curUrl)
          this.routes[this.curUrl]();
      };
  
      this.init = function(){
          window.addEventListener('load', this.refresh.bind(this), false);
          window.addEventListener('hashchange', this.refresh.bind(this), false);
      }
  }
  var R = new Router();
  R.init();
  var res = $('#main-con');
  //工时填报
  R.route('/workquery', function() {
      $("#pageCssLink").attr("href",'../topages/workquery/workquery.css');
      res.load('../topages/workquery/workquery.html');
      $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
      $('#button-chargingrule').addClass('ITD-topbar-clickactive');
  });
  //员工管理
  R.route('/staffmanage', function() {
      $("#pageCssLink").attr("href",'../topages/staffmanage/staffmanage.css');
      res.load('../topages/staffmanage/staffmanage.html');
      $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
      $('#button-chargingrule').addClass('ITD-topbar-clickactive');
  });
  //工时统计
  R.route('/hourscount', function() {
      $("#pageCssLink").attr("href",'../topages/hourscount/hourscount.css');
      res.load('../topages/hourscount/hourscount.html');
      $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
      $('#button-chargingrule').addClass('ITD-topbar-clickactive');
  });