bad-in.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="common-page" style="padding: 0;">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <u-navbar title="不良入库" :border="false" fixed safe-area-inset-top>
  6. <template #left>
  7. <u-icon name="arrow-left" color="#333333" size="20" @click="goBack"></u-icon>
  8. </template>
  9. <template #right>
  10. <u-text type="primary" text="提交" @click="onSubmit"></u-text>
  11. </template>
  12. </u-navbar>
  13. </view>
  14. <!-- 主要内容区域 -->
  15. <view class="content">
  16. <!-- 订单基本信息 -->
  17. <view class="info-section">
  18. <u-form :model="formData" ref="formRef" label-width="70px">
  19. <u-form-item label="订单总数" required>
  20. <u-input v-model="formData.totalOrders" disabled />
  21. </u-form-item>
  22. <u-form-item label="仓库" required>
  23. <u-input v-model="formData.warehouse" @click="selectWarehouse" />
  24. </u-form-item>
  25. <u-form-item label="库位" required>
  26. <u-input v-model="formData.location" @click="selectLocation" />
  27. </u-form-item>
  28. </u-form>
  29. </view>
  30. <!-- 订单列表 -->
  31. <view class="order-list">
  32. <bad-item v-for="(order, index) in orders" :key="index" :data="order" @delete="deleteOrder(index)"
  33. @edit="editOrder(index)"></bad-item>
  34. </view>
  35. <!-- 底部扫码输入框 -->
  36. <view class="fixed-bottom pad-20" style="background: #ffffff;">
  37. <u-search placeholder="请输入/扫描条码" v-model="scanCode" @confirm="onScanConfirm" :show-action="false"
  38. custom-style="margin-right:10px"></u-search>
  39. <u-icon name="scan" size="28" color="#19be6b" @click="openScan"></u-icon>
  40. </view>
  41. </view>
  42. <!-- 备注弹窗 -->
  43. <remark-dialog v-model:visible="remarkVisible" :initial-value="currentRemark"
  44. @confirm="handleRemarkConfirm"></remark-dialog>
  45. </view>
  46. </template>
  47. <script setup>
  48. import {
  49. ref,
  50. reactive,
  51. onMounted,
  52. onUnmounted
  53. } from 'vue';
  54. import BadItem from './components/BadItem.vue';
  55. import VolumeTTS from '@/utils/VolumeTTS.js'
  56. import RemarkDialog from './components/RemarkDialog.vue'
  57. // 表单数据
  58. const formData = reactive({
  59. totalOrders: '3',
  60. warehouse: '河南仓',
  61. location: 'K001-0111'
  62. });
  63. // 订单列表
  64. const orders = ref([{
  65. orderNo: '000001',
  66. badCount: '5',
  67. logisticsNo: 'DPK202444118877',
  68. checkDate: '2024-11-14',
  69. operator: '李程雪'
  70. }, {
  71. orderNo: '000001',
  72. badCount: '5',
  73. logisticsNo: 'DPK202444118877',
  74. checkDate: '2024-11-14',
  75. operator: '李程雪'
  76. },]);
  77. const scanCode = ref('');
  78. // 备注弹窗相关
  79. const remarkVisible = ref(false)
  80. const currentRemark = ref('')
  81. const currentEditIndex = ref(-1)
  82. // 方法定义
  83. const goBack = () => {
  84. uni.navigateBack();
  85. };
  86. const onSubmit = () => {
  87. uni.showModal({
  88. title: '提交确认',
  89. content: '是否确认提交本次入库?',
  90. success: (res) => {
  91. if (res.confirm) {
  92. handleSubmitConfirm()
  93. }
  94. }
  95. })
  96. }
  97. const handleSubmitConfirm = async () => {
  98. try {
  99. uni.showLoading({
  100. title: '提交中...'
  101. })
  102. // TODO: 这里添加实际的提交逻辑
  103. await new Promise(resolve => setTimeout(resolve, 1000)) // 模拟请求
  104. uni.hideLoading()
  105. uni.showToast({
  106. title: '提交成功',
  107. icon: 'success'
  108. })
  109. // 提交成功后返回上一页
  110. setTimeout(() => {
  111. uni.navigateBack()
  112. }, 1500)
  113. } catch (error) {
  114. uni.hideLoading()
  115. uni.showToast({
  116. title: '提交失败',
  117. icon: 'error'
  118. })
  119. }
  120. }
  121. const editOrder = (index) => {
  122. // 编辑订单
  123. openRemarkDialog(index)
  124. };
  125. const onScanConfirm = () => {
  126. // 扫码确认逻辑
  127. // #ifdef APP-PLUS || MP-WEIXIN
  128. uni.scanCode({
  129. scanType: ['barCode'], // 支持条形码和二维码
  130. success: (res) => {
  131. scanCode.value = res.result;
  132. },
  133. fail: (err) => {
  134. uni.showToast({
  135. title: '扫码失败',
  136. icon: 'error'
  137. });
  138. }
  139. });
  140. // #endif
  141. // #ifdef H5
  142. uni.showToast({
  143. title: 'H5环境不支持扫码,请手动输入',
  144. icon: 'none'
  145. });
  146. // #endif
  147. };
  148. const openScan = () => {
  149. // 打开扫码器
  150. };
  151. //选择库位
  152. function selectLocation() {
  153. uni.navigateTo({
  154. url: "/pages/index/wms/location-select"
  155. })
  156. }
  157. // 删除订单
  158. const deleteOrder = (index) => {
  159. orders.value.splice(index, 1);
  160. // 更新总数
  161. formData.totalOrders = orders.value.length.toString();
  162. };
  163. const ttsModule = ref(null);
  164. onMounted(() => {
  165. ttsModule.value = new VolumeTTS();
  166. // 监听库位选择
  167. uni.$on('updateLocation', (locationCode) => {
  168. formData.location = locationCode
  169. })
  170. // 监听仓库选择
  171. uni.$on('updateWarehouse', (warehouseName) => {
  172. formData.warehouse = warehouseName
  173. })
  174. })
  175. // 记得在页面卸载时移除事件监听
  176. onUnmounted(() => {
  177. uni.$off('updateLocation')
  178. uni.$off('updateWarehouse')
  179. })
  180. // 打开备注弹窗
  181. const openRemarkDialog = (index, remark = '') => {
  182. currentEditIndex.value = index
  183. currentRemark.value = remark
  184. remarkVisible.value = true
  185. }
  186. // 处理备注确认
  187. const handleRemarkConfirm = (remark) => {
  188. if (currentEditIndex.value >= 0) {
  189. orders.value[currentEditIndex.value].remark = remark
  190. }
  191. currentEditIndex.value = -1
  192. currentRemark.value = ''
  193. }
  194. // 打开仓库选择页面
  195. const selectWarehouse = () => {
  196. uni.navigateTo({
  197. url: '/pages/index/wms/warehouse-select'
  198. })
  199. }
  200. </script>
  201. <style scoped>
  202. .content {
  203. padding-top: 44px;
  204. border-radius: 0;
  205. }
  206. .info-section {
  207. background-color: #ffffff;
  208. padding: 15px;
  209. padding-bottom: 5px;
  210. margin-bottom: 12px;
  211. }
  212. .order-list {
  213. margin-bottom: 60px;
  214. }
  215. </style>