index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="return_of_parts" style="width: 100%; height: 100vh">
  3. <zj-page-container>
  4. <view class="list_info_state">
  5. <scroll-view scroll-x="true" class="scroll">
  6. <view class="box" v-for="(item, index) in stateList" :key="index" @tap.stop="stateIndex = index">
  7. <view
  8. :class="{
  9. selectox: stateIndex === index
  10. }"
  11. >{{ item.name }}</view
  12. >
  13. <view v-if="stateIndex === index" class="xhxh"></view>
  14. </view>
  15. </scroll-view>
  16. </view>
  17. <zj-page-fill
  18. @scrolltolower="carScrolltolower"
  19. @refresherrefresh="carRefresherrefresh"
  20. @refresherrestore="carRefresherrestore"
  21. :scrollAttribute="{
  22. 'refresher-enabled': true,
  23. 'refresher-triggered': refresherTriggered
  24. }"
  25. >
  26. <view class="list_view_lay">
  27. <block v-for="(item, index) in list" :key="index">
  28. <card :item="item" />
  29. </block>
  30. </view>
  31. </zj-page-fill>
  32. </zj-page-container>
  33. </view>
  34. </template>
  35. <script>
  36. import zjPageContainer from '@/components/zj-page-container/zj-page-container.vue'
  37. import zjPageFill from '@/components/zj-page-container/zj-page-fill.vue'
  38. import card from './card.vue'
  39. import { getStorage } from '@/common/utils/storage.js'
  40. export default {
  41. components: {
  42. zjPageContainer,
  43. zjPageFill,
  44. card
  45. },
  46. data() {
  47. return {
  48. stateList: [
  49. {
  50. name: '全部',
  51. num: 0,
  52. type: ''
  53. },
  54. {
  55. name: '待审核',
  56. num: 0,
  57. type: 'SUBMIT'
  58. },
  59. {
  60. name: '已经审核',
  61. num: 0,
  62. type: 'AGREE'
  63. },
  64. {
  65. name: '驳回',
  66. num: 0,
  67. type: 'REJECT'
  68. }
  69. ],
  70. stateIndex: 0,
  71. // 下拉刷新状态
  72. refresherTriggered: false,
  73. redcbol: false,
  74. pageNo: 1,
  75. pageSize: 20,
  76. list: [],
  77. partsNumber: '',
  78. isMore: true
  79. }
  80. },
  81. onLoad: function (option) {
  82. this.partsNumber = option.partsNumber || ''
  83. this.redc(true)
  84. },
  85. computed: {
  86. stateType() {
  87. return this.stateList[this.stateIndex].type
  88. },
  89. userInfo() {
  90. return getStorage('user')
  91. },
  92. idcard() {
  93. return this.userInfo.idCard
  94. }
  95. },
  96. watch: {
  97. stateType(newv) {
  98. this.redc(true)
  99. }
  100. },
  101. methods: {
  102. // 获取新件返还管理列表
  103. getList() {
  104. this.$api
  105. .get('/app/worker/change-sales/list', {
  106. pageNo: this.pageNo,
  107. pageSize: this.pageSize,
  108. identity: this.idcard,
  109. partsNumber: this.partsNumber,
  110. flag: this.stateType
  111. })
  112. .then(res => {
  113. if (res.data.records.length < this.pageSize) {
  114. this.isMore = false
  115. }
  116. if (this.refresherTriggered || this.redcbol) {
  117. this.list = res.data.records
  118. this.refresherTriggered = false
  119. this.redcbol = false
  120. } else {
  121. this.list = [...this.list, ...res.data.records]
  122. }
  123. })
  124. .catch(() => {
  125. if (this.refresherTriggered) {
  126. this.list = []
  127. this.refresherTriggered = false
  128. }
  129. })
  130. },
  131. // 滚动到底部
  132. carScrolltolower(e) {
  133. if (this.isMore) {
  134. this.pageNo++
  135. this.getList()
  136. }
  137. },
  138. // 触发下拉刷新
  139. carRefresherrefresh(e) {
  140. this.refresherTriggered = true
  141. this.redc()
  142. },
  143. // 切换更新数据
  144. redc(v) {
  145. this.redcbol = v
  146. this.isMore = true
  147. this.pageNo = 1
  148. this.getList()
  149. },
  150. // 下拉刷新结束
  151. carRefresherrestore(e) {}
  152. }
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. .return_of_parts {
  157. .list_info_state {
  158. width: 100%;
  159. height: 88rpx;
  160. box-sizing: border-box;
  161. background: #ffffff;
  162. position: relative;
  163. .scroll {
  164. width: 100%;
  165. overflow: hidden;
  166. white-space: nowrap;
  167. }
  168. .box {
  169. display: inline-block;
  170. width: auto;
  171. height: 88upx;
  172. margin-right: 30upx;
  173. position: relative;
  174. line-height: 88upx;
  175. .xhxh {
  176. position: absolute;
  177. left: 10%;
  178. bottom: 0;
  179. width: 80%;
  180. height: 6upx;
  181. background: #6da7ff;
  182. }
  183. }
  184. .selectox {
  185. color: #6da7ff;
  186. }
  187. .box:first-child {
  188. margin-left: 30upx;
  189. }
  190. }
  191. .list_view_lay {
  192. width: 100%;
  193. box-sizing: border-box;
  194. padding: 30upx;
  195. }
  196. }
  197. </style>