myShopTour.vue 12 KB

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