index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="devic-box">
  3. <!-- 建议放在外层 -->
  4. <u-navbar :bgStatusImage="backPic0" :bgImage="backPic" title="设备监测" @leftClick="devicemenuShow"
  5. :safeAreaInsetTop="true" :fixed="true" height="50px" bgColor="transparent" titleStyle="fw600 fs-18"
  6. leftIconColor="#303133">
  7. <view class="u-nav-slot" slot="left">
  8. <u-icon name="arrow-left" size="20"> </u-icon>
  9. </view>
  10. </u-navbar>
  11. <view class="devic-box-content">
  12. <view v-if="menushow" class="menupage">
  13. <DeviceMenu @menuClick="menuClick"></DeviceMenu>
  14. </view>
  15. <!-- <u-tabs v-if="!menushow" class="devic-box-tab" :current="PageCur" :list="tabList" @click="NavChange"></u-tabs> -->
  16. <u-tabs v-if="!menushow" class="devic-box-tab" :current="pageCurNew" :list="tabListNew"
  17. @click="NavChange"></u-tabs>
  18. <view class="">
  19. <!-- <home cur="home" :showColum="showColum" v-if="pageCurNew == '0' && !menushow" :key="0" :deviceType="deviceType"
  20. @setMenushow="setMenushow"></home> -->
  21. <home cur="home" :showColum="showColum" v-if="!menushow" :key="0" :deviceType="deviceType"
  22. @setMenushow="setMenushow"></home>
  23. <!-- <history :key="1" cur="history" :showColum="showColum" :deviceType="deviceType"
  24. v-if="PageCur == '1' && !menushow" @setMenushow="setMenushow"></history>
  25. <operation :key="2" :showColum="showColum" :deviceType="deviceType" cur="operation"
  26. v-if="PageCur == '2' && !menushow" @setMenushow="setMenushow"></operation> -->
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import api from "@/api/api";
  33. import DeviceMenu from "./devicemenu/devicemenu.vue";
  34. export default {
  35. components: {
  36. DeviceMenu,
  37. },
  38. data() {
  39. return {
  40. // backPic0: "url(/static/topnavbar0.png)",
  41. // backPic: "url(../../static/topnavbar.png)",
  42. backPic0: "",
  43. backPic: "",
  44. // PageCur: "0",
  45. pageCurNew: '',
  46. showColum: {},
  47. menushow: true,
  48. deviceType: "",
  49. // tabList: [
  50. // {
  51. // name: "设备监测",
  52. // },
  53. // {
  54. // name: "历史数据",
  55. // },
  56. // {
  57. // name: "操作记录",
  58. // },
  59. // ],
  60. tabListNew: [],
  61. };
  62. },
  63. created() {
  64. this.getShowColum();
  65. },
  66. onLoad: function () {
  67. // this.PageCur = "0";
  68. },
  69. methods: {
  70. NavChange: function (item) {
  71. console.log("item", item);
  72. // this.PageCur = item.index;
  73. this.deviceType = item.id;
  74. this.menushow = false;
  75. },
  76. devicemenuShow(e) {
  77. this.menushow = !this.menushow;
  78. },
  79. menuClick(params) {
  80. debugger;
  81. let data = params.menu.map((item) => item.children).flatMap((i) => i).map((v, index) => {
  82. return {
  83. name: v.itemText,
  84. id: v.itemValue,
  85. index: index,
  86. };
  87. });
  88. this.deviceType = params.id;
  89. this.tabListNew = data;
  90. this.pageCurNew = this.tabListNew.find(item => item.id == params.id).index;
  91. console.log("data", data);
  92. this.menushow = false;
  93. },
  94. getShowColum() {
  95. new Promise((resolve, reject) => {
  96. api
  97. .getShowColum({})
  98. .then((response) => {
  99. if (response.data.code == 200) {
  100. var showlist = response.data.result;
  101. this.$store.commit("SET_SHOWCOLUM", showlist);
  102. this.showColum = showlist;
  103. console.log("showColum", this.showColum);
  104. } else {
  105. resolve(response);
  106. }
  107. })
  108. .catch((error) => {
  109. console.log("catch===>response", response);
  110. reject(error);
  111. });
  112. });
  113. },
  114. setMenushow(params) {
  115. if (params) {
  116. this.menushow = params.menushow;
  117. }
  118. },
  119. },
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. // .devic-box {
  124. // // background: #f4f7fd;
  125. // }
  126. .devic-box-content {
  127. height: calc(100vh - 101px);
  128. margin-top: 50px;
  129. overflow-y: auto;
  130. // background: #f4f7fd;
  131. }
  132. .menupage {
  133. min-height: 100%;
  134. // background: #f4f7fd;
  135. }
  136. ::v-deep .u-tabs__wrapper {
  137. margin: 0px 15px !important;
  138. }
  139. </style>