spotChecking.vue 7.5 KB

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