order copy.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="保养工单"
  8. @clickLeft="back"
  9. ></uni-nav-bar>
  10. <template>
  11. <view class="tab-title">
  12. <view
  13. v-for="(item, index) in tabList"
  14. :key="index"
  15. class="tab-item"
  16. :class="index === pickTabIndex ? 'active' : ''"
  17. @click="changeChartsTab(index)"
  18. >
  19. {{ item.label }}
  20. <text v-if="index == 0" class="title-red">{{ item.number }}</text>
  21. <text v-else class="title-num">({{ item.number }})</text>
  22. </view>
  23. </view>
  24. <view class="tab-title__placeholder"></view>
  25. </template>
  26. <OrderTask
  27. v-for="(item, index) in tabList"
  28. :key="index"
  29. v-show="index === pickTabIndex"
  30. :list="pageList"
  31. ></OrderTask>
  32. </view>
  33. </template>
  34. <script>
  35. import OrderTask from './OrderTask.vue'
  36. import { post, get, postJ } from '@/utils/api.js'
  37. let [page, size, isEnd] = [1, 10, true]
  38. export default {
  39. components: {
  40. OrderTask
  41. },
  42. data () {
  43. return {
  44. tabList: [
  45. {
  46. value: 0,
  47. label: '待接收',
  48. list: [],
  49. number: 0
  50. },
  51. {
  52. value: 1,
  53. label: '执行中',
  54. list: [],
  55. number: 0
  56. },
  57. {
  58. value: 3,
  59. label: '已完成',
  60. list: [],
  61. number: 0
  62. }
  63. ],
  64. pageList: [],
  65. pickTabIndex: 0
  66. }
  67. },
  68. onLoad () {
  69. // this.getList()
  70. },
  71. onShow () {
  72. this.getFirstList()
  73. this.getStatus()
  74. },
  75. onReachBottom: function () {
  76. if (isEnd) {
  77. return
  78. }
  79. // 显示加载图标
  80. uni.showLoading({
  81. title: '数据加载中'
  82. })
  83. this.getMoreLists()
  84. },
  85. methods: {
  86. getStatus () {
  87. postJ(this.apiUrl + `/workOrder/getWorkOrderTotal`, {
  88. workOrderType: 2
  89. }).then(res => {
  90. let data = res.data
  91. this.tabList[0].number = data.waitExecutionNum
  92. this.tabList[1].number = data.executoryNum
  93. this.tabList[2].number = data.finishNum
  94. })
  95. },
  96. getFirstList: function () {
  97. page = 1
  98. isEnd = true
  99. this.getList()
  100. },
  101. getMoreLists: function () {
  102. //获取更多数据
  103. page++
  104. this.getList()
  105. },
  106. //获取列表数据
  107. getList () {
  108. let data = {
  109. page,
  110. size
  111. }
  112. const pickTabIndex = this.pickTabIndex
  113. let status = this.tabList[pickTabIndex].value
  114. post(
  115. this.apiUrl +
  116. `/workOrder/getWorkOrderListApp?page=${page}&size=${size}`,
  117. { status, workOrderType: 2 },
  118. true
  119. ).then(res => {
  120. let data = res.data.records
  121. if (page === 1) {
  122. this.pageList = res.data.records
  123. } else {
  124. this.pageList.push(...data)
  125. }
  126. isEnd = this.pageList.length >= res.data.total
  127. // page < pageTotal ? (isEnd = false) : (isEnd = true);
  128. })
  129. },
  130. //切换选项卡
  131. changeChartsTab (index) {
  132. this.pickTabIndex = index
  133. this.getFirstList()
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .tab-title {
  140. position: fixed;
  141. z-index: 9;
  142. width: 100%;
  143. padding: 0 30rpx;
  144. display: flex;
  145. justify-content: space-between;
  146. height: $tab-height;
  147. line-height: $tab-height;
  148. background-color: #ffffff;
  149. border-bottom: 1px solid #f2f2f2;
  150. box-sizing: border-box;
  151. .tab-item {
  152. width: 30%;
  153. text-align: center;
  154. font-size: 32rpx;
  155. color: $uni-text-color-grey;
  156. }
  157. .tab-item.active {
  158. color: $j-primary-border-green;
  159. border-bottom: 1px solid $j-primary-border-green;
  160. }
  161. .title-num {
  162. font-size: 26rpx;
  163. }
  164. .title-red {
  165. display: inline-block;
  166. font-size: 22rpx;
  167. padding: 0 10rpx;
  168. border-radius: 50rpx;
  169. color: #ffffff;
  170. background: red;
  171. line-height: 38rpx;
  172. position: absolute;
  173. top: 10rpx;
  174. min-width: 18rpx;
  175. }
  176. }
  177. </style>