order.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="order-page">
  3. <view scroll-y class="order-list">
  4. <block v-if="!$util.isEmpty(list.data)">
  5. <OrderItem v-for="(item, index) in list.data" :key="index" :info="item" @click="gotoDetails(item)"></OrderItem>
  6. </block>
  7. <block v-else>
  8. <AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
  9. </block>
  10. </view>
  11. <view class="app-footer open_btn">
  12. <view @click="addEvent" class="admin-button-com middle blue">新增采购</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import Tabs from "@/components/plugin/tabs";
  18. import OrderItem from "./orderItem";
  19. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  20. import { list } from "@/mixins";
  21. import { PURCHASE_ORDER_STATUS } from "@/utils/declare";
  22. import { getPurchaseListApi } from "@/api/purchase/index";
  23. export default {
  24. components: {
  25. Tabs,
  26. OrderItem,
  27. AppWrapperEmpty
  28. },
  29. mixins: [list],
  30. data() {
  31. return {
  32. PURCHASE_ORDER_STATUS,
  33. tabIndex: 0,
  34. tabs: [
  35. {
  36. name: "全部",
  37. key: "",
  38. value: "25"
  39. },
  40. {
  41. name: "待确认",
  42. key: "1",
  43. value: "25"
  44. },
  45. {
  46. name: "待配送",
  47. key: "2",
  48. value: "25"
  49. },
  50. {
  51. name: "配送中",
  52. key: "3",
  53. value: "25"
  54. },
  55. {
  56. name: "已完成",
  57. key: "4",
  58. value: "25"
  59. }
  60. ]
  61. };
  62. },
  63. onPullDownRefresh() {
  64. this.resetList();
  65. this._list().then(res => {
  66. uni.stopPullDownRefresh();
  67. });
  68. },
  69. methods: {
  70. async init() {
  71. this._list();
  72. },
  73. _list() {
  74. let options = {
  75. page: this.list.page,
  76. pageSize: this.list.pageSize,
  77. status: this.tabs[this.tabIndex].key
  78. };
  79. return getPurchaseListApi(options)
  80. .then(res => {
  81. const {
  82. data: { allNum, unPayNum, unSendNum, sendingNum, finishNum }
  83. } = res;
  84. this.completes(res);
  85. for (let index = 0; index < this.tabs.length; index++) {
  86. const element = this.tabs[index];
  87. if (element.key == "") {
  88. // this.tabs[index].value = allNum;
  89. this.$set(this.tabs, index, {
  90. ...this.tabs[index],
  91. value: allNum
  92. });
  93. } else if (element.key == PURCHASE_ORDER_STATUS.CONFIRM) {
  94. this.tabs[index].value = unPayNum;
  95. } else if (element.key == PURCHASE_ORDER_STATUS.UNDIS) {
  96. this.tabs[index].value = unSendNum;
  97. } else if (element.key == PURCHASE_ORDER_STATUS.DIS) {
  98. this.tabs[index].value = sendingNum;
  99. } else if (element.key == PURCHASE_ORDER_STATUS.DONE) {
  100. this.tabs[index].value = finishNum;
  101. }
  102. }
  103. })
  104. .catch(err => {
  105. console.log(3333, err);
  106. });
  107. },
  108. changeTabEvent(info) {
  109. const { index } = info;
  110. if (this.tabIndex == index) {
  111. return false;
  112. } else {
  113. this.tabIndex = index;
  114. this.resetList();
  115. this._list();
  116. }
  117. },
  118. getItemStatusName(status) {
  119. let name = "";
  120. switch (status) {
  121. case OUT_STATUS.CONFIRM:
  122. name = "待出库";
  123. break;
  124. case OUT_STATUS.DONE:
  125. name = "已出库";
  126. break;
  127. default:
  128. break;
  129. }
  130. return name;
  131. },
  132. addEvent() {
  133. uni.navigateTo({
  134. url: `/pagesPurchase/add`,
  135. success: result => {},
  136. fail: () => {},
  137. complete: () => {}
  138. });
  139. },
  140. gotoDetails(item) {
  141. uni.navigateTo({
  142. url: `/pagesPurchase/info?orderSn=${item.orderSn}`,
  143. success: result => {},
  144. fail: () => {},
  145. complete: () => {}
  146. });
  147. }
  148. }
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. .order-page {
  153. height: 100%;
  154. display: flex;
  155. flex-direction: column;
  156. background-color: #f9fbfc;
  157. .order-list {
  158. padding-top: 20upx;
  159. padding-bottom: 80upx;
  160. flex: 1;
  161. // padding-bottom: 50upx;
  162. .allot-item {
  163. margin-bottom: 1px;
  164. padding: 30upx;
  165. display: flex;
  166. align-items: center;
  167. box-shadow: 0px 1px 0px 0px #eeeeee;
  168. background-color: #fff;
  169. .info {
  170. flex: 1;
  171. margin-right: 20px;
  172. .info-order {
  173. font-size: 32upx;
  174. font-weight: 600;
  175. color: #333333;
  176. }
  177. .info-name {
  178. margin: 40upx 0 20upx;
  179. font-size: 28upx;
  180. font-weight: 400;
  181. color: #666666;
  182. }
  183. .info-time {
  184. margin-right: 30upx;
  185. font-size: 28upx;
  186. font-weight: 400;
  187. color: #666666;
  188. }
  189. }
  190. .status {
  191. display: flex;
  192. flex-direction: column;
  193. align-items: center;
  194. flex-shrink: 0;
  195. width: 100upx;
  196. color: #cccccc;
  197. .status-name {
  198. margin-top: 10upx;
  199. font-size: 24upx;
  200. }
  201. .iconfont {
  202. font-size: 46upx;
  203. }
  204. &.primary {
  205. color: #3385ff;
  206. }
  207. &.gray {
  208. color: #cccccc;
  209. }
  210. &.warn {
  211. color: #ffaf1d;
  212. }
  213. }
  214. }
  215. }
  216. .bar-view {
  217. flex-shrink: 0;
  218. display: flex;
  219. justify-content: flex-end;
  220. align-items: center;
  221. padding: 0 30upx;
  222. width: 100%;
  223. height: 100upx;
  224. box-shadow: 0px -1px 6px 0px rgba(4, 0, 0, 0.06);
  225. .btn-view {
  226. display: flex;
  227. .admin-button-com {
  228. margin: 0 10upx;
  229. width: 140upx;
  230. }
  231. }
  232. }
  233. }
  234. </style>