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

220 lines
5.8 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/gonghuo/detail?p_sn='+ item.p_sn)">
  16. <view class="lf-row-between item" v-if="item.canteen.canteen_name">
  17. <view class="lf-color-gray">采购方</view>
  18. <view class="lf-color-black">{{ item.canteen.canteen_name }}</view>
  19. </view>
  20. <view class="lf-row-between item" v-if="item.created_at">
  21. <view class="lf-color-gray">发单时间</view>
  22. <view class="lf-color-black">{{ item.created_at }}</view>
  23. </view>
  24. <view class="lf-row-between item" v-if="item.deadline_text">
  25. <view class="lf-color-gray">预计收货时间</view>
  26. <view class="lf-color-black">{{ item.deadline_text }}</view>
  27. </view>
  28. <view class="lf-row-between item" v-if="item.receive_time">
  29. <view class="lf-color-gray">实际送达时间</view>
  30. <view class="lf-color-black">{{ item.receive_time }}</view>
  31. </view>
  32. <view class="lf-row-between item" v-if="item.cate_number">
  33. <view class="lf-color-gray">商品种类</view>
  34. <view class="lf-color-black">{{ item.cate_number }}</view>
  35. </view>
  36. <view class="lf-row-between item" v-if="item.state">
  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, // scroll-view下拉刷新状态,当前默认没有触发
  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. '已发货': 'passed',
  96. '已收货': 'passed',
  97. '已入库': 'passed',
  98. '备货中': 'wait',
  99. '待接单': 'quoted-price',
  100. '已退单': 'refuse'
  101. }
  102. return class_name[val];
  103. }
  104. }
  105. },
  106. onLoad(){
  107. this.windowHeight = uni.getSystemInfoSync().windowHeight;
  108. this.getData();
  109. },
  110. methods: {
  111. getData(options){
  112. let item = this.tab_list[this.current];
  113. let state = item.name == '全部' ? '' : item.name;
  114. this.$http(this.API.API_SUPPLIER_PURCHASEORDERLIST, {
  115. state: this.current,
  116. page: item.page,
  117. page_size: this.page_size
  118. }).then(res => {
  119. console.log("res", res);
  120. let list = res.data.list || {};
  121. if(options && options.refresh){
  122. item.isRefresher = false;
  123. }
  124. item.isPage = this.$isRight(list.next_page_url); // 是否有下一页
  125. if(!item.isPage){
  126. item.loading_class = false;
  127. item.loading_text = '已加载全部数据~'
  128. }
  129. if(item.page == 1){
  130. item.list = list.data;
  131. }else{
  132. item.list.push(...list.data);
  133. }
  134. }).catch(err => {
  135. if(options && options.refresh){
  136. item.isRefresher = false;
  137. }
  138. })
  139. },
  140. tabsChange(current){
  141. this.current = current;
  142. if(this.tab_list[this.current].list.length <= 0){
  143. this.getData();
  144. }
  145. },
  146. swiperChange(event){
  147. this.current = event.detail.current;
  148. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  149. if(this.tab_list[this.current].list.length <= 0){
  150. this.getData();
  151. }
  152. },
  153. // 滚动到底部
  154. scrolltolower(){
  155. let item = this.tab_list[this.current];
  156. if(item.isPage){
  157. item.page++;
  158. this.getData();
  159. }
  160. },
  161. // 下拉刷新
  162. onRefresherrefresh(){
  163. this.$u.throttle(() => {
  164. let item = this.tab_list[this.current];
  165. item.isRefresher = true;
  166. item.page = 1;
  167. item.isPage = true;
  168. item.loading_class = true;
  169. item.loading_text = '正在加载中...';
  170. item.list = [];
  171. this.getData({refresh: true});
  172. }, 200);
  173. }
  174. }
  175. }
  176. </script>
  177. <style>
  178. page{
  179. background-color: #f6f6f6;
  180. }
  181. </style>
  182. <style lang="scss" scoped="scoped">
  183. .card{
  184. width: 100%;
  185. height: max-content;
  186. background-color: #FFFFFF;
  187. border-radius: 20rpx;
  188. padding: 0 20rpx;
  189. box-sizing: border-box;
  190. margin-bottom: 30rpx;
  191. .item{
  192. padding: 20rpx 0;
  193. box-sizing: border-box;
  194. width: 100%;
  195. // border-bottom: 1rpx solid #E5E5E5;
  196. font-size: 28rpx;
  197. &:last-child{
  198. border-bottom: none;
  199. }
  200. }
  201. // 已报价,等待审核
  202. .quoted-price{
  203. color: #777777;
  204. }
  205. // 等待报价
  206. .wait{
  207. color: #1833F2;
  208. }
  209. // 已通过审核
  210. .passed{
  211. color: #0BCE5F;
  212. }
  213. // 报价被拒绝
  214. .refuse{
  215. color: #FF0000;
  216. }
  217. }
  218. </style>