spotChecking.vue 7.7 KB

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