bad-out-order.vue 8.6 KB

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