myShopTour.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. <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 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" @openPicke="openPicker" @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 { getLookUpDatas } from '@/api/data.js'
  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: 15, // 一页多少条
  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. formatTime(s){
  113. let time = ''
  114. if(moment.duration(s*1000).hours()){
  115. time += moment.duration(s*1000).hours() + '时'
  116. }
  117. if(moment.duration(s*1000).minutes()){
  118. time += moment.duration(s*1000).minutes() + '分'
  119. }
  120. if(moment.duration(s*1000).seconds()){
  121. time += moment.duration(s*1000).seconds() + '秒'
  122. }
  123. return time
  124. }
  125. },
  126. onLoad() {
  127. this.getLookUpData('TASK_STATUS') // 获取任务状态
  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. getLookUpData(code) {
  147. getLookUpDatas({ type: code }).then(res => {
  148. if (res.status == 200) {
  149. if(code == 'TASK_STATUS'){ // 状态
  150. res.data.unshift({dispName: '全部', code: ''})
  151. this.tabList = res.data
  152. }
  153. }
  154. })
  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. if(res.status == 200){
  173. if(this.pageNo>1){
  174. this.list = this.list.concat(res.data.list || [])
  175. }else{
  176. this.list = res.data.list || []
  177. }
  178. this.total = res.data.count || 0
  179. }else{
  180. this.list = []
  181. this.total = 0
  182. this.noDataText = res.message || '暂无数据'
  183. }
  184. this.status = 'loadmore'
  185. })
  186. },
  187. // 查看详情
  188. getDetails(item){
  189. if(item.type == 'POINT_INSPECTION'){ // 点检任务
  190. uni.navigateTo({
  191. url: '/pages/spotCheckDetails/spotCheckDetails?taskId=' + item.id
  192. })
  193. }else{ // 现场巡店、视频巡店
  194. uni.navigateTo({
  195. url: '/pages/shopTourDetails/shopTourDetails?taskId=' + item.id
  196. })
  197. }
  198. },
  199. // tabs通知swiper切换
  200. tabsChange(index) {
  201. this.swiperCurrent = index
  202. },
  203. swiperChange(e) {
  204. this.action = 'swiperChange'
  205. this.status = 'loading'
  206. this.typeId = this.tabList[e.detail.current].code
  207. },
  208. // swiper-item左右移动,通知tabs的滑块跟随移动
  209. transition(e) {
  210. let dx = e.detail.dx
  211. this.$refs.uTabs.setDx(dx)
  212. },
  213. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  214. // swiper滑动结束,分别设置tabs和swiper的状态
  215. animationfinish(e) {
  216. let current = e.detail.current
  217. let isCurtab = this.current == current
  218. if(this.status!="nomore"){
  219. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab
  220. if(loadData){
  221. this.$refs.uTabs.setFinishCurrent(current)
  222. this.swiperCurrent = current
  223. this.current = current
  224. this.resetPage()
  225. }
  226. }
  227. },
  228. // scroll-view到底部加载更多
  229. onreachBottom() {
  230. this.action = 'onreachBottom'
  231. if (this.list.length < this.total) {
  232. this.pageNo += 1
  233. } else {
  234. this.status = 'nomore'
  235. }
  236. },
  237. // 打开筛选条件
  238. onNavigationBarButtonTap(e) {
  239. this.openScreen = true
  240. },
  241. // 初始化数据
  242. resetPage(){
  243. this.status = 'loading'
  244. // 上划分页
  245. if(this.action == 'onreachBottom'){
  246. this.pageInit()
  247. }
  248. // 左右切换tab
  249. if(this.action == 'swiperChange'){
  250. this.list = []
  251. this.pageInit(1)
  252. }
  253. },
  254. // 获取近几天的数据
  255. get7day(day){
  256. let today = new Date()
  257. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  258. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  259. let tYear = today.getFullYear()
  260. let tMonth = today.getMonth()
  261. let tDate = today.getDate()
  262. tMonth = this.doHandleMonth(tMonth + 1)
  263. tDate = this.doHandleMonth(tDate)
  264. return tYear + "-" + tMonth + "-" + tDate
  265. },
  266. // 月份
  267. doHandleMonth(month){
  268. let m = month
  269. if(month.toString().length == 1){
  270. m = "0" + month
  271. }
  272. return m
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="scss">
  278. page {
  279. background-color: #f8f8f8;
  280. height: calc(100vh - 44px);
  281. }
  282. .myShopTour-wrap {
  283. height: 100%;
  284. // 内容
  285. .myShopTour-con{
  286. .data-list{
  287. height: calc(100vh - 84px);
  288. .swiper-item{
  289. height: 100%;
  290. width: 100%;
  291. overflow: hidden;
  292. .scroll-con{
  293. height: 100%;
  294. width: 100%;
  295. overflow: auto;
  296. // 列表
  297. .record-con{
  298. position: relative;
  299. .alert-tips{
  300. position: fixed;
  301. top: 0upx;
  302. left: 0;
  303. width: 100%;
  304. z-index: 3;
  305. padding: 20upx 30upx 10upx;
  306. background-color: #fff;
  307. text{
  308. display: block;
  309. font-size: 24upx;
  310. padding: 4upx 10upx;
  311. border: 1upx solid #fcbd71;
  312. background-color: #fdf6ec;
  313. border-radius: 6upx;
  314. }
  315. }
  316. .record-item{
  317. background-color: #fff;
  318. margin: 20upx 30upx 20upx;
  319. padding: 14upx 30upx 20upx;
  320. border-radius: 12upx;
  321. .item-head{
  322. display: flex;
  323. justify-content: space-between;
  324. align-items: center;
  325. padding: 10upx 0;
  326. .item-c-tit{
  327. flex-grow: 1;
  328. padding-right: 18upx;
  329. font-weight: bold;
  330. }
  331. .item-c-type{
  332. flex-shrink: 0;
  333. }
  334. }
  335. .item-main{
  336. font-size: 26upx;
  337. line-height: 48upx;
  338. padding: 6upx 0;
  339. position: relative;
  340. .item-tit{
  341. display: inline-block;
  342. position: absolute;
  343. left: 0;
  344. top: 8upx;
  345. }
  346. .item-val{
  347. display: inline-block;
  348. padding-left: 150upx;
  349. }
  350. }
  351. .item-grid{
  352. margin-top: 10upx;
  353. .text-blue{
  354. color: #2979ff;
  355. }
  356. .text-green{
  357. color: #19be6b;
  358. }
  359. .text-red{
  360. color: #fa3534;
  361. }
  362. .text-yellow{
  363. color: #ff9900;
  364. }
  365. .grid-num{
  366. font-weight: bold;
  367. }
  368. .grid-text{
  369. font-size: 26upx;
  370. padding-top: 10upx;
  371. color: #666;
  372. }
  373. }
  374. }
  375. }
  376. .loadmore{
  377. padding: 30upx;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .screenModel-wrap{
  384. padding-bottom: 80upx;
  385. .condition-con{
  386. padding: 20upx 30upx;
  387. .screen-module{
  388. margin: 0 0 20upx;
  389. .screen-tit{
  390. color: #464646;
  391. font-size: 26upx;
  392. }
  393. .screen-time-val{
  394. font-size: 26upx;
  395. background-color: #f4f4f4;
  396. border-radius: 12upx;
  397. padding: 10upx 14upx;
  398. margin: 10upx 0;
  399. text-align: center;
  400. text{
  401. display: inline-block;
  402. width: 85%;
  403. }
  404. .close-circle{
  405. display: inline-block;
  406. padding-left: 3%;
  407. vertical-align: bottom;
  408. }
  409. }
  410. .screen-inp-val{
  411. margin: 10upx 0;
  412. .screen-inp{
  413. color: #464646;
  414. font-size: 26upx;
  415. }
  416. }
  417. }
  418. }
  419. .btns{
  420. position: fixed;
  421. bottom: 0;
  422. left: 0;
  423. width: 100%;
  424. background-color: rgba(0,0,0,.025);
  425. .btn{
  426. width: 40%;
  427. margin: 20upx 5%;
  428. padding: 30upx 0;
  429. }
  430. }
  431. }
  432. }
  433. </style>