location-order-list.vue 3.5 KB

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