自主产品,供应链食堂系统。将两个端拆开了。
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.

233 lines
5.9 KiB

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