list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <My_search @openFilter="openFilter" @startSearch="startSearch" />
  4. <My_listbox ref="List" @getlist="getlist" :empty='empty'>
  5. <navigator v-for="item in list" :key="item.w_deviceid" class="item"
  6. :url="'/packageA/facility/detail?id=' + item.w_deviceid">
  7. <view class="name u-line-1">设备:{{ item.devicename || ' --' }}</view>
  8. <view class="row u-line-1">设备编号:<text>{{ item.serialnumber || ' --' }}</text></view>
  9. <view class="row u-line-1">设备地址:<text>{{ (item.province + item.city + item.county + item.address) || ' --'
  10. }}</text>
  11. </view>
  12. <view class="status" :style="{ background: item.bgColor }">{{ item.status }}</view>
  13. </navigator>
  14. <view v-if="istabbar" class="cu-bar tabbar" />
  15. </My_listbox>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. istabbar: Boolean
  22. },
  23. name: "list",
  24. data() {
  25. return {
  26. empty: false,
  27. list: [],
  28. uninitialized: true,
  29. "content": {
  30. "pageNumber": 1,
  31. "pageTotal": 1,
  32. "pageSize": 20,
  33. "where": {
  34. "condition": "",
  35. "status": ""
  36. }
  37. }
  38. }
  39. },
  40. methods: {
  41. init(forcedUpdating = true) {
  42. this.uninitialized = false;
  43. this.getlist(forcedUpdating);
  44. },
  45. getlist(init) {
  46. let content = this.content;
  47. if (init) {
  48. content.pageNumber = 1;
  49. content.pageTotal = 1;
  50. }
  51. if (content.pageNumber > content.pageTotal) return;
  52. this.$Http.basic({
  53. "id": 20230615153202,
  54. content
  55. }).then(res => {
  56. console.log("设备列表", res)
  57. if (this.cutoff(res.msg)) return;
  58. this.$refs.List.RefreshToComplete();
  59. this.$refs.List.setHeight();
  60. this.empty = !res.data.length;
  61. content.pageNumber = res.pageNumber + 1;
  62. content.pageTotal = res.pageTotal;
  63. res.data = res.data.map(v => {
  64. switch (v.status) {
  65. case '在线':
  66. v.bgColor = "#3874F6";
  67. break;
  68. case '禁用':
  69. v.bgColor = "#EB4B5C";
  70. break;
  71. default:
  72. v.bgColor = "#BBBBBB";
  73. break;
  74. }
  75. return v
  76. })
  77. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data)
  78. this.content = content;
  79. })
  80. },
  81. startSearch(condition) {
  82. if (condition == this.content.where.condition) return;
  83. this.content.where.condition = condition;
  84. this.getlist(true)
  85. },
  86. openFilter(e) {
  87. console.log("开始筛选", e)
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .item {
  94. position: relative;
  95. width: 355px;
  96. background: #FFFFFF;
  97. border-radius: 4px;
  98. margin: 5px auto;
  99. margin-bottom: 10px;
  100. padding: 10px;
  101. box-sizing: border-box;
  102. overflow: hidden;
  103. .name {
  104. width: 300px;
  105. line-height: 21px;
  106. font-size: 15px;
  107. font-family: PingFang SC-Medium, PingFang SC;
  108. font-weight: bold;
  109. color: #333333;
  110. margin-bottom: 10px;
  111. }
  112. .row {
  113. line-height: 17px;
  114. font-size: 12px;
  115. color: #666666;
  116. margin-bottom: 5px;
  117. text {
  118. line-height: 17px;
  119. font-size: 12px;
  120. color: #0A3971;
  121. }
  122. }
  123. .status {
  124. position: absolute;
  125. right: 0;
  126. top: 0;
  127. border-radius: 0px 4px 0px 4px;
  128. background: red;
  129. text-align: center;
  130. line-height: 24px;
  131. padding: 0 10px;
  132. font-size: 12px;
  133. font-family: PingFang SC-Regular, PingFang SC;
  134. color: #FFFFFF;
  135. }
  136. }
  137. </style>