bad-out-order.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="container">
  3. <!-- 搜索框 -->
  4. <u-sticky>
  5. <view class="search-area flex-c mb-20">
  6. <u-search v-model="searchText" placeholder="请输入运单号/订单编号" :show-action="false" :clearabled="true"
  7. @change="onSearch" height="40">
  8. </u-search>
  9. <u-icon name="scan" size="28" color="#19be6b" @click="openScan"></u-icon>
  10. </view>
  11. </u-sticky>
  12. <view class="content">
  13. <!-- 基本信息 -->
  14. <view class="info-section">
  15. <view class="info-item">库位:{{ locationInfo.location }}</view>
  16. <view class="info-item">物流单号:{{ locationInfo.logisticsNo }}</view>
  17. <view class="info-item">订单编号:{{ locationInfo.orderNo }}</view>
  18. <view class="info-item">订单商品:{{ locationInfo.goodsCount }}</view>
  19. <view class="info-item">备注信息:{{ locationInfo.remark }}</view>
  20. </view>
  21. <!-- 极差商品列表 -->
  22. <view class="bad-list">
  23. <view class="list-title mb-6">极差</view>
  24. <view v-for="(item, index) in badList" :key="index">
  25. <BadOutCard :item="item" />
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 底部按钮 -->
  30. <view class="fixed-bottom">
  31. <u-button size="large" type="warning" text="反馈" @click="openRemarkDialog" />
  32. <u-button size="large" type="primary" text="确定出库" @click="onConfirm" />
  33. </view>
  34. <!-- 备注弹窗 -->
  35. <remark-dialog v-model:visible="remarkVisible" :initial-value="currentRemark"
  36. @confirm="handleRemarkConfirm"></remark-dialog>
  37. </view>
  38. </template>
  39. <script setup>
  40. import { ref, onMounted } from 'vue'
  41. import BadOutCard from './components/BadOutCard.vue'
  42. import RemarkDialog from './components/RemarkDialog.vue';
  43. import VolumeTTS from '@/utils/VolumeTTS.js';
  44. import { onLoad } from '@dcloudio/uni-app'
  45. const ttsModule = ref(null)
  46. // 搜索文本
  47. const searchText = ref('')
  48. // 位置信息
  49. const locationInfo = ref({
  50. location: '',
  51. logisticsNo: '',
  52. orderNo: '',
  53. goodsCount: '',
  54. remark: ''
  55. })
  56. // 极差商品列表
  57. const badList = ref([])
  58. onLoad((options) => {
  59. if (options.searchText) {
  60. searchText.value = options.searchText
  61. onSearch()
  62. }
  63. ttsModule.value = new VolumeTTS()
  64. })
  65. // 判断搜索类型
  66. const getSearchType = (text) => {
  67. // 这里可以根据实际业务逻辑调整判断条件
  68. // 假设订单号都是纯数字,物流号包含字母
  69. return /^[0-9]+$/.test(text) ? 1 : 2
  70. }
  71. // 搜索处理
  72. const onSearch = async () => {
  73. if (!searchText.value) return
  74. try {
  75. const searchType = getSearchType(searchText.value)
  76. const { data } = await uni.$u.http.post('/app/stock/findOrderOutStock', {
  77. search: searchText.value,
  78. searchType: searchType
  79. })
  80. if (data) {
  81. // 更新页面数据
  82. locationInfo.value = {
  83. location: data.location || '',
  84. logisticsNo: data.logisticsNo || '',
  85. orderNo: data.orderNo || '',
  86. goodsCount: data.goodsCount || '',
  87. remark: data.remark || ''
  88. }
  89. badList.value = data.badList || []
  90. }
  91. } catch (error) {
  92. uni.showToast({
  93. title: '获取数据失败',
  94. icon: 'none'
  95. })
  96. }
  97. }
  98. // 打开扫码
  99. const openScan = () => {
  100. // #ifdef APP-PLUS || MP-WEIXIN
  101. uni.scanCode({
  102. success: (res) => {
  103. searchText.value = res.result
  104. onSearch()
  105. },
  106. fail: (err) => {
  107. uni.showToast({
  108. title: '扫码失败',
  109. icon: 'error'
  110. })
  111. }
  112. })
  113. // #endif
  114. // #ifdef H5
  115. uni.showToast({
  116. title: 'H5环境不支持扫码',
  117. icon: 'none'
  118. })
  119. // #endif
  120. }
  121. // 确认出库
  122. const onConfirm = () => {
  123. uni.showModal({
  124. title: '确认提示',
  125. content: '是否确认出库?',
  126. success: async (res) => {
  127. if (res.confirm) {
  128. try {
  129. await uni.$u.http.post('/app/stock/outStock', {
  130. orderId: locationInfo.value.orderNo,
  131. positionCode: locationInfo.value.location,
  132. outputRemark: locationInfo.value.remark
  133. })
  134. uni.showToast({
  135. title: '出库成功',
  136. icon: 'success'
  137. })
  138. ttsModule.value.speak('出库成功')
  139. // 清空数据
  140. searchText.value = ''
  141. locationInfo.value = {
  142. location: '',
  143. logisticsNo: '',
  144. orderNo: '',
  145. goodsCount: '',
  146. remark: ''
  147. }
  148. badList.value = []
  149. } catch (error) {
  150. uni.showToast({
  151. title: '出库失败',
  152. icon: 'none'
  153. })
  154. }
  155. }
  156. }
  157. })
  158. }
  159. // 备注弹窗相关
  160. const remarkVisible = ref(false)
  161. const currentRemark = ref('')
  162. const currentEditIndex = ref(-1)
  163. // 打开备注弹窗
  164. const openRemarkDialog = (index, remark = '') => {
  165. currentEditIndex.value = index
  166. currentRemark.value = remark
  167. remarkVisible.value = true
  168. }
  169. // 处理备注确认
  170. const handleRemarkConfirm = (remark) => {
  171. if (currentEditIndex.value >= 0) {
  172. orders.value[currentEditIndex.value].remark = remark
  173. }
  174. currentEditIndex.value = -1
  175. currentRemark.value = ''
  176. }
  177. </script>
  178. <style scoped>
  179. .container {
  180. padding-bottom: 120rpx;
  181. }
  182. .info-section {
  183. background-color: #fff;
  184. padding: 20rpx;
  185. border-radius: 8rpx;
  186. margin-bottom: 20rpx;
  187. }
  188. .info-item {
  189. line-height: 1.8;
  190. }
  191. .list-title {
  192. font-size: 32rpx;
  193. font-weight: bold;
  194. background-color: rgb(222, 134, 143, 0.5);
  195. padding: 10rpx 0;
  196. padding-left: 30rpx;
  197. }
  198. .bad-list {
  199. margin-bottom: 20rpx;
  200. }
  201. .footer {
  202. position: fixed;
  203. bottom: 100rpx;
  204. left: 0;
  205. right: 0;
  206. background-color: #fff;
  207. padding: 20rpx;
  208. }
  209. .btn-group {
  210. display: flex;
  211. justify-content: space-around;
  212. }
  213. .search-wrapper {
  214. position: fixed;
  215. bottom: 0;
  216. left: 0;
  217. right: 0;
  218. background-color: #fff;
  219. padding: 20rpx;
  220. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  221. }
  222. </style>