index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="container">
  3. <cu-custom id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="isBack">
  6. <block slot="backText">返回</block>
  7. <block slot="content">
  8. 设备中心
  9. </block>
  10. </cu-custom>
  11. <My_search :heightReduction="heightReduction" ref="Search" @onFilter="onFilter" @startSearch="startSearch"
  12. :filter="filter">
  13. <template slot="left">
  14. <view class="change" hover-class="navigator-hover" @click="changePage(PageCur == '设备列表' ? '设备地图' : '设备列表')">
  15. {{ PageCur == '设备列表' ? '列表' : '地图' }}
  16. </view>
  17. </template>
  18. </My_search>
  19. <list ref="设备列表" :empty="empty" :list="list" v-show="PageCur == '设备列表'" />
  20. <my-map ref="设备地图" :tabHeight="tabHeight" :markers="markers" v-show="PageCur == '设备地图'" />
  21. </view>
  22. </template>
  23. <script>
  24. import list from "./list.vue"
  25. import myMap from "./my-map.vue";
  26. export default {
  27. components: { list, myMap },
  28. props: {
  29. tabHeight: {
  30. type: Number,
  31. default: 98
  32. }
  33. },
  34. name: "facility",
  35. data() {
  36. return {
  37. condition: "",
  38. empty: false,
  39. isBack: true,
  40. uninitialized: true,
  41. PageCur: "设备列表",
  42. list: [],
  43. markers: [],
  44. "where": {
  45. "condition": "",
  46. "status": ""
  47. },
  48. filter: [{
  49. label: "状态",
  50. list: [{
  51. status: '全部',
  52. value: ""
  53. }, {
  54. status: '在线',
  55. value: "在线"
  56. }, {
  57. status: '离线',
  58. value: "离线"
  59. }, {
  60. status: '禁用',
  61. value: "禁用"
  62. }],
  63. key: "status",
  64. selectKey: "value",
  65. showKey: 'status',
  66. default: "0",
  67. selectIndex: 0,
  68. }],
  69. heightReduction: 0
  70. }
  71. },
  72. onLoad(options) {
  73. this.getlist();
  74. setTimeout(() => this.loadElement(), 100)
  75. },
  76. methods: {
  77. init() {
  78. this.getlist();
  79. this.PageCur = '设备地图';
  80. this.isBack = false;
  81. this.heightReduction = 45
  82. setTimeout(() => this.loadElement(true, {
  83. mode: 'minus',
  84. num: 50
  85. }), 100)
  86. },
  87. changePage(page) {
  88. this.PageCur = page;
  89. this.loadElement()
  90. },
  91. loadElement(forcedUpdating, data) {
  92. let page = this.$refs[this.PageCur];
  93. if (page.uninitialized || forcedUpdating) page.init();
  94. },
  95. getlist() {
  96. this.$Http.basic({
  97. "id": 20230615153202,
  98. "content": {
  99. "pageNumber": 1,
  100. "pageSize": 99999,
  101. where: this.where
  102. }
  103. }).then(res => {
  104. console.log("设备列表", res)
  105. if (this.cutoff(res.msg)) return;
  106. this.empty = res.data.length == 0;
  107. this.$refs.Search.onFinish();
  108. this.markers = res.data.filter(v => v.latitude).map(v => {
  109. v.id = v.w_deviceid - 0;
  110. v.title = v.devicename;
  111. if (this.usePort == 'h5') v.iconPath = require("../../static/img/icon.png");
  112. v.customCallout = { display: 'BYCLICK', anchorY: -10 }
  113. return v
  114. });
  115. this.list = res.data.map(v => {
  116. switch (v.status) {
  117. case '在线':
  118. v.bgColor = "#3C9CFF";
  119. break;
  120. case '禁用':
  121. v.bgColor = "#F56C6C";
  122. break;
  123. default:
  124. v.bgColor = "#F9AE3D";
  125. break;
  126. }
  127. return v
  128. })
  129. })
  130. },
  131. startSearch(condition) {
  132. if (condition == this.where.condition) return;
  133. this.where.condition = condition;
  134. this.getlist()
  135. },
  136. onFilter(where) {
  137. console.log("开始筛选", where)
  138. where.condition = this.where.condition;
  139. this.where = where;
  140. this.getlist()
  141. },
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. /deep/.My_search {
  147. padding-left: 0 !important;
  148. }
  149. .change {
  150. height: 30px;
  151. line-height: 30px;
  152. text-align: center;
  153. margin-left: 5px;
  154. font-size: 14px;
  155. color: #FFFFFF;
  156. border-radius: 4px;
  157. padding: 0 10px;
  158. margin-right: 5px;
  159. border-radius: 4px;
  160. }
  161. </style>