index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <div class="container">
  3. <div class="task">
  4. <div class="top">
  5. <div class="nav-bar">
  6. <van-nav-bar title="移库任务-上架" left-arrow @click-left="goBack" @click-right="onClickRight" >
  7. <template #left>
  8. <van-icon name="arrow-left" size="25" />
  9. <div style="color: #fff;height: 46px;padding-right:20px;line-height: 46px">返回</div>
  10. </template>
  11. <template #right>
  12. <div class="nav-right" style="color: #fff">重置</div>
  13. </template>
  14. </van-nav-bar>
  15. </div>
  16. <div class="content">
  17. <div class="take-delivery">
  18. <div class="take-info">
  19. <div class="take-info-no">
  20. <div class="info-no-title">
  21. <div>任务号:{{ code==0?'--':code }}</div>
  22. <div v-if="taskDetail.expectQuantity">
  23. <div><span style="font-size: 13px">任务数:</span><span
  24. style="color: #0077ff;font-weight: bold;">{{ taskDetail.doneQuantity || 0
  25. }}/{{ taskDetail.expectQuantity || 0 }}</span></div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <van-progress v-if="taskDetail.expectQuantity && taskDetail.doneQuantity/taskDetail.expectQuantity>=0"
  31. :percentage="((taskDetail.doneQuantity/taskDetail.expectQuantity)*100).toFixed(2)"
  32. stroke-width="4" />
  33. <div class="take-barcode">
  34. <div style="display: flex;justify-content: space-between;padding-right: 10px;">
  35. <div style="flex: 1">
  36. <van-notice-bar :background="'none'" :speed="50" :text="tips" />
  37. </div>
  38. <div>箱规:{{activeBarcode.packId || '--'}}</div>
  39. </div>
  40. <div class="barcode-input">
  41. <van-search
  42. ref="searchRef"
  43. v-model.lazy="searchBarcode"
  44. placeholder="请扫描商品条码"
  45. @search="_handlerScan(searchBarcode)"
  46. label="商品条码:"
  47. left-icon=""
  48. :class="[scanType===2?'search-input-barcode':'','van-hairline--bottom']"
  49. @focus="scanType=2"
  50. autocomplete="off"
  51. >
  52. </van-search>
  53. </div>
  54. <div class="barcode-input">
  55. <van-search
  56. ref="searchRef"
  57. v-model.lazy="searchLocation"
  58. placeholder="请扫描移入库位"
  59. @search="_handlerScan(searchLocation)"
  60. label="移入库位:"
  61. left-icon=""
  62. :class="[scanType===3?'search-input-barcode':'','van-hairline--bottom']"
  63. @focus="scanType=3"
  64. autocomplete="off"
  65. >
  66. </van-search>
  67. </div>
  68. <div class="barcode-input">
  69. <van-search
  70. ref="numberRef"
  71. v-model="count"
  72. placeholder="请输入移入数量"
  73. type="number"
  74. label="移入数量:"
  75. left-icon=""
  76. autocomplete="off"
  77. show-action
  78. :min="1"
  79. :class="[scanType===4?'search-input-barcode':'','van-hairline--bottom']"
  80. @focus="scanType=4"
  81. :max="activeBarcode.id?activeBarcode.remainUpQuantity:10000"
  82. @search="onConfirm"
  83. >
  84. <template #action >
  85. <div style="display: flex; align-items: center;flex-direction: column;margin-left: 20px" v-if="activeBarcode.id">
  86. <div style="font-size: 14px">待移入:{{activeBarcode.remainUpQuantity}}</div>
  87. </div>
  88. </template>
  89. </van-search>
  90. </div>
  91. <div class="barcode-input" v-if="activeBarcode.id" >
  92. <van-search
  93. v-model="activeBarcode.name"
  94. readonly
  95. label="商品名称:"
  96. left-icon=""
  97. >
  98. </van-search>
  99. </div>
  100. <div class="lot" v-if="activeBarcode.id">
  101. <div class="lot-list">
  102. <div>生产:{{activeBarcode.productDate}}</div>
  103. <div>失效:{{activeBarcode.invalidDate}}</div>
  104. <div>质量:{{activeBarcode.quality}}</div>
  105. <div>属性仓:{{activeBarcode.attribute}}</div>
  106. </div>
  107. </div>
  108. </div>
  109. <div class="take-button">
  110. <div class="button-text" @click="onConfirm">上架</div>
  111. <!-- <van-button type="primary" size="large" style="height: 36px" @click="onConfirm" >上架</van-button>-->
  112. </div>
  113. </div>
  114. <van-divider :style="{ color: '#333', borderColor: '#1989fa', padding: '0 16px',margin:'5px 0' }">推荐库位
  115. </van-divider>
  116. <div class="move-stock-list">
  117. <table class="task-table">
  118. <thead>
  119. <tr>
  120. <th style="width: 100px;">库位</th>
  121. <th style="width: 100px;">类型</th>
  122. <th style="width: 50px">数量</th>
  123. </tr>
  124. </thead>
  125. <tbody>
  126. <tr v-for="(item, index) in locationList" :key="index" v-if="locationList.length>0" >
  127. <td>{{ item.location }}</td>
  128. <td>{{ locationType[item.type] || item.type }}</td>
  129. <td>{{ item.quantity ||'空' }}</td>
  130. </tr>
  131. <tr v-else>
  132. <td colspan="3">
  133. <div>暂无数据</div>
  134. </td>
  135. </tr>
  136. </tbody>
  137. </table>
  138. </div>
  139. </div>
  140. </div>
  141. <div class="tab-bar">
  142. <van-tabbar :fixed="false" route>
  143. <van-tabbar-item replace to="/move-list" icon="description">列表</van-tabbar-item>
  144. <van-tabbar-item replace @click.prevent="linkTask()" icon="descending">下架</van-tabbar-item>
  145. <van-tabbar-item replace to="/move-putaway" icon="ascending">上架</van-tabbar-item>
  146. </van-tabbar>
  147. </div>
  148. </div>
  149. <!-- 单据选择-->
  150. <van-action-sheet v-model:show="lotBarcodeTrueFalseBy" cancel-text="取消" description="请选择商品批次" close-on-click-action>
  151. <van-cell-group>
  152. <van-cell v-for="item in matchBarcodeList" @click="setBarcode(item)" >
  153. <template #title>
  154. {{ item.barcode }}(数量:{{ item.remainUpQuantity }})
  155. </template>
  156. <template #label>
  157. <div>生产日期:{{ item.productDate || '--' }}</div>
  158. <div>失效日期:{{ item.invalidDate || '--' }}</div>
  159. <div>质量状态:{{ item.quality || '--' }}</div>
  160. <div>属性仓:{{ item.attribute || '--' }}</div>
  161. </template>
  162. </van-cell>
  163. </van-cell-group>
  164. </van-action-sheet>
  165. </div>
  166. </template>
  167. <script setup>
  168. import { ref, computed,onMounted, onUnmounted } from 'vue'
  169. import { androidFocus, getHeader, goBack, scanError, scanSuccess } from '@/utils/android'
  170. import { useStore } from '@/store/modules/user'
  171. import { useRouter, useRoute } from 'vue-router'
  172. import { getMoveTaskUp, moveTaskDown, moveTaskUp } from '@/api/transferMove/index'
  173. import { closeLoading, showLoading } from '@/utils/loading'
  174. import { barcodeToUpperCase } from '@/utils/dataType.js'
  175. import { showConfirmDialog, showNotify } from 'vant'
  176. import { getRecommendedLocation } from '@/api/haikang/index'
  177. import { closeListener, openListener, scanInit } from '@/utils/keydownListener.js'
  178. try {
  179. getHeader()
  180. androidFocus()
  181. } catch (error) {
  182. }
  183. // 页面初始化
  184. onMounted(() => {
  185. openListener()
  186. scanInit(_handlerScan)
  187. loadData()
  188. })
  189. const router = useRouter()
  190. const storeUser = useStore()
  191. const route = useRoute()
  192. const warehouse = storeUser.warehouse
  193. const code = route.query.code
  194. //商品条码
  195. const searchBarcode = ref('')
  196. //库位
  197. const searchLocation = ref('')
  198. //提示
  199. const tips=ref('请扫描商品条码')
  200. //库位类型
  201. const locationType = {
  202. 'EA': '件拣货库位',
  203. 'AP': '补充拣货位',
  204. 'CS': '箱拣货库位',
  205. 'HP': '快拣补货位',
  206. 'PC': '箱/件合并拣货库位',
  207. 'PT': '播种库位',
  208. 'RS': '存储库位',
  209. 'SS': '理货站',
  210. 'ST': '过渡库位',
  211. 'WB': '组装工作区',
  212. }
  213. const count = ref('')
  214. const scanType = ref(2)
  215. const taskDetail = ref({})
  216. const taskList = ref([])
  217. const locationList = ref([])
  218. //待移入列表
  219. const orderList = computed(() => {
  220. return taskList.value
  221. .filter(item => item.remainUpQuantity !== 0)
  222. })
  223. //匹配列表
  224. const matchBarcodeList = ref([])
  225. //当前条码
  226. const activeBarcode = ref({})
  227. //批次选择
  228. const lotBarcodeTrueFalseBy = ref(false)
  229. const _handlerScan = async (code) => {
  230. if (!code) return
  231. const checkBarcode = barcodeToUpperCase(code)
  232. if (scanType.value == 2) {
  233. const barcode = [...new Set(
  234. orderList.value
  235. .flatMap(item => [item.barcode, item.barcode2, item.sku])
  236. .filter(value => value !== null && value !== '' && value !== undefined),
  237. )]
  238. count.value=''
  239. if (barcode.some(item => barcodeToUpperCase(item) === checkBarcode)) {
  240. taskList.value = await barcodeMatching(checkBarcode)
  241. matchBarcodeList.value = orderList.value.filter(item => ((barcodeToUpperCase(item.barcode) === checkBarcode || barcodeToUpperCase(item.sku) == checkBarcode || (item.barcode2 ? barcodeToUpperCase(item.barcode2) === checkBarcode : item.barcode2 === checkBarcode))))
  242. if (matchBarcodeList.value.length == 1) {
  243. activeBarcode.value = matchBarcodeList.value[0]
  244. searchLocation.value = ''
  245. searchBarcode.value=code
  246. _getLocation(activeBarcode.value)
  247. } else if (matchBarcodeList.value.length > 1) {
  248. tips.value='请选择产品批次'
  249. scanError()
  250. lotBarcodeTrueFalseBy.value = true
  251. activeBarcode.value = {}
  252. searchLocation.value = ''
  253. locationList.value=[]
  254. }
  255. }else {
  256. scanError()
  257. tips.value=`${code}-商品条码不匹配,请重新扫描`
  258. showNotify({ type: 'warning', duration: 3000, message: `${code}-商品条码不匹配,请重新扫描` })
  259. searchBarcode.value = ''
  260. searchLocation.value = ''
  261. activeBarcode.value = {}
  262. locationList.value=[]
  263. }
  264. }else if(scanType.value == 3){
  265. scanSuccess()
  266. searchLocation.value= barcodeToUpperCase(checkBarcode)
  267. tips.value='请输入移入数量'
  268. scanType.value=4
  269. count.value=1
  270. }
  271. }
  272. const onConfirm=()=>{
  273. if(!activeBarcode.value.id ){
  274. scanError()
  275. tips.value='请扫描商品条码'
  276. showNotify({ type: 'warning', duration: 3000, message: '请扫描商品条码' })
  277. return
  278. }
  279. if(!searchLocation.value){
  280. scanError()
  281. tips.value='请扫描移入库位'
  282. showNotify({ type: 'warning', duration: 3000, message: '请扫描移入库位' })
  283. return
  284. }
  285. if(!count.value || count.value==0){
  286. scanError()
  287. tips.value='请输入移入数量'
  288. showNotify({ type: 'warning', duration: 3000, message: '请输入移入数量' })
  289. return
  290. }
  291. if(count.value<activeBarcode.value.remainUpQuantity){
  292. showConfirmDialog({
  293. title: '温馨提示', message: '移入数量小于待移入数量是否确认上架?',
  294. }).then(() => {
  295. _moveTaskDown()
  296. }).catch(() => {
  297. scanType.value=4
  298. });
  299. return
  300. }
  301. _moveTaskDown()
  302. }
  303. //上架
  304. const _moveTaskDown=()=>{
  305. showLoading()
  306. const data={id:activeBarcode.value.id,container:'*',doQty:count.value,location:searchLocation.value}
  307. moveTaskUp(data).then(res => {
  308. showNotify({ type: 'success', duration: 3000, message: '上架成功,正在刷新数据' })
  309. loadData()
  310. }).catch(err=>{
  311. scanError()
  312. }).finally(() => {
  313. closeLoading()
  314. })
  315. }
  316. const setBarcode=(item)=>{
  317. activeBarcode.value=item
  318. searchBarcode.value=item.barcode
  319. lotBarcodeTrueFalseBy.value=false;
  320. _getLocation(item)
  321. }
  322. const _getLocation=(item)=>{
  323. const params = { warehouse, lotNum:item.lotNum, owner:item.customerId}
  324. showLoading()
  325. getRecommendedLocation(params).then(res => {
  326. scanSuccess()
  327. locationList.value=res.data
  328. tips.value='请扫描移入库位'
  329. scanType.value=3
  330. searchLocation.value=''
  331. }).catch(err=>{
  332. locationList.value=[]
  333. scanError()
  334. tips.value=err.message
  335. }).finally(f=>{
  336. closeLoading()
  337. })
  338. }
  339. const onClickRight=()=>{
  340. showConfirmDialog({
  341. title: '温馨提示', message: '是否重置扫描商品数据?',
  342. }).then(() => {
  343. loadData()
  344. }).catch(() => {});
  345. }
  346. //条码匹配放到前边
  347. const barcodeMatching = (checkBarcode) => {
  348. const matchingItems = [];
  349. const nonMatchingItems = [];
  350. taskList.value.forEach(item => {
  351. const isMatchingBarcode =
  352. barcodeToUpperCase(item.barcode) === checkBarcode ||
  353. checkBarcode === barcodeToUpperCase(item.sku) ||
  354. (item.barcode2 && barcodeToUpperCase(item.barcode2) === checkBarcode) ||
  355. (item.barcode2 === checkBarcode);
  356. if (isMatchingBarcode) {
  357. matchingItems.push(item); // 匹配条形码的项
  358. } else {
  359. nonMatchingItems.push(item); // 不匹配的项
  360. }
  361. });
  362. return [...matchingItems, ...nonMatchingItems];
  363. };
  364. const loadData = async () => {
  365. if (code == 0) return
  366. showLoading()
  367. getMoveTaskUp(code).then(res => {
  368. taskDetail.value = res.data
  369. if (res.data.itemList.length > 0) {
  370. // scanSuccess()
  371. taskList.value = res.data.itemList
  372. activeBarcode.value={}
  373. searchLocation.value=''
  374. searchBarcode.value=''
  375. count.value=''
  376. tips.value='请扫描商品条码'
  377. locationList.value=[]
  378. scanType.value=2
  379. }
  380. }).catch(err=>{
  381. scanError()
  382. }).finally(() => {
  383. closeLoading()
  384. })
  385. }
  386. // 进入任务
  387. const linkTask=()=>{
  388. router.push({ name: 'MoveDown', query: { code } });
  389. }
  390. onUnmounted(() => {
  391. closeListener()
  392. })
  393. window.onRefresh = loadData
  394. </script>
  395. <style scoped lang="sass">
  396. .container
  397. width: 100%
  398. .task
  399. display: flex
  400. flex-direction: column
  401. height: 100vh
  402. .top
  403. flex: 1
  404. display: flex
  405. flex-direction: column
  406. .nav-bar
  407. height: 46px
  408. .content
  409. flex: 1
  410. font-size: 14px
  411. .lot
  412. font-size: 12px
  413. padding: 5px
  414. color: #666
  415. .lot-list
  416. display: flex
  417. justify-content: space-between
  418. .take-delivery
  419. .take-info
  420. padding: 6px 10px
  421. background: linear-gradient(160deg, #cfe1ff 20%, white 50%, white 100%)
  422. display: flex
  423. flex-direction: column
  424. text-align: left
  425. .take-info-no
  426. flex: 1
  427. .info-no-title
  428. font-size: 17px
  429. font-width: 500
  430. display: flex
  431. justify-content: space-between
  432. align-items: center
  433. .take-barcode
  434. margin-top: 10px
  435. text-align: left
  436. background: #FFFFFF
  437. .barcode-input
  438. height: 50px
  439. ::v-deep(.van-search)
  440. padding: 0
  441. ::v-deep(.van-search__field)
  442. min-height: 50px
  443. border-bottom: 2px solid #ffffff
  444. ::v-deep(.van-search__content)
  445. background: #fff
  446. min-height: 50px
  447. display: flex
  448. align-items: center
  449. ::v-deep(.van-field)
  450. min-height: 50px
  451. display: flex
  452. align-items: center
  453. ::v-deep(.van-field__control)
  454. font-size: 16px
  455. min-height: 50px
  456. line-height: 50px
  457. ::v-deep(.van-search__label)
  458. font-size: 16px
  459. line-height: 50px
  460. .search-input-barcode
  461. ::v-deep(.van-search__field)
  462. border-bottom: 2px solid #0077ff
  463. z-index: 2
  464. .take-button
  465. padding: 10px 20px 0 20px
  466. .button-text
  467. background: #1989fa
  468. color: #ffffff
  469. height: 36px
  470. width: 100%
  471. border-radius: 5px
  472. font-size: 15px
  473. font-weight: bold
  474. line-height: 36px
  475. .move-stock-list
  476. width: 100%
  477. overflow-y: auto
  478. max-height: 60vh
  479. min-height: 100px
  480. .move-button
  481. background: #1989fa
  482. color: #fff
  483. width: 100%
  484. height: 30px
  485. font-size: 15px
  486. line-height: 30px
  487. font-weight: bold
  488. .task-table, .task-table-bin, .task-table-box
  489. width: 100%
  490. table-layout: fixed
  491. border-collapse: collapse
  492. font-size: 13px
  493. .task-table th, .task-table-bin th, .task-table td, .task-table-bin td, .task-table-box th, .task-table-box td
  494. text-align: center
  495. border: 1px solid #ccc
  496. word-wrap: break-word
  497. word-break: break-all
  498. .task-table thead, .task-table-bin thead, .task-table-box thead
  499. background-color: #3f8dff
  500. position: sticky
  501. top: 0
  502. z-index: 10
  503. -webkit-sticky: top
  504. font-size: 15px
  505. color: white
  506. .task-table-bin thead
  507. background-color: #3f8dff
  508. .task-table-bin tbody
  509. background: #cde7ff
  510. .tab-bar
  511. height: 50px
  512. </style>