index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <van-nav-bar
  3. :title="$t('inventoryQuery.inOutFlow')"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. >
  8. </van-nav-bar>
  9. <van-search
  10. v-model="req.keyword"
  11. placeholder="请输入关键词"
  12. @search="onRefresh"
  13. />
  14. <van-tabs v-model:active="active" @change="handleChangeTab">
  15. <van-tab :title="$t('inventoryQuery.all')" name="all"></van-tab>
  16. <van-tab :title="$t('inventoryQuery.warehousing')" name="1"></van-tab>
  17. <van-tab :title="$t('inventoryQuery.outbound')" name="2"></van-tab>
  18. <!-- <van-tab
  19. v-for="(item, index) in warehouseData"
  20. :title="item.name"
  21. :name="item.id"
  22. >
  23. </van-tab> -->
  24. </van-tabs>
  25. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  26. <div class="list">
  27. <van-list
  28. v-model:loading="loading"
  29. :finished="finished"
  30. :finished-text="$t('common.noMore')"
  31. @load="onLoad"
  32. style="margin-bottom: 60px"
  33. >
  34. <div style="margin-top: 10px">
  35. <div v-for="(item, index) in listData" :key="item.id" class="item">
  36. <div class="row">
  37. <div class="left">{{$t('inventoryQuery.operationType')}}</div>
  38. <div class="center">
  39. {{ item.type }}
  40. </div>
  41. <div class="right">
  42. {{ item.createTime }}
  43. </div>
  44. </div>
  45. <div class="row">
  46. <div class="left">{{$t('inventoryQuery.warehouseName')}}</div>
  47. <div class="center">
  48. {{ item.warehouseName }}
  49. </div>
  50. </div>
  51. <div class="row">
  52. <div class="left">{{$t('inventoryQuery.itemName')}}</div>
  53. <div class="center">
  54. {{ item.productName }}
  55. </div>
  56. </div>
  57. <div class="row">
  58. <div class="left">{{$t('inventoryQuery.operationQuantity')}}</div>
  59. <div class="center">
  60. {{ item.quantity }}
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </van-list>
  66. </div>
  67. </van-pull-refresh>
  68. </template>
  69. <script setup>
  70. import { ref, getCurrentInstance, onMounted } from "vue";
  71. import commonList from "@/components/common-list.vue";
  72. import { useRoute } from "vue-router";
  73. const loading = ref(false);
  74. const router = useRoute();
  75. const route = useRoute();
  76. const req = ref({
  77. pageNum: 1,
  78. keyword: null,
  79. type: "",
  80. warehouseId: "",
  81. productId: "",
  82. });
  83. const finished = ref(false);
  84. const proxy = getCurrentInstance().proxy;
  85. const listData = ref([]);
  86. const warehouseData = ref([]);
  87. const active = ref("all");
  88. const listConfig = ref([
  89. {
  90. label: proxy.t('inventoryQuery.itemType'),
  91. prop: "type",
  92. },
  93. {
  94. label: proxy.t('inventoryQuery.itemName'),
  95. prop: "productName",
  96. },
  97. {
  98. label: proxy.t('inventoryQuery.inventoryQuantity'),
  99. prop: "quantity",
  100. },
  101. ]);
  102. const onRefresh = () => {
  103. req.value.pageNum = 1;
  104. finished.value = false;
  105. getList("refresh");
  106. };
  107. const onLoad = () => {
  108. getList();
  109. };
  110. const onClickLeft = () => {
  111. if (route.query.productId || route.query.warehouseId) {
  112. history.back();
  113. } else {
  114. proxy.$router.push("/main/working");
  115. }
  116. };
  117. const onClickRight = () => {
  118. proxy.$router.push("/main/manualInboundAdd");
  119. };
  120. const toDtl = (row) => {
  121. proxy.$router.push({
  122. path: "manualInboundAdd",
  123. query: {
  124. id: row.id,
  125. },
  126. });
  127. };
  128. const getList = (type) => {
  129. loading.value = true;
  130. proxy
  131. .post("/stockJournalDetails/page", req.value)
  132. .then((res) => {
  133. res.data.rows.map(item => {
  134. item.type = item.type === 1 ? proxy.t('inventoryQuery.warehousing') : proxy.t('inventoryQuery.outbound')
  135. })
  136. listData.value =
  137. type === "refresh"
  138. ? res.data.rows
  139. : listData.value.concat(res.data.rows);
  140. if (req.value.pageNum * 10 >= res.data.total) {
  141. finished.value = true;
  142. }
  143. req.value.pageNum++;
  144. loading.value = false;
  145. console.log(listData.value, "wssa");
  146. })
  147. .catch((err) => {
  148. loading.value = false;
  149. });
  150. };
  151. const getWarehouseData = () => {
  152. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
  153. warehouseData.value = res.data.rows;
  154. });
  155. };
  156. const handleChangeTab = () => {
  157. req.value.type = active.value === "all" ? "" : active.value;
  158. req.value.pageNum = 1;
  159. listData.value = [];
  160. getList();
  161. };
  162. // getWarehouseData();
  163. onMounted(() => {
  164. req.value.productId = route.query.productId ? route.query.productId : "";
  165. req.value.warehouseId = route.query.warehouseId
  166. ? route.query.warehouseId
  167. : "";
  168. listData.value = [];
  169. getList();
  170. });
  171. </script>
  172. <style lang="scss" scoped>
  173. .list {
  174. min-height: 70vh;
  175. }
  176. .item {
  177. padding: 10px 10px 0;
  178. border-bottom: 1px solid #dddddd;
  179. background: #fff;
  180. .row {
  181. display: flex;
  182. margin-bottom: 6px;
  183. .left {
  184. width: 70px;
  185. }
  186. .center {
  187. flex: 1;
  188. }
  189. .left,
  190. .right {
  191. color: #999999;
  192. }
  193. }
  194. }
  195. </style>