spotChecking.vue 7.6 KB

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