location-order-list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. } from '@dcloudio/uni-app'
  31. import LocationOrderItem from './components/LocationOrderItem.vue'
  32. const orderCode = ref('')
  33. const originList = ref([])
  34. const orderList = ref([])
  35. //根据库位编号查询订单
  36. const detail = ref({})
  37. const getOrderListByPositionCode = (positionCode) => {
  38. uni.$u.http.get('/app/stock/getOrderByPositionCode?positionCode=' + positionCode).then(res => {
  39. if (res.code == 200) {
  40. detail.value = res.data
  41. orderList.value = res.data.godownStockLogResults
  42. originList.value = res.data.godownStockLogResults
  43. if (originList.value.length > 0) {
  44. uni.$u.ttsModule.speak('查询到' + originList.value.length + '条订单')
  45. } else {
  46. uni.$u.toast('暂无订单')
  47. uni.$u.ttsModule.speak('暂无订单')
  48. }
  49. } else {
  50. uni.$u.toast(res.msg)
  51. uni.$u.ttsModule.speak(res.msg)
  52. }
  53. })
  54. }
  55. const onSearch = () => {
  56. if (!orderCode.value) {
  57. orderList.value = originList.value
  58. uni.$u.toast('请输入订单号或物流单号')
  59. return
  60. }
  61. // 判断是否为纯数字字符串(订单号)
  62. const searchValue = String(orderCode.value).trim()
  63. const isNumeric = /^[0-9]+$/.test(searchValue)
  64. // 在orderList中搜索
  65. const result = originList.value.filter(item => {
  66. if (isNumeric) {
  67. // 如果是纯数字,按orderId搜索
  68. return item.orderId === orderCode.value
  69. } else {
  70. // 非纯数字,按物流单号搜索
  71. return item.waybillCode === orderCode.value
  72. }
  73. })
  74. orderList.value = result
  75. }
  76. function openScan() {
  77. uni.scanCode({
  78. success: (res) => {
  79. orderCode.value = res.result
  80. onSearch()
  81. }
  82. })
  83. }
  84. onLoad((options) => {
  85. if (options.positionCode) {
  86. getOrderListByPositionCode(options.positionCode)
  87. }
  88. // #ifdef APP-PLUS
  89. uni.$u.useGlobalEvent((e) => {
  90. if (e.barcode) {
  91. orderCode.value = res.result
  92. onSearch()
  93. }
  94. })
  95. // #endif
  96. })
  97. onShow(() => {
  98. uni.$u.updateActivePageOnShow()
  99. })
  100. </script>
  101. <style lang="scss" scoped>
  102. .header {
  103. display: flex;
  104. justify-content: space-between;
  105. padding: 20rpx 30rpx;
  106. background-color: #ffffff;
  107. }
  108. .status {
  109. color: green;
  110. }
  111. .log-item {
  112. display: flex;
  113. justify-content: space-between;
  114. padding: 20rpx 30rpx;
  115. border-bottom: 1px solid #e0e0e0;
  116. }
  117. </style>