myShopTour.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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:'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. status: 'loadmore', // 加载状态
  121. noDataText: '暂无数据', // 列表数据为空时提示文字
  122. list: [ // 数据列表
  123. { 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 },
  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. { 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 },
  128. ],
  129. openScreen: false, // 是否打开筛选
  130. dateMode: 'range', // date单个日期 range日期范围
  131. searchForm: { // 查询条件
  132. creatTime: [], // 创建时间默认筛选近7天
  133. store: ''
  134. },
  135. openStore: false, // 选择门店
  136. storeList: [
  137. { value: '1', label: '江' },
  138. { value: '2', label: '河' }
  139. ],
  140. showPicker: false, // 是否选择创建时间
  141. range: [], // 筛选创建时间的默认值
  142. type: 'range', // 日期时间类型
  143. storeName: '', // 筛选门店名称
  144. defaultStoreValue: [], // 门店默认选中下标
  145. }
  146. },
  147. onLoad() {
  148. this.pageInit()
  149. },
  150. methods: {
  151. // 返回
  152. goBack() {
  153. uni.navigateBack({
  154. delta: 1
  155. });
  156. },
  157. pageInit(){
  158. this.range = [ this.get7day(-6), this.get7day(0) ]
  159. this.searchForm.creatTime = [ this.get7day(-6), this.get7day(0) ]
  160. this.total = 0
  161. this.pageNo = 1
  162. },
  163. // tabs通知swiper切换
  164. tabsChange(index) {
  165. this.swiperCurrent = index
  166. this.list = []
  167. this.status = "loading"
  168. },
  169. swiperChange(event){
  170. this.list = []
  171. this.status = "loading"
  172. },
  173. // swiper-item左右移动,通知tabs的滑块跟随移动
  174. transition(e) {
  175. let dx = e.detail.dx;
  176. this.$refs.uTabs.setDx(dx);
  177. },
  178. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  179. // swiper滑动结束,分别设置tabs和swiper的状态
  180. animationfinish(e) {
  181. let current = e.detail.current
  182. if(current != this.current){
  183. this.$refs.uTabs.setFinishCurrent(current)
  184. this.swiperCurrent = current
  185. this.current = current
  186. this.pageInit()
  187. }
  188. },
  189. // scroll-view到底部加载更多
  190. onreachBottom() {
  191. if(this.list.length < this.total){
  192. this.pageNo += 1
  193. this.pageInit()
  194. }else{
  195. this.status = "nomore"
  196. }
  197. },
  198. // 显示日期选择
  199. onShowDatePicker(type){
  200. this.type = type
  201. this.showPicker = true
  202. this.searchForm.creatTime = this[type]
  203. },
  204. // 日期选择
  205. onSelected(e) {
  206. this.showPicker = false
  207. if(e) {
  208. this[this.type] = e.value
  209. }
  210. },
  211. // 获取近几天的数据
  212. get7day(day){
  213. let today = new Date()
  214. let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
  215. today.setTime(targetday_milliseconds) //注意,这行是关键代码
  216. let tYear = today.getFullYear()
  217. let tMonth = today.getMonth()
  218. let tDate = today.getDate()
  219. tMonth = this.doHandleMonth(tMonth + 1)
  220. tDate = this.doHandleMonth(tDate)
  221. return tYear + "-" + tMonth + "-" + tDate
  222. },
  223. // 月份
  224. doHandleMonth(month){
  225. let m = month
  226. if(month.toString().length == 1){
  227. m = "0" + month
  228. }
  229. return m
  230. },
  231. // 选择门店
  232. confirmStore(e){
  233. this.storeName = e[0].label
  234. this.defaultStoreValue = [this.storeList.findIndex(item => item.value == e[0].value)]
  235. },
  236. // 情空 筛选门店
  237. clearStore(){
  238. this.storeName = ''
  239. this.defaultStoreValue = []
  240. },
  241. // 重置筛选条件
  242. resetF(){
  243. this.range = this.searchForm.creatTime
  244. let ind = [this.storeList.findIndex(item => item.value == this.searchForm.store)]
  245. if(ind == -1){
  246. this.defaultStoreValue = []
  247. this.storeName = ''
  248. }else{
  249. this.defaultStoreValue = [ind]
  250. this.storeName = this.storeList[ind].label
  251. }
  252. },
  253. // 确定筛选
  254. submitF(){
  255. this.searchForm.creatTime = this.range
  256. if(this.storeName){
  257. this.searchForm.store = this.storeList[this.defaultStoreValue[0]].value
  258. }else{
  259. this.searchForm.store = ''
  260. }
  261. this.openScreen = false
  262. },
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. page {
  268. background-color: #f8f8f8;
  269. height: calc(100vh - 44px);
  270. }
  271. .myShopTour-wrap {
  272. height: 100%;
  273. /* 自定义导航栏样式 */
  274. .slot-wrap {
  275. display: flex;
  276. align-items: center;
  277. /* 如果您想让slot内容占满整个导航栏的宽度 */
  278. flex: 1;
  279. /* 如果您想让slot内容与导航栏左右有空隙 */
  280. padding: 0 30rpx;
  281. color: #fff;
  282. font-size: 28upx;
  283. .left-icon {
  284. flex-grow: 1;
  285. font-size: 32upx;
  286. margin-right: 10upx;
  287. text-align: center;
  288. }
  289. .right-icon {
  290. padding-left: 50upx;
  291. }
  292. .uni-icons {
  293. margin-right: 10upx;
  294. }
  295. }
  296. // 内容
  297. .myShopTour-con{
  298. .data-list{
  299. height: calc(100vh - 84px);
  300. .swiper-item{
  301. .scroll-con{
  302. height: 100%;
  303. // 列表
  304. .record-con{
  305. padding-top: 20upx;
  306. .alert-tips{
  307. font-size: 24upx;
  308. padding: 4upx 10upx;
  309. margin: 0upx 30upx 10upx;
  310. border: 1upx solid #fcbd71;
  311. background-color: #fdf6ec;
  312. border-radius: 6upx;
  313. }
  314. .record-item{
  315. background-color: #fff;
  316. margin: 0upx 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: 10upx;
  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. .condition-item{
  386. .condition-tit{
  387. display: block;
  388. font-size: 26upx;
  389. margin: 20upx 0;
  390. }
  391. .condition-val{
  392. display: block;
  393. font-size: 24upx;
  394. background-color: #f4f4f4;
  395. border-radius: 12upx;
  396. padding: 10upx 14upx;
  397. margin: 10upx 0;
  398. text-align: center;
  399. text{
  400. display: inline-block;
  401. width: 85%;
  402. }
  403. .close-circle{
  404. display: inline-block;
  405. padding-left: 3%;
  406. vertical-align: bottom;
  407. }
  408. }
  409. }
  410. }
  411. .btns{
  412. position: fixed;
  413. bottom: 0;
  414. left: 0;
  415. width: 100%;
  416. background-color: rgba(0,0,0,.025);
  417. .btn{
  418. width: 40%;
  419. margin: 20upx 5%;
  420. padding: 30upx 0;
  421. }
  422. }
  423. }
  424. .choose-date-wrap{
  425. z-index: 999999;
  426. }
  427. }
  428. </style>