自主项目,食堂系统,前端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.

217 lines
5.4 KiB

  1. <template>
  2. <view>
  3. <view class="tabs">
  4. <u-tabs :list="tab_list" :is-scroll="true" :current="current" bg-color="#f6f6f6" active-color="#11D189" @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/canteen/purchase/detail?p_sn='+ item.p_sn)">
  16. <view class="lf-row-between item">
  17. <view class="lf-color-gray">供应商</view>
  18. <view class="lf-color-black">{{ item.supplier.supplier_name }}</view>
  19. </view>
  20. <view class="lf-row-between item">
  21. <view class="lf-color-gray">批次号</view>
  22. <view class="lf-color-black"></view>
  23. </view>
  24. <view class="lf-row-between item">
  25. <view class="lf-color-gray">发单时间</view>
  26. <view class="lf-color-black">{{ item.receiving_start }}</view>
  27. </view>
  28. <view class="lf-row-between item">
  29. <view class="lf-color-gray">送达时间</view>
  30. <view class="lf-color-black">{{ item.receiving_end }}</view>
  31. </view>
  32. <view class="lf-row-between item">
  33. <view class="lf-color-gray">商品种类</view>
  34. <view class="lf-color-black"></view>
  35. </view>
  36. <view class="lf-row-between item">
  37. <view class="lf-color-gray">订单状态</view>
  38. <view :class="stateClass(item.state)">{{ item.state }}</view>
  39. </view>
  40. </view>
  41. <view class="loading-more">
  42. <text v-if="tabItem.list.length" :class="{'loading-more-text': tabItem.loading_class}">{{ tabItem.loading_text }}</text>
  43. <lf-nocontent v-else class="lf-m-t-50"></lf-nocontent>
  44. </view>
  45. </scroll-view>
  46. </swiper-item>
  47. </swiper>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data(){
  53. let _public = {
  54. loading_class: true,
  55. loading_text: '正在加载中...',
  56. page: 1,
  57. isPage: true,
  58. isRefresher: false
  59. };
  60. return {
  61. current: 0,
  62. tab_list: [{
  63. name: '全部',
  64. list: [],
  65. ..._public
  66. },{
  67. name: '未发单',
  68. list: [],
  69. ..._public
  70. },{
  71. name: '待接单',
  72. list: [],
  73. ..._public
  74. },{
  75. name: '备货中',
  76. list: [],
  77. ..._public
  78. },{
  79. name: '已发货',
  80. list: [],
  81. ..._public
  82. },{
  83. name: '已入库',
  84. list: [],
  85. ..._public
  86. }],
  87. page_size: 10,
  88. windowHeight: 0
  89. }
  90. },
  91. computed: {
  92. stateClass(){
  93. return function(val){
  94. let class_name = {
  95. '等待接单': 'quoted-price',
  96. '等待发货': 'wait',
  97. '已完成': 'passed',
  98. '已退单': 'refuse'
  99. }
  100. return class_name[val];
  101. }
  102. }
  103. },
  104. onLoad(){
  105. this.windowHeight = uni.getSystemInfoSync().windowHeight;
  106. this.getData();
  107. },
  108. methods: {
  109. // 获取数据
  110. getData(options){
  111. let item = this.tab_list[this.current];
  112. this.$http(this.API.API_CANTEEN_PURCHASEORDERLIST, {
  113. page: item.page,
  114. page_size: this.page_size,
  115. state: ''
  116. }).then(res => {
  117. console.log("getData", res);
  118. let list = res.data.list || {};
  119. let isPage = this.$isRight(list.next_page_url);
  120. item.isPage = isPage;
  121. if(!isPage){
  122. item.loading_class = false;
  123. item.loading_text = '已加载全部数据~';
  124. }
  125. if(options && options.refresh){
  126. item.isRefresher = false;
  127. }
  128. if(item.page == 1){
  129. item.list = list.data;
  130. }else{
  131. item.list.push(...list.data);
  132. }
  133. });
  134. },
  135. // 切换tabs
  136. tabsChange(current){
  137. this.current = current;
  138. if(this.tab_list[this.current].list.length <= 0){
  139. this.getData();
  140. }
  141. },
  142. // 切换swiper
  143. swiperChange(event){
  144. this.current = event.detail.current;
  145. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  146. if(this.tab_list[this.current].list.length <= 0){
  147. this.getData();
  148. }
  149. },
  150. // 页面滚动到底部,触发分页
  151. scrolltolower(){
  152. let item = this.tab_list[this.current];
  153. if(item.isPage){
  154. item.page++;
  155. this.getData();
  156. }
  157. },
  158. // 下拉刷新
  159. onRefresherrefresh(){
  160. this.$u.throttle(() => {
  161. let item = this.tab_list[this.current];
  162. item.isRefresher = true;
  163. item.page = 1;
  164. item.isPage = true;
  165. item.loading_class = true;
  166. item.loading_text = '正在加载中...';
  167. item.list = [];
  168. this.getData({refresh: true});
  169. }, 200);
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. page{
  176. background-color: #f6f6f6;
  177. }
  178. </style>
  179. <style lang="scss" scoped="scoped">
  180. .card{
  181. width: 100%;
  182. height: max-content;
  183. background-color: #FFFFFF;
  184. border-radius: 20rpx;
  185. padding: 0 20rpx;
  186. box-sizing: border-box;
  187. margin-bottom: 30rpx;
  188. .item{
  189. padding: 20rpx 0;
  190. box-sizing: border-box;
  191. width: 100%;
  192. border-bottom: 1rpx solid #E5E5E5;
  193. font-size: 28rpx;
  194. &:last-child{
  195. border-bottom: none;
  196. }
  197. }
  198. // 已报价,等待审核
  199. .quoted-price{
  200. color: #777777;
  201. }
  202. // 等待报价
  203. .wait{
  204. color: #1833F2;
  205. }
  206. // 已通过审核
  207. .passed{
  208. color: #0BCE5F;
  209. }
  210. // 报价被拒绝
  211. .refuse{
  212. color: #FF0000;
  213. }
  214. }
  215. </style>