myShopTour.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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.orderStatus" type="primary" />
  29. </view>
  30. <view class="item-main">
  31. <text class="item-tit">创建时间:</text>
  32. <text class="item-val">{{item.creatTime}}</text>
  33. </view>
  34. <view class="item-main">
  35. <text class="item-tit">完成时间:</text>
  36. <text class="item-val">{{item.completionTime}}</text>
  37. </view>
  38. <view class="item-main">
  39. <text class="item-tit">巡店耗时:</text>
  40. <text class="item-val">{{item.timeConsuming}}</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">18</text>
  45. <text class="grid-text">检查项</text>
  46. </u-grid-item>
  47. <u-grid-item>
  48. <text class="grid-num text-green">13</text>
  49. <text class="grid-text">合格</text>
  50. </u-grid-item>
  51. <u-grid-item>
  52. <text class="grid-num text-red">3</text>
  53. <text class="grid-text">不合格</text>
  54. </u-grid-item>
  55. <u-grid-item>
  56. <text class="grid-num text-yellow">2</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. export default {
  99. components: { MxDatePicker },
  100. data() {
  101. return {
  102. background: {
  103. // 渐变色
  104. backgroundImage: 'linear-gradient(45deg, rgb(85, 170, 255), rgb(21, 102, 223))'
  105. },
  106. tabList: [ // tab切换 类型
  107. { dispName: '全部', code:'' },
  108. { dispName: '待处理', code:'0' },
  109. { dispName: '进行中', code:'1' },
  110. { dispName: '已完成', code:'2' },
  111. { dispName: '已过期', code:'3' }
  112. ],
  113. current: 0, // tabs组件的current值,表示当前活动的tab选项
  114. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  115. pageNo: 1, // 当前页码
  116. pageSize: 15, // 一页多少条
  117. total: 0, // 总条数
  118. // status: 'loading', // 加载状态
  119. status: 'loadmore', // 加载状态
  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.total = 0
  154. this.pageNo = 1
  155. },
  156. // tabs通知swiper切换
  157. tabsChange(index) {
  158. this.swiperCurrent = index
  159. this.list = []
  160. this.status = "loading"
  161. },
  162. swiperChange(event){
  163. this.list = []
  164. this.status = "loading"
  165. },
  166. // swiper-item左右移动,通知tabs的滑块跟随移动
  167. transition(e) {
  168. let dx = e.detail.dx;
  169. this.$refs.uTabs.setDx(dx);
  170. },
  171. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  172. // swiper滑动结束,分别设置tabs和swiper的状态
  173. animationfinish(e) {
  174. let current = e.detail.current
  175. if(current != this.current){
  176. this.$refs.uTabs.setFinishCurrent(current)
  177. this.swiperCurrent = current
  178. this.current = current
  179. this.pageInit()
  180. }
  181. },
  182. // scroll-view到底部加载更多
  183. onreachBottom() {
  184. if(this.list.length < this.total){
  185. this.pageNo += 1
  186. this.pageInit()
  187. }else{
  188. this.status = "nomore"
  189. }
  190. },
  191. // 显示日期选择
  192. onShowDatePicker(type){
  193. this.type = type
  194. this.showPicker = true
  195. this.searchForm.creatTime = this[type]
  196. },
  197. // 日期选择
  198. onSelected(e) {
  199. this.showPicker = false
  200. if(e) {
  201. this[this.type] = e.value
  202. }
  203. },
  204. // 获取近几天的数据
  205. get7day(day){
  206. let today = new Date()
  207. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  208. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  209. let tYear = today.getFullYear()
  210. let tMonth = today.getMonth()
  211. let tDate = today.getDate()
  212. tMonth = this.doHandleMonth(tMonth + 1)
  213. tDate = this.doHandleMonth(tDate)
  214. return tYear + "-" + tMonth + "-" + tDate
  215. },
  216. // 月份
  217. doHandleMonth(month){
  218. let m = month
  219. if(month.toString().length == 1){
  220. m = "0" + month
  221. }
  222. return m
  223. },
  224. // 打开筛选条件
  225. openScreenFun(){
  226. this.openScreen = true
  227. },
  228. // 重置筛选条件
  229. resetF(){
  230. this.range = this.searchForm.creatTime
  231. this.storeName = this.searchForm.store
  232. },
  233. // 确定筛选
  234. submitF(){
  235. this.searchForm.creatTime = this.range
  236. this.searchForm.store = this.storeName
  237. this.openScreen = false
  238. },
  239. }
  240. }
  241. </script>
  242. <style lang="scss" scoped>
  243. page {
  244. background-color: #f8f8f8;
  245. height: calc(100vh - 44px);
  246. }
  247. .myShopTour-wrap {
  248. height: 100%;
  249. /* 自定义导航栏样式 */
  250. .slot-wrap {
  251. display: flex;
  252. align-items: center;
  253. /* 如果您想让slot内容占满整个导航栏的宽度 */
  254. flex: 1;
  255. /* 如果您想让slot内容与导航栏左右有空隙 */
  256. padding: 0 30rpx;
  257. color: #fff;
  258. font-size: 28upx;
  259. .left-icon {
  260. flex-grow: 1;
  261. font-size: 32upx;
  262. margin-right: 10upx;
  263. text-align: center;
  264. }
  265. .right-icon {
  266. padding-left: 50upx;
  267. }
  268. .uni-icons {
  269. margin-right: 10upx;
  270. }
  271. }
  272. // 内容
  273. .myShopTour-con{
  274. .data-list{
  275. height: calc(100vh - 84px);
  276. .swiper-item{
  277. .scroll-con{
  278. height: 100%;
  279. // 列表
  280. .record-con{
  281. padding-top: 74upx;
  282. position: relative;
  283. .alert-tips{
  284. position: fixed;
  285. top: 0upx;
  286. left: 0;
  287. width: 100%;
  288. z-index: 3;
  289. padding: 20upx 30upx 10upx;
  290. background-color: #fff;
  291. text{
  292. display: block;
  293. font-size: 24upx;
  294. padding: 4upx 10upx;
  295. border: 1upx solid #fcbd71;
  296. background-color: #fdf6ec;
  297. border-radius: 6upx;
  298. }
  299. }
  300. .record-item{
  301. background-color: #fff;
  302. margin: 20upx 30upx 20upx;
  303. padding: 14upx 30upx 20upx;
  304. border-radius: 12upx;
  305. .item-head{
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. padding: 10upx 0;
  310. .item-c-tit{
  311. flex-grow: 1;
  312. padding-right: 18upx;
  313. font-weight: bold;
  314. }
  315. .item-c-type{
  316. flex-shrink: 0;
  317. }
  318. }
  319. .item-main{
  320. font-size: 26upx;
  321. line-height: 48upx;
  322. padding: 6upx 0;
  323. position: relative;
  324. .item-tit{
  325. display: inline-block;
  326. position: absolute;
  327. left: 0;
  328. top: 8upx;
  329. }
  330. .item-val{
  331. display: inline-block;
  332. padding-left: 150upx;
  333. }
  334. }
  335. .item-grid{
  336. margin-top: 10upx;
  337. .text-blue{
  338. color: #2979ff;
  339. }
  340. .text-green{
  341. color: #19be6b;
  342. }
  343. .text-red{
  344. color: #fa3534;
  345. }
  346. .text-yellow{
  347. color: #ff9900;
  348. }
  349. .grid-num{
  350. font-weight: bold;
  351. }
  352. .grid-text{
  353. font-size: 26upx;
  354. padding-top: 10upx;
  355. color: #666;
  356. }
  357. }
  358. }
  359. }
  360. .loadmore{
  361. padding: 30upx;
  362. }
  363. }
  364. }
  365. }
  366. }
  367. .screenModel-wrap{
  368. padding-bottom: 80upx;
  369. .condition-con{
  370. padding: 20upx 30upx;
  371. .screen-module{
  372. margin: 0 0 20upx;
  373. .screen-tit{
  374. color: #464646;
  375. font-size: 26upx;
  376. }
  377. .screen-time-val{
  378. font-size: 26upx;
  379. background-color: #f4f4f4;
  380. border-radius: 12upx;
  381. padding: 10upx 14upx;
  382. margin: 10upx 0;
  383. text-align: center;
  384. text{
  385. display: inline-block;
  386. width: 85%;
  387. }
  388. .close-circle{
  389. display: inline-block;
  390. padding-left: 3%;
  391. vertical-align: bottom;
  392. }
  393. }
  394. .screen-inp-val{
  395. margin: 10upx 0;
  396. .screen-inp{
  397. color: #464646;
  398. font-size: 26upx;
  399. }
  400. }
  401. }
  402. }
  403. .btns{
  404. position: fixed;
  405. bottom: 0;
  406. left: 0;
  407. width: 100%;
  408. background-color: rgba(0,0,0,.025);
  409. .btn{
  410. width: 40%;
  411. margin: 20upx 5%;
  412. padding: 30upx 0;
  413. }
  414. }
  415. }
  416. .choose-date-wrap{
  417. z-index: 999999;
  418. }
  419. }
  420. </style>