myShopTour.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view class="myShopTour-wrap">
  3. <!-- 内容 -->
  4. <view class="myShopTour-con">
  5. <u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
  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="primary" />
  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. <u-grid class="item-grid" :col="4" hover-class="none">
  33. <u-grid-item>
  34. <text class="grid-num text-blue">{{item.totalTargetCount}}</text>
  35. <text class="grid-text">检查项</text>
  36. </u-grid-item>
  37. <u-grid-item>
  38. <text class="grid-num text-green">{{item.passTargetCount}}</text>
  39. <text class="grid-text">合格</text>
  40. </u-grid-item>
  41. <u-grid-item>
  42. <text class="grid-num text-red">{{item.notPassTargetCount}}</text>
  43. <text class="grid-text">不合格</text>
  44. </u-grid-item>
  45. <u-grid-item>
  46. <text class="grid-num text-yellow">{{item.notWorkTargetCount}}</text>
  47. <text class="grid-text">不适用</text>
  48. </u-grid-item>
  49. </u-grid>
  50. </view>
  51. </view>
  52. <u-empty text="暂无数据" img-width="120" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  53. <u-loadmore bg-color="#f8f8f8" v-if="list.length < total || status == 'loading'" :status="status" class="loadmore" />
  54. </scroll-view>
  55. </swiper-item>
  56. </swiper>
  57. </view>
  58. <!-- 筛选弹框 -->
  59. <search-modal :visible="openScreen" :defaultParams="searchForm" @openPicke="openPicker" @refresh="refresh" @close="openScreen=false"></search-modal>
  60. </view>
  61. </template>
  62. <script>
  63. import moment from "moment"
  64. import searchModal from './searchModal.vue'
  65. import wPicker from "@/components/w-picker/w-picker.vue"
  66. import { queryMyTask } from '@/api/task.js'
  67. export default {
  68. components: { wPicker, searchModal },
  69. data() {
  70. return {
  71. tabList: [ // tab切换 类型
  72. { dispName: '全部', code:'' },
  73. { dispName: '待处理', code:'PENDING' },
  74. { dispName: '进行中', code:'RUNNING' },
  75. { dispName: '已完成', code:'FINISHED' },
  76. { dispName: '已过期', code:'EXPIRED' }
  77. ],
  78. current: 0, // tabs组件的current值,表示当前活动的tab选项
  79. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  80. pageNo: 1, // 当前页码
  81. pageSize: 15, // 一页多少条
  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. formatTime(s){
  114. let time = ''
  115. if(moment.duration(s*1000).hours()){
  116. time += moment.duration(s*1000).hours() + '时'
  117. }
  118. if(moment.duration(s*1000).minutes()){
  119. time += moment.duration(s*1000).minutes() + '分'
  120. }
  121. if(moment.duration(s*1000).seconds()){
  122. time += moment.duration(s*1000).seconds() + '秒'
  123. }
  124. return time
  125. }
  126. },
  127. onLoad() {
  128. this.searchForm.beginDate = this.get7day(-6)
  129. this.searchForm.endDate = this.get7day(0)
  130. this.resetPage()
  131. uni.$on("updatePointTaskList",()=>{
  132. this.resetPage()
  133. })
  134. },
  135. onUnload() {
  136. uni.$off("updatePointTaskList")
  137. },
  138. methods: {
  139. // 获取查询参数 刷新列表
  140. refresh(params){
  141. // console.log(params,'1111111111')
  142. this.searchForm = params
  143. this.pageInit(1)
  144. },
  145. // 查询列表
  146. pageInit(pageNo){
  147. if (pageNo) {
  148. this.pageNo = pageNo
  149. }
  150. let params = {
  151. pageNo: this.pageNo,
  152. pageSize: this.pageSize,
  153. beginDate: this.searchForm.beginDate ? this.searchForm.beginDate : '',
  154. endDate: this.searchForm.endDate ? this.searchForm.endDate : '',
  155. storeName: this.searchForm.storeName ? this.searchForm.storeName : '',
  156. typeList: this.searchForm.sourceType ? this.searchForm.sourceType : [],
  157. status: this.typeId == '' ? '' : this.typeId // 任务状态
  158. }
  159. this.status = 'loading'
  160. queryMyTask(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. getDetails(item){
  178. uni.navigateTo({
  179. url: '/pages/shopTourDetails/shopTourDetails?taskId=' + item.id
  180. })
  181. },
  182. // tabs通知swiper切换
  183. tabsChange(index) {
  184. this.swiperCurrent = index
  185. },
  186. swiperChange(e) {
  187. this.action = 'swiperChange'
  188. this.status = 'loading'
  189. this.typeId = this.tabList[e.detail.current].code
  190. },
  191. // swiper-item左右移动,通知tabs的滑块跟随移动
  192. transition(e) {
  193. let dx = e.detail.dx
  194. this.$refs.uTabs.setDx(dx)
  195. },
  196. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  197. // swiper滑动结束,分别设置tabs和swiper的状态
  198. animationfinish(e) {
  199. let current = e.detail.current
  200. let isCurtab = this.current == current
  201. if(this.status!="nomore"){
  202. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab
  203. if(loadData){
  204. this.$refs.uTabs.setFinishCurrent(current)
  205. this.swiperCurrent = current
  206. this.current = current
  207. this.resetPage()
  208. }
  209. }
  210. },
  211. // scroll-view到底部加载更多
  212. onreachBottom() {
  213. this.action = 'onreachBottom'
  214. if (this.list.length < this.total) {
  215. this.pageNo += 1
  216. } else {
  217. this.status = 'nomore'
  218. }
  219. },
  220. // 打开筛选条件
  221. onNavigationBarButtonTap(e) {
  222. this.openScreen = true
  223. },
  224. // 初始化数据
  225. resetPage(){
  226. this.status = 'loading'
  227. // 上划分页
  228. if(this.action == 'onreachBottom'){
  229. this.pageInit()
  230. }
  231. // 左右切换tab
  232. if(this.action == 'swiperChange'){
  233. this.list = []
  234. this.pageInit(1)
  235. }
  236. },
  237. // 获取近几天的数据
  238. get7day(day){
  239. let today = new Date()
  240. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  241. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  242. let tYear = today.getFullYear()
  243. let tMonth = today.getMonth()
  244. let tDate = today.getDate()
  245. tMonth = this.doHandleMonth(tMonth + 1)
  246. tDate = this.doHandleMonth(tDate)
  247. return tYear + "-" + tMonth + "-" + tDate
  248. },
  249. // 月份
  250. doHandleMonth(month){
  251. let m = month
  252. if(month.toString().length == 1){
  253. m = "0" + month
  254. }
  255. return m
  256. },
  257. }
  258. }
  259. </script>
  260. <style lang="scss">
  261. page {
  262. background-color: #f8f8f8;
  263. height: calc(100vh - 44px);
  264. }
  265. .myShopTour-wrap {
  266. height: 100%;
  267. // 内容
  268. .myShopTour-con{
  269. .data-list{
  270. height: calc(100vh - 84px);
  271. .swiper-item{
  272. height: 100%;
  273. width: 100%;
  274. overflow: hidden;
  275. .scroll-con{
  276. height: 100%;
  277. width: 100%;
  278. overflow: auto;
  279. // 列表
  280. .record-con{
  281. position: relative;
  282. .alert-tips{
  283. position: fixed;
  284. top: 0upx;
  285. left: 0;
  286. width: 100%;
  287. z-index: 3;
  288. padding: 20upx 30upx 10upx;
  289. background-color: #fff;
  290. text{
  291. display: block;
  292. font-size: 24upx;
  293. padding: 4upx 10upx;
  294. border: 1upx solid #fcbd71;
  295. background-color: #fdf6ec;
  296. border-radius: 6upx;
  297. }
  298. }
  299. .record-item{
  300. background-color: #fff;
  301. margin: 20upx 30upx 20upx;
  302. padding: 14upx 30upx 20upx;
  303. border-radius: 12upx;
  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>