TabPage.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="tab-wrap">
  3. <div class="tab"
  4. v-if="allMoudles.data&&allMoudles.data.length>0 && moduleShow">
  5. <p v-for="(it,index) in allMoudles.data"
  6. :style="{'width':1/allMoudles.data.length*100+'%'}"
  7. :key="it.id"
  8. @click="clickTab(it,index)">
  9. <span :class="{current:finish[it.type]}" v-if="type[it.type]==1">
  10. <i class="order">{{index+1}}</i>
  11. {{it.name}}
  12. <i class="line" v-if="currentTab[it.type]"></i>
  13. </span>
  14. </p>
  15. </div>
  16. <div class="content">
  17. <router-view></router-view>
  18. </div>
  19. <!-- 详情页 -->
  20. <div class="detail" v-if="detailShow">
  21. <DetailBox :flags="allMoudles.order"/>
  22. </div>
  23. </div>
  24. </template>
  25. <script type="text/javascript">
  26. import Symptom from './Symptom.vue';
  27. import AddContent from './AddContent.vue';
  28. import DiagTreat from './DiagTreat.vue';
  29. import Others from './Others.vue';
  30. import Preview from './Preview.vue';
  31. import {moduleConfig,moduleCP,getRouteName} from '../utils/tools.js';
  32. import DetailBox from './DetailBox.vue';
  33. import {mapState} from 'vuex';
  34. export default {
  35. name: 'TabPage',
  36. data() {
  37. return {
  38. moduleShow:true,
  39. number:0,
  40. moduleCP:moduleCP,
  41. routerName:'',
  42. allMoudles:{}
  43. }
  44. },
  45. computed:{
  46. ...mapState({
  47. finish: state => state.finish,
  48. currentTab: state => state.currentTab,
  49. detailShow: state => state.detailShow,
  50. symChoose: state => state.symptom.choose,
  51. type: state => state.tabType,
  52. config: state => state.sysConfig,
  53. tmpAllMoudles: state => state.allMoudles,
  54. }),
  55. },
  56. created() {
  57. this.routerName = this.$route.name
  58. if (this.config.length == 0) {//登录进去返回到列表页,扫码返回到开始页
  59. let scan = localStorage.getItem('scan');
  60. let params = JSON.parse(localStorage.getItem('infoParam'));
  61. let param = JSON.parse(localStorage.getItem('loginParam'));
  62. let data = JSON.parse(localStorage.getItem('loginData'));
  63. if(!scan){
  64. if(data.length>1){
  65. this.$router.replace({path:'/department'});
  66. }else{
  67. this.$router.replace({path:'/home',query:param});
  68. }
  69. }else{
  70. this.$router.replace({path:'/home',query:Object.assign({}, params,{scan:true})});
  71. }
  72. }
  73. },
  74. mounted(){
  75. let tmpModule = moduleConfig(this.config,this.tmpAllMoudles);
  76. this.allMoudles = tmpModule;
  77. this.$store.commit('setActiveModule', tmpModule);
  78. },
  79. methods: {
  80. // 症状情况有内容后才可以点击tab栏
  81. clickTab(item,index){
  82. if(this.symChoose.length>0){
  83. this.number = index;
  84. this.flag = item.type;
  85. // this.finish[parseInt(item.type)] = true;
  86. this.$store.commit('setFinish',item.type)
  87. let routeName = getRouteName(item.type)
  88. this.$router.push({
  89. path:routeName
  90. })
  91. }
  92. },
  93. },
  94. components: {
  95. Symptom,
  96. DiagTreat,
  97. Others,
  98. AddContent,
  99. Preview,
  100. DetailBox
  101. }
  102. }
  103. </script>
  104. <style lang="less" scoped>
  105. @import '../less/base.less';
  106. .tab-wrap {
  107. width: 100%;
  108. height: 100%;
  109. padding-bottom: 0.88rem;
  110. padding-top: 0.82rem;
  111. background-color: #fff;
  112. .tab {
  113. position: fixed;
  114. top: 0;
  115. left: 0;
  116. width: 100%;
  117. background: #fff;
  118. z-index: 101;
  119. height: 0.82rem;
  120. line-height: 0.82rem;
  121. border-bottom: 1px solid #ededed;
  122. box-sizing: border-box;
  123. padding-top: 0.16rem;
  124. p {
  125. display: inline-block;
  126. padding: 0 0.2rem;
  127. box-sizing: border-box;
  128. }
  129. span {
  130. font-size: 0.28rem;
  131. display: inline-block;
  132. vertical-align: top;
  133. width: 100%;
  134. height: 0.5rem;
  135. line-height: 0.5rem;
  136. color: #colors[text];
  137. text-align: center;
  138. position: relative;
  139. }
  140. .line {
  141. width: .6rem;
  142. height: .04rem;
  143. background-color: #colors[btn];
  144. display: inline-block;
  145. position: relative;
  146. bottom: .2rem;
  147. }
  148. .current {
  149. color: #colors[btn];
  150. }
  151. }
  152. .content {
  153. font-size: 0.3rem;
  154. }
  155. }
  156. </style>