bad-out-order.vue 8.4 KB

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