order.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. <view class="top-wrapper">
  14. <view class="tab_box rx-sc">
  15. <view class="tab_item" v-for="(item,index) in tabList" :key="index"
  16. :class="{active: pickTabIndex == index}">
  17. <view @click="changeChartsTab(index)">
  18. {{item.label}}
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <OrderTask v-for="(item, index) in tabList" :key="index" v-show="index === pickTabIndex" :list="item.list"
  24. :type="tabList.value"></OrderTask>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. getWorkOrderList
  30. } from '@/api/myTicket'
  31. import OrderTask from './OrderTask.vue'
  32. import {
  33. post,
  34. postJ
  35. } from '@/utils/api.js'
  36. let [page, size, isEnd] = [1, 10, false]
  37. export default {
  38. components: {
  39. OrderTask
  40. },
  41. data() {
  42. return {
  43. tabList: [{
  44. value: 0,
  45. label: '待接收',
  46. list: [],
  47. number: 0
  48. },
  49. {
  50. value: 2,
  51. label: '执行中',
  52. list: [],
  53. number: 0
  54. },
  55. {
  56. value: 3,
  57. label: '已完成',
  58. list: [],
  59. number: 0
  60. }
  61. ],
  62. pickTabIndex: 0,
  63. qrContent: null,
  64. barType: 0
  65. }
  66. },
  67. onShow() {
  68. this.getFirstList()
  69. this.getStatus()
  70. },
  71. onReachBottom: function() {
  72. if (isEnd) {
  73. return
  74. }
  75. // 显示加载图标
  76. uni.showLoading({
  77. title: '数据加载中'
  78. })
  79. this.getMoreLists()
  80. },
  81. methods: {
  82. getStatus() {
  83. getWorkOrderList({
  84. orderStatus: [0],
  85. type: 1,
  86. pageNum: 1,
  87. size: 1
  88. }).then(res => {
  89. console.log(res,'res ===')
  90. this.tabList[0].number = res.count
  91. })
  92. getWorkOrderList({
  93. orderStatus: [2],
  94. type: 1,
  95. pageNum: 1,
  96. size: 1
  97. }).then(res => {
  98. this.tabList[1].number = res.count
  99. })
  100. getWorkOrderList({
  101. orderStatus: [3],
  102. type: 1,
  103. pageNum: 1,
  104. size: 1
  105. }).then(res => {
  106. this.tabList[2].number = res.count
  107. })
  108. getWorkOrderList({
  109. orderStatus: [4],
  110. type: 1,
  111. pageNum: 1,
  112. size: 1
  113. }).then(res => {
  114. this.tabList[3].number = res.count
  115. })
  116. },
  117. getCount() {
  118. statistics().then(data => {
  119. console.log('onsole.log(data)-----------')
  120. console.log(data)
  121. this.tabList = this.tabList.map(item => {
  122. switch (item.value) {
  123. case '0':
  124. return {
  125. ...item, badge: {
  126. value: data.maintenanceNum
  127. }
  128. }
  129. case '2':
  130. return {
  131. ...item, badge: {
  132. value: data.patrolInspection
  133. }
  134. }
  135. case '3':
  136. return {
  137. ...item, badge: {
  138. value: data.quantityNum
  139. }
  140. }
  141. case '4':
  142. return {
  143. ...item, badge: {
  144. value: data.repairsNum
  145. }
  146. }
  147. }
  148. })
  149. })
  150. },
  151. getFirstList: function() {
  152. page = 1
  153. // isEnd = true
  154. isEnd = false
  155. this.getList()
  156. },
  157. getMoreLists: function() {
  158. //获取更多数据
  159. page++
  160. this.getList()
  161. },
  162. getList() {
  163. uni.showLoading({
  164. title: '数据加载中'
  165. })
  166. let params = {
  167. orderStatus: [this.tabList[this.pickTabIndex].value],
  168. type: 1,
  169. pageNum: page,
  170. size
  171. }
  172. getWorkOrderList(params)
  173. .then(res => {
  174. // this.tabList[this.pickTabIndex].list = res.list
  175. // isEnd = this.tabList[this.pickTabIndex].list >= res.count
  176. if(page == 1){
  177. this.tabList[this.pickTabIndex].list = res.list;
  178. }else{
  179. this.tabList[this.pickTabIndex].list.push(...res.list);
  180. }
  181. isEnd = this.tabList[this.pickTabIndex].list.length >= res.count;
  182. uni.hideLoading();
  183. })
  184. .catch(() => {
  185. uni.hideLoading();
  186. })
  187. },
  188. changeChartsTab(index) {
  189. this.pickTabIndex = index;
  190. this.getFirstList();
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. .top-wrapper {
  197. display: flex;
  198. align-items: center;
  199. background-color: #fff;
  200. position: relative;
  201. .tab_box {
  202. width: 100%;
  203. height: 68rpx;
  204. .tab_item {
  205. height: 68rpx;
  206. line-height: 68rpx;
  207. padding: 0 20rpx;
  208. font-size: 32rpx;
  209. // color: #979C9E;
  210. }
  211. .active {
  212. box-sizing: border-box;
  213. border-bottom: 6rpx solid $theme-color;
  214. color: $theme-color;
  215. }
  216. }
  217. }
  218. .tab-title {
  219. position: fixed;
  220. z-index: 99;
  221. width: 100%;
  222. padding: 10rpx;
  223. // display: flex;
  224. // justify-content: space-between;
  225. height: $tab-height;
  226. line-height: $tab-height;
  227. background-color: #ffffff;
  228. border-bottom: 1px solid #f2f2f2;
  229. // box-sizing: border-box;
  230. white-space: nowrap;
  231. overflow: auto hidden;
  232. display: flex;
  233. &::-webkit-scrollbar {
  234. /*滚动条整体样式*/
  235. width: 10px;
  236. /*高宽分别对应横竖滚动条的尺寸*/
  237. height: 1px;
  238. }
  239. &::-webkit-scrollbar-thumb {
  240. /*滚动条里面小方块*/
  241. border-radius: 10px;
  242. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  243. background: #535353;
  244. }
  245. &::-webkit-scrollbar-track {
  246. /*滚动条里面轨道*/
  247. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  248. border-radius: 10px;
  249. background: #ededed;
  250. }
  251. .tab-item {
  252. flex: 1;
  253. text-align: center;
  254. display: inline-block;
  255. font-size: 32rpx;
  256. color: $uni-text-color-grey;
  257. }
  258. .tab-item.active {
  259. color: $j-primary-border-green;
  260. border-bottom: 1px solid $j-primary-border-green;
  261. }
  262. .title-num {
  263. font-size: 26rpx;
  264. }
  265. .title-red {
  266. display: inline-block;
  267. font-size: 22rpx;
  268. padding: 0 10rpx;
  269. border-radius: 50rpx;
  270. color: #ffffff;
  271. background: red;
  272. line-height: 38rpx;
  273. position: absolute;
  274. top: 10rpx;
  275. min-width: 18rpx;
  276. }
  277. }
  278. </style>