bad-out-order.vue 8.1 KB

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