delivery.vue 13 KB

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