index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="goods-page">
  3. <u-navbar
  4. height="40px"
  5. title="货物信息录入"
  6. bgColor="#fff"
  7. autoBack
  8. placeholder
  9. >
  10. <view class="u-nav-slot depot-label" slot="right" @click="stashClick">
  11. <view class="name">{{ curDepotName }}</view>
  12. </view>
  13. </u-navbar>
  14. <view class="container_main">
  15. <u-sticky :offsetTop="offsetTop" bgColor="#fff">
  16. <view class="search-box">
  17. <u-search
  18. placeholder="请输入单据编号或名称"
  19. shape="square"
  20. v-model="query.number"
  21. :showAction="false"
  22. :clearabled="true"
  23. @search="handleSearch"
  24. @clear="handleSearch"
  25. ></u-search>
  26. </view>
  27. </u-sticky>
  28. <view class="content-box">
  29. <view class="content-box-val"> </view>
  30. <u-empty
  31. mode="data"
  32. text="暂无内容"
  33. marginTop="60"
  34. icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
  35. v-if="list.length == 0"
  36. ></u-empty>
  37. <!-- 加载更多 -->
  38. <u-loadmore
  39. v-if="list.length > 0"
  40. :status="loadStatus"
  41. @loadmore="onLoadMore"
  42. />
  43. </view>
  44. </view>
  45. <error-pop
  46. v-model="actionPop.errorShow"
  47. isCenter
  48. cancelBtnText="取消"
  49. confirmBtnText="确定"
  50. @close="actionPop.errorShow = false"
  51. @confirm="submit"
  52. :content="actionPop.errorText"
  53. ></error-pop>
  54. </view>
  55. </template>
  56. <script>
  57. import checkItem from "./components/check-item.vue";
  58. import {
  59. taskStocktakingList,
  60. startTask,
  61. taskComplete,
  62. taskStocktakingDetail,
  63. } from "@/common/request/apis/inventoryTask";
  64. import { mapGetters } from "vuex";
  65. export default {
  66. components: {
  67. checkItem,
  68. errorPop,
  69. },
  70. data() {
  71. return {
  72. offsetTop: 0,
  73. query: {
  74. number: "",
  75. },
  76. currentPage: 1,
  77. pageSize: 10,
  78. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  79. list: [],
  80. // 中心仓
  81. cangName: "",
  82. };
  83. },
  84. computed: {
  85. ...mapGetters(["depotInfo"]),
  86. curDepotId() {
  87. return this.depotInfo ? this.depotInfo.id : "";
  88. },
  89. curDepotName() {
  90. return this.depotInfo ? this.depotInfo.depotName : "";
  91. },
  92. },
  93. onLoad() {
  94. let systemInfo = uni.getSystemInfoSync();
  95. let statusBarHeight = systemInfo.statusBarHeight;
  96. this.offsetTop = statusBarHeight + 40;
  97. this.loadData();
  98. },
  99. onShow() {},
  100. onPullDownRefresh() {
  101. // 下拉刷新
  102. this.onRefresh();
  103. },
  104. onReachBottom() {
  105. // 触底加载更多
  106. this.onLoadMore();
  107. },
  108. methods: {
  109. async onRefresh() {
  110. try {
  111. await this.loadData(true);
  112. } finally {
  113. uni.stopPullDownRefresh();
  114. }
  115. },
  116. async onLoadMore() {
  117. if (this.loadStatus !== "loadmore") return;
  118. this.loadStatus = "loading";
  119. try {
  120. await this.loadData();
  121. } catch (e) {
  122. this.loadStatus = "loadmore";
  123. }
  124. },
  125. async loadData(isRefresh = false) {
  126. if (isRefresh) {
  127. this.currentPage = 1;
  128. this.list = [];
  129. }
  130. try {
  131. this.loadStatus = "loading";
  132. const currentPage = this.currentPage;
  133. const pageSize = this.pageSize;
  134. const params = {
  135. currentPage,
  136. pageSize,
  137. ...this.query,
  138. depotId: this.curDepotId,
  139. };
  140. console.log("params=====", params);
  141. const res = await taskStocktakingList(params);
  142. const { rows, total } = res.data;
  143. this.list = [...this.list, ...rows];
  144. if (currentPage * pageSize < Number(total)) {
  145. this.currentPage++;
  146. this.loadStatus = "loadmore";
  147. } else {
  148. this.loadStatus = "nomore";
  149. }
  150. } catch (error) {}
  151. },
  152. handleSearch(value) {
  153. this.loadData(true);
  154. },
  155. },
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .goods-page {
  160. min-height: 100vh;
  161. background-color: #f0f6fb;
  162. .container_main {
  163. .search-box {
  164. background-color: rgba(191, 200, 219, 0.2);
  165. margin: 0 32rpx;
  166. display: flex;
  167. align-items: center;
  168. justify-content: space-between;
  169. border-radius: 8rpx;
  170. ::v-deep .u-search__content {
  171. background-color: transparent !important;
  172. .u-search__content__input {
  173. background-color: transparent !important;
  174. }
  175. }
  176. .scan-icon {
  177. width: 100rpx;
  178. height: 100%;
  179. image {
  180. width: 40rpx;
  181. height: 40rpx;
  182. }
  183. }
  184. }
  185. .content-box {
  186. padding: 24rpx;
  187. &-val {
  188. border-radius: 16rpx 16rpx 0 0;
  189. overflow: hidden;
  190. }
  191. }
  192. }
  193. }
  194. </style>