location-order-list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. onUnmounted
  27. } from 'vue'
  28. import {
  29. onLoad,
  30. onShow
  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. // #ifdef APP-PLUS
  86. const { unregister } = uni.$u.useEventListener((e) => {
  87. if (e.barcode) {
  88. orderCode.value = e.barcode
  89. onSearch()
  90. }
  91. });
  92. // #endif
  93. onLoad((options) => {
  94. if (options.positionCode) {
  95. getOrderListByPositionCode(options.positionCode)
  96. }
  97. });
  98. onUnmounted(() => {
  99. // #ifdef APP-PLUS
  100. unregister();
  101. // #endif
  102. });
  103. </script>
  104. <style lang="scss" scoped>
  105. .header {
  106. display: flex;
  107. justify-content: space-between;
  108. padding: 20rpx 30rpx;
  109. background-color: #ffffff;
  110. }
  111. .status {
  112. color: green;
  113. }
  114. .log-item {
  115. display: flex;
  116. justify-content: space-between;
  117. padding: 20rpx 30rpx;
  118. border-bottom: 1px solid #e0e0e0;
  119. }
  120. </style>