lubrication.vue 4.8 KB

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