list.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view>
  3. <common-tabs :list='list' :current="current" @change='change' />
  4. <view class="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, index) in listData"
  9. :key="item.id"
  10. @click="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. <view class="d-flex j-between border-bottom pb-2 a-center">
  15. <view class="text-color-b f-size-26">{{ item.spareName }}</view>
  16. <my-badge
  17. :text="statusMap[item.status]"
  18. :status="dict[item.status]"
  19. />
  20. </view>
  21. <view class="mt-2 d-flex j-between">
  22. <view class="text-color-3 f-size-32 f-weight-bold">{{
  23. item.storeName
  24. }}</view>
  25. </view>
  26. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  27. item.startTime
  28. }}</view>
  29. </view>
  30. <view class="py3">
  31. <u-loadmore :status="status" />
  32. </view>
  33. </template>
  34. <template v-else>
  35. <view class="empty">
  36. <u-empty text="暂无数据" mode="list"></u-empty>
  37. </view>
  38. </template>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. list: [],
  47. current: 0,
  48. sbId: "",
  49. // 加载更多
  50. status: "loadmore",
  51. page: 1,
  52. limit: 10,
  53. type: "",
  54. loadMore: true,
  55. listData: [],
  56. statusMap: null,
  57. dict: null,
  58. maskId: 0,
  59. };
  60. },
  61. onPullDownRefresh() {
  62. // 请求结束取消刷新
  63. this.page = 1;
  64. this.loadMore = true;
  65. this.listData = [];
  66. this.initData();
  67. uni.stopPullDownRefresh();
  68. },
  69. onReachBottom() {
  70. if (this.loadMore) {
  71. this.page++;
  72. this.initData();
  73. }
  74. },
  75. onLoad(options) {
  76. this.sbId = options.sbId
  77. this.initData();
  78. this.statusMap = this.$DictCache.getLabelByValueMapByType(
  79. this.$DictCache.TYPE.STORE_CHECK_JOB_STATUS
  80. );
  81. this.list = [{ label: "全部", value: "" }].concat(
  82. this.$DictCache.getChildrenList(this.$DictCache.TYPE.STORE_CHECK_JOB_STATUS)
  83. );
  84. this.dict = this.$DictCache.COLOR.STORE_CHECK_JOB_STATUS;
  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. let that = this;
  98. let params = [];
  99. params.push(id);
  100. uni.showModal({
  101. title: "提示",
  102. content: "您确认删除吗?",
  103. success: (res) => {
  104. if (res.confirm) {
  105. this.$Http.deleteCheckJobs(params).then((res) => {
  106. uni.showToast({ title: "删除成功" });
  107. this.page = 1;
  108. this.loadMore = true;
  109. this.listData = [];
  110. this.initData();
  111. });
  112. } else if (res.cancel) {
  113. }
  114. },
  115. });
  116. },
  117. // 详情
  118. handleDetail(id) {
  119. // if (index == 0) {
  120. // uni.navigateTo({
  121. // url: '../check-add/check-add'
  122. // });
  123. // } else {
  124. // uni.navigateTo({
  125. // url: '../check-detail/check-detail'
  126. // });
  127. // }
  128. if (this.maskId != 0) return this.maskId = 0
  129. uni.navigateTo({
  130. url: "/pages/store-check/store-check-detail?detailId=" + id,
  131. });
  132. },
  133. // tab
  134. change(index) {
  135. this.current = index;
  136. if (index == 0) {
  137. this.type = "";
  138. } else {
  139. this.type = index;
  140. }
  141. this.page = 1;
  142. this.loadMore = true;
  143. this.listData = [];
  144. this.initData();
  145. },
  146. handleClick() {
  147. uni.navigateTo({
  148. url: "/pages/check-add/check-add-test",
  149. });
  150. },
  151. initData() {
  152. const that = this;
  153. that.status = "loading";
  154. this.$Http
  155. .getStoreCheckJobPage({
  156. pageNum: this.page,
  157. pageSize: this.limit,
  158. sbId: this.sbId,
  159. type: 1,
  160. filter: 0,
  161. status: this.type,
  162. })
  163. .then((res) => {
  164. const data = res.data.rows;
  165. if (data && data.length > 0 && data.length < that.limit) {
  166. that.status = "nomore";
  167. that.loadMore = false;
  168. } else if (data.length == that.limit) {
  169. that.status = "loadmore";
  170. } else {
  171. that.status = "nomore";
  172. }
  173. that.listData = [...that.listData, ...data];
  174. });
  175. },
  176. },
  177. };
  178. </script>
  179. <style>
  180. page {
  181. background-color: #f4f4f4;
  182. }
  183. .box {
  184. padding-right: 0;
  185. border-radius: 20rpx;
  186. }
  187. </style>