myShopTour.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="myShopTour-wrap">
  3. <!-- 自定义标题 -->
  4. <u-navbar :is-back="false" :border-bottom="false" :background="background" id="navbar">
  5. <view class="slot-wrap">
  6. <view class="back-icon" @click="goBack">
  7. <u-icon name="arrow-left" color="#fff" size="32"></u-icon>
  8. </view>
  9. <view class="left-icon">我的巡店</view>
  10. <view class="right-icon">
  11. <u-icon name="more-dot-fill" color="#fff" size="28" @click="openScreenFun"></u-icon>
  12. </view>
  13. </view>
  14. </u-navbar>
  15. <!-- 内容 -->
  16. <view class="myShopTour-con">
  17. <u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
  18. <swiper class="data-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  19. <swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
  20. <scroll-view scroll-y class="scroll-con" @scrolltolower="onreachBottom">
  21. <view class="record-con">
  22. <view v-show="searchForm.creatTime.length != 0" class="alert-tips">
  23. <text>{{searchForm.creatTime[0]}} ~ {{searchForm.creatTime[1]}}</text>
  24. </view>
  25. <view class="record-item" v-for="(item,index) in list" :key="index">
  26. <view class="item-head">
  27. <text class="item-c-tit">{{item.name}}</text>
  28. <u-tag class="item-c-type" :text="item.status" type="primary" />
  29. </view>
  30. <view class="item-main">
  31. <text class="item-tit">创建时间:</text>
  32. <text class="item-val">{{item.startTime}}</text>
  33. </view>
  34. <view class="item-main">
  35. <text class="item-tit">完成时间:</text>
  36. <text class="item-val">{{item.endTime}}</text>
  37. </view>
  38. <view class="item-main">
  39. <text class="item-tit">巡店耗时:</text>
  40. <text class="item-val">{{item.spendTime}}秒</text>
  41. </view>
  42. <u-grid class="item-grid" :col="4" hover-class="none">
  43. <u-grid-item>
  44. <text class="grid-num text-blue">{{item.totalTargetCount}}</text>
  45. <text class="grid-text">检查项</text>
  46. </u-grid-item>
  47. <u-grid-item>
  48. <text class="grid-num text-green">{{item.passTargetCount}}</text>
  49. <text class="grid-text">合格</text>
  50. </u-grid-item>
  51. <u-grid-item>
  52. <text class="grid-num text-red">{{item.notPassTargetCount}}</text>
  53. <text class="grid-text">不合格</text>
  54. </u-grid-item>
  55. <u-grid-item>
  56. <text class="grid-num text-yellow">{{item.notWorkTargetCount}}</text>
  57. <text class="grid-text">不适用</text>
  58. </u-grid-item>
  59. </u-grid>
  60. </view>
  61. </view>
  62. <u-empty text="暂无数据" img-width="120" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  63. <u-loadmore bg-color="#f8f8f8" v-if="list.length < total || status == 'loading'" :status="status" class="loadmore" />
  64. </scroll-view>
  65. </swiper-item>
  66. </swiper>
  67. </view>
  68. <!-- 筛选弹框 -->
  69. <u-popup v-model="openScreen" mode="right" length="80%" class="screenModel-wrap">
  70. <!-- 条件项 -->
  71. <view class="condition-con">
  72. <view class="screen-module">
  73. <text class="screen-tit">创建时间:</text>
  74. <view class="screen-time-val">
  75. <text @click="onShowDatePicker('range')">{{ range.length == 0 ? '请选择' : range[0] + '~' + range[1] }}</text>
  76. <u-icon v-show="range.length != 0" name="close-circle-fill" color="#c8c0cc" size="32" class="close-circle" @click="range=[]"></u-icon>
  77. </view>
  78. </view>
  79. <view class="screen-module">
  80. <text class="screen-tit">门店:</text>
  81. <view class="screen-inp-val">
  82. <u-input class="screen-inp" v-model="storeName" :height="52" placeholder="请输入" type="text" :border="true" />
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 按钮 -->
  87. <view class="btns">
  88. <u-button type="warning" shape="circle" size="mini" class="btn reset-btn" @click="resetF">重置</u-button>
  89. <u-button type="error" shape="circle" size="mini" class="btn ok-btn" @click="submitF">确定</u-button>
  90. </view>
  91. </u-popup>
  92. <!-- 选择创建时间 -->
  93. <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" />
  94. </view>
  95. </template>
  96. <script>
  97. import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue"
  98. import { queryMyTask } from '@/api/task.js'
  99. export default {
  100. components: { MxDatePicker },
  101. data() {
  102. return {
  103. background: {
  104. // 渐变色
  105. backgroundImage: 'linear-gradient(45deg, rgb(85, 170, 255), rgb(21, 102, 223))'
  106. },
  107. tabList: [ // tab切换 类型
  108. { dispName: '全部', code:'' },
  109. { dispName: '待处理', code:'0' },
  110. { dispName: '进行中', code:'1' },
  111. { dispName: '已完成', code:'2' },
  112. { dispName: '已过期', code:'3' }
  113. ],
  114. current: 0, // tabs组件的current值,表示当前活动的tab选项
  115. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  116. pageNo: 1, // 当前页码
  117. pageSize: 15, // 一页多少条
  118. total: 0, // 总条数
  119. status: 'loading', // 加载状态
  120. noDataText: '暂无数据', // 列表数据为空时提示文字
  121. list: [ // 数据列表
  122. { name: '常青二店', creatTime: '2020-09-08 09:16', orderStatus: 'haveInHand', completionTime: '2020-09-08 09:16', timeConsuming: '5小时18分钟', inspectionItems: 18, qualified: 14, unqualified: 2, notApplicable: 2 },
  123. { name: '常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店常青二店', creatTime: '2020-09-08 09:16', orderStatus: 'completed', completionTime: '2020-09-08 09:16', timeConsuming: '5小时18分钟', inspectionItems: 18, qualified: 14, unqualified: 2, notApplicable: 2 },
  124. { name: '常青二店', creatTime: '2020-09-08 09:16', orderStatus: 'invalid', completionTime: '2020-09-08 09:16', timeConsuming: '5小时18分钟', inspectionItems: 18, qualified: 14, unqualified: 2, notApplicable: 2 },
  125. { name: '常青二店', creatTime: '2020-09-08 09:16', orderStatus: 'haveInHand', completionTime: '2020-09-08 09:16', timeConsuming: '5小时18分钟', inspectionItems: 18, qualified: 14, unqualified: 2, notApplicable: 2 },
  126. { name: '常青二店', creatTime: '2020-09-08 09:16', orderStatus: 'completed', completionTime: '2020-09-08 09:16', timeConsuming: '5小时18分钟', inspectionItems: 18, qualified: 14, unqualified: 2, notApplicable: 2 },
  127. ],
  128. openScreen: false, // 是否打开筛选
  129. dateMode: 'range', // date单个日期 range日期范围
  130. searchForm: { // 查询条件
  131. creatTime: [], // 创建时间默认筛选近7天
  132. store: ''
  133. },
  134. showPicker: false, // 是否选择创建时间
  135. range: [], // 筛选创建时间的默认值
  136. type: 'range', // 日期时间类型
  137. storeName: '', // 筛选的门店名称
  138. }
  139. },
  140. onLoad() {
  141. this.pageInit()
  142. },
  143. methods: {
  144. // 返回
  145. goBack() {
  146. uni.navigateBack({
  147. delta: 1
  148. });
  149. },
  150. pageInit(){
  151. this.range = [ this.get7day(-6), this.get7day(0) ]
  152. this.searchForm.creatTime = [ this.get7day(-6), this.get7day(0) ]
  153. this.status = 'loading'
  154. queryMyTask({
  155. pageNo: this.pageNo,
  156. pageSize: this.pageSize,
  157. beginDate: this.searchForm.creatTime[0],
  158. endDate: this.searchForm.creatTime[1],
  159. storeName: this.searchForm.store
  160. }).then(res => {
  161. console.log(res)
  162. if(res.status == 200){
  163. if(this.pageNo>1){
  164. this.list = this.list.concat(res.data.list || [])
  165. }else{
  166. this.list = res.data.list || []
  167. }
  168. this.noDataText = '暂无数据' // 有列表数据时不显示,因此只用默认设置为无数据时所需显示的'暂无数据'即可
  169. this.total = res.data.count || 0
  170. }else{
  171. this.list = []
  172. this.noDataText = res.message
  173. this.total = 0
  174. }
  175. this.status = 'loadmore'
  176. })
  177. },
  178. // tabs通知swiper切换
  179. tabsChange(index) {
  180. this.swiperCurrent = index
  181. this.list = []
  182. this.status = "loading"
  183. },
  184. swiperChange(event){
  185. this.list = []
  186. this.status = "loading"
  187. },
  188. // swiper-item左右移动,通知tabs的滑块跟随移动
  189. transition(e) {
  190. let dx = e.detail.dx;
  191. this.$refs.uTabs.setDx(dx);
  192. },
  193. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  194. // swiper滑动结束,分别设置tabs和swiper的状态
  195. animationfinish(e) {
  196. let current = e.detail.current
  197. if(current != this.current){
  198. this.$refs.uTabs.setFinishCurrent(current)
  199. this.swiperCurrent = current
  200. this.current = current
  201. this.pageInit()
  202. }
  203. },
  204. // scroll-view到底部加载更多
  205. onreachBottom() {
  206. if(this.list.length < this.total){
  207. this.pageNo += 1
  208. this.pageInit()
  209. }else{
  210. this.status = "nomore"
  211. }
  212. },
  213. // 显示日期选择
  214. onShowDatePicker(type){
  215. this.type = type
  216. this.showPicker = true
  217. this.searchForm.creatTime = this[type]
  218. },
  219. // 日期选择
  220. onSelected(e) {
  221. this.showPicker = false
  222. if(e) {
  223. this[this.type] = e.value
  224. }
  225. },
  226. // 获取近几天的数据
  227. get7day(day){
  228. let today = new Date()
  229. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  230. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  231. let tYear = today.getFullYear()
  232. let tMonth = today.getMonth()
  233. let tDate = today.getDate()
  234. tMonth = this.doHandleMonth(tMonth + 1)
  235. tDate = this.doHandleMonth(tDate)
  236. return tYear + "-" + tMonth + "-" + tDate
  237. },
  238. // 月份
  239. doHandleMonth(month){
  240. let m = month
  241. if(month.toString().length == 1){
  242. m = "0" + month
  243. }
  244. return m
  245. },
  246. // 打开筛选条件
  247. openScreenFun(){
  248. this.openScreen = true
  249. },
  250. // 重置筛选条件
  251. resetF(){
  252. this.range = this.searchForm.creatTime
  253. this.storeName = this.searchForm.store
  254. },
  255. // 确定筛选
  256. submitF(){
  257. this.searchForm.creatTime = this.range
  258. this.searchForm.store = this.storeName
  259. this.openScreen = false
  260. this.pageInit()
  261. },
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. page {
  267. background-color: #f8f8f8;
  268. height: calc(100vh - 44px);
  269. }
  270. .myShopTour-wrap {
  271. height: 100%;
  272. /* 自定义导航栏样式 */
  273. .slot-wrap {
  274. display: flex;
  275. align-items: center;
  276. /* 如果您想让slot内容占满整个导航栏的宽度 */
  277. flex: 1;
  278. /* 如果您想让slot内容与导航栏左右有空隙 */
  279. padding: 0 30rpx;
  280. color: #fff;
  281. font-size: 28upx;
  282. .left-icon {
  283. flex-grow: 1;
  284. font-size: 32upx;
  285. margin-right: 10upx;
  286. text-align: center;
  287. }
  288. .right-icon {
  289. padding-left: 50upx;
  290. }
  291. .uni-icons {
  292. margin-right: 10upx;
  293. }
  294. }
  295. // 内容
  296. .myShopTour-con{
  297. .data-list{
  298. height: calc(100vh - 84px);
  299. .swiper-item{
  300. .scroll-con{
  301. height: 100%;
  302. // 列表
  303. .record-con{
  304. padding-top: 74upx;
  305. position: relative;
  306. .alert-tips{
  307. position: fixed;
  308. top: 0upx;
  309. left: 0;
  310. width: 100%;
  311. z-index: 3;
  312. padding: 20upx 30upx 10upx;
  313. background-color: #fff;
  314. text{
  315. display: block;
  316. font-size: 24upx;
  317. padding: 4upx 10upx;
  318. border: 1upx solid #fcbd71;
  319. background-color: #fdf6ec;
  320. border-radius: 6upx;
  321. }
  322. }
  323. .record-item{
  324. background-color: #fff;
  325. margin: 20upx 30upx 20upx;
  326. padding: 14upx 30upx 20upx;
  327. border-radius: 12upx;
  328. .item-head{
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. padding: 10upx 0;
  333. .item-c-tit{
  334. flex-grow: 1;
  335. padding-right: 18upx;
  336. font-weight: bold;
  337. }
  338. .item-c-type{
  339. flex-shrink: 0;
  340. }
  341. }
  342. .item-main{
  343. font-size: 26upx;
  344. line-height: 48upx;
  345. padding: 6upx 0;
  346. position: relative;
  347. .item-tit{
  348. display: inline-block;
  349. position: absolute;
  350. left: 0;
  351. top: 8upx;
  352. }
  353. .item-val{
  354. display: inline-block;
  355. padding-left: 150upx;
  356. }
  357. }
  358. .item-grid{
  359. margin-top: 10upx;
  360. .text-blue{
  361. color: #2979ff;
  362. }
  363. .text-green{
  364. color: #19be6b;
  365. }
  366. .text-red{
  367. color: #fa3534;
  368. }
  369. .text-yellow{
  370. color: #ff9900;
  371. }
  372. .grid-num{
  373. font-weight: bold;
  374. }
  375. .grid-text{
  376. font-size: 26upx;
  377. padding-top: 10upx;
  378. color: #666;
  379. }
  380. }
  381. }
  382. }
  383. .loadmore{
  384. padding: 30upx;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .screenModel-wrap{
  391. padding-bottom: 80upx;
  392. .condition-con{
  393. padding: 20upx 30upx;
  394. .screen-module{
  395. margin: 0 0 20upx;
  396. .screen-tit{
  397. color: #464646;
  398. font-size: 26upx;
  399. }
  400. .screen-time-val{
  401. font-size: 26upx;
  402. background-color: #f4f4f4;
  403. border-radius: 12upx;
  404. padding: 10upx 14upx;
  405. margin: 10upx 0;
  406. text-align: center;
  407. text{
  408. display: inline-block;
  409. width: 85%;
  410. }
  411. .close-circle{
  412. display: inline-block;
  413. padding-left: 3%;
  414. vertical-align: bottom;
  415. }
  416. }
  417. .screen-inp-val{
  418. margin: 10upx 0;
  419. .screen-inp{
  420. color: #464646;
  421. font-size: 26upx;
  422. }
  423. }
  424. }
  425. }
  426. .btns{
  427. position: fixed;
  428. bottom: 0;
  429. left: 0;
  430. width: 100%;
  431. background-color: rgba(0,0,0,.025);
  432. .btn{
  433. width: 40%;
  434. margin: 20upx 5%;
  435. padding: 30upx 0;
  436. }
  437. }
  438. }
  439. .choose-date-wrap{
  440. z-index: 999999;
  441. }
  442. }
  443. </style>