check.vue 4.8 KB

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