index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. new Vue({
  2. el: '#app',
  3. data: function () {
  4. return {
  5. // iframeSrc: "../../new-quailty-manager/html/new-quailty-manager.html",
  6. loading: false,
  7. historyArr:[{url:'../html/home.html',text:'首页'},], //历史记录
  8. activeIndex:'0' , //当前历史记录选中的下标
  9. leftTabActive:'2-0',//左边菜单中当前高亮下标
  10. isCollapse: false, //导航栏是否隐藏
  11. screenWidth: document.body.clientWidth,//屏幕宽度
  12. }
  13. },
  14. computed: {
  15. navWidth:function() { //左边菜单的的宽度
  16. return this.isCollapse ? '51px' : '200px'
  17. },
  18. titleTip:function() {
  19. return this.isCollapse ? '显示导航栏' : '隐藏导航栏'
  20. },
  21. },
  22. mounted:function() {
  23. this.resize()
  24. this.bidnEvent()
  25. },
  26. methods: {
  27. bidnEvent:function(){ //供子页面调用的事件 (子页面是iframe)
  28. var vm =this;
  29. GlobalEventBus.$on("setLoading", function(arg) { //控制整个界面加载
  30. if(arg && arg.loading){
  31. vm.loading = true
  32. }
  33. else{
  34. vm.loading = false
  35. }
  36. });
  37. GlobalEventBus.$on("setIframeUrl", function(arg) { //新打开窗口并且记录历史记录
  38. vm.setHistory(arg.history)
  39. });
  40. GlobalEventBus.$on("setleftTabUrl", function(arg) { //打开左边菜单中的页面 可直接传对应
  41. vm.handleSelect(arg.key)
  42. });
  43. },
  44. resize:function() { //监听页面改变大小
  45. const that = this
  46. this.isCollapse = this.screenWidth >= 786 ? false : true;
  47. window.onresize = function() {
  48. return (function(){
  49. window.screenWidth = document.body.clientWidth;
  50. that.screenWidth = window.screenWidth;
  51. })()
  52. }
  53. },
  54. handleSelect: function (key) {
  55. console.log(key)
  56. var vm = this;
  57. var activeObj =null;
  58. switch (key) {
  59. case '1':
  60. this.isCollapse = !this.isCollapse;
  61. break;
  62. case '2-0':
  63. activeObj = {url:'../html/search.html',text:'全文病历检索'};
  64. break;
  65. case '2-1':
  66. window.open('../../bigData/html/medical.html')
  67. break;
  68. case '2-2':
  69. window.open('../../bigData/html/medical.html')
  70. break;
  71. case '2-3':
  72. window.open('../../bigData/html/home.html')
  73. break;
  74. case '2-4':
  75. activeObj = {url:'../html/yibiaofenxi.html',text:'医保控费分析'};
  76. break;
  77. }
  78. if(!activeObj)return
  79. this.leftTabActive=key
  80. activeObj.fromLeft=true
  81. // key=key.toString()
  82. // this.isActive = key.substring(0, 1)
  83. // var childrenIndex= key.split('-')[1]-1;
  84. // var activeObj = this.tabList[(this.isActive-1)].children[childrenIndex];
  85. vm.setHistory(activeObj)
  86. },
  87. deleteHistory:function(index){
  88. this.historyArr.splice(index,1);
  89. if(!this.historyArr[this.activeIndex] && this.activeIndex-1>=0){
  90. this.activeIndex-=1
  91. }
  92. },
  93. setHistory:function(obj){
  94. var vm = this;
  95. var exist = false;
  96. var index = null;
  97. // if(typeof(obj)=='string'){ //如果左边菜单换成数组的话 现在暂时没空
  98. // vm.tabList.forEach(function(v){
  99. // v.children.forEach(function(value){
  100. // if(typeof(obj)=='string' && obj.indexOf(value.url) != -1){
  101. // var obj1 =newObj(value);
  102. // obj1.url=obj;
  103. // obj=obj1;
  104. // }
  105. // })
  106. // })
  107. // }
  108. vm.historyArr= vm.historyArr.map(function(v,i){ //检测要跳转的url是否在历史记录中
  109. if(obj.url.indexOf(v.url.split('?')[0]) != -1 ){
  110. switch (obj.url){ //已经存在并且在左边的菜单的话则需要高亮左边菜单
  111. case "../html/home.html":obj.index='2-0';break;
  112. case "../html/search.html":obj.index='2-0';break;
  113. case "../html/yibiaofenxi.html":obj.index='2-4';break;
  114. }
  115. exist=true;
  116. index = i;
  117. if(v.url!=obj.url && !obj.fromLeft) v.url=obj.url //如果参数不同则重新赋值 按左边的则不需要比较
  118. }
  119. return v
  120. })
  121. if(!exist){ //不存在则添加进历史记录
  122. vm.historyArr.push(obj);
  123. this.activeIndex =vm.historyArr.length-1
  124. }
  125. else{ //存在则直接跳转
  126. this.activeIndex =index
  127. }
  128. if(obj.index)
  129. this.leftTabActive=obj.index //控制左边菜单选中
  130. },
  131. controlRouter:function(key) {
  132. switch (key) {
  133. case '1':
  134. this.closeAllHistory();
  135. break;
  136. case '2':
  137. this.closeAllHistory(true);
  138. break;
  139. }
  140. },
  141. closeAllHistory:function(is) { //不传参则全部关闭 传参则关闭除了自己之外的
  142. var that =this;
  143. if (is && this.activeIndex !=0) {
  144. this.historyArr = this.historyArr.filter(function(v,i) {
  145. return i == that.activeIndex || i==0
  146. })
  147. this.activeIndex=1
  148. }
  149. else{
  150. this.historyArr = this.historyArr.filter(function(v,i) {
  151. return i ==0
  152. })
  153. this.activeIndex=0
  154. }
  155. },
  156. },
  157. watch: {
  158. screenWidth:function(value) {
  159. this.isCollapse = value >= 786 ? false : true;
  160. },
  161. }
  162. })