delivery.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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,'2',status)">
  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. status: null
  175. }
  176. },
  177. onLoad(e) {
  178. this.id = e.id
  179. this.status = e.status
  180. this.getOrderDetail(e.id)
  181. this.getOrderInfo(e.id)
  182. },
  183. computed: {
  184. ...mapGetters(['cangName']),
  185. speciesNum() {
  186. let num = 0
  187. if(this.goodsList.length == 0 || !this.goodsList) {
  188. num = 0
  189. }else {
  190. num = this.goodsList.length
  191. }
  192. return num
  193. },
  194. // 手动输入的数量
  195. goodsNum() {
  196. let num = 0
  197. if(this.goodsList.length == 0 || !this.goodsList) {
  198. num = 0
  199. }else {
  200. this.goodsList.forEach(item=>{
  201. num+=item.materialNumber
  202. })
  203. }
  204. return num
  205. },
  206. // 订单返回的数量
  207. orderGoodsNum() {
  208. let num = 0
  209. if(this.goodsList.length == 0 || !this.goodsList) {
  210. num = 0
  211. }else {
  212. this.goodsList.forEach(item=>{
  213. num+=item.operNumber
  214. })
  215. }
  216. return num
  217. }
  218. },
  219. onShow() {
  220. uni.$on('scanFinish',(data)=>{
  221. if(this.goodsList.length == 0)return uni.$u.toast("该货物不属于该任务")
  222. let index = this.goodsList.findIndex(item=>item.barCode == data)
  223. if(index == -1) return uni.$u.toast("该货物不属于该任务");
  224. this.scanIndex = index
  225. this.scanNum = this.goodsList[index].materialNumber
  226. this.scanedShow = true
  227. })
  228. },
  229. onHide() {
  230. uni.$off('scanFinish')
  231. },
  232. onUnload() {
  233. uni.$off('scanFinish')
  234. },
  235. methods:{
  236. scanCode() {
  237. this.$scan.scanCode()
  238. },
  239. calendarConfirm(val) {
  240. this.goodsList.forEach(item=>{
  241. if(item.id == this.chooseGoodsInfo.id) {
  242. item.productionDate = this.$u.timeFormat(val.value, 'yyyy-mm-dd')
  243. }
  244. })
  245. this.calendarShow = false
  246. },
  247. calendarCole() {
  248. this.calendarShow = false
  249. },
  250. calendarClick(item) {
  251. console.log(item.productionDate,'item.productionDate')
  252. this.chooseGoodsInfo = item
  253. if(item.productionDate) {
  254. this.value1 = Number(new Date(item.productionDate))
  255. }else {
  256. this.value1 = Number(new Date())
  257. }
  258. this.calendarShow = true
  259. },
  260. getOrderInfo(id) {
  261. orderInfo(id)
  262. .then(res=>{
  263. if(res.code == 200) {
  264. this.orderInfo = res.data
  265. console.log('this.orderInfo====',this.orderInfo)
  266. }
  267. })
  268. },
  269. getOrderDetail(id) {
  270. orderDetail(id)
  271. .then(res=>{
  272. if(res.code == 200) {
  273. res.data.rows.forEach(item=>{
  274. if(item.imgName && item.imgName.length >0) {
  275. item.imgNameArr = item.imgName.split(",")
  276. }else {
  277. item.imgNameArr = []
  278. }
  279. item.materialNumber = 0
  280. })
  281. this.goodsList = res.data.rows
  282. console.log('goodsList==========',this.goodsList )
  283. }
  284. })
  285. },
  286. submitClick() {
  287. let num = 0
  288. console.log('this.goodsList=====',this.goodsList)
  289. this.goodsList.forEach(item=>{
  290. if(item.materialNumber * 1 != item.operNumber ) {
  291. num ++
  292. }
  293. })
  294. console.log('num=====',num)
  295. if(num>0) {
  296. return this.errorShow = true
  297. }
  298. console.log('111111=====',1111)
  299. this.toOrderSubmit()
  300. },
  301. toOrderSubmit() {
  302. console.log('this.goodsList=====',this.goodsList)
  303. let materials = this.goodsList.map(item=> {
  304. return {
  305. barCode:item.barCode,
  306. materialNumber:item.materialNumber,
  307. productionDate:item.productionDate ? this.$u.timeFormat(item.productionDate, 'yyyy-mm-dd') : ''
  308. }
  309. })
  310. let params = {
  311. id:this.id,
  312. materials:materials,
  313. voucherPicture:this.voucherPicture || '',
  314. remark:this.orderInfo.mark || ''
  315. }
  316. console.log('orderSubmit========params====',params)
  317. orderSubmit(params)
  318. .then(res=>{
  319. console.log('orderSubmit============res=====',res)
  320. if(res.code == 200) {
  321. if(this.errorShow){
  322. this.errorShow = false
  323. }
  324. this.successShow = true
  325. }else{
  326. uni.showToast({
  327. icon: 'error',
  328. mask: true,
  329. title: res.msg||'服务错误'
  330. })
  331. }
  332. })
  333. },
  334. confirm() {
  335. this.toOrderSubmit()
  336. this.errorShow = false
  337. },
  338. backClick() {
  339. uni.setStorageSync('orderRefresh',true)
  340. uni.navigateBack()
  341. },
  342. // 扫码确认
  343. scanConfirm(val) {
  344. this.goodsList[this.scanIndex].materialNumber = Number(val)
  345. this.scanedShow = false
  346. },
  347. manualClick() {
  348. this.goodsShow = true
  349. },
  350. toDetail(val) {
  351. uni.navigateTo({
  352. url:`/pages/goods/detail?id=${val.id}&name=${val.materialName}`
  353. })
  354. },
  355. }
  356. }
  357. </script>
  358. <style lang="scss" scoped>
  359. .deliver-page {
  360. min-height: 100vh;
  361. background-color: #F0F6FB;
  362. padding-bottom: 130rpx;
  363. .container_main {
  364. padding: 24rpx;
  365. .info-box {
  366. background-color: #fff;
  367. border-radius: 16rpx 16rpx 0 0;
  368. padding: 24rpx 24rpx 0 24rpx;
  369. .info-line {
  370. border-bottom: 1px solid #F4F4F4;
  371. min-height: 92rpx;
  372. color: #333;
  373. font-family: "PingFang SC";
  374. font-size: 28rpx;
  375. font-weight: 400;
  376. display: flex;
  377. align-items: center;
  378. &-label {
  379. width: 162rpx;
  380. }
  381. .must-box {
  382. color: #FF3B1D;
  383. }
  384. }
  385. }
  386. .min-height {
  387. height: 300rpx;
  388. overflow: hidden;
  389. }
  390. .btn-box {
  391. height: 112rpx;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. background-color: #fff;
  396. border-radius: 0 0 16rpx 16rpx;
  397. .btn-cont {
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. width: 154rpx;
  402. height: 56rpx;
  403. border-radius: 120rpx;
  404. border: 1px solid #D9D9D9;
  405. color: #666;
  406. font-family: "PingFang SC";
  407. font-size: 28rpx;
  408. font-weight: 400;
  409. }
  410. }
  411. .scan-box {
  412. margin-top: 24rpx;
  413. padding: 24rpx 0;
  414. border-radius: 16rpx;
  415. background: #FFF;
  416. display: flex;
  417. .tips-text {
  418. color: #333;
  419. font-size: 28rpx;
  420. font-weight: 400;
  421. line-height: 48rpx;
  422. }
  423. .tips-text2 {
  424. color: #0256FF;
  425. font-size: 24rpx;
  426. font-weight: 400;
  427. display: flex;
  428. align-items: center;
  429. .radio-box {
  430. width: 32rpx;
  431. height: 32rpx;
  432. border-radius: 50%;
  433. border: 1px solid #D9D9D9;
  434. margin-right: 16rpx;
  435. }
  436. }
  437. .scan-box-l {
  438. width: 100%;
  439. display: flex;
  440. flex-direction: column;
  441. align-items: center;
  442. position: relative;
  443. &::after {
  444. content: '';
  445. display: block;
  446. width: 1px;
  447. height: 138rpx;
  448. background-color: #F4F4F4;
  449. position: absolute;
  450. top: 50%;
  451. right: 0;
  452. transform: translateY(-50%);
  453. }
  454. }
  455. .scan-box-r {
  456. width: 50%;
  457. display: flex;
  458. flex-direction: column;
  459. align-items: center;
  460. }
  461. }
  462. .cargo-list {
  463. padding: 24rpx 0;
  464. background-color: #fff;
  465. margin-top: 24rpx;
  466. border-radius: 16rpx;
  467. .cargo-list-title {
  468. font-family: "PingFang SC";
  469. font-size: 32rpx;
  470. font-style: normal;
  471. font-weight: bold;
  472. display: flex;
  473. align-items: center;
  474. position: relative;
  475. padding-left: 50rpx;
  476. &::after {
  477. content: '';
  478. display: block;
  479. width: 6rpx;
  480. height: 30rpx;
  481. border-radius: 100px;
  482. background: #0256FF;
  483. position: absolute;
  484. top: 50%;
  485. left: 24rpx;
  486. transform: translateY(-50%);
  487. }
  488. .cargo-list-title-tips {
  489. color: #0256FF;
  490. font-size: 24rpx;
  491. font-weight: 400;
  492. }
  493. }
  494. .num-box {
  495. display: flex;
  496. align-items: center;
  497. justify-content: space-between;
  498. padding: 0 48rpx 0 26rpx;
  499. .num-box-text {
  500. color: #666;
  501. font-family: "PingFang SC";
  502. font-size: 28rpx;
  503. font-weight: 400;
  504. }
  505. .input {
  506. width: 112rpx;
  507. text-align: center;
  508. border-bottom: 1px solid #0256FF;
  509. margin: 0 8rpx;
  510. }
  511. .minus {
  512. width: 40rpx;
  513. height: 40rpx;
  514. border-radius: 8rpx;
  515. border: 1px solid #0256FF;
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. }
  520. .plus {
  521. width: 40rpx;
  522. height: 40rpx;
  523. border-radius: 8rpx;
  524. background-color: #0256FF;
  525. display: flex;
  526. align-items: center;
  527. justify-content: center;
  528. }
  529. }
  530. }
  531. }
  532. .footer-box {
  533. background-color: #fff;
  534. height: 126rpx;
  535. position: fixed;
  536. bottom: 0;
  537. left: 0;
  538. right: 0;
  539. display: flex;
  540. align-items: center;
  541. justify-content: space-between;
  542. padding: 0 40rpx 0 60rpx;
  543. .footer-box-l {
  544. color: #666;
  545. font-family: "PingFang SC";
  546. font-size: 28rpx;
  547. font-weight: 400;
  548. }
  549. .submitBtn {
  550. width: 362rpx;
  551. height: 76rpx;
  552. border-radius: 16rpx;
  553. background: #0256FF;
  554. color: #FFF;
  555. font-size: 28rpx;
  556. font-weight: 500;
  557. margin: 0;
  558. }
  559. }
  560. }
  561. </style>