spotChecking.vue 7.0 KB

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