delivery.vue 13 KB

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