order.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="报修申请单"
  8. @clickLeft="back"
  9. >
  10. </uni-nav-bar>
  11. <template>
  12. <view class="tab-title">
  13. <view
  14. v-for="(item, index) in tabList"
  15. :key="index"
  16. class="tab-item"
  17. v-text="item.label"
  18. :class="index === pickTabIndex ? 'active' : ''"
  19. @click="changeChartsTab(index)"
  20. ></view>
  21. </view>
  22. <view class="tab-title__placeholder"></view>
  23. </template>
  24. <view>
  25. <OrderTask
  26. v-for="(item, index) in tabList"
  27. :key="index"
  28. v-show="index === pickTabIndex"
  29. :list="item.list"
  30. >
  31. </OrderTask>
  32. <view class="fixed add">
  33. <u-button class="button" type="primary" @click="jump">报修</u-button>
  34. </view>
  35. </view>
  36. <!-- <view class="" v-if="pickTabIndex == 1">
  37. <OrderTask v-for="(item,index) in tabList" :key="index" :type="pickTabIndex+1" v-show="index === pickTabIndex"
  38. :list="item.list"></OrderTask>
  39. </view> -->
  40. </view>
  41. </template>
  42. <script>
  43. import OrderTask from './OrderTask.vue'
  44. import { post, postJ } from '@/utils/api.js'
  45. let [page, size, isEnd] = [1, 10, true]
  46. export default {
  47. components: {
  48. OrderTask
  49. },
  50. data () {
  51. return {
  52. tabList: [
  53. {
  54. label: '待执行',
  55. value: '0',
  56. list: []
  57. },
  58. {
  59. label: '执行中',
  60. value: '1',
  61. list: []
  62. },
  63. {
  64. label: '已完成',
  65. value: '2',
  66. list: []
  67. }
  68. ],
  69. pickTabIndex: 0,
  70. worksheetList: []
  71. }
  72. },
  73. onShow () {
  74. this.getFirstList()
  75. },
  76. onReachBottom: function () {
  77. if (isEnd) {
  78. return
  79. }
  80. this.getMoreLists()
  81. },
  82. methods: {
  83. jump () {
  84. uni.navigateTo({
  85. url: '../repair/index'
  86. })
  87. },
  88. getFirstList: function () {
  89. page = 1
  90. isEnd = true
  91. this.getList()
  92. },
  93. getMoreLists: function () {
  94. //获取更多数据
  95. page++
  96. this.getList()
  97. },
  98. changeChartsTab (index) {
  99. this.pickTabIndex = index
  100. this.getFirstList()
  101. },
  102. getList () {
  103. uni.showLoading({
  104. title: '加载中'
  105. })
  106. let paging = this.URLSearchParams({
  107. page,
  108. size
  109. })
  110. //2 - 99 [已完成]
  111. let searchStatus = this.tabList[this.pickTabIndex].value
  112. postJ(this.apiUrl + `/repair/info/getPage?` + paging, {
  113. searchStatus: searchStatus
  114. })
  115. .then(res => {
  116. let data = res.data.records
  117. //let data = [{repairsCode:'asd',sourceCode:'sad',status:'2',id:'1'}]
  118. let pageTotal = res.data.pages
  119. if (page === 1) {
  120. this.tabList[this.pickTabIndex].list = data
  121. } else {
  122. data.forEach(element => {
  123. this.tabList[this.pickTabIndex].list.push(element)
  124. })
  125. }
  126. console.log(this.tabList)
  127. page < pageTotal ? (isEnd = false) : (isEnd = true)
  128. })
  129. .then(() => {
  130. uni.hideLoading()
  131. })
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .tab-title {
  138. position: fixed;
  139. width: 100%;
  140. display: flex;
  141. justify-content: space-between;
  142. height: 82rpx;
  143. line-height: 82rpx;
  144. background-color: #ffffff;
  145. border-bottom: 1px solid #f2f2f2;
  146. z-index: 99;
  147. box-sizing: border-box;
  148. .tab-item {
  149. width: 50%;
  150. text-align: center;
  151. font-size: 32rpx;
  152. color: $uni-text-color-grey;
  153. }
  154. .tab-item.active {
  155. color: $j-primary-border-green;
  156. border-bottom: 1px solid $j-primary-border-green;
  157. }
  158. }
  159. .fixed {
  160. position: fixed;
  161. width: 100%;
  162. left: 0;
  163. }
  164. .add {
  165. bottom: 0;
  166. }
  167. .button {
  168. background-color: #157a2c;
  169. border: none;
  170. }
  171. </style>