myShopTour.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <view class="myShopTour-wrap">
  3. <!-- 内容 -->
  4. <view class="myShopTour-con">
  5. <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>
  6. <swiper class="data-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  7. <swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
  8. <scroll-view scroll-y class="scroll-con" @scrolltolower="onreachBottom">
  9. <view class="record-con" :style="{'paddingTop': searchForm.beginDate ? '74upx' : ''}">
  10. <!-- 筛选日期,近7天 -->
  11. <view v-show="searchForm.beginDate" class="alert-tips">
  12. <text>创建时间:{{searchForm.beginDate}} 至 {{searchForm.endDate}}</text>
  13. </view>
  14. <view class="record-item" v-if="index==current" v-for="(item,sindex) in list" :key="item.id" @click="getDetails(item)">
  15. <view class="item-head">
  16. <text class="item-c-tit">{{item.storeName}}</text>
  17. <u-tag size="mini" mode="plain" shape="circle" class="item-c-type" :text="item.status | taskStatus" :type="item.status | statusCls" />
  18. </view>
  19. <view class="item-main">
  20. <text class="item-tit">创建时间:</text>
  21. <text class="item-val">{{item.startTime}}</text>
  22. </view>
  23. <view class="item-main">
  24. <text class="item-tit">完成时间:</text>
  25. <text class="item-val">{{item.endTime ? item.endTime : '--'}}</text>
  26. </view>
  27. <view class="item-main">
  28. <text class="item-tit">巡店耗时:</text>
  29. <text class="item-val" v-if="item.spendTime">{{ item.spendTime | formatTime }}</text>
  30. <text class="item-val" v-else>--</text>
  31. </view>
  32. <view class="item-main">
  33. <text class="item-tit">检查方式:</text>
  34. <text class="item-val">{{ item.typeDictValue }}</text>
  35. </view>
  36. <u-grid class="item-grid" :col="4" hover-class="none">
  37. <u-grid-item>
  38. <text class="grid-num text-blue">{{item.totalTargetCount}}</text>
  39. <text class="grid-text">检查项</text>
  40. </u-grid-item>
  41. <u-grid-item>
  42. <text class="grid-num text-green">{{item.passTargetCount}}</text>
  43. <text class="grid-text">合格</text>
  44. </u-grid-item>
  45. <u-grid-item>
  46. <text class="grid-num text-red">{{item.notPassTargetCount}}</text>
  47. <text class="grid-text">不合格</text>
  48. </u-grid-item>
  49. <u-grid-item>
  50. <text class="grid-num text-yellow">{{item.notWorkTargetCount}}</text>
  51. <text class="grid-text">不适用</text>
  52. </u-grid-item>
  53. </u-grid>
  54. </view>
  55. </view>
  56. <u-empty style="padding-top: 10vh;height: auto;" :text="noDataText" img-width="120" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  57. <view class="list-nomore" v-if="status == 'nomore'">已经到底了</view>
  58. <u-loadmore bg-color="#f8f8f8" v-if="list.length < total || status == 'loading'" :status="status" class="loadmore" />
  59. </scroll-view>
  60. </swiper-item>
  61. </swiper>
  62. </view>
  63. <!-- 筛选弹框 -->
  64. <search-modal :visible="openScreen" :defaultParams="searchForm" @refresh="refresh" @close="openScreen=false"></search-modal>
  65. </view>
  66. </template>
  67. <script>
  68. import moment from "moment"
  69. import searchModal from './searchModal.vue'
  70. import wPicker from "@/components/w-picker/w-picker.vue"
  71. import { queryMyTask } from '@/api/task.js'
  72. export default {
  73. components: { wPicker, searchModal },
  74. data() {
  75. return {
  76. tabList: [], // tab切换 类型
  77. current: 0, // tabs组件的current值,表示当前活动的tab选项
  78. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  79. pageNo: 1, // 当前页码
  80. pageSize: 5, // 一页多少条
  81. total: 0, // 总条数
  82. status: 'loading', // 加载状态
  83. noDataText: '暂无数据', // 列表数据为空时提示文字
  84. list: [], // 数据列表
  85. openScreen: false, // 是否打开筛选
  86. searchForm: { // 查询条件
  87. beginDate: '', // 创建时间默认筛选近7天
  88. endDate: '', // 创建时间默认筛选近7天
  89. sourceType: [], // 检查方式
  90. storeName: '' // 门店名称
  91. },
  92. typeId: '', // 记录状态
  93. // action:'swiperChange', // 操作类型,上划分页,或左右滑动
  94. }
  95. },
  96. filters: {
  97. // 任务类型
  98. taskStatus(val){
  99. let str = ''
  100. if(val == 'PENDING'){
  101. str = '待处理'
  102. }else if(val == 'RUNNING'){
  103. str = '进行中'
  104. }else if(val == 'FINISHED'){
  105. str = '已完成'
  106. }else if(val == 'EXPIRED'){
  107. str = '已过期'
  108. }
  109. return str
  110. },
  111. // 状态颜色标记
  112. statusCls(val){
  113. let str = ''
  114. if(val == 'PENDING'){
  115. str = 'error'
  116. }else if(val == 'RUNNING'){
  117. str = 'primary'
  118. }else if(val == 'FINISHED'){
  119. str = 'success'
  120. }else if(val == 'EXPIRED'){
  121. str = 'warning'
  122. }
  123. return str
  124. },
  125. // 巡店耗时 秒转时分
  126. formatTime(s){
  127. let time = ''
  128. if(moment.duration(s*1000).hours()){
  129. time += moment.duration(s*1000).hours() + '时'
  130. }
  131. if(moment.duration(s*1000).minutes()){
  132. time += moment.duration(s*1000).minutes() + '分'
  133. }
  134. if(moment.duration(s*1000).seconds()){
  135. time += moment.duration(s*1000).seconds() + '秒'
  136. }
  137. return time
  138. }
  139. },
  140. onLoad() {
  141. // 获取任务状态 对象深度克隆
  142. this.tabList = this.$u.deepClone(this.$store.state.vuex_taskStatus)
  143. this.tabList.unshift({dispName: '全部', code: ''})
  144. this.searchForm.beginDate = this.get7day(-6)
  145. this.searchForm.endDate = this.get7day(0)
  146. this.pageInit(1)
  147. },
  148. methods: {
  149. // 获取查询参数 刷新列表
  150. refresh(params){
  151. this.searchForm = params
  152. this.list = []
  153. this.total = 0
  154. this.pageInit(1)
  155. },
  156. // 查询列表
  157. pageInit(pageNo){
  158. if (pageNo) {
  159. this.pageNo = pageNo
  160. }
  161. let params = {
  162. pageNo: this.pageNo,
  163. pageSize: this.pageSize,
  164. beginDate: this.searchForm.beginDate ? this.searchForm.beginDate : '',
  165. endDate: this.searchForm.endDate ? this.searchForm.endDate : '',
  166. storeName: this.searchForm.storeName ? this.searchForm.storeName : '',
  167. typeList: this.searchForm.sourceType ? this.searchForm.sourceType : [],
  168. status: this.typeId == '' ? '' : this.typeId // 任务状态
  169. }
  170. this.status = 'loading'
  171. queryMyTask(params).then(res => {
  172. console.log(res)
  173. if(res.status == 200){
  174. if(this.pageNo>1){
  175. this.list = this.list.concat(res.data.list || [])
  176. }else{
  177. this.list = res.data.list || []
  178. }
  179. this.total = res.data.count || 0
  180. }else{
  181. this.list = []
  182. this.total = 0
  183. this.noDataText = res.message || '暂无数据'
  184. }
  185. this.status = 'loadmore'
  186. })
  187. },
  188. // 查看详情
  189. getDetails(item){
  190. if(item.type == 'POINT_INSPECTION'){ // 点检任务
  191. uni.navigateTo({
  192. url: '/pages/spotCheckDetails/spotCheckDetails?taskId=' + item.id
  193. })
  194. }else{ // 现场巡店、视频巡店
  195. uni.navigateTo({
  196. url: '/pages/shopTourDetails/shopTourDetails?taskId=' + item.id
  197. })
  198. }
  199. },
  200. // tabs通知swiper切换
  201. tabsChange(index) {
  202. this.swiperCurrent = index
  203. },
  204. swiperChange(e) {
  205. this.pageNo = 1
  206. this.list = []
  207. this.status = "loading"
  208. this.typeId = this.tabList[e.detail.current].code
  209. },
  210. // swiper-item左右移动,通知tabs的滑块跟随移动
  211. transition(e) {
  212. let dx = e.detail.dx
  213. this.$refs.uTabs.setDx(dx)
  214. },
  215. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  216. // swiper滑动结束,分别设置tabs和swiper的状态
  217. animationfinish(e) {
  218. let current = e.detail.current;
  219. if(current != this.current){
  220. this.$refs.uTabs.setFinishCurrent(current)
  221. this.swiperCurrent = current
  222. this.current = current
  223. this.pageInit()
  224. }
  225. },
  226. // scroll-view到底部加载更多
  227. onreachBottom() {
  228. console.log('onreachBottom')
  229. if(this.list.length < this.total){
  230. this.pageNo += 1
  231. this.pageInit()
  232. }else{
  233. uni.showToast({
  234. title: '已经到底了',
  235. icon: 'none'
  236. });
  237. this.status = "nomore"
  238. }
  239. },
  240. // 打开筛选条件
  241. onNavigationBarButtonTap(e) {
  242. this.openScreen = true
  243. },
  244. // 获取近几天的数据
  245. get7day(day){
  246. let today = new Date()
  247. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  248. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  249. let tYear = today.getFullYear()
  250. let tMonth = today.getMonth()
  251. let tDate = today.getDate()
  252. tMonth = this.doHandleMonth(tMonth + 1)
  253. tDate = this.doHandleMonth(tDate)
  254. return tYear + "-" + tMonth + "-" + tDate
  255. },
  256. // 月份
  257. doHandleMonth(month){
  258. let m = month
  259. if(month.toString().length == 1){
  260. m = "0" + month
  261. }
  262. return m
  263. },
  264. }
  265. }
  266. </script>
  267. <style lang="scss">
  268. page {
  269. background-color: #f8f8f8;
  270. height: 100vh;
  271. }
  272. .myShopTour-wrap {
  273. height: 100%;
  274. // 内容
  275. .myShopTour-con{
  276. .uTabs{
  277. border-bottom: 1px solid #EEEEEE;
  278. box-shadow: 1px 1px 3px #eeeeee;
  279. }
  280. .data-list{
  281. height: calc(100vh - 50px);
  282. .swiper-item{
  283. height: 100%;
  284. width: 100%;
  285. overflow: hidden;
  286. .scroll-con{
  287. height: 100%;
  288. width: 100%;
  289. overflow: auto;
  290. // 列表
  291. .record-con{
  292. position: relative;
  293. .alert-tips{
  294. position: fixed;
  295. top: 0upx;
  296. left: 0;
  297. width: 100%;
  298. z-index: 3;
  299. padding: 20upx 30upx 10upx;
  300. background-color: #F8F8F8;
  301. border-bottom: 1px solid #EEEEEE;
  302. text{
  303. display: block;
  304. font-size: 24upx;
  305. padding: 4upx 10upx;
  306. }
  307. }
  308. .record-item{
  309. background-color: #fff;
  310. margin: 20upx 30upx 20upx;
  311. padding: 14upx 30upx 20upx;
  312. border-radius: 6upx;
  313. box-shadow: 1px 1px 3px #EEEEEE;
  314. .item-head{
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. padding: 10upx 0;
  319. .item-c-tit{
  320. flex-grow: 1;
  321. padding-right: 18upx;
  322. font-weight: bold;
  323. }
  324. .item-c-type{
  325. flex-shrink: 0;
  326. }
  327. }
  328. .item-main{
  329. font-size: 26upx;
  330. line-height: 48upx;
  331. padding: 6upx 0;
  332. position: relative;
  333. .item-tit{
  334. display: inline-block;
  335. position: absolute;
  336. left: 0;
  337. top: 8upx;
  338. }
  339. .item-val{
  340. display: inline-block;
  341. padding-left: 150upx;
  342. }
  343. }
  344. .item-grid{
  345. margin-top: 10upx;
  346. .text-blue{
  347. color: #2979ff;
  348. }
  349. .text-green{
  350. color: #19be6b;
  351. }
  352. .text-red{
  353. color: #fa3534;
  354. }
  355. .text-yellow{
  356. color: #ff9900;
  357. }
  358. .grid-num{
  359. font-weight: bold;
  360. }
  361. .grid-text{
  362. font-size: 26upx;
  363. padding-top: 10upx;
  364. color: #666;
  365. }
  366. }
  367. }
  368. }
  369. .loadmore{
  370. padding:100upx 30upx;
  371. }
  372. }
  373. }
  374. }
  375. }
  376. .screenModel-wrap{
  377. padding-bottom: 80upx;
  378. .condition-con{
  379. padding: 20upx 30upx;
  380. .screen-module{
  381. margin: 0 0 20upx;
  382. .screen-tit{
  383. color: #464646;
  384. font-size: 26upx;
  385. }
  386. .screen-time-val{
  387. font-size: 26upx;
  388. background-color: #f4f4f4;
  389. border-radius: 12upx;
  390. padding: 10upx 14upx;
  391. margin: 10upx 0;
  392. text-align: center;
  393. text{
  394. display: inline-block;
  395. width: 85%;
  396. }
  397. .close-circle{
  398. display: inline-block;
  399. padding-left: 3%;
  400. vertical-align: bottom;
  401. }
  402. }
  403. .screen-inp-val{
  404. margin: 10upx 0;
  405. .screen-inp{
  406. color: #464646;
  407. font-size: 26upx;
  408. }
  409. }
  410. }
  411. }
  412. .btns{
  413. position: fixed;
  414. bottom: 0;
  415. left: 0;
  416. width: 100%;
  417. background-color: rgba(0,0,0,.025);
  418. .btn{
  419. width: 40%;
  420. margin: 20upx 5%;
  421. padding: 30upx 0;
  422. }
  423. }
  424. }
  425. }
  426. </style>