index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view>
  3. <cu-custom ref="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="设备列表" :tabHeight="tabHeight" :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: Number
  30. },
  31. name: "facility",
  32. data() {
  33. return {
  34. condition: "",
  35. empty: false,
  36. isBack: true,
  37. uninitialized: true,
  38. PageCur: "设备列表",
  39. list: [],
  40. markers: [],
  41. where: {
  42. condition: "",
  43. status: ""
  44. },
  45. filter: [{
  46. label: "状态",
  47. list: [{
  48. status: '全部',
  49. value: ""
  50. }, {
  51. status: '在线',
  52. value: "在线"
  53. }, {
  54. status: '离线',
  55. value: "离线"
  56. }, {
  57. status: '禁用',
  58. value: "禁用"
  59. }],
  60. key: "status",
  61. selectKey: "value",
  62. showKey: 'status',
  63. default: "0",
  64. selectIndex: 1,
  65. }],
  66. heightReduction: 0
  67. }
  68. },
  69. onLoad(options) {
  70. if (options.status) this.where.status = options.status;
  71. this.getlist();
  72. this.$Http.updateFacilityList = this.getlist.bind(this);
  73. setTimeout(() => this.loadElement(), 100)
  74. },
  75. methods: {
  76. init() {
  77. this.getlist();
  78. this.PageCur = '设备地图';
  79. this.isBack = false;
  80. this.heightReduction = 45
  81. setTimeout(() => this.loadElement(true, {
  82. mode: 'minus',
  83. num: 50
  84. }), 100)
  85. },
  86. changePage(page) {
  87. this.PageCur = page;
  88. this.loadElement()
  89. },
  90. loadElement(forcedUpdating, data) {
  91. let page = this.$refs[this.PageCur];
  92. if (page.uninitialized || forcedUpdating) page.init();
  93. },
  94. getlist() {
  95. return new Promise((resolve) => {
  96. this.$Http.basic({
  97. "id": 20230711144102,
  98. "content": {
  99. nocache: true,
  100. "pageNumber": 1,
  101. "pageSize": 99999,
  102. where: this.where
  103. }
  104. }).then(res => {
  105. console.log("设备列表", res)
  106. if (this.cutoff(res.msg)) return;
  107. resolve(res.msg == '成功')
  108. this.empty = res.data.length == 0;
  109. this.$refs.Search.onFinish();
  110. this.markers = res.data.filter(v => v.latitude).map(v => {
  111. v.id = v.w_deviceid - 0;
  112. v.title = v.devicename;
  113. if (this.usePort == 'h5') v.iconPath = require("../../static/img/location.png");
  114. v.customCallout = { display: 'BYCLICK', anchorY: -10 }
  115. return v
  116. });
  117. this.list = res.data.map(v => {
  118. switch (v.status) {
  119. case '在线':
  120. v.bgColor = "#3C9CFF";
  121. break;
  122. case '禁用':
  123. v.bgColor = "#F56C6C";
  124. break;
  125. default:
  126. v.bgColor = "#F9AE3D";
  127. break;
  128. }
  129. return v
  130. })
  131. })
  132. })
  133. },
  134. startSearch(condition) {
  135. if (condition == this.where.condition) return;
  136. this.where.condition = condition;
  137. this.getlist()
  138. },
  139. onFilter(where) {
  140. console.log("开始筛选", where)
  141. where.condition = this.where.condition;
  142. this.where = where;
  143. this.getlist()
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. /deep/.My_search {
  150. padding-left: 0 !important;
  151. }
  152. .change {
  153. height: 30px;
  154. line-height: 30px;
  155. text-align: center;
  156. margin-left: 5px;
  157. font-size: 14px;
  158. color: #FFFFFF;
  159. border-radius: 4px;
  160. padding: 0 10px;
  161. margin-right: 5px;
  162. border-radius: 4px;
  163. }
  164. </style>