myShopTour.vue 12 KB

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