spare.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view>
  3. <common-tabs :list="list" :current="current" @change="change" />
  4. <view class="main p-top8">
  5. <template v-if="listData.length > 0">
  6. <view
  7. class="mx3 my2 p3 bg-color-white box p-relative"
  8. v-for="item in listData"
  9. :key="item.id"
  10. @tap="handleDetail(item.id)"
  11. @longpress="showMask(item.id,$event)">
  12. <!-- -->
  13. <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" @del="handleDel(item.id)" />
  14. <!-- -->
  15. <view class="d-flex j-between border-bottom pb-2 a-center">
  16. <view class="text-color-b f-size-26">{{ item.name }}</view>
  17. <my-badge :text="statusMap[item.status]" :status="dict[item.status]" />
  18. </view>
  19. <view class="mt-2 d-flex j-between">
  20. <view class="text-color-3 f-size-32 f-weight-bold">{{
  21. item.zbh==null?item.no:item.zbh
  22. }}</view>
  23. </view>
  24. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  25. item.model
  26. }}</view>
  27. </view>
  28. <view class="py3">
  29. <u-loadmore :status="status" />
  30. </view>
  31. </template>
  32. <template v-else>
  33. <view class="empty">
  34. <u-empty text="暂无数据" mode="list"></u-empty>
  35. </view>
  36. </template>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. list: [],
  45. current: 0,
  46. // 加载更多
  47. status: 'loadmore',
  48. page: 1,
  49. limit: 10,
  50. type: '',
  51. loadMore: true,
  52. listData: [],
  53. statusMap: {},
  54. dict: null,
  55. maskId: 0,
  56. maskState: false
  57. };
  58. },
  59. onPullDownRefresh() {
  60. // 请求结束取消刷新
  61. this.page = 1;
  62. this.loadMore = true;
  63. this.listData = [];
  64. this.initData();
  65. uni.stopPullDownRefresh();
  66. },
  67. onReachBottom() {
  68. if (this.loadMore) {
  69. this.page++;
  70. this.initData();
  71. }
  72. },
  73. onLoad() {
  74. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  75. this.$DictCache.TYPE.SB_INFO_STATUS
  76. );
  77. this.list = [{
  78. label: '全部',
  79. value: ''
  80. }].concat(
  81. this.$DictCache.getChildrenList(this.$DictCache.TYPE.SB_INFO_STATUS)
  82. );
  83. this.dict = this.$DictCache.COLOR.SB_INFO_STATUS;
  84. this.initData();
  85. },
  86. onHide() {
  87. this.maskId = 0
  88. },
  89. methods: {
  90. showMask(id, e) {
  91. this.maskId = id
  92. // #ifdef H5
  93. e.preventDefault()
  94. // #endif
  95. },
  96. handleDel(id) {
  97. console.log(id);
  98. const that = this;
  99. const params = [];
  100. params.push(id);
  101. uni.showModal({
  102. title: '提示',
  103. content: '您确认删除吗?',
  104. success: (res) => {
  105. if (res.confirm) {
  106. this.$Http.deleteSbInfos(params).then((res) => {
  107. uni.showToast({
  108. title: '删除成功'
  109. });
  110. this.page = 1;
  111. this.loadMore = true;
  112. this.listData = [];
  113. this.initData();
  114. });
  115. } else if (res.cancel) {}
  116. }
  117. });
  118. },
  119. // 跳转详情
  120. handleDetail(id) {
  121. if (this.maskId != 0) return this.maskId = 0
  122. if (this.maskState) return this.maskState = false
  123. uni.navigateTo({
  124. url: '/pages/equipment-detail/equipment-detail?detailId=' + id
  125. });
  126. },
  127. // 点击 tab
  128. change(index) {
  129. this.current = index;
  130. if (index == 0) {
  131. this.type = '';
  132. } else {
  133. this.type = index;
  134. }
  135. this.page = 1;
  136. this.loadMore = true;
  137. this.listData = [];
  138. this.initData();
  139. },
  140. initData() {
  141. const that = this;
  142. that.status = 'loading';
  143. this.$Http
  144. .getSbInfoPage({
  145. pageNum: this.page,
  146. pageSize: this.limit,
  147. filter: -1,
  148. status: this.type,
  149. dataScope: {
  150. sortBy: 'asc',
  151. sortName: 'no'
  152. }
  153. })
  154. .then((res) => {
  155. const data = res.data.rows;
  156. if (data && data.length > 0 && data.length < that.limit) {
  157. that.status = 'nomore';
  158. that.loadMore = false;
  159. } else if (data.length === that.limit) {
  160. that.status = 'loadmore';
  161. } else {
  162. that.status = 'nomore';
  163. }
  164. that.listData = [...that.listData, ...data];
  165. });
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="less">
  171. page {
  172. background-color: #f4f4f4;
  173. }
  174. .main {
  175. .box {
  176. border-radius: 20rpx;
  177. padding-right: 0;
  178. }
  179. }
  180. </style>