index.vue 2.4 KB

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