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

242 lines
6.1 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. '待审核': 'quoted-price',
  101. '待接单': 'quoted-price',
  102. '备货中': 'wait',
  103. '已发货': 'wait',
  104. '已收货': 'passed',
  105. '已入库': 'passed',
  106. '已退单': 'refuse',
  107. '已撤销': 'refuse'
  108. }
  109. return class_name[val];
  110. }
  111. }
  112. },
  113. onLoad(){
  114. this.windowHeight = uni.getSystemInfoSync().windowHeight;
  115. this.getData();
  116. },
  117. methods: {
  118. // 获取数据
  119. getData(options){
  120. let item = this.tab_list[this.current];
  121. // let tabType = 0
  122. // if(this.current == 2) {
  123. // tabType = 3
  124. // }else if(this.current == 3){
  125. // tabType = 4
  126. // }else if(this.current == 4){
  127. // tabType = 5
  128. // }else if(this.current == 5){
  129. // tabType = 7
  130. // }else {
  131. // tabType = this.current
  132. // }
  133. this.$http(this.API.API_CANTEEN_PURCHASEORDERLIST, {
  134. page: item.page,
  135. page_size: this.page_size,
  136. state: this.current || ''
  137. }).then(res => {
  138. console.log("getData", res);
  139. let list = res.data.list || {};
  140. let isPage = this.$isRight(list.next_page_url);
  141. item.isPage = isPage;
  142. if(!isPage){
  143. item.loading_class = false;
  144. item.loading_text = '已加载全部数据~';
  145. }
  146. if(options && options.refresh){
  147. item.isRefresher = false;
  148. }
  149. if(item.page == 1){
  150. item.list = list.data;
  151. }else{
  152. item.list.push(...list.data);
  153. }
  154. }).catch(err => {
  155. if(options && options.refresh){
  156. item.isRefresher = false;
  157. }
  158. })
  159. },
  160. // 切换tabs
  161. tabsChange(current){
  162. this.current = current;
  163. if(this.tab_list[this.current].list.length <= 0){
  164. this.getData();
  165. }
  166. },
  167. // 切换swiper
  168. swiperChange(event){
  169. this.current = event.detail.current;
  170. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  171. if(this.tab_list[this.current].list.length <= 0){
  172. this.getData();
  173. }
  174. },
  175. // 页面滚动到底部,触发分页
  176. scrolltolower(){
  177. let item = this.tab_list[this.current];
  178. if(item.isPage){
  179. item.page++;
  180. this.getData();
  181. }
  182. },
  183. // 下拉刷新
  184. onRefresherrefresh(){
  185. this.$u.throttle(() => {
  186. let item = this.tab_list[this.current];
  187. item.isRefresher = true;
  188. item.page = 1;
  189. item.isPage = true;
  190. item.loading_class = true;
  191. item.loading_text = '正在加载中...';
  192. item.list = [];
  193. this.getData({refresh: true});
  194. }, 200);
  195. }
  196. }
  197. }
  198. </script>
  199. <style>
  200. page{
  201. background-color: #f6f6f6;
  202. }
  203. </style>
  204. <style lang="scss" scoped="scoped">
  205. .card{
  206. width: 100%;
  207. height: max-content;
  208. background-color: #FFFFFF;
  209. border-radius: 20rpx;
  210. padding: 0 20rpx;
  211. box-sizing: border-box;
  212. margin-bottom: 30rpx;
  213. .item{
  214. padding: 20rpx 0;
  215. box-sizing: border-box;
  216. width: 100%;
  217. border-bottom: 1rpx solid #E5E5E5;
  218. font-size: 28rpx;
  219. &:last-child{
  220. border-bottom: none;
  221. }
  222. }
  223. // 已报价,等待审核
  224. .quoted-price{
  225. color: #777777;
  226. }
  227. // 等待报价
  228. .wait{
  229. color: #1833F2;
  230. }
  231. // 已通过审核
  232. .passed{
  233. color: #0BCE5F;
  234. }
  235. // 报价被拒绝
  236. .refuse{
  237. color: #FF0000;
  238. }
  239. }
  240. </style>