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

199 lines
5.0 KiB

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