delivery.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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" :show-print="true" @print="(e) => handlePrint(e.id)">
  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" :max="item.inventory">
  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. </good-item>
  106. </block>
  107. </view>
  108. </view>
  109. <view class="footer-box">
  110. <view class="footer-box-l">
  111. <view>货物种类:{{speciesNum}}种</view>
  112. <view>货物总数:{{orderGoodsNum}}件</view>
  113. </view>
  114. <button class="submitBtn" @tap="submitClick">
  115. 提交
  116. </button>
  117. </view>
  118. <error-pop v-model="errorShow" @close="errorShow = false" @confirm="confirm" :content="popText.errorText"></error-pop>
  119. <success-pop v-model="successShow" @close="successShow = false" @backClick="backClick" :content="popText.successText"></success-pop>
  120. <!-- 扫码之后弹窗 -->
  121. <scaned-pop v-if="scanedShow" v-model="scanedShow" :scanNum="scanNum" @close="scanedShow = false" @confirm="scanConfirm"></scaned-pop>
  122. <goods-pop v-model="goodsShow" @close="goodsShow = false"></goods-pop>
  123. <!-- 打印条码弹框 -->
  124. <print-pop :show.sync="blePrintPop.show" :info="blePrintPop.data" @confirm="startPrint"></print-pop>
  125. <!-- 选择蓝牙设备弹框 -->
  126. <ble-pop :show.sync="bleSelectPop.show" :list="discoveredDevices" @close="closeBleSelectPop" @refresh="refreshBleDevice" @selectItem="handleSelectBle"></ble-pop>
  127. <ble-tip-pop v-model="bleErrorTipPop.show" :is-center="true" @confirm="bleErrorTipConfirm" :content="bleErrorTipPop.content" :extraText="bleErrorTipPop.extraText"> </ble-tip-pop>
  128. </view>
  129. </template>
  130. <script>
  131. import goodItem from '@/components/good-item/good-item.vue'
  132. import errorPop from '@/components/error-pop/error-pop.vue'
  133. import successPop from '@/components/success-pop/success-pop.vue'
  134. import scanedPop from '@/components/scaned-pop/scaned-pop.vue'
  135. import goodsPop from '@/components/goods-pop/goods-pop.vue'
  136. import {orderDetail, orderInfo, orderSubmit} from '@/common/request/apis/purchase'
  137. import {mapGetters} from 'vuex'
  138. import blePrintMixin from '@/common/mixins/blePrintMixin.js'
  139. export default {
  140. mixins: [blePrintMixin],
  141. components: {
  142. goodItem,
  143. errorPop,
  144. successPop,
  145. scanedPop,
  146. goodsPop,
  147. },
  148. data() {
  149. return {
  150. popText:{
  151. errorText:'实际出库数量与应出库数量有差异,是否确认提交?',
  152. successText:'出库成功!'
  153. },
  154. goodsShow:false,
  155. scanedShow:false,
  156. errorShow:false,
  157. successShow:false,
  158. value:0,
  159. isUnfold: true, //是否展开
  160. info: {
  161. mark: '',
  162. url: ''
  163. },
  164. goodsList: [],
  165. orderInfo:{},
  166. id:'',
  167. calendarShow:false,
  168. value1: '',
  169. maxDate:Number(new Date()),
  170. chooseGoodsInfo:{},
  171. voucherPicture:'',
  172. scanIndex:-1,
  173. scanNum:1,
  174. }
  175. },
  176. onLoad(e) {
  177. this.id = e.id
  178. this.getOrderDetail(e.id)
  179. this.getOrderInfo(e.id)
  180. },
  181. computed: {
  182. ...mapGetters(['cangName']),
  183. speciesNum() {
  184. let num = 0
  185. if(this.goodsList.length == 0 || !this.goodsList) {
  186. num = 0
  187. }else {
  188. num = this.goodsList.length
  189. }
  190. return num
  191. },
  192. // 手动输入的数量
  193. goodsNum() {
  194. let num = 0
  195. if(this.goodsList.length == 0 || !this.goodsList) {
  196. num = 0
  197. }else {
  198. this.goodsList.forEach(item=>{
  199. num+=item.materialNumber
  200. })
  201. }
  202. return num
  203. },
  204. // 订单返回的数量
  205. orderGoodsNum() {
  206. let num = 0
  207. if(this.goodsList.length == 0 || !this.goodsList) {
  208. num = 0
  209. }else {
  210. this.goodsList.forEach(item=>{
  211. num+=item.operNumber
  212. })
  213. }
  214. return num
  215. }
  216. },
  217. onShow() {
  218. uni.$on('scanFinish',(data)=>{
  219. if(this.goodsList.length == 0)return uni.$u.toast("该货物不属于该任务")
  220. let index = this.goodsList.findIndex(item=>item.barCode == data)
  221. if(index == -1) return uni.$u.toast("该货物不属于该任务");
  222. this.scanIndex = index
  223. this.scanNum = this.goodsList[index].materialNumber
  224. this.scanedShow = true
  225. })
  226. },
  227. onHide() {
  228. uni.$off('scanFinish')
  229. },
  230. onUnload() {
  231. uni.$off('scanFinish')
  232. },
  233. methods:{
  234. scanCode() {
  235. this.$scan.scanCode()
  236. },
  237. calendarConfirm(val) {
  238. this.goodsList.forEach(item=>{
  239. if(item.id == this.chooseGoodsInfo.id) {
  240. item.productionDate = this.$u.timeFormat(val.value, 'yyyy-mm-dd')
  241. }
  242. })
  243. this.calendarShow = false
  244. },
  245. calendarCole() {
  246. this.calendarShow = false
  247. },
  248. calendarClick(item) {
  249. console.log(item.productionDate,'item.productionDate')
  250. this.chooseGoodsInfo = item
  251. if(item.productionDate) {
  252. this.value1 = Number(new Date(item.productionDate))
  253. }else {
  254. this.value1 = Number(new Date())
  255. }
  256. this.calendarShow = true
  257. },
  258. getOrderInfo(id) {
  259. orderInfo(id)
  260. .then(res=>{
  261. if(res.code == 200) {
  262. this.orderInfo = res.data
  263. console.log('this.orderInfo====',this.orderInfo)
  264. }
  265. })
  266. },
  267. getOrderDetail(id) {
  268. orderDetail(id)
  269. .then(res=>{
  270. if(res.code == 200) {
  271. res.data.rows.forEach(item=>{
  272. if(item.imgName && item.imgName.length >0) {
  273. item.imgNameArr = item.imgName.split(",")
  274. }else {
  275. item.imgNameArr = []
  276. }
  277. item.materialNumber = 0
  278. })
  279. this.goodsList = res.data.rows
  280. console.log('goodsList==========',this.goodsList )
  281. }
  282. })
  283. },
  284. submitClick() {
  285. let num = 0
  286. console.log('this.goodsList=====',this.goodsList)
  287. this.goodsList.forEach(item=>{
  288. if(item.materialNumber * 1 != item.operNumber ) {
  289. num ++
  290. }
  291. })
  292. console.log('num=====',num)
  293. if(num>0) {
  294. return this.errorShow = true
  295. }
  296. console.log('111111=====',1111)
  297. this.toOrderSubmit()
  298. },
  299. toOrderSubmit() {
  300. let materials = this.goodsList.map(item=> {
  301. return {
  302. batchNumber:item.batchNumber,
  303. materialNumber:item.materialNumber,
  304. productionDate:item.productionDate ? this.$u.timeFormat(item.productionDate, 'yyyy-mm-dd') : ''
  305. }
  306. })
  307. let params = {
  308. id:this.id,
  309. materials:materials,
  310. voucherPicture:this.voucherPicture || '',
  311. remark:this.orderInfo.mark || ''
  312. }
  313. console.log('orderSubmit========params====',params)
  314. orderSubmit(params)
  315. .then(res=>{
  316. console.log('orderSubmit============res=====',res)
  317. if(res.code == 200) {
  318. if(this.errorShow){
  319. this.errorShow = false
  320. }
  321. this.successShow = true
  322. }else{
  323. uni.showToast({
  324. icon: 'error',
  325. mask: true,
  326. title: res.msg||'服务错误'
  327. })
  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. }
  354. </script>
  355. <style lang="scss" scoped>
  356. .deliver-page {
  357. min-height: 100vh;
  358. background-color: #F0F6FB;
  359. padding-bottom: 130rpx;
  360. .container_main {
  361. padding: 24rpx;
  362. .info-box {
  363. background-color: #fff;
  364. border-radius: 16rpx 16rpx 0 0;
  365. padding: 24rpx 24rpx 0 24rpx;
  366. .info-line {
  367. border-bottom: 1px solid #F4F4F4;
  368. min-height: 92rpx;
  369. color: #333;
  370. font-family: "PingFang SC";
  371. font-size: 28rpx;
  372. font-weight: 400;
  373. display: flex;
  374. align-items: center;
  375. &-label {
  376. width: 162rpx;
  377. }
  378. .must-box {
  379. color: #FF3B1D;
  380. }
  381. }
  382. }
  383. .min-height {
  384. height: 300rpx;
  385. overflow: hidden;
  386. }
  387. .btn-box {
  388. height: 112rpx;
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. background-color: #fff;
  393. border-radius: 0 0 16rpx 16rpx;
  394. .btn-cont {
  395. display: flex;
  396. align-items: center;
  397. justify-content: center;
  398. width: 154rpx;
  399. height: 56rpx;
  400. border-radius: 120rpx;
  401. border: 1px solid #D9D9D9;
  402. color: #666;
  403. font-family: "PingFang SC";
  404. font-size: 28rpx;
  405. font-weight: 400;
  406. }
  407. }
  408. .scan-box {
  409. margin-top: 24rpx;
  410. padding: 24rpx 0;
  411. border-radius: 16rpx;
  412. background: #FFF;
  413. display: flex;
  414. .tips-text {
  415. color: #333;
  416. font-size: 28rpx;
  417. font-weight: 400;
  418. line-height: 48rpx;
  419. }
  420. .tips-text2 {
  421. color: #0256FF;
  422. font-size: 24rpx;
  423. font-weight: 400;
  424. display: flex;
  425. align-items: center;
  426. .radio-box {
  427. width: 32rpx;
  428. height: 32rpx;
  429. border-radius: 50%;
  430. border: 1px solid #D9D9D9;
  431. margin-right: 16rpx;
  432. }
  433. }
  434. .scan-box-l {
  435. width: 100%;
  436. display: flex;
  437. flex-direction: column;
  438. align-items: center;
  439. position: relative;
  440. &::after {
  441. content: '';
  442. display: block;
  443. width: 1px;
  444. height: 138rpx;
  445. background-color: #F4F4F4;
  446. position: absolute;
  447. top: 50%;
  448. right: 0;
  449. transform: translateY(-50%);
  450. }
  451. }
  452. .scan-box-r {
  453. width: 50%;
  454. display: flex;
  455. flex-direction: column;
  456. align-items: center;
  457. }
  458. }
  459. .cargo-list {
  460. padding: 24rpx 0;
  461. background-color: #fff;
  462. margin-top: 24rpx;
  463. border-radius: 16rpx;
  464. .cargo-list-title {
  465. font-family: "PingFang SC";
  466. font-size: 32rpx;
  467. font-style: normal;
  468. font-weight: bold;
  469. display: flex;
  470. align-items: center;
  471. position: relative;
  472. padding-left: 50rpx;
  473. &::after {
  474. content: '';
  475. display: block;
  476. width: 6rpx;
  477. height: 30rpx;
  478. border-radius: 100px;
  479. background: #0256FF;
  480. position: absolute;
  481. top: 50%;
  482. left: 24rpx;
  483. transform: translateY(-50%);
  484. }
  485. .cargo-list-title-tips {
  486. color: #0256FF;
  487. font-size: 24rpx;
  488. font-weight: 400;
  489. }
  490. }
  491. .num-box {
  492. display: flex;
  493. align-items: center;
  494. justify-content: space-between;
  495. padding: 0 48rpx 0 26rpx;
  496. .num-box-text {
  497. color: #666;
  498. font-family: "PingFang SC";
  499. font-size: 28rpx;
  500. font-weight: 400;
  501. }
  502. .input {
  503. width: 112rpx;
  504. text-align: center;
  505. border-bottom: 1px solid #0256FF;
  506. margin: 0 8rpx;
  507. }
  508. .minus {
  509. width: 40rpx;
  510. height: 40rpx;
  511. border-radius: 8rpx;
  512. border: 1px solid #0256FF;
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. }
  517. .plus {
  518. width: 40rpx;
  519. height: 40rpx;
  520. border-radius: 8rpx;
  521. background-color: #0256FF;
  522. display: flex;
  523. align-items: center;
  524. justify-content: center;
  525. }
  526. }
  527. }
  528. }
  529. .footer-box {
  530. background-color: #fff;
  531. height: 126rpx;
  532. position: fixed;
  533. bottom: 0;
  534. left: 0;
  535. right: 0;
  536. display: flex;
  537. align-items: center;
  538. justify-content: space-between;
  539. padding: 0 40rpx 0 60rpx;
  540. .footer-box-l {
  541. color: #666;
  542. font-family: "PingFang SC";
  543. font-size: 28rpx;
  544. font-weight: 400;
  545. }
  546. .submitBtn {
  547. width: 362rpx;
  548. height: 76rpx;
  549. border-radius: 16rpx;
  550. background: #0256FF;
  551. color: #FFF;
  552. font-size: 28rpx;
  553. font-weight: 500;
  554. margin: 0;
  555. }
  556. }
  557. }
  558. </style>