index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <!-- 建议放在外层 -->
  4. <u-navbar title="设备中心" @leftClick="devicemenuShow" :safeAreaInsetTop="true">
  5. <view class="u-nav-slot" slot="left">
  6. <u-icon name="list" size="20"> </u-icon>
  7. </view>
  8. </u-navbar>
  9. <view v-if="menushow" class="menupage">
  10. <DeviceMenu @menuClick="menuClick"></DeviceMenu>
  11. </view>
  12. <u-tabs class="devic-box-tab" :current="PageCur" :list="tabList" @click="NavChange"></u-tabs>
  13. <view class="">
  14. <home cur="home" :showColum="showColum" v-if="PageCur == '0' && !menushow" :key="0" :deviceType="deviceType"
  15. @setMenushow="setMenushow"></home>
  16. <history :key="1" cur="history" :showColum="showColum" :deviceType="deviceType"
  17. v-if="PageCur == '1' && !menushow" @setMenushow="setMenushow"></history>
  18. <operation :key="2" :showColum="showColum" :deviceType="deviceType" cur="operation"
  19. v-if="PageCur == '2' && !menushow" @setMenushow="setMenushow"></operation>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import api from "@/api/api";
  25. import DeviceMenu from "./devicemenu/devicemenu.vue";
  26. export default {
  27. components: {
  28. DeviceMenu,
  29. },
  30. data() {
  31. return {
  32. PageCur: "0",
  33. showColum: {},
  34. menushow: false,
  35. deviceType: '',
  36. tabList: [
  37. {
  38. name: '设备监测'
  39. },
  40. {
  41. name: '历史数据'
  42. },
  43. {
  44. name: '操作记录'
  45. },
  46. ],
  47. };
  48. },
  49. created() {
  50. this.getShowColum();
  51. },
  52. onLoad: function () {
  53. this.PageCur = "0";
  54. },
  55. methods: {
  56. NavChange: function (item) {
  57. this.PageCur = item.index;
  58. this.menushow = false
  59. },
  60. devicemenuShow(e) {
  61. this.menushow = !this.menushow;
  62. },
  63. menuClick(id) {
  64. debugger
  65. // this.TabCur = id;
  66. this.deviceType = id;
  67. this.menushow = false;
  68. },
  69. getShowColum() {
  70. new Promise((resolve, reject) => {
  71. api
  72. .getShowColum({})
  73. .then((response) => {
  74. if (response.data.code == 200) {
  75. var showlist = response.data.result;
  76. this.$store.commit("SET_SHOWCOLUM", showlist);
  77. this.showColum = showlist;
  78. } else {
  79. resolve(response);
  80. }
  81. })
  82. .catch((error) => {
  83. console.log("catch===>response", response);
  84. reject(error);
  85. });
  86. });
  87. },
  88. setMenushow(params) {
  89. if (params) {
  90. this.menushow = params.menushow
  91. }
  92. }
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. .devic-box-tab {
  98. // margin-top: 50px;
  99. }
  100. </style>