myShopTour.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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">
  10. <!-- 筛选日期,近7天 -->
  11. <view v-show="searchForm.creatTime.length != 0" class="alert-tips">
  12. <text>{{searchForm.creatTime[0]}} ~ {{searchForm.creatTime[1]}}</text>
  13. </view>
  14. <view class="record-item" v-if="index==current" v-for="(item,sindex) in list" :key="item.id">
  15. <view class="item-head">
  16. <text class="item-c-tit">{{item.name}}</text>
  17. <u-tag class="item-c-type" :text="item.status" 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}}</text>
  26. </view>
  27. <view class="item-main">
  28. <text class="item-tit">巡店耗时:</text>
  29. <text class="item-val">{{item.spendTime}}秒</text>
  30. </view>
  31. <u-grid class="item-grid" :col="4" hover-class="none">
  32. <u-grid-item>
  33. <text class="grid-num text-blue">{{item.totalTargetCount}}</text>
  34. <text class="grid-text">检查项</text>
  35. </u-grid-item>
  36. <u-grid-item>
  37. <text class="grid-num text-green">{{item.passTargetCount}}</text>
  38. <text class="grid-text">合格</text>
  39. </u-grid-item>
  40. <u-grid-item>
  41. <text class="grid-num text-red">{{item.notPassTargetCount}}</text>
  42. <text class="grid-text">不合格</text>
  43. </u-grid-item>
  44. <u-grid-item>
  45. <text class="grid-num text-yellow">{{item.notWorkTargetCount}}</text>
  46. <text class="grid-text">不适用</text>
  47. </u-grid-item>
  48. </u-grid>
  49. </view>
  50. </view>
  51. <u-empty text="暂无数据" img-width="120" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  52. <u-loadmore bg-color="#f8f8f8" v-if="list.length < total || status == 'loading'" :status="status" class="loadmore" />
  53. </scroll-view>
  54. </swiper-item>
  55. </swiper>
  56. </view>
  57. <!-- 筛选弹框 -->
  58. <u-popup v-model="openScreen" mode="right" length="80%" class="screenModel-wrap">
  59. <!-- 条件项 -->
  60. <view class="condition-con">
  61. <view class="screen-module">
  62. <text class="screen-tit">创建时间:</text>
  63. <view class="screen-time-val">
  64. <text @click="onShowDatePicker('range')">{{ range.length == 0 ? '请选择' : range[0] + '~' + range[1] }}</text>
  65. <u-icon v-show="range.length != 0" name="close-circle-fill" color="#c8c0cc" size="32" class="close-circle" @click="range=[]"></u-icon>
  66. </view>
  67. </view>
  68. <view class="screen-module">
  69. <text class="screen-tit">门店:</text>
  70. <view class="screen-inp-val">
  71. <u-input class="screen-inp" v-model="storeName" :height="52" placeholder="请输入" type="text" :border="true" />
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 按钮 -->
  76. <view class="btns">
  77. <u-button type="warning" shape="circle" size="mini" class="btn reset-btn" @click="resetF">重置</u-button>
  78. <u-button type="error" shape="circle" size="mini" class="btn ok-btn" @click="submitF">确定</u-button>
  79. </view>
  80. </u-popup>
  81. <!-- 选择创建时间 -->
  82. <!-- <mx-date-picker class="choose-date-wrap" :show="showPicker" :type="type" :value="searchForm.creatTime" :show-tips="true" :begin-text="'开始'" :end-text="'结束'" :show-seconds="true" @confirm="onSelected" @cancel="onSelected" /> -->
  83. <w-picker
  84. :visible.sync="showPicker"
  85. mode="range"
  86. startYear="2017"
  87. endYear="2030"
  88. :value="searchForm.creatTime"
  89. :current="false"
  90. @confirm="onSelected($event,'range')"
  91. @cancel="onSelected"
  92. ref="range"></w-picker>
  93. </view>
  94. </template>
  95. <script>
  96. import wPicker from "@/components/w-picker/w-picker.vue"
  97. import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue"
  98. import { queryMyTask } from '@/api/task.js'
  99. export default {
  100. components: { MxDatePicker, wPicker },
  101. data() {
  102. return {
  103. tabList: [ // tab切换 类型
  104. { dispName: '全部', code:'' },
  105. { dispName: '待处理', code:'0' },
  106. { dispName: '进行中', code:'1' },
  107. { dispName: '已完成', code:'2' },
  108. { dispName: '已过期', code:'3' }
  109. ],
  110. current: 0, // tabs组件的current值,表示当前活动的tab选项
  111. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  112. pageNo: 1, // 当前页码
  113. pageSize: 15, // 一页多少条
  114. total: 0, // 总条数
  115. status: 'loading', // 加载状态
  116. noDataText: '暂无数据', // 列表数据为空时提示文字
  117. list: [], // 数据列表
  118. openScreen: false, // 是否打开筛选
  119. dateMode: 'range', // date单个日期 range日期范围
  120. searchForm: { // 查询条件
  121. creatTime: [], // 创建时间默认筛选近7天
  122. store: ''
  123. },
  124. showPicker: false, // 是否选择创建时间
  125. range: [], // 筛选创建时间的默认值
  126. type: 'range', // 日期时间类型
  127. storeName: '', // 筛选的门店名称
  128. typeId: '', // 记录状态
  129. action:'swiperChange', // 操作类型,上划分页,或左右滑动
  130. }
  131. },
  132. onLoad() {
  133. this.resetPage()
  134. this.range = [ this.get7day(-6), this.get7day(0) ]
  135. this.searchForm.creatTime = [ this.get7day(-6), this.get7day(0) ]
  136. uni.$on("updatePointTaskList",()=>{
  137. this.resetPage()
  138. })
  139. },
  140. onUnload() {
  141. uni.$off("updatePointTaskList")
  142. },
  143. methods: {
  144. // 查询列表
  145. pageInit(pageNo){
  146. if (pageNo) {
  147. this.pageNo = pageNo
  148. }
  149. let params = {
  150. pageNo: this.pageNo,
  151. pageSize: this.pageSize,
  152. beginDate: this.searchForm.creatTime[0],
  153. endDate: this.searchForm.creatTime[1],
  154. storeName: this.searchForm.store,
  155. status: this.typeId==''?'':this.typeId // 任务状态
  156. }
  157. this.status = 'loading'
  158. queryMyTask(params).then(res => {
  159. if(res.status == 200){
  160. if(this.pageNo>1){
  161. this.list = this.list.concat(res.data.list || [])
  162. }else{
  163. this.list = res.data.list || []
  164. }
  165. this.total = res.data.count || 0
  166. }else{
  167. this.list = []
  168. this.total = 0
  169. this.noDataText = res.message || '暂无数据'
  170. }
  171. this.status = 'loadmore'
  172. })
  173. },
  174. // tabs通知swiper切换
  175. tabsChange(index) {
  176. this.swiperCurrent = index
  177. },
  178. swiperChange(e) {
  179. this.action = 'swiperChange'
  180. this.status = 'loading'
  181. this.typeId = this.tabList[e.detail.current].code
  182. },
  183. // swiper-item左右移动,通知tabs的滑块跟随移动
  184. transition(e) {
  185. let dx = e.detail.dx
  186. this.$refs.uTabs.setDx(dx)
  187. },
  188. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  189. // swiper滑动结束,分别设置tabs和swiper的状态
  190. animationfinish(e) {
  191. let current = e.detail.current
  192. let isCurtab = this.current == current
  193. if(this.status!="nomore"){
  194. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab
  195. if(loadData){
  196. this.$refs.uTabs.setFinishCurrent(current)
  197. this.swiperCurrent = current
  198. this.current = current
  199. this.resetPage()
  200. }
  201. }
  202. },
  203. // scroll-view到底部加载更多
  204. onreachBottom() {
  205. this.action = 'onreachBottom'
  206. if (this.list.length < this.total) {
  207. this.pageNo += 1
  208. } else {
  209. this.status = 'nomore'
  210. }
  211. },
  212. // 初始化数据
  213. resetPage(){
  214. this.status = 'loading'
  215. // 上划分页
  216. if(this.action == 'onreachBottom'){
  217. this.pageInit()
  218. }
  219. // 左右切换tab
  220. if(this.action == 'swiperChange'){
  221. this.list = []
  222. this.pageInit(1)
  223. }
  224. },
  225. // 选择日期范围
  226. onSelected(e){
  227. this.showPicker = false
  228. if(e) {
  229. this.range = e.value
  230. }
  231. },
  232. // 显示日期选择
  233. onShowDatePicker(type){
  234. this.showPicker = true
  235. this.searchForm.creatTime = this.range
  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. onNavigationBarButtonTap(e) {
  259. this.resetF()
  260. this.openScreen = true
  261. },
  262. // 重置筛选条件
  263. resetF(){
  264. this.range = this.searchForm.creatTime
  265. this.storeName = this.searchForm.store
  266. },
  267. // 确定筛选
  268. submitF(){
  269. this.searchForm.creatTime = this.range
  270. this.searchForm.store = this.storeName
  271. this.openScreen = false
  272. this.pageInit()
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  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. padding-top: 74upx;
  299. position: relative;
  300. .alert-tips{
  301. position: fixed;
  302. top: 0upx;
  303. left: 0;
  304. width: 100%;
  305. z-index: 3;
  306. padding: 20upx 30upx 10upx;
  307. background-color: #fff;
  308. text{
  309. display: block;
  310. font-size: 24upx;
  311. padding: 4upx 10upx;
  312. border: 1upx solid #fcbd71;
  313. background-color: #fdf6ec;
  314. border-radius: 6upx;
  315. }
  316. }
  317. .record-item{
  318. background-color: #fff;
  319. margin: 20upx 30upx 20upx;
  320. padding: 14upx 30upx 20upx;
  321. border-radius: 12upx;
  322. .item-head{
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. padding: 10upx 0;
  327. .item-c-tit{
  328. flex-grow: 1;
  329. padding-right: 18upx;
  330. font-weight: bold;
  331. }
  332. .item-c-type{
  333. flex-shrink: 0;
  334. }
  335. }
  336. .item-main{
  337. font-size: 26upx;
  338. line-height: 48upx;
  339. padding: 6upx 0;
  340. position: relative;
  341. .item-tit{
  342. display: inline-block;
  343. position: absolute;
  344. left: 0;
  345. top: 8upx;
  346. }
  347. .item-val{
  348. display: inline-block;
  349. padding-left: 150upx;
  350. }
  351. }
  352. .item-grid{
  353. margin-top: 10upx;
  354. .text-blue{
  355. color: #2979ff;
  356. }
  357. .text-green{
  358. color: #19be6b;
  359. }
  360. .text-red{
  361. color: #fa3534;
  362. }
  363. .text-yellow{
  364. color: #ff9900;
  365. }
  366. .grid-num{
  367. font-weight: bold;
  368. }
  369. .grid-text{
  370. font-size: 26upx;
  371. padding-top: 10upx;
  372. color: #666;
  373. }
  374. }
  375. }
  376. }
  377. .loadmore{
  378. padding: 30upx;
  379. }
  380. }
  381. }
  382. }
  383. }
  384. .screenModel-wrap{
  385. padding-bottom: 80upx;
  386. .condition-con{
  387. padding: 20upx 30upx;
  388. .screen-module{
  389. margin: 0 0 20upx;
  390. .screen-tit{
  391. color: #464646;
  392. font-size: 26upx;
  393. }
  394. .screen-time-val{
  395. font-size: 26upx;
  396. background-color: #f4f4f4;
  397. border-radius: 12upx;
  398. padding: 10upx 14upx;
  399. margin: 10upx 0;
  400. text-align: center;
  401. text{
  402. display: inline-block;
  403. width: 85%;
  404. }
  405. .close-circle{
  406. display: inline-block;
  407. padding-left: 3%;
  408. vertical-align: bottom;
  409. }
  410. }
  411. .screen-inp-val{
  412. margin: 10upx 0;
  413. .screen-inp{
  414. color: #464646;
  415. font-size: 26upx;
  416. }
  417. }
  418. }
  419. }
  420. .btns{
  421. position: fixed;
  422. bottom: 0;
  423. left: 0;
  424. width: 100%;
  425. background-color: rgba(0,0,0,.025);
  426. .btn{
  427. width: 40%;
  428. margin: 20upx 5%;
  429. padding: 30upx 0;
  430. }
  431. }
  432. }
  433. }
  434. </style>