自主项目,食堂系统,前端uniapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
4.9 KiB

  1. <template>
  2. <view>
  3. <view class="tabs">
  4. <u-tabs :list="tab_list" :is-scroll="false" :current="current" bg-color="#f6f6f6" active-color="#1833F2" @change="tabsChange"></u-tabs>
  5. </view>
  6. <swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '750rpx'}"
  7. :current="current" @change="swiperChange">
  8. <swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
  9. <scroll-view class="lf-w-100 lf-h-100 lf-p-l-32 lf-p-r-32 lf-border-box"
  10. :scroll-y="true" :refresher-enabled="true"
  11. refresher-background="#f6f6f6"
  12. @scrolltolower="scrolltolower"
  13. :refresher-triggered="tabItem.isRefresher"
  14. @refresherrefresh="onRefresherrefresh">
  15. <view class="card" v-for="(item, index) in tabItem.list" :key="item.id" @click="$url('/pages/supply/order/detail?q_sn='+ item.q_sn)">
  16. <view class="lf-row-between upper">
  17. <view class="lf-font-28 lf-color-333">订单状态</view>
  18. <view class="order-btn" :class="stateClass(item.state)">{{ item.state }}</view>
  19. </view>
  20. <view class="lf-row-between lower">
  21. <view>报价单号 {{ item.q_sn }}</view>
  22. <view>{{ item.deadline }}</view>
  23. </view>
  24. </view>
  25. <view class="loading-more">
  26. <text v-if="tabItem.list.length" :class="{'loading-more-text': tabItem.loading_class}">{{ tabItem.loading_text }}</text>
  27. <lf-nocontent v-else class="lf-m-t-50"></lf-nocontent>
  28. </view>
  29. </scroll-view>
  30. </swiper-item>
  31. </swiper>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data(){
  37. return {
  38. current: 0,
  39. tab_list: [{
  40. name: '全部',
  41. state_name: '',
  42. loading_class: true,
  43. loading_text: '正在加载中...',
  44. page: 1,
  45. isPage: true,
  46. isRefresher: false, // scroll-view下拉刷新状态,当前默认没有触发
  47. list: []
  48. },{
  49. name: '审核中',
  50. state_name: '审核中',
  51. loading_class: true,
  52. loading_text: '正在加载中...',
  53. page: 1,
  54. isPage: true,
  55. isRefresher: false,
  56. list: []
  57. },{
  58. name: '已完成',
  59. state_name: '已完成',
  60. loading_class: true,
  61. loading_text: '正在加载中...',
  62. page: 1,
  63. isPage: true,
  64. isRefresher: false,
  65. list: []
  66. }],
  67. page_size: 10,
  68. windowHeight: 0,
  69. }
  70. },
  71. computed: {
  72. stateClass(){
  73. return function(val){
  74. let class_name = {
  75. '已通过': 'quoted-price',
  76. '待发起': 'wait',
  77. '待审核': 'passed',
  78. '未通过': 'refuse'
  79. }
  80. return class_name[val];
  81. }
  82. }
  83. },
  84. onLoad(){
  85. this.windowHeight = uni.getSystemInfoSync().windowHeight;
  86. this.getData();
  87. },
  88. methods: {
  89. getData(options){
  90. let item = this.tab_list[this.current];
  91. this.$http(this.API.API_SUPPLIER_QUOTATIONORDERLIST, {
  92. state: item.state_name,
  93. page: item.page,
  94. page_size: this.page_size
  95. }).then(res => {
  96. if(options && options.refresh){
  97. item.isRefresher = false;
  98. }
  99. // item.isPage = res.isPage; // 是否有下一页
  100. if(!item.isPage){
  101. item.loading_class = false;
  102. item.loading_text = '已加载全部数据~'
  103. }
  104. if(item.page == 1){
  105. item.list = res.data.list;
  106. }else{
  107. item.list.push(...res.data.list);
  108. }
  109. })
  110. },
  111. tabsChange(current){
  112. this.current = current;
  113. if(this.tab_list[this.current].list.length <= 0){
  114. this.getData();
  115. }
  116. },
  117. swiperChange(event){
  118. this.current = event.detail.current;
  119. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  120. if(this.tab_list[this.current].list.length <= 0){
  121. this.getData();
  122. }
  123. },
  124. // 滚动到底部
  125. scrolltolower(){
  126. let item = this.tab_list[this.current];
  127. if(item.isPage){
  128. item.page++;
  129. this.getData();
  130. }
  131. },
  132. // 下拉刷新
  133. onRefresherrefresh(){
  134. this.$u.throttle(() => {
  135. let item = this.tab_list[this.current];
  136. item.isRefresher = true;
  137. item.page = 1;
  138. item.isPage = true;
  139. item.loading_class = true;
  140. item.loading_text = '正在加载中...';
  141. item.list = [];
  142. this.getData({refresh: true});
  143. }, 200);
  144. }
  145. }
  146. }
  147. </script>
  148. <style>
  149. page{
  150. background-color: #f6f6f6;
  151. }
  152. </style>
  153. <style lang="scss" scoped="scoped">
  154. .card{
  155. width: 100%;
  156. height: max-content;
  157. background-color: #FFFFFF;
  158. border-radius: 20rpx;
  159. padding: 0 20rpx;
  160. box-sizing: border-box;
  161. margin-bottom: 30rpx;
  162. .upper{
  163. width: 100%;
  164. padding: 20rpx 0;
  165. border-bottom: 1rpx solid #e5e5e5;
  166. box-sizing: border-box;
  167. .order-btn{
  168. width: max-content;
  169. height: 62rpx;
  170. border-radius: 32rpx;
  171. // border: 2rpx solid #777777;
  172. // padding: 0 20rpx;
  173. line-height: 60rpx;
  174. font-size: 28rpx;
  175. }
  176. // 已通过
  177. .quoted-price{
  178. color: #777777;
  179. }
  180. // 待发起
  181. .wait{
  182. color: #1833F2;
  183. }
  184. // 待审核
  185. .passed{
  186. color: #0BCE5F;
  187. }
  188. // 未通过
  189. .refuse{
  190. color: #FF0000;
  191. }
  192. }
  193. .lower{
  194. padding: 20rpx 0;
  195. font-size: 24rpx;
  196. color: #777777;
  197. }
  198. }
  199. </style>