order.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="保养工单" @clickLeft="back"></uni-nav-bar>
  4. <template>
  5. <view class="tab-title">
  6. <view v-for="(item, index) in tabList" :key="index" class="tab-item" :class="index === pickTabIndex ? 'active' : ''" @click="changeChartsTab(index)">
  7. {{ item.label }}
  8. <text v-if="item.number > 0" class="title-red">{{ item.number }}</text>
  9. </view>
  10. </view>
  11. <view class="tab-title__placeholder"></view>
  12. </template>
  13. <OrderTask v-for="(item, index) in tabList" :key="index" v-show="index === pickTabIndex" :list="item.list" :type="tabList.value"></OrderTask>
  14. </view>
  15. </template>
  16. <script>
  17. import { getWorkOrderList } from '@/api/myTicket'
  18. import OrderTask from './OrderTask.vue'
  19. import { post, postJ } from '@/utils/api.js'
  20. let [page, size, isEnd] = [1, 10, true]
  21. export default {
  22. components: {
  23. OrderTask
  24. },
  25. data() {
  26. return {
  27. tabList: [
  28. {
  29. value: 0,
  30. label: '待接收',
  31. list: [],
  32. number: 0
  33. },
  34. {
  35. value: 2,
  36. label: '执行中',
  37. list: [],
  38. number: 0
  39. },
  40. {
  41. value: 3,
  42. label: '已完成',
  43. list: [],
  44. number: 0
  45. }
  46. ],
  47. pickTabIndex: 0,
  48. qrContent: null,
  49. barType: 0
  50. }
  51. },
  52. onShow() {
  53. this.getFirstList()
  54. this.getStatus()
  55. },
  56. onReachBottom: function () {
  57. if (isEnd) {
  58. return
  59. }
  60. // 显示加载图标
  61. uni.showLoading({
  62. title: '数据加载中'
  63. })
  64. this.getMoreLists()
  65. },
  66. methods: {
  67. getStatus() {
  68. getWorkOrderList({ orderStatus: [0], type: 2, pageNum: 1, size: 1 }).then(res => {
  69. this.tabList[0].number = res.count
  70. })
  71. getWorkOrderList({ orderStatus: [2], type: 2, pageNum: 1, size: 1 }).then(res => {
  72. this.tabList[1].number = res.count
  73. })
  74. getWorkOrderList({ orderStatus: [3], type: 2, pageNum: 1, size: 1 }).then(res => {
  75. this.tabList[2].number = res.count
  76. })
  77. getWorkOrderList({ orderStatus: [4], type: 2, pageNum: 1, size: 1 }).then(res => {
  78. this.tabList[3].number = res.count
  79. })
  80. },
  81. getCount() {
  82. statistics().then(data => {
  83. console.log('onsole.log(data)-----------')
  84. console.log(data)
  85. this.tabList = this.tabList.map(item => {
  86. switch (item.value) {
  87. case '0':
  88. return { ...item, badge: { value: data.maintenanceNum } }
  89. case '2':
  90. return { ...item, badge: { value: data.patrolInspection } }
  91. case '3':
  92. return { ...item, badge: { value: data.quantityNum } }
  93. case '4':
  94. return { ...item, badge: { value: data.repairsNum } }
  95. }
  96. })
  97. })
  98. },
  99. getFirstList: function () {
  100. page = 1
  101. isEnd = true
  102. this.getList()
  103. },
  104. getMoreLists: function () {
  105. //获取更多数据
  106. page++
  107. this.getList()
  108. },
  109. getList() {
  110. uni.showLoading({
  111. title: '数据加载中'
  112. })
  113. let params = {
  114. orderStatus: [this.tabList[this.pickTabIndex].value],
  115. type: 2,
  116. pageNum: page,
  117. size
  118. }
  119. getWorkOrderList(params)
  120. .then(res => {
  121. this.tabList[this.pickTabIndex].list = res.list
  122. isEnd = this.tabList[this.pickTabIndex].list >= res.count
  123. uni.hideLoading()
  124. })
  125. .catch(() => {
  126. uni.hideLoading()
  127. })
  128. },
  129. changeChartsTab(index) {
  130. this.pickTabIndex = index
  131. this.getFirstList()
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .tab-title {
  138. position: fixed;
  139. z-index: 99;
  140. width: 100%;
  141. padding: 10rpx;
  142. // display: flex;
  143. // justify-content: space-between;
  144. height: $tab-height;
  145. line-height: $tab-height;
  146. background-color: #ffffff;
  147. border-bottom: 1px solid #f2f2f2;
  148. // box-sizing: border-box;
  149. white-space: nowrap;
  150. overflow: auto hidden;
  151. display: flex;
  152. &::-webkit-scrollbar {
  153. /*滚动条整体样式*/
  154. width: 10px;
  155. /*高宽分别对应横竖滚动条的尺寸*/
  156. height: 1px;
  157. }
  158. &::-webkit-scrollbar-thumb {
  159. /*滚动条里面小方块*/
  160. border-radius: 10px;
  161. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  162. background: #535353;
  163. }
  164. &::-webkit-scrollbar-track {
  165. /*滚动条里面轨道*/
  166. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  167. border-radius: 10px;
  168. background: #ededed;
  169. }
  170. .tab-item {
  171. flex: 1;
  172. text-align: center;
  173. display: inline-block;
  174. font-size: 32rpx;
  175. color: $uni-text-color-grey;
  176. }
  177. .tab-item.active {
  178. color: $j-primary-border-green;
  179. border-bottom: 1px solid $j-primary-border-green;
  180. }
  181. .title-num {
  182. font-size: 26rpx;
  183. }
  184. .title-red {
  185. display: inline-block;
  186. font-size: 22rpx;
  187. padding: 0 10rpx;
  188. border-radius: 50rpx;
  189. color: #ffffff;
  190. background: red;
  191. line-height: 38rpx;
  192. position: absolute;
  193. top: 10rpx;
  194. min-width: 18rpx;
  195. }
  196. }
  197. </style>