location-order-list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <view class="flex-d">
  5. <text>仓库: {{ detail.godownName }}</text>
  6. <text class="mt-16">库位编号: {{ detail.positionCode }}</text>
  7. <text class="mt-16">订单数量: {{ originList.length }}</text>
  8. </view>
  9. </view>
  10. <view class="product-details">
  11. <LocationOrderItem v-for="(item, index) in orderList" :key="index" :item="item" />
  12. </view>
  13. <!-- 底部扫码输入框 -->
  14. <view class="fixed-bottom pad-20" style="background: #ffffff;">
  15. <u-search placeholder="请输入快递单号/订单编号" :searchIconSize="24" bgColor="#f6f7f6"
  16. @search="onSearch" v-model="orderCode" :clearabled="true" :focus="false"
  17. :showAction="false" :height="42"></u-search>
  18. <u-icon name="scan" size="36" color="#19be6b" @click="openScan"></u-icon>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import {
  24. reactive,
  25. ref
  26. } from 'vue'
  27. import {
  28. onLoad,
  29. onShow,
  30. onUnload
  31. } from '@dcloudio/uni-app'
  32. import LocationOrderItem from './components/LocationOrderItem.vue'
  33. const orderCode = ref('')
  34. const originList = ref([])
  35. const orderList = ref([])
  36. //根据库位编号查询订单
  37. const detail = ref({})
  38. const getOrderListByPositionCode = (positionCode) => {
  39. uni.$u.http.get('/app/stock/getOrderByPositionCode?positionCode=' + positionCode).then(res => {
  40. if (res.code == 200) {
  41. detail.value = res.data
  42. orderList.value = res.data.godownStockLogResults
  43. originList.value = res.data.godownStockLogResults
  44. if (originList.value.length > 0) {
  45. uni.$u.ttsModule.speak('查询到' + originList.value.length + '条订单')
  46. } else {
  47. uni.$u.toast('暂无订单')
  48. uni.$u.ttsModule.speak('暂无订单')
  49. }
  50. } else {
  51. uni.$u.toast(res.msg)
  52. uni.$u.ttsModule.speak(res.msg)
  53. }
  54. })
  55. }
  56. const onSearch = () => {
  57. if (!orderCode.value) {
  58. orderList.value = originList.value
  59. uni.$u.toast('请输入订单号或物流单号')
  60. return
  61. }
  62. // 判断是否为纯数字字符串(订单号)
  63. const searchValue = String(orderCode.value).trim()
  64. const isNumeric = /^[0-9]+$/.test(searchValue)
  65. // 在orderList中搜索
  66. const result = originList.value.filter(item => {
  67. if (isNumeric) {
  68. // 如果是纯数字,按orderId搜索
  69. return item.orderId === orderCode.value
  70. } else {
  71. // 非纯数字,按物流单号搜索
  72. return item.waybillCode === orderCode.value
  73. }
  74. })
  75. orderList.value = result
  76. }
  77. function openScan() {
  78. uni.scanCode({
  79. success: (res) => {
  80. orderCode.value = res.result
  81. onSearch()
  82. }
  83. })
  84. }
  85. onLoad((options) => {
  86. if (options.positionCode) {
  87. getOrderListByPositionCode(options.positionCode)
  88. }
  89. // #ifdef APP-PLUS
  90. uni.$u.useGlobalEvent((e) => {
  91. if (e.barcode) {
  92. orderCode.value = res.result
  93. onSearch()
  94. }
  95. })
  96. // #endif
  97. })
  98. onShow(() => {
  99. uni.$u.updateActivePageOnShow()
  100. })
  101. onUnload(() => {
  102. uni.$u.cleanupOnPageUnload();
  103. });
  104. </script>
  105. <style lang="scss" scoped>
  106. .header {
  107. display: flex;
  108. justify-content: space-between;
  109. padding: 20rpx 30rpx;
  110. background-color: #ffffff;
  111. }
  112. .status {
  113. color: green;
  114. }
  115. .log-item {
  116. display: flex;
  117. justify-content: space-between;
  118. padding: 20rpx 30rpx;
  119. border-bottom: 1px solid #e0e0e0;
  120. }
  121. </style>