spotChecking.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. this.status = 'nomore';
  132. }
  133. },
  134. resetPage(){
  135. this.status = 'loading';
  136. // 上划分页
  137. if(this.action == 'onreachBottom'){
  138. this.getRow();
  139. }
  140. // 左右切换tab
  141. if(this.action == 'swiperChange'){
  142. this.list = [];
  143. this.getRow(1);
  144. }
  145. },
  146. // 查询列表
  147. getRow(pageNo) {
  148. let _this = this;
  149. if (pageNo) {
  150. this.pageNo = pageNo;
  151. }
  152. let params = {
  153. pageNo: this.pageNo,
  154. pageSize: this.pageSize,
  155. type: 'POINT_INSPECTION', // 任务类型
  156. status: this.typeId=='1'?'':this.typeId ,// 任务状态
  157. inspectorId: 1
  158. };
  159. this.status = 'loading';
  160. getTasksList(params).then(res => {
  161. if (res.status == 200) {
  162. if (_this.pageNo > 1) {
  163. _this.list = _this.list.concat(res.data.list || []);
  164. } else {
  165. _this.list = res.data.list || [];
  166. }
  167. _this.total = res.data.count || 0;
  168. } else {
  169. _this.list = [];
  170. _this.total = 0;
  171. _this.noDataText = res.message || '暂无数据';
  172. }
  173. _this.status = 'loadmore';
  174. });
  175. },
  176. // 开始点检
  177. toSpotCheck(item){
  178. console.log(item)
  179. console.log('/pages/spotCheck/spotCheck?taskId=' + item.id + '&types=video&storeId='+item.storeId+'&storeName='+item.storeName)
  180. // 判断当前门店是否已绑定设备
  181. findStoreVsDevice({storeCode:item.storeCode}).then(res=>{
  182. if(res.data.length){
  183. // 门店下的设备
  184. this.$u.vuex('vuex_storeVideoList',res.data)
  185. uni.navigateTo({
  186. url: '/pages/spotCheck/spotCheck?taskId=' + item.id + '&types=video&storeId='+item.storeId+'&storeName='+item.storeName
  187. });
  188. }else{
  189. uni.showToast({
  190. icon: 'none',
  191. title: '当前门店没有绑定设备,暂时不能点检巡店'
  192. })
  193. }
  194. })
  195. },
  196. //判断状态,待处理的跳转的开始点检页面,已完成的查看点检结果,已过期的不处理
  197. viewRow(item) {
  198. // 已完成的
  199. if(item.status == 'FINISHED'){
  200. uni.navigateTo({
  201. url: '/pages/spotCheckCenter/spotCheckResult?id=' + item.id
  202. });
  203. }
  204. // 待处理,开始点检
  205. if(item.status == 'PENDING'){
  206. this.toSpotCheck(item)
  207. }
  208. },
  209. }
  210. };
  211. </script>
  212. <style lang="scss">
  213. page {
  214. height: 100%;
  215. background: #F8F8F8;
  216. }
  217. .pagesCons {
  218. height: 100%;
  219. display: flex;
  220. flex-direction: column;
  221. .tab-body {
  222. .uTabs{
  223. border-bottom: 1px solid #EEEEEE;
  224. box-shadow: 1px 1px 3px #eeeeee;
  225. }
  226. .check-list {
  227. height: calc(100vh - 56px);
  228. }
  229. .check-order-list {
  230. background: #ffffff;
  231. padding: 10upx 20upx;
  232. margin: 25upx;
  233. border-radius: 6upx;
  234. box-shadow: 1px 1px 3px #eeeeee;
  235. .check-row {
  236. display: flex;
  237. align-items: center;
  238. padding: 20upx 10upx;
  239. font-size: 28upx;
  240. &:first-child {
  241. border-bottom: 1px solid #f8f8f8;
  242. }
  243. &:last-child {
  244. border-top: 1px solid #f8f8f8;
  245. font-size: 26upx;
  246. }
  247. .createDate{
  248. color: #999;
  249. }
  250. > view {
  251. &:first-child {
  252. flex-grow: 1;
  253. width: 50%;
  254. }
  255. }
  256. .item-c-type{
  257. flex-shrink: 0;
  258. }
  259. .action {
  260. margin: 0 6rpx;
  261. padding: 0 20rpx;
  262. color: #fff;
  263. }
  264. .dcl {
  265. color: #f72525;
  266. }
  267. .jxz{
  268. color: #007AFF;
  269. }
  270. .ygq {
  271. color: #999;
  272. }
  273. .ywc {
  274. color: #10c71e;
  275. }
  276. .check-btns {
  277. width: '50%';
  278. display: flex;
  279. align-items: center;
  280. justify-content: flex-end;
  281. > view {
  282. margin-left: 35upx;
  283. font-size: 28upx;
  284. }
  285. }
  286. .uni-icons {
  287. margin: 0 5upx;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </style>