myShopTour.vue 12 KB

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