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

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