delivery.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="deliver-page">
  3. <u-navbar height="40px" title="货物出库" bgColor="#0256FF" :titleStyle="{color:'#fff'}" leftIconColor="#fff" autoBack
  4. placeholder>
  5. </u-navbar>
  6. <view class="container_main">
  7. <view class="info-box" :class="isUnfold ? '':'min-height'">
  8. <view class="info-line">
  9. <view class="info-line-label">
  10. <text>发出仓库</text>
  11. </view>
  12. <view class="info-line-value">
  13. {{cangName}}
  14. </view>
  15. </view>
  16. <view class="info-line">
  17. <view class="info-line-label">
  18. <text>客户</text>
  19. </view>
  20. <view class="info-line-value">
  21. {{orderInfo.supplierName || '-'}}
  22. </view>
  23. </view>
  24. <view class="info-line">
  25. <view class="info-line-label">
  26. <text>出库类型</text>
  27. </view>
  28. <view class="info-line-value">
  29. {{orderInfo.subType || '-'}}
  30. </view>
  31. </view>
  32. <view class="info-line" v-if="orderInfo.submitTime">
  33. <view class="info-line-label">
  34. <text>出库日期</text>
  35. </view>
  36. <view class="info-line-value">
  37. {{orderInfo.submitTime || '-'}}
  38. </view>
  39. </view>
  40. <view class="info-line">
  41. <view class="info-line-label">
  42. <text>配送地址</text>
  43. </view>
  44. <view class="info-line-value">
  45. {{orderInfo.receiverAddress || '-'}}
  46. </view>
  47. </view>
  48. <view class="info-line">
  49. <view class="info-line-label">
  50. <text>上传凭证</text>
  51. </view>
  52. <view class="info-line-value ss-p-y-24">
  53. <upload-image v-model="voucherPicture" width="196rpx" height="196rpx"></upload-image>
  54. </view>
  55. </view>
  56. <view class="info-line">
  57. <view class="info-line-label">
  58. <text>备注信息</text>
  59. </view>
  60. <view class="info-line-value">
  61. <u-input v-model="orderInfo.mark" placeholder="请输入备注信息" border="none"></u-input>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="btn-box">
  66. <view class="btn-cont" @click="isUnfold = !isUnfold">
  67. <text>{{isUnfold ? '收起' : '展开'}}</text>
  68. <u-icon :name="isUnfold?'arrow-up':'arrow-down'"></u-icon>
  69. </view>
  70. </view>
  71. <view class="scan-box">
  72. <view class="scan-box-l" @click="scanCode">
  73. <u-image width="120rpx" height="120rpx" src="@/static/image/zidong-saoma-img.png"></u-image>
  74. <view class="tips-text">扫描快速识别货物</view>
  75. <view class="tips-text2">
  76. <u-icon name="checkmark-circle-fill" color="#0256FF"></u-icon>
  77. <text>连续扫描</text>
  78. </view>
  79. </view>
  80. <!-- <view class="scan-box-r" @click="manualClick">
  81. <u-image width="120rpx" height="120rpx" src="@/static/image/shoudong-saoma-img.png"></u-image>
  82. <view class="tips-text">手动选择</view>
  83. </view> -->
  84. </view>
  85. <!-- 货物清单 -->
  86. <view class="cargo-list">
  87. <view class="cargo-list-title">
  88. <view>出库货物清单</view>
  89. <view class="cargo-list-title-tips">(轻触货物查看详情)</view>
  90. </view>
  91. <block v-for="(item,i) in goodsList" :key="i">
  92. <good-item :item="item" @toDetail="toDetail">
  93. <view class="num-box" @click.stop="">
  94. <view class="num-box-text">已确认出库数量</view>
  95. <u-number-box v-model="item.materialNumber" min="0" :inputWidth="56">
  96. <!-- <view slot="minus" class="minus">
  97. <u-icon name="minus" color="#0256FF" size="12"></u-icon>
  98. </view>
  99. <text slot="input" class="input">{{item.materialNumber}}</text>
  100. <view slot="plus" class="plus">
  101. <u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
  102. </view> -->
  103. </u-number-box>
  104. </view>
  105. <view class="action-btn-box">
  106. <view class="print-btn" @click="handlePrint(item)">
  107. 打印条码
  108. </view>
  109. </view>
  110. </good-item>
  111. </block>
  112. </view>
  113. </view>
  114. <view class="footer-box">
  115. <view class="footer-box-l">
  116. <view>货物种类:{{speciesNum}}种</view>
  117. <view>货物总数:{{orderGoodsNum}}件</view>
  118. </view>
  119. <button class="submitBtn" @tap="submitClick">
  120. 提交
  121. </button>
  122. </view>
  123. <error-pop v-model="errorShow" @close="errorShow = false" @confirm="confirm" :content="popText.errorText"></error-pop>
  124. <success-pop v-model="successShow" @close="successShow = false" @backClick="backClick" :content="popText.successText"></success-pop>
  125. <!-- 扫码之后弹窗 -->
  126. <scaned-pop v-if="scanedShow" v-model="scanedShow" :scanNum="scanNum" @close="scanedShow = false" @confirm="scanConfirm"></scaned-pop>
  127. <goods-pop v-model="goodsShow" @close="goodsShow = false"></goods-pop>
  128. <!-- 打印条码弹框 -->
  129. <print-pop :show.sync="blePrintPop.show" :info="blePrintPop.data" @confirm="startPrint"></print-pop>
  130. <!-- 选择蓝牙设备弹框 -->
  131. <ble-pop :show.sync="bleSelectPop.show" :list="discoveredDevices" @close="closeBleSelectPop" @refresh="refreshBleDevice" @selectItem="handleSelectBle"></ble-pop>
  132. <ble-tip-pop v-model="bleErrorTipPop.show" :is-center="true" @confirm="bleErrorTipConfirm" :content="bleErrorTipPop.content" :extraText="bleErrorTipPop.extraText"> </ble-tip-pop>
  133. </view>
  134. </template>
  135. <script>
  136. import goodItem from '@/components/good-item/good-item.vue'
  137. import errorPop from '@/components/error-pop/error-pop.vue'
  138. import successPop from '@/components/success-pop/success-pop.vue'
  139. import scanedPop from '@/components/scaned-pop/scaned-pop.vue'
  140. import goodsPop from '@/components/goods-pop/goods-pop.vue'
  141. import printPop from '@/components/print-pop/print-pop.vue'
  142. import blePop from '@/components/ble-pop/ble-pop.vue'
  143. import bleTipPop from './components/ble-tip-pop.vue'
  144. import {orderDetail, orderInfo, orderSubmit} from '@/common/request/apis/purchase'
  145. import {mapGetters} from 'vuex'
  146. import blePrintMixin from '@/common/mixins/blePrintMixin.js'
  147. export default {
  148. mixins: [blePrintMixin],
  149. components: {
  150. goodItem,
  151. errorPop,
  152. successPop,
  153. scanedPop,
  154. goodsPop,
  155. printPop,
  156. blePop,
  157. bleTipPop
  158. },
  159. data() {
  160. return {
  161. popText:{
  162. errorText:'实际出库数量与应出库数量有差异,是否确认提交?',
  163. successText:'出库成功!'
  164. },
  165. goodsShow:false,
  166. scanedShow:false,
  167. errorShow:false,
  168. successShow:false,
  169. value:0,
  170. isUnfold: true, //是否展开
  171. info: {
  172. mark: '',
  173. url: ''
  174. },
  175. goodsList: [],
  176. orderInfo:{},
  177. id:'',
  178. calendarShow:false,
  179. value1: '',
  180. maxDate:Number(new Date()),
  181. chooseGoodsInfo:{},
  182. voucherPicture:'',
  183. scanIndex:-1,
  184. scanNum:1,
  185. }
  186. },
  187. onLoad(e) {
  188. this.id = e.id
  189. this.getOrderDetail(e.id)
  190. this.getOrderInfo(e.id)
  191. },
  192. computed: {
  193. ...mapGetters(['cangName']),
  194. speciesNum() {
  195. let num = 0
  196. if(this.goodsList.length == 0 || !this.goodsList) {
  197. num = 0
  198. }else {
  199. num = this.goodsList.length
  200. }
  201. return num
  202. },
  203. // 手动输入的数量
  204. goodsNum() {
  205. let num = 0
  206. if(this.goodsList.length == 0 || !this.goodsList) {
  207. num = 0
  208. }else {
  209. this.goodsList.forEach(item=>{
  210. num+=item.materialNumber
  211. })
  212. }
  213. return num
  214. },
  215. // 订单返回的数量
  216. orderGoodsNum() {
  217. let num = 0
  218. if(this.goodsList.length == 0 || !this.goodsList) {
  219. num = 0
  220. }else {
  221. this.goodsList.forEach(item=>{
  222. num+=item.operNumber
  223. })
  224. }
  225. return num
  226. }
  227. },
  228. onShow() {
  229. uni.$on('scanFinish',(data)=>{
  230. if(this.goodsList.length == 0)return uni.$u.toast("该货物不属于该任务")
  231. let index = this.goodsList.findIndex(item=>item.barCode == data)
  232. if(index == -1) return uni.$u.toast("该货物不属于该任务");
  233. this.scanIndex = index
  234. this.scanNum = this.goodsList[index].materialNumber
  235. this.scanedShow = true
  236. })
  237. },
  238. onHide() {
  239. uni.$off('scanFinish')
  240. },
  241. onUnload() {
  242. uni.$off('scanFinish')
  243. },
  244. methods:{
  245. scanCode() {
  246. this.$scan.scanCode()
  247. },
  248. calendarConfirm(val) {
  249. this.goodsList.forEach(item=>{
  250. if(item.id == this.chooseGoodsInfo.id) {
  251. item.productionDate = this.$u.timeFormat(val.value, 'yyyy-mm-dd')
  252. }
  253. })
  254. this.calendarShow = false
  255. },
  256. calendarCole() {
  257. this.calendarShow = false
  258. },
  259. calendarClick(item) {
  260. console.log(item.productionDate,'item.productionDate')
  261. this.chooseGoodsInfo = item
  262. if(item.productionDate) {
  263. this.value1 = Number(new Date(item.productionDate))
  264. }else {
  265. this.value1 = Number(new Date())
  266. }
  267. this.calendarShow = true
  268. },
  269. getOrderInfo(id) {
  270. orderInfo(id)
  271. .then(res=>{
  272. if(res.code == 200) {
  273. this.orderInfo = res.data
  274. console.log('this.orderInfo====',this.orderInfo)
  275. }
  276. })
  277. },
  278. getOrderDetail(id) {
  279. orderDetail(id)
  280. .then(res=>{
  281. if(res.code == 200) {
  282. res.data.rows.forEach(item=>{
  283. if(item.imgName && item.imgName.length >0) {
  284. item.imgNameArr = item.imgName.split(",")
  285. }else {
  286. item.imgNameArr = []
  287. }
  288. item.materialNumber = 0
  289. })
  290. this.goodsList = res.data.rows
  291. console.log('goodsList==========',this.goodsList )
  292. }
  293. })
  294. },
  295. submitClick() {
  296. let num = 0
  297. this.goodsList.forEach(item=>{
  298. if(item.materialNumber * 1 != item.operNumber ) {
  299. num ++
  300. }
  301. })
  302. if(num>0) {
  303. return this.errorShow = true
  304. }
  305. this.toOrderSubmit()
  306. },
  307. toOrderSubmit() {
  308. let materials = this.goodsList.map(item=> {
  309. return {
  310. batchNumber:item.batchNumber,
  311. materialNumber:item.materialNumber,
  312. productionDate:item.productionDate ? this.$u.timeFormat(item.productionDate, 'yyyy-mm-dd') : ''
  313. }
  314. })
  315. let params = {
  316. id:this.id,
  317. materials:materials,
  318. voucherPicture:this.voucherPicture || '',
  319. remark:this.orderInfo.mark || ''
  320. }
  321. orderSubmit(params)
  322. .then(res=>{
  323. if(res.code == 200) {
  324. if(this.errorShow){
  325. this.errorShow = false
  326. }
  327. this.successShow = true
  328. }
  329. })
  330. },
  331. confirm() {
  332. this.toOrderSubmit()
  333. this.errorShow = false
  334. },
  335. backClick() {
  336. uni.setStorageSync('orderRefresh',true)
  337. uni.navigateBack()
  338. },
  339. // 扫码确认
  340. scanConfirm(val) {
  341. this.goodsList[this.scanIndex].materialNumber = Number(val)
  342. this.scanedShow = false
  343. },
  344. manualClick() {
  345. this.goodsShow = true
  346. },
  347. toDetail(val) {
  348. uni.navigateTo({
  349. url:`/pages/goods/detail?id=${val.id}&name=${val.materialName}`
  350. })
  351. },
  352. //条码逻辑
  353. handlePrint(item) {
  354. this.openBlePrintPop(item)
  355. },
  356. //开始打印
  357. startPrint(data){
  358. this.writeData(data)
  359. }
  360. }
  361. }
  362. </script>
  363. <style lang="scss" scoped>
  364. .deliver-page {
  365. min-height: 100vh;
  366. background-color: #F0F6FB;
  367. padding-bottom: 130rpx;
  368. .container_main {
  369. padding: 24rpx;
  370. .info-box {
  371. background-color: #fff;
  372. border-radius: 16rpx 16rpx 0 0;
  373. padding: 24rpx 24rpx 0 24rpx;
  374. .info-line {
  375. border-bottom: 1px solid #F4F4F4;
  376. min-height: 92rpx;
  377. color: #333;
  378. font-family: "PingFang SC";
  379. font-size: 28rpx;
  380. font-weight: 400;
  381. display: flex;
  382. align-items: center;
  383. &-label {
  384. width: 162rpx;
  385. }
  386. .must-box {
  387. color: #FF3B1D;
  388. }
  389. }
  390. }
  391. .min-height {
  392. height: 300rpx;
  393. overflow: hidden;
  394. }
  395. .btn-box {
  396. height: 112rpx;
  397. display: flex;
  398. align-items: center;
  399. justify-content: center;
  400. background-color: #fff;
  401. border-radius: 0 0 16rpx 16rpx;
  402. .btn-cont {
  403. display: flex;
  404. align-items: center;
  405. justify-content: center;
  406. width: 154rpx;
  407. height: 56rpx;
  408. border-radius: 120rpx;
  409. border: 1px solid #D9D9D9;
  410. color: #666;
  411. font-family: "PingFang SC";
  412. font-size: 28rpx;
  413. font-weight: 400;
  414. }
  415. }
  416. .scan-box {
  417. margin-top: 24rpx;
  418. padding: 24rpx 0;
  419. border-radius: 16rpx;
  420. background: #FFF;
  421. display: flex;
  422. .tips-text {
  423. color: #333;
  424. font-size: 28rpx;
  425. font-weight: 400;
  426. line-height: 48rpx;
  427. }
  428. .tips-text2 {
  429. color: #0256FF;
  430. font-size: 24rpx;
  431. font-weight: 400;
  432. display: flex;
  433. align-items: center;
  434. .radio-box {
  435. width: 32rpx;
  436. height: 32rpx;
  437. border-radius: 50%;
  438. border: 1px solid #D9D9D9;
  439. margin-right: 16rpx;
  440. }
  441. }
  442. .scan-box-l {
  443. width: 100%;
  444. display: flex;
  445. flex-direction: column;
  446. align-items: center;
  447. position: relative;
  448. &::after {
  449. content: '';
  450. display: block;
  451. width: 1px;
  452. height: 138rpx;
  453. background-color: #F4F4F4;
  454. position: absolute;
  455. top: 50%;
  456. right: 0;
  457. transform: translateY(-50%);
  458. }
  459. }
  460. .scan-box-r {
  461. width: 50%;
  462. display: flex;
  463. flex-direction: column;
  464. align-items: center;
  465. }
  466. }
  467. .cargo-list {
  468. padding: 24rpx 0;
  469. background-color: #fff;
  470. margin-top: 24rpx;
  471. border-radius: 16rpx;
  472. .cargo-list-title {
  473. font-family: "PingFang SC";
  474. font-size: 32rpx;
  475. font-style: normal;
  476. font-weight: bold;
  477. display: flex;
  478. align-items: center;
  479. position: relative;
  480. padding-left: 50rpx;
  481. &::after {
  482. content: '';
  483. display: block;
  484. width: 6rpx;
  485. height: 30rpx;
  486. border-radius: 100px;
  487. background: #0256FF;
  488. position: absolute;
  489. top: 50%;
  490. left: 24rpx;
  491. transform: translateY(-50%);
  492. }
  493. .cargo-list-title-tips {
  494. color: #0256FF;
  495. font-size: 24rpx;
  496. font-weight: 400;
  497. }
  498. }
  499. .num-box {
  500. display: flex;
  501. align-items: center;
  502. justify-content: space-between;
  503. padding: 0 48rpx 0 26rpx;
  504. .num-box-text {
  505. color: #666;
  506. font-family: "PingFang SC";
  507. font-size: 28rpx;
  508. font-weight: 400;
  509. }
  510. .input {
  511. width: 112rpx;
  512. text-align: center;
  513. border-bottom: 1px solid #0256FF;
  514. margin: 0 8rpx;
  515. }
  516. .minus {
  517. width: 40rpx;
  518. height: 40rpx;
  519. border-radius: 8rpx;
  520. border: 1px solid #0256FF;
  521. display: flex;
  522. align-items: center;
  523. justify-content: center;
  524. }
  525. .plus {
  526. width: 40rpx;
  527. height: 40rpx;
  528. border-radius: 8rpx;
  529. background-color: #0256FF;
  530. display: flex;
  531. align-items: center;
  532. justify-content: center;
  533. }
  534. }
  535. }
  536. }
  537. .footer-box {
  538. background-color: #fff;
  539. height: 126rpx;
  540. position: fixed;
  541. bottom: 0;
  542. left: 0;
  543. right: 0;
  544. display: flex;
  545. align-items: center;
  546. justify-content: space-between;
  547. padding: 0 40rpx 0 60rpx;
  548. .footer-box-l {
  549. color: #666;
  550. font-family: "PingFang SC";
  551. font-size: 28rpx;
  552. font-weight: 400;
  553. }
  554. .submitBtn {
  555. width: 362rpx;
  556. height: 76rpx;
  557. border-radius: 16rpx;
  558. background: #0256FF;
  559. color: #FFF;
  560. font-size: 28rpx;
  561. font-weight: 500;
  562. margin: 0;
  563. }
  564. }
  565. }
  566. .action-btn-box{
  567. text-align: right;
  568. padding: 30rpx 48rpx 0 26rpx;
  569. .print-btn{
  570. font-family: PingFang SC;
  571. font-weight: 500;
  572. font-size: 28rpx;
  573. color: #0256FF;
  574. }
  575. }
  576. </style>