order-query-list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="container">
  3. <view class="header" v-if="detail.orderId">
  4. <view class="flex-d">
  5. <text>订单编号: {{ detail.orderId }}</text>
  6. <text class="mt-16">库位: {{ detail.positionCode }}</text>
  7. </view>
  8. <view class="status">
  9. <text>{{ detail.stockStatus == 1 ? '已入库' : '已出库' }}</text>
  10. </view>
  11. </view>
  12. <view style="background-color: #ffffff" class="pad-5 mt-20 content-info" v-if="detail.orderId">
  13. <u-tabs :list="list1" v-model="activeTab" :itemStyle="{ height: '44px', width: '48%' }"
  14. @change="handleTabChange"></u-tabs>
  15. <view v-if="activeTab === 0" class="product-details">
  16. <BookInfo :bookList="detail.detailVoList" :detail="detail" :isShow="false" />
  17. </view>
  18. <view v-else class="operation-logs mt-20">
  19. <view v-for="(log, index) in operationLogs" :key="index" class="log-item">
  20. <text>{{ log.createTime }}</text>
  21. <text>{{ log.createName }}</text>
  22. <text>{{ log.content }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 底部扫码输入框 -->
  27. <view class="fixed-bottom pad-20" style="background: #ffffff;">
  28. <u-search placeholder="请输入快递单号/订单编号" :searchIconSize="24" bgColor="#f6f7f6"
  29. @search="orderQuery" v-model="query.search" custom-style="font-size:32rpx"
  30. placeholder-style="font-size:32rpx" :clearabled="true" :focus="false" :showAction="false"
  31. :height="42"></u-search>
  32. <u-icon name="scan" size="34" color="#19be6b" @click="openScan"></u-icon>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {
  38. reactive,
  39. ref
  40. } from 'vue'
  41. import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
  42. import BookInfo from '../detail/components/BookInfo.vue'
  43. const list1 = reactive([{
  44. name: '商品明细'
  45. }, {
  46. name: "操作记录"
  47. }])
  48. const activeTab = ref(0)
  49. const query = reactive({
  50. searchType: 2,
  51. search: ''
  52. })
  53. // 判断搜索类型
  54. const determineSearchType = (search) => {
  55. // 判断是否为纯数字的字符串
  56. const isNumberString = /^\d+$/.test(search.toString())
  57. return isNumberString ? 1 : 2
  58. }
  59. //订单查询 /app/stock/findOrder
  60. const detail = ref({})
  61. const orderQuery = () => {
  62. if (!query.search) {
  63. uni.$u.toast('请输入快递单号/订单编号')
  64. uni.$u.ttsModule.speak('请输入快递单号/订单编号')
  65. return
  66. }
  67. // 设置搜索类型
  68. query.searchType = determineSearchType(query.search)
  69. uni.$u.http.get('/app/stock/findOrder', { params: query }).then(res => {
  70. if (res.code == 200) {
  71. detail.value = res.data
  72. uni.$u.ttsModule.speak('查询成功')
  73. getOperationLogs(res.data.orderId)
  74. } else {
  75. uni.$u.toast(res.msg)
  76. uni.$u.ttsModule.speak(res.msg)
  77. }
  78. })
  79. }
  80. //获取操作记录
  81. const operationLogs = ref([])
  82. const getOperationLogs = (orderId) => {
  83. uni.$u.http.get('/app/stock/getGodownStocklog', {params: {orderId}}).then(res => {
  84. if(res.code == 200){
  85. operationLogs.value = res.data
  86. }
  87. })
  88. }
  89. function handleTabChange(tab) {
  90. activeTab.value = tab.index
  91. }
  92. function openScan() {
  93. uni.scanCode({
  94. success: (res) => {
  95. query.search = res.result
  96. orderQuery()
  97. }
  98. })
  99. }
  100. onLoad((options) => {
  101. if(options.id){
  102. query.search = options.id
  103. orderQuery()
  104. }
  105. // #ifdef APP-PLUS
  106. uni.$u.useGlobalEvent((e) => {
  107. if (e.barcode) {
  108. getDetailByCode(e.barcode)
  109. }
  110. })
  111. // #endif
  112. })
  113. onShow(() => {
  114. uni.$u.updateActivePageOnShow()
  115. })
  116. onUnload(() => {
  117. uni.$u.cleanupOnPageUnload();
  118. });
  119. </script>
  120. <style lang="scss" scoped>
  121. .header {
  122. display: flex;
  123. justify-content: space-between;
  124. padding: 20rpx 30rpx;
  125. background-color: #ffffff;
  126. }
  127. .status {
  128. color: green;
  129. }
  130. .content-info{
  131. padding-bottom: 60px;
  132. }
  133. .log-item {
  134. display: flex;
  135. justify-content: space-between;
  136. padding: 20rpx 30rpx;
  137. border-bottom: 1px solid #e0e0e0;
  138. }
  139. </style>