myShopTour.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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="openScreen=true"></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">{{searchForm.creatTime[0]}} ~ {{searchForm.creatTime[1]}}</view>
  23. <view class="record-item" v-for="(item,index) in list" :key="index">
  24. <view class="item-head">
  25. <text class="item-c-tit">{{item.name}}</text>
  26. <u-tag class="item-c-type" :text="item.orderStatus" type="primary" />
  27. </view>
  28. <view class="item-main">
  29. <text class="item-tit">创建时间:</text>
  30. <text class="item-val">{{item.creatTime}}</text>
  31. </view>
  32. <view class="item-main">
  33. <text class="item-tit">完成时间:</text>
  34. <text class="item-val">{{item.completionTime}}</text>
  35. </view>
  36. <view class="item-main">
  37. <text class="item-tit">巡店耗时:</text>
  38. <text class="item-val">{{item.timeConsuming}}</text>
  39. </view>
  40. <u-grid class="item-grid" :col="4" hover-class="none">
  41. <u-grid-item>
  42. <text class="grid-num text-blue">18</text>
  43. <text class="grid-text">检查项</text>
  44. </u-grid-item>
  45. <u-grid-item>
  46. <text class="grid-num text-green">13</text>
  47. <text class="grid-text">合格</text>
  48. </u-grid-item>
  49. <u-grid-item>
  50. <text class="grid-num text-red">3</text>
  51. <text class="grid-text">不合格</text>
  52. </u-grid-item>
  53. <u-grid-item>
  54. <text class="grid-num text-yellow">2</text>
  55. <text class="grid-text">不适用</text>
  56. </u-grid-item>
  57. </u-grid>
  58. </view>
  59. </view>
  60. <u-empty text="暂无数据" img-width="120" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  61. <u-loadmore bg-color="#f8f8f8" v-if="list.length < total || status == 'loading'" :status="status" class="loadmore" />
  62. </scroll-view>
  63. </swiper-item>
  64. </swiper>
  65. </view>
  66. <!-- 筛选弹框 -->
  67. <u-popup v-model="openScreen" mode="right" length="60%" class="screenModel-wrap">
  68. <!-- 条件项 -->
  69. <view class="condition-con">
  70. <view class="condition-item">
  71. <text class="condition-tit">创建时间</text>
  72. <view class="condition-val">
  73. <text @click="onShowDatePicker('range')">{{range[0] ? range[0] : '请选择'}} ~ {{range[1] ? range[1] : '请选择'}}</text>
  74. <u-icon v-show="range.length != 0" name="close-circle" color="#999" size="28" class="close-circle" @click="range=[]"></u-icon>
  75. </view>
  76. </view>
  77. <view class="condition-item">
  78. <text class="condition-tit">门店</text>
  79. <view class="condition-val">
  80. <text @click="openStore=!openStore">{{storeName ? storeName : '全部'}}</text>
  81. <u-icon v-show="storeName" name="close-circle" color="#999" size="28" class="close-circle" @click="clearStore"></u-icon>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 按钮 -->
  86. <view class="btns">
  87. <u-button type="warning" shape="circle" size="mini" class="btn reset-btn" @click="resetF">重置</u-button>
  88. <u-button type="error" shape="circle" size="mini" class="btn ok-btn" @click="submitF">确定</u-button>
  89. </view>
  90. </u-popup>
  91. <!-- 选择创建时间 -->
  92. <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" />
  93. <!-- 选择门店 -->
  94. <u-select v-model="openStore" :default-value="defaultStoreValue" :list="storeList" @confirm="confirmStore" class="choose-store-wrap"></u-select>
  95. </view>
  96. </template>
  97. <script>
  98. import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue"
  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:'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: 'invalid', 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: 'haveInHand', 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: 'completed', 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. openStore: false, // 选择门店
  135. storeList: [
  136. { value: '1', label: '江' },
  137. { value: '2', label: '河' }
  138. ],
  139. showPicker: false, // 是否选择创建时间
  140. range: [], // 筛选创建时间的默认值
  141. type: 'range', // 日期时间类型
  142. storeName: '', // 筛选门店名称
  143. defaultStoreValue: [], // 门店默认选中下标
  144. }
  145. },
  146. onLoad() {
  147. this.pageInit()
  148. },
  149. methods: {
  150. // 返回
  151. goBack() {
  152. uni.navigateBack({
  153. delta: 1
  154. });
  155. },
  156. pageInit(){
  157. this.range = [ this.get7day(-6), this.get7day(0) ]
  158. this.searchForm.creatTime = [ this.get7day(-6), this.get7day(0) ]
  159. this.total = 0
  160. this.pageNo = 1
  161. },
  162. // tabs通知swiper切换
  163. tabsChange(index) {
  164. this.swiperCurrent = index
  165. this.list = []
  166. this.status = "loading"
  167. },
  168. swiperChange(event){
  169. this.list = []
  170. this.status = "loading"
  171. },
  172. // swiper-item左右移动,通知tabs的滑块跟随移动
  173. transition(e) {
  174. let dx = e.detail.dx;
  175. this.$refs.uTabs.setDx(dx);
  176. },
  177. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  178. // swiper滑动结束,分别设置tabs和swiper的状态
  179. animationfinish(e) {
  180. let current = e.detail.current
  181. if(current != this.current){
  182. this.$refs.uTabs.setFinishCurrent(current)
  183. this.swiperCurrent = current
  184. this.current = current
  185. this.pageInit()
  186. }
  187. },
  188. // scroll-view到底部加载更多
  189. onreachBottom() {
  190. if(this.list.length < this.total){
  191. this.pageNo += 1
  192. this.pageInit()
  193. }else{
  194. this.status = "nomore"
  195. }
  196. },
  197. // 显示日期选择
  198. onShowDatePicker(type){
  199. this.type = type
  200. this.showPicker = true
  201. this.searchForm.creatTime = this[type]
  202. },
  203. // 日期选择
  204. onSelected(e) {
  205. this.showPicker = false
  206. if(e) {
  207. this[this.type] = e.value
  208. }
  209. },
  210. // 获取近几天的数据
  211. get7day(day){
  212. let today = new Date()
  213. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  214. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  215. let tYear = today.getFullYear()
  216. let tMonth = today.getMonth()
  217. let tDate = today.getDate()
  218. tMonth = this.doHandleMonth(tMonth + 1)
  219. tDate = this.doHandleMonth(tDate)
  220. return tYear + "-" + tMonth + "-" + tDate
  221. },
  222. // 月份
  223. doHandleMonth(month){
  224. let m = month
  225. if(month.toString().length == 1){
  226. m = "0" + month
  227. }
  228. return m
  229. },
  230. // 选择门店
  231. confirmStore(e){
  232. this.storeName = e[0].label
  233. this.defaultStoreValue = [this.storeList.findIndex(item => item.value == e[0].value)]
  234. },
  235. // 情空 筛选门店
  236. clearStore(){
  237. this.storeName = ''
  238. this.defaultStoreValue = []
  239. },
  240. // 重置筛选条件
  241. resetF(){
  242. this.range = this.searchForm.creatTime
  243. let ind = [this.storeList.findIndex(item => item.value == this.searchForm.store)]
  244. if(ind == -1){
  245. this.defaultStoreValue = []
  246. this.storeName = ''
  247. }else{
  248. this.defaultStoreValue = [ind]
  249. this.storeName = this.storeList[ind].label
  250. }
  251. },
  252. // 确定筛选
  253. submitF(){
  254. this.searchForm.creatTime = this.range
  255. if(this.storeName){
  256. this.searchForm.store = this.storeList[this.defaultStoreValue[0]].value
  257. }else{
  258. this.searchForm.store = ''
  259. }
  260. this.openScreen = false
  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. .alert-tips{
  305. font-size: 24upx;
  306. padding: 4upx 10upx;
  307. margin: 20upx 30upx 10upx;
  308. border: 1upx solid #fcbd71;
  309. background-color: #fdf6ec;
  310. border-radius: 6upx;
  311. }
  312. .record-item{
  313. background-color: #fff;
  314. margin: 20upx 30upx 20upx;
  315. padding: 14upx 30upx 20upx;
  316. border-radius: 12upx;
  317. .item-head{
  318. display: flex;
  319. justify-content: space-between;
  320. align-items: center;
  321. padding: 10upx 0;
  322. .item-c-tit{
  323. flex-grow: 1;
  324. padding-right: 18upx;
  325. font-weight: bold;
  326. }
  327. .item-c-type{
  328. flex-shrink: 0;
  329. }
  330. }
  331. .item-main{
  332. font-size: 26upx;
  333. line-height: 48upx;
  334. padding: 6upx 0;
  335. position: relative;
  336. .item-tit{
  337. display: inline-block;
  338. position: absolute;
  339. left: 0;
  340. top: 10upx;
  341. }
  342. .item-val{
  343. display: inline-block;
  344. padding-left: 150upx;
  345. }
  346. }
  347. .item-grid{
  348. margin-top: 10upx;
  349. .text-blue{
  350. color: #2979ff;
  351. }
  352. .text-green{
  353. color: #19be6b;
  354. }
  355. .text-red{
  356. color: #fa3534;
  357. }
  358. .text-yellow{
  359. color: #ff9900;
  360. }
  361. .grid-num{
  362. font-weight: bold;
  363. }
  364. .grid-text{
  365. font-size: 26upx;
  366. padding-top: 10upx;
  367. color: #666;
  368. }
  369. }
  370. }
  371. }
  372. .loadmore{
  373. padding: 30upx;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. .screenModel-wrap{
  380. padding-bottom: 80upx;
  381. .condition-con{
  382. padding: 20upx 30upx;
  383. .condition-item{
  384. .condition-tit{
  385. display: block;
  386. font-size: 26upx;
  387. margin: 20upx 0;
  388. }
  389. .condition-val{
  390. display: block;
  391. font-size: 24upx;
  392. background-color: #f4f4f4;
  393. border-radius: 12upx;
  394. padding: 10upx 14upx;
  395. margin: 10upx 0;
  396. text-align: center;
  397. text{
  398. display: inline-block;
  399. width: 85%;
  400. }
  401. .close-circle{
  402. display: inline-block;
  403. padding-left: 3%;
  404. vertical-align: bottom;
  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. .choose-date-wrap{
  423. z-index: 999999;
  424. }
  425. }
  426. </style>