index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. this.$Http.updateFacilityList = this.getlist.bind(this);
  75. setTimeout(() => this.loadElement(), 100)
  76. },
  77. methods: {
  78. init() {
  79. this.getlist();
  80. this.PageCur = '设备地图';
  81. this.isBack = false;
  82. this.heightReduction = 45
  83. setTimeout(() => this.loadElement(true, {
  84. mode: 'minus',
  85. num: 50
  86. }), 100)
  87. },
  88. changePage(page) {
  89. this.PageCur = page;
  90. this.loadElement()
  91. },
  92. loadElement(forcedUpdating, data) {
  93. let page = this.$refs[this.PageCur];
  94. if (page.uninitialized || forcedUpdating) page.init();
  95. },
  96. getlist() {
  97. return new Promise((resolve) => {
  98. this.$Http.basic({
  99. "id": 20230711144102,
  100. "content": {
  101. nocache: true,
  102. "pageNumber": 1,
  103. "pageSize": 99999,
  104. where: this.where
  105. }
  106. }).then(res => {
  107. console.log("11设备列表", res)
  108. if (this.cutoff(res.msg)) return;
  109. resolve(res.msg == '成功')
  110. this.empty = res.data.length == 0;
  111. this.$refs.Search.onFinish();
  112. this.markers = res.data.filter(v => v.latitude).map(v => {
  113. v.id = v.w_deviceid - 0;
  114. v.title = v.devicename;
  115. if (this.usePort == 'h5') v.iconPath = require("../../static/img/location.png");
  116. v.customCallout = { display: 'BYCLICK', anchorY: -10 }
  117. return v
  118. });
  119. this.list = res.data.map(v => {
  120. switch (v.status) {
  121. case '在线':
  122. v.bgColor = "#3C9CFF";
  123. break;
  124. case '禁用':
  125. v.bgColor = "#F56C6C";
  126. break;
  127. default:
  128. v.bgColor = "#F9AE3D";
  129. break;
  130. }
  131. return v
  132. })
  133. })
  134. })
  135. },
  136. startSearch(condition) {
  137. if (condition == this.where.condition) return;
  138. this.where.condition = condition;
  139. this.getlist()
  140. },
  141. onFilter(where) {
  142. console.log("开始筛选", where)
  143. where.condition = this.where.condition;
  144. this.where = where;
  145. this.getlist()
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. /deep/.My_search {
  152. padding-left: 0 !important;
  153. }
  154. .change {
  155. height: 30px;
  156. line-height: 30px;
  157. text-align: center;
  158. margin-left: 5px;
  159. font-size: 14px;
  160. color: #FFFFFF;
  161. border-radius: 4px;
  162. padding: 0 10px;
  163. margin-right: 5px;
  164. border-radius: 4px;
  165. }
  166. </style>