myShopTour.vue 12 KB

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