order.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. v-text="item.label"
  17. :class="index === pickTabIndex ? 'active' : ''"
  18. @click="changeChartsTab(index)"
  19. ></view>
  20. </view>
  21. <view class="tab-title__placeholder"></view>
  22. </template>
  23. <view :class="pickTabIndex == 4 ? 'pb40' : ''">
  24. <view class="" v-if="pickTabIndex !== 4">
  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>
  33. <!-- < <OrderTask> v-if="pickTabIndex == 0" :list="worksheetList" :type="pickTabIndex"></OrderTask>
  34. <OrderTask v-if="pickTabIndex == 1" :list="worksheetList" :type="pickTabIndex"></OrderTask>
  35. <OrderTask v-if="pickTabIndex == 2" :list="worksheetList" :type="pickTabIndex"></OrderTask>
  36. <OrderTask v-if="pickTabIndex == 3" :list="worksheetList" :type="pickTabIndex"></OrderTask>-->
  37. <OrderSpare
  38. v-if="pickTabIndex == 4"
  39. :list="tabList[pickTabIndex].list"
  40. ></OrderSpare>
  41. </view>
  42. <view class="fixed" v-if="pickTabIndex == 4">
  43. <u-button type="primary">归还</u-button>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import OrderTask from './OrderTask.vue'
  49. import OrderSpare from './OrderSpare.vue'
  50. import { post } from '@/utils/api.js'
  51. export default {
  52. components: {
  53. OrderTask,
  54. OrderSpare
  55. },
  56. data () {
  57. return {
  58. params: {
  59. page: 1,
  60. size: 10
  61. },
  62. isEnd: true,
  63. // tabList: ['全部', '未归还', '已归还', '已使用', '所有备件'],
  64. tabList: [
  65. {
  66. value: '0',
  67. label: '全部',
  68. list: []
  69. },
  70. {
  71. value: '1',
  72. label: '未归还',
  73. list: []
  74. },
  75. {
  76. value: '2',
  77. label: '已归还',
  78. list: []
  79. },
  80. {
  81. value: '3',
  82. label: '已使用',
  83. list: []
  84. },
  85. {
  86. value: '4',
  87. label: '所有备件',
  88. list: []
  89. }
  90. ],
  91. pickTabIndex: 0
  92. }
  93. },
  94. onLoad () {
  95. //this.getList()
  96. },
  97. onReachBottom: function () {
  98. if (this.isEnd) {
  99. return
  100. }
  101. this.params.page++
  102. this.getList()
  103. },
  104. methods: {
  105. getList () {
  106. uni.showLoading({
  107. title: '加载中'
  108. })
  109. let url = null,
  110. params = {
  111. ...this.params
  112. }
  113. if (this.tabList[this.pickTabIndex].value == 4) {
  114. url = `${this.apiUrl}/feature/book/spareparts/sparepartList`
  115. params.sparepartTypeCode = '03000000000000000000'
  116. }
  117. //2 - 99 [已完成]
  118. post(url, params)
  119. .then(res => {
  120. if (this.params.page === 1) {
  121. this.tabList[this.pickTabIndex].list = res.data.items
  122. } else {
  123. res.data.items.forEach(element => {
  124. this.tabList[this.pickTabIndex].list.push(element)
  125. })
  126. }
  127. this.params.page < res.data.pageTotal
  128. ? (this.isEnd = false)
  129. : (this.isEnd = true)
  130. })
  131. .then(() => {
  132. uni.hideLoading()
  133. })
  134. },
  135. changeChartsTab (index) {
  136. this.pickTabIndex = index
  137. this.getList()
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .tab-title {
  144. position: fixed;
  145. z-index: 9;
  146. width: 100%;
  147. display: flex;
  148. justify-content: space-between;
  149. height: $tab-height;
  150. line-height: $tab-height;
  151. background-color: #ffffff;
  152. border-bottom: 1px solid #f2f2f2;
  153. box-sizing: border-box;
  154. .tab-item {
  155. width: 25%;
  156. text-align: center;
  157. font-size: 32rpx;
  158. color: $uni-text-color-grey;
  159. }
  160. .tab-item.active {
  161. color: $j-primary-border-green;
  162. border-bottom: 1px solid $j-primary-border-green;
  163. }
  164. }
  165. .pb40 {
  166. padding-bottom: 80rpx;
  167. }
  168. .fixed {
  169. position: fixed;
  170. bottom: 0;
  171. left: 0;
  172. width: 100%;
  173. }
  174. </style>