Bottom.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="bottom" style="z-index: 1000;">
  3. <div style="display: flex; justify-content: left; flex-flow: row;height: 100%;">
  4. <div :class="item.active?'btn active':'btn'" v-for="item in navlist" :style="{backgroundImage: item.active?`url(${btnFrontBg})`:''}" @click="loadNavModel(item);">
  5. <img :src="item.active?item.img1:item.img" :key="item.code" :t='item.code' :class="item.active?'active':''">
  6. <div>{{ item.name }}</div>
  7. </div>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import { ref,onMounted,watch } from 'vue';
  13. import api from "@/api/system";
  14. export default {
  15. props:{
  16. facModelLoadState:{
  17. type:Boolean,
  18. required: true
  19. },
  20. userRole:{
  21. type:String
  22. }
  23. },
  24. setup(props,{emit}) {
  25. let clickTime = 0;
  26. let ClickTimeLong = 2;//导航间隔时长
  27. let clickTimer = null;
  28. const showIndexData = ref('');
  29. let dataTimer = null;
  30. const btnFrontBg = require('@/assets/image/nav_btn_front.png');
  31. let navlist=ref([
  32. {"code":"FAC","name":"全厂","active":true,"img":require('@/assets/image/nav_ico_fac1.png'),"img1":require('@/assets/image/nav_ico_fac2.png')},
  33. {"code":"IN02","name":"经编","active":false,"img":require('@/assets/image/nav_ico_in021.png'),"img1":require('@/assets/image/nav_ico_in022.png')},
  34. //{"code":"IN04","name":"前整","active":false,"img":require('@/assets/image/nav_ico_in041.png'),"img1":require('@/assets/image/nav_ico_in042.png')},
  35. {"code":"IN03","name":"染整","active":false,"img":require('@/assets/image/nav_ico_in031.png'),"img1":require('@/assets/image/nav_ico_in032.png')},
  36. //{"code":"IN05","name":"后整","active":false,"img":require('@/assets/image/nav_ico_in051.png'),"img1":require('@/assets/image/nav_ico_in052.png')},
  37. ]);
  38. watch(() => props.facModelLoadState, newVal=> {
  39. if(newVal){
  40. //模型加载完成
  41. console.log('全厂模型加载完成')
  42. if(window.CurrentTargetType==null||window.CurrentTargetType=='') window.CurrentTargetType='FAC';
  43. for(let i=0;i<navlist.value.length;i++){
  44. if(navlist.value[i].code==window.CurrentTargetType){
  45. navlist.value[i].active=true;
  46. }else navlist.value[i].active=false;
  47. }
  48. clickTimeCal();
  49. }
  50. },{deep:true,immediate:true})
  51. watch(() => props.userRole, newVal=> {
  52. showIndexData.value = newVal;
  53. },{deep:true,immediate:true})
  54. let DataFull={
  55. GetProductionLneInfo:function(){
  56. if(window.CurrentTargetType=='IN02'||window.CurrentTargetType=='FAC'){
  57. clearTimeout(dataTimer);
  58. return;
  59. }
  60. dataTimer = setTimeout(() => {
  61. DataFull.GetProductionLneInfo();
  62. }, 2*60*1000);
  63. api.GetProductionLneInfo().then(res=>{
  64. if(res==null || res.code!=0){
  65. return;
  66. }
  67. window.IN345LINE = res.data;
  68. })
  69. }
  70. }
  71. //const emit = defineEmits(['call']);
  72. function clickTimeCal(){
  73. clickTime = 0;
  74. window.clearInterval(clickTimer);
  75. clickTimer = setInterval(function(){
  76. clickTime++; //切换间隔时长计数器
  77. if(clickTime>10000) clickTime = ClickTimeLong;//达到一定时长时后,初始化为最大间隔时长
  78. },1000)
  79. }
  80. function loadNavModel(item){
  81. if(clickTime<ClickTimeLong){
  82. //切换间隔小于4秒时,不响应
  83. return;
  84. }
  85. for(let i=0;i<navlist.value.length;i++){
  86. if(navlist.value[i].code==item.code){
  87. navlist.value[i].active=true;
  88. }else navlist.value[i].active=false;
  89. }
  90. window.CurrentTargetType=item.code;
  91. if(window.CurrentTargetType=='IN03' ||window.CurrentTargetType=='IN04' || window.CurrentTargetType=='IN05'){
  92. clearTimeout(dataTimer);
  93. DataFull.GetProductionLneInfo();
  94. }
  95. emit('loadNavModel',item);
  96. clickTimeCal();
  97. }
  98. onMounted(()=>{
  99. if(window.CurrentTargetType==null || window.CurrentTargetType=='') window.CurrentTargetType='FAC';
  100. })
  101. return{
  102. navlist,
  103. btnFrontBg,
  104. loadNavModel
  105. }
  106. }
  107. }
  108. </script>