spotChecking.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="pagesCons">
  3. <view class="tab-body">
  4. <view><u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper></view>
  5. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  6. <swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;" v-for="(tabs, index) in tabList" :key="index">
  7. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom">
  8. <view class="check-order-list" v-for="(item, index) in list" :key="item.id">
  9. <view class="check-row" @click="viewRow(item)">
  10. <view class="createDate">{{ item.createDate }}</view>
  11. <view :class="clsStatus(item.status)">{{ item.status }}</view>
  12. </view>
  13. <view class="check-row" @click="viewRow(item)">
  14. <view>
  15. <view style="font-size: 30upx;margin-bottom: 10upx;">{{ item.name }}</view>
  16. <view style="color: #666666;">{{ item.storeName }}</view>
  17. </view>
  18. <view>
  19. <text v-if="item.status=='待处理'" style="color: #007AFF;">开始点检</text>
  20. <text v-if="item.status=='已完成'" style="color: #007AFF;">查看结果</text>
  21. <u-icon v-if="item.status!='已过期'" name="icon-xian-11" custom-prefix="xd-icon" size="28" color="#888888"></u-icon>
  22. </view>
  23. </view>
  24. </view>
  25. <u-empty :text="noDataText" img-width="120" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  26. <view style="padding: 20upx;"><u-loadmore v-if="total > pageSize || status == 'loading'" :status="status" /></view>
  27. </scroll-view>
  28. </swiper-item>
  29. </swiper>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { getTaskList } from '@/api/task.js';
  35. import { getLookUpDatas, listLookUp } from '@/api/data';
  36. import { clzConfirm } from '@/libs/tools.js';
  37. export default {
  38. data() {
  39. return {
  40. status: 'loadmore',
  41. noDataText: '暂无数据',
  42. tabList: [
  43. {
  44. dispName: '待处理',
  45. code: 4
  46. },
  47. {
  48. dispName: '已完成',
  49. code: 3
  50. },
  51. {
  52. dispName: '已过期',
  53. code: 2
  54. },
  55. {
  56. dispName: '全部',
  57. code: 1
  58. }
  59. ],
  60. typeId:'1',
  61. current: 0,
  62. swiperCurrent: 0,
  63. pageNo: 1,
  64. pageSize: 10,
  65. list: [],
  66. total: 0
  67. };
  68. },
  69. onLoad() {
  70. this.getRow();
  71. },
  72. methods: {
  73. message(title) {
  74. uni.showToast({
  75. icon: 'none',
  76. title: title
  77. });
  78. },
  79. // tabs通知swiper切换
  80. tabsChange(index) {
  81. this.swiperCurrent = index;
  82. },
  83. swiperChange(event) {
  84. console.log(event.detail);
  85. this.list = [];
  86. this.status = 'loading';
  87. },
  88. // swiper-item左右移动,通知tabs的滑块跟随移动
  89. transition(e) {
  90. let dx = e.detail.dx;
  91. this.$refs.uTabs.setDx(dx);
  92. },
  93. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  94. // swiper滑动结束,分别设置tabs和swiper的状态
  95. animationfinish(e) {
  96. let current = e.detail.current;
  97. if (current != this.current) {
  98. this.$refs.uTabs.setFinishCurrent(current);
  99. this.swiperCurrent = current;
  100. this.current = current;
  101. this.getRow();
  102. }
  103. },
  104. // scroll-view到底部加载更多
  105. onreachBottom() {
  106. console.log(this.list.length, this.total);
  107. if (this.list.length < this.total) {
  108. this.pageNo += 1;
  109. this.getRow();
  110. } else {
  111. this.status = 'nomore';
  112. }
  113. },
  114. // 查询列表
  115. getRow(pageNo) {
  116. let _this = this;
  117. if (pageNo) {
  118. this.pageNo = pageNo;
  119. }
  120. this.typeId = this.tabList[this.swiperCurrent].code
  121. let params = {
  122. pageNo: this.pageNo,
  123. pageSize: this.pageSize,
  124. type: '点检任务', // 任务类型
  125. status: this.typeId=='1'?'':this.typeId // 任务状态
  126. };
  127. this.status = 'loading';
  128. getTaskList(params).then(res => {
  129. if (res.code == 200 || res.status == 204 || res.status == 200) {
  130. if (_this.pageNo > 1) {
  131. _this.list = _this.list.concat(res.data.list || []);
  132. } else {
  133. _this.list = res.data.list || [];
  134. }
  135. _this.total = res.data.count || 0;
  136. } else {
  137. _this.list = [];
  138. _this.total = 0;
  139. _this.noDataText = res.message;
  140. }
  141. _this.status = 'loadmore';
  142. });
  143. },
  144. //判断状态,待处理的跳转的开始点检页面,已完成的查看点检结果,已过期的不处理
  145. viewRow(item) {
  146. // 已完成的
  147. if(item.status == '已完成'){
  148. uni.navigateTo({
  149. url: '/pages/spotCheckCenter/spotCheckResult?id=' + item.id
  150. });
  151. }
  152. // 待处理,开始点检
  153. if(item.status == '待处理'){
  154. }
  155. },
  156. clsStatus(status){
  157. if(status == '待处理'){
  158. return 'dcl'
  159. }
  160. if(status == '已完成'){
  161. return 'ywc'
  162. }
  163. if(status == '已过期'){
  164. return 'ygq'
  165. }
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. page {
  172. height: 100%;
  173. }
  174. .pagesCons {
  175. height: 100%;
  176. display: flex;
  177. flex-direction: column;
  178. .tab-body {
  179. .check-list {
  180. height: calc(100vh - 120px);
  181. }
  182. .check-order-list {
  183. background: #ffffff;
  184. padding: 10upx 20upx;
  185. margin: 25upx;
  186. border-radius: 6upx;
  187. box-shadow: 1px 1px 3px #eeeeee;
  188. .check-row {
  189. display: flex;
  190. align-items: center;
  191. padding: 20upx 10upx;
  192. font-size: 28upx;
  193. &:first-child {
  194. border-bottom: 1px dashed #f8f8f8;
  195. font-size: 26upx;
  196. }
  197. &:last-child {
  198. border-top: 1px dashed #f8f8f8;
  199. }
  200. > view {
  201. &:first-child {
  202. flex-grow: 1;
  203. }
  204. }
  205. .action {
  206. margin: 0 6rpx;
  207. padding: 0 20rpx;
  208. color: #fff;
  209. }
  210. .dcl {
  211. color: #f72525;
  212. }
  213. .ygq {
  214. color: #999;
  215. }
  216. .ywc {
  217. color: #10c71e;
  218. }
  219. .check-btns {
  220. width: '50%';
  221. display: flex;
  222. align-items: center;
  223. justify-content: flex-end;
  224. > view {
  225. margin-left: 35upx;
  226. font-size: 28upx;
  227. }
  228. }
  229. .u-tag {
  230. border-radius: 0;
  231. }
  232. .uni-icons {
  233. margin: 0 5upx;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. </style>