Blame view

topages/topagesTmp.js 2.41 KB
726eb6d7   Andy   add
1
2
3
  /**
   * Created by mac on 18/7/24.
   */
b11cbb37   liuqimichale   登录
4
  
d5f95b92   liuqimichale   登录
5
6
  var id = fn.getRoleId()
  if(id == '3'){
b11cbb37   liuqimichale   登录
7
8
9
10
      $('#nav-bar-container').append(' <li class="navbar-active" id="button-workfill"><a href="#/workfill">工时填报</a></li> <li id="button-workquery"><a href="#/workquery" >工时查询</a></li> <li id="button-hourscount"><a href="#/hourscount" >工时统计</a></li> <li id="button-staffmanage"><a href="#/staffmanage" >员工管理</a></li>')
  }else{
      $('#nav-bar-container').append('<li class="navbar-active" id="button-workfill"><a href="#/workfill">工时填报</a></li> <li id="button-workquery"><a href="#/workquery" >工时查询</a></li> <li id="button-hourscount"><a href="#/hourscount" >工时统计</a></li>')
  }
726eb6d7   Andy   add
11
12
13
14
15
16
17
18
19
  function Router(){
      this.routes = {};
      this.curUrl = '';
  
      this.route = function(path, callback){
          this.routes[path] = callback || function(){};
      };
  
      this.refresh = function(){
eed1287c   liuqimichale   登录
20
          this.curUrl = location.hash.slice(1) || '/workfill';
726eb6d7   Andy   add
21
22
23
24
25
26
27
28
29
30
31
32
          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');
d34df23d   liuqimichale   头部公用
33
34
35
  //工时查询
  
  R.route('/workfill', function() {
7ad8be37   Andy   new route
36
37
      $("#pageCssLink").attr("href",'topages/workfill/workfill.css?a=1');
      res.load('topages/workfill/workfill.html');
d34df23d   liuqimichale   头部公用
38
39
40
41
  
      $('.nav-bar-container li').removeClass('navbar-active');
      $('#button-workfill').addClass('navbar-active');
  });
726eb6d7   Andy   add
42
43
  //工时填报
  R.route('/workquery', function() {
7ad8be37   Andy   new route
44
45
      $("#pageCssLink").attr("href",'topages/workquery/workquery.css?a=1');
      res.load('topages/workquery/workquery.html');
d34df23d   liuqimichale   头部公用
46
47
      $('.nav-bar-container li').removeClass('navbar-active');
      $('#button-workquery').addClass('navbar-active');
726eb6d7   Andy   add
48
49
50
  });
  //员工管理
  R.route('/staffmanage', function() {
7ad8be37   Andy   new route
51
52
      $("#pageCssLink").attr("href",'topages/staffmanage/staffmanage.css');
      res.load('topages/staffmanage/staffmanage.html');
d34df23d   liuqimichale   头部公用
53
54
      $('.nav-bar-container li').removeClass('navbar-active');
      $('#button-staffmanage').addClass('navbar-active');
726eb6d7   Andy   add
55
56
57
  });
  //工时统计
  R.route('/hourscount', function() {
7ad8be37   Andy   new route
58
59
      $("#pageCssLink").attr("href",'topages/hourscount/hourscount.css');
      res.load('topages/hourscount/hourscount.html');
d34df23d   liuqimichale   头部公用
60
61
      $('.nav-bar-container li').removeClass('navbar-active');
      $('#button-hourscount').addClass('navbar-active');
726eb6d7   Andy   add
62
  });