equipment.vue 6.0 KB

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