put-storage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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 ss-p-y-24">
  45. <upload-image v-model="voucherPicture" width="196rpx" height="196rpx"></upload-image>
  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">
  53. <u-input v-model="orderInfo.mark" placeholder="请输入备注信息" border="none"></u-input>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="btn-box">
  58. <view class="btn-cont" @click="isUnfold = !isUnfold">
  59. <text>{{isUnfold ? '收起' : '展开'}}</text>
  60. <u-icon :name="isUnfold?'arrow-up':'arrow-down'"></u-icon>
  61. </view>
  62. </view>
  63. <view class="scan-box">
  64. <view class="scan-box-l" @click="scanCode">
  65. <u-image width="120rpx" height="120rpx" src="@/static/image/zidong-saoma-img.png"></u-image>
  66. <view class="tips-text">扫描快速识别货物</view>
  67. <view class="tips-text2">
  68. <u-icon name="checkmark-circle-fill" color="#0256FF"></u-icon>
  69. <text>连续扫描</text>
  70. </view>
  71. </view>
  72. <view class="scan-box-r" @click="manualClick">
  73. <u-image width="120rpx" height="120rpx" src="@/static/image/shoudong-saoma-img.png"></u-image>
  74. <view class="tips-text">手动选择</view>
  75. </view>
  76. </view>
  77. <!-- 货物清单 -->
  78. <view class="cargo-list">
  79. <view class="cargo-list-title">
  80. <view>入库货物清单</view>
  81. <view class="cargo-list-title-tips">(轻触货物查看详情)</view>
  82. </view>
  83. <block v-for="(item,i) in goodsList" :key="i">
  84. <good-item :item="item" @toDetail="toDetail" @calendarClick="calendarClick">
  85. <view class="num-box">
  86. <view class="num-box-text">已确认入库数量</view>
  87. <u-number-box v-model="item.materialNumber">
  88. <view slot="minus" class="minus">
  89. <u-icon name="minus" color="#0256FF" size="12"></u-icon>
  90. </view>
  91. <text slot="input" class="input">{{item.materialNumber}}</text>
  92. <view slot="plus" class="plus">
  93. <u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
  94. </view>
  95. </u-number-box>
  96. </view>
  97. </good-item>
  98. </block>
  99. </view>
  100. </view>
  101. <view class="footer-box">
  102. <view class="footer-box-l">
  103. <view>货物种类:{{speciesNum}}种</view>
  104. <view>货物种数:{{goodsNum}}件</view>
  105. </view>
  106. <button class="submitBtn" @tap="submitClick">
  107. 提交
  108. </button>
  109. </view>
  110. <error-pop v-model="errorShow" @close="errorShow = false" @confirm="confirm" :content="popText.errorText"></error-pop>
  111. <success-pop v-model="successShow" @close="successShow = false" @backClick="backClick" :content="popText.successText"></success-pop>
  112. <!-- 扫码之后弹窗 -->
  113. <scaned-pop v-if="scanedShow" v-model="scanedShow" :scanNum="scanNum" @close="scanedShow = false" @confirm="scanConfirm"></scaned-pop>
  114. <goods-pop v-model="goodsShow" @close="goodsShow = false" type="caigou"></goods-pop>
  115. <u-datetime-picker
  116. :show="calendarShow"
  117. v-model="value1"
  118. :maxDate="maxDate"
  119. mode="date"
  120. :closeOnClickOverlay="true"
  121. @confirm="calendarConfirm"
  122. @cancel="calendarShow = false"
  123. ></u-datetime-picker>
  124. </view>
  125. </template>
  126. <script>
  127. import goodItem from '@/components/good-item/good-item.vue'
  128. import errorPop from '@/components/error-pop/error-pop.vue'
  129. import successPop from '@/components/success-pop/success-pop.vue'
  130. import scanedPop from '@/components/scaned-pop/scaned-pop.vue'
  131. import goodsPop from '@/components/goods-pop/goods-pop.vue'
  132. import {orderDetail, orderInfo, orderSubmit} from '@/common/request/apis/purchase'
  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. onShow() {
  175. uni.$on('scanFinish',(data)=>{
  176. if(this.goodsList.length == 0)return
  177. let index = this.goodsList.findIndex(item=>item.barCode == data)
  178. if(index == -1) return
  179. this.scanIndex = index
  180. this.scanNum = 1
  181. this.scanedShow = true
  182. })
  183. },
  184. onHide() {
  185. uni.$off('scanFinish')
  186. },
  187. onUnload() {
  188. uni.$off('scanFinish')
  189. },
  190. computed: {
  191. speciesNum() {
  192. let num = 0
  193. if(this.goodsList.length == 0 || !this.goodsList) {
  194. num = 0
  195. }else {
  196. num = this.goodsList.length
  197. }
  198. return num
  199. },
  200. // 手动输入的数量
  201. goodsNum() {
  202. let num = 0
  203. if(this.goodsList.length == 0 || !this.goodsList) {
  204. num = 0
  205. }else {
  206. this.goodsList.forEach(item=>{
  207. num+=item.materialNumber
  208. })
  209. }
  210. return num
  211. },
  212. // 订单返回的数量
  213. orderGoodsNum() {
  214. let num = 0
  215. if(this.goodsList.length == 0 || !this.goodsList) {
  216. num = 0
  217. }else {
  218. this.goodsList.forEach(item=>{
  219. num+=item.operNumber
  220. })
  221. }
  222. return num
  223. }
  224. },
  225. methods:{
  226. scanCode() {
  227. this.$scan.scanCode()
  228. },
  229. calendarConfirm(val) {
  230. this.goodsList.forEach(item=>{
  231. if(item.id == this.chooseGoodsInfo.id) {
  232. item.productionDate = this.$u.timeFormat(val.value, 'yyyy-mm-dd')
  233. }
  234. })
  235. this.calendarShow = false
  236. },
  237. calendarCole() {
  238. this.calendarShow = false
  239. },
  240. calendarClick(item) {
  241. console.log(item.productionDate,'item.productionDate')
  242. this.chooseGoodsInfo = item
  243. if(item.productionDate) {
  244. this.value1 = Number(new Date(item.productionDate))
  245. }else {
  246. this.value1 = Number(new Date())
  247. }
  248. this.calendarShow = true
  249. },
  250. getOrderInfo(id) {
  251. orderInfo(id)
  252. .then(res=>{
  253. if(res.code == 200) {
  254. this.orderInfo = res.data
  255. }
  256. })
  257. },
  258. getOrderDetail(id) {
  259. orderDetail(id)
  260. .then(res=>{
  261. if(res.code == 200) {
  262. res.data.rows.forEach(item=>{
  263. item.materialNumber = 0
  264. })
  265. this.goodsList = res.data.rows
  266. }
  267. })
  268. },
  269. submitClick() {
  270. if(this.orderGoodsNum != this.goodsNum) {
  271. return this.errorShow = true
  272. }
  273. this.toOrderSubmit()
  274. },
  275. toOrderSubmit() {
  276. let materials = this.goodsList.map(item=> {
  277. return {
  278. batchNumber:item.batchNumber,
  279. materialNumber:item.materialNumber,
  280. productionDate:item.productionDate ? this.$u.timeFormat(item.productionDate, 'yyyy-mm-dd') : ''
  281. }
  282. })
  283. let params = {
  284. id:this.id,
  285. materials:materials,
  286. voucherPicture:this.voucherPicture || '',
  287. remark:this.orderInfo.mark || ''
  288. }
  289. orderSubmit(params)
  290. .then(res=>{
  291. if(res.code == 200) {
  292. if(this.errorShow){
  293. this.errorShow = false
  294. }
  295. this.successShow = true
  296. }
  297. })
  298. },
  299. confirm() {
  300. this.toOrderSubmit()
  301. this.errorShow = false
  302. },
  303. backClick() {
  304. uni.setStorageSync('orderRefresh',true)
  305. uni.navigateBack()
  306. },
  307. // 扫码确认
  308. scanConfirm(val) {
  309. this.goodsList[this.scanIndex].materialNumber += Number(val)
  310. this.scanedShow = false
  311. },
  312. manualClick() {
  313. // this.goodsShow = true
  314. },
  315. toDetail(val) {
  316. uni.navigateTo({
  317. url:`/pages/goods/detail?id=${val.id}&name=${val.materialName}`
  318. })
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. .deliver-page {
  325. min-height: 100vh;
  326. background-color: #F0F6FB;
  327. padding-bottom: 130rpx;
  328. .container_main {
  329. padding: 24rpx;
  330. .info-box {
  331. background-color: #fff;
  332. border-radius: 16rpx 16rpx 0 0;
  333. padding: 24rpx 24rpx 0 24rpx;
  334. .info-line {
  335. border-bottom: 1px solid #F4F4F4;
  336. min-height: 92rpx;
  337. color: #333;
  338. font-family: "PingFang SC";
  339. font-size: 28rpx;
  340. font-weight: 400;
  341. display: flex;
  342. align-items: center;
  343. &-label {
  344. width: 162rpx;
  345. }
  346. .must-box {
  347. color: #FF3B1D;
  348. }
  349. }
  350. }
  351. .min-height {
  352. height: 300rpx;
  353. overflow: hidden;
  354. }
  355. .btn-box {
  356. height: 112rpx;
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. background-color: #fff;
  361. border-radius: 0 0 16rpx 16rpx;
  362. .btn-cont {
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. width: 154rpx;
  367. height: 56rpx;
  368. border-radius: 120rpx;
  369. border: 1px solid #D9D9D9;
  370. color: #666;
  371. font-family: "PingFang SC";
  372. font-size: 28rpx;
  373. font-weight: 400;
  374. }
  375. }
  376. .scan-box {
  377. margin-top: 24rpx;
  378. padding: 24rpx 0;
  379. border-radius: 16rpx;
  380. background: #FFF;
  381. display: flex;
  382. .tips-text {
  383. color: #333;
  384. font-size: 28rpx;
  385. font-weight: 400;
  386. line-height: 48rpx;
  387. }
  388. .tips-text2 {
  389. color: #0256FF;
  390. font-size: 24rpx;
  391. font-weight: 400;
  392. display: flex;
  393. align-items: center;
  394. .radio-box {
  395. width: 32rpx;
  396. height: 32rpx;
  397. border-radius: 50%;
  398. border: 1px solid #D9D9D9;
  399. margin-right: 16rpx;
  400. }
  401. }
  402. .scan-box-l {
  403. width: 50%;
  404. display: flex;
  405. flex-direction: column;
  406. align-items: center;
  407. position: relative;
  408. &::after {
  409. content: '';
  410. display: block;
  411. width: 1px;
  412. height: 138rpx;
  413. background-color: #F4F4F4;
  414. position: absolute;
  415. top: 50%;
  416. right: 0;
  417. transform: translateY(-50%);
  418. }
  419. }
  420. .scan-box-r {
  421. width: 50%;
  422. display: flex;
  423. flex-direction: column;
  424. align-items: center;
  425. }
  426. }
  427. .cargo-list {
  428. padding: 24rpx 0;
  429. background-color: #fff;
  430. margin-top: 24rpx;
  431. border-radius: 16rpx;
  432. .cargo-list-title {
  433. font-family: "PingFang SC";
  434. font-size: 32rpx;
  435. font-style: normal;
  436. font-weight: bold;
  437. display: flex;
  438. align-items: center;
  439. position: relative;
  440. padding-left: 50rpx;
  441. &::after {
  442. content: '';
  443. display: block;
  444. width: 6rpx;
  445. height: 30rpx;
  446. border-radius: 100px;
  447. background: #0256FF;
  448. position: absolute;
  449. top: 50%;
  450. left: 24rpx;
  451. transform: translateY(-50%);
  452. }
  453. .cargo-list-title-tips {
  454. color: #0256FF;
  455. font-size: 24rpx;
  456. font-weight: 400;
  457. }
  458. }
  459. .num-box {
  460. display: flex;
  461. align-items: center;
  462. justify-content: space-between;
  463. padding: 0 48rpx 0 26rpx;
  464. .num-box-text {
  465. color: #666;
  466. font-family: "PingFang SC";
  467. font-size: 28rpx;
  468. font-weight: 400;
  469. }
  470. .input {
  471. width: 112rpx;
  472. text-align: center;
  473. border-bottom: 1px solid #0256FF;
  474. margin: 0 8rpx;
  475. }
  476. .minus {
  477. width: 40rpx;
  478. height: 40rpx;
  479. border-radius: 8rpx;
  480. border: 1px solid #0256FF;
  481. display: flex;
  482. align-items: center;
  483. justify-content: center;
  484. }
  485. .plus {
  486. width: 40rpx;
  487. height: 40rpx;
  488. border-radius: 8rpx;
  489. background-color: #0256FF;
  490. display: flex;
  491. align-items: center;
  492. justify-content: center;
  493. }
  494. }
  495. }
  496. }
  497. .footer-box {
  498. background-color: #fff;
  499. height: 126rpx;
  500. position: fixed;
  501. bottom: 0;
  502. left: 0;
  503. right: 0;
  504. display: flex;
  505. align-items: center;
  506. justify-content: space-between;
  507. padding: 0 40rpx 0 60rpx;
  508. .footer-box-l {
  509. color: #666;
  510. font-family: "PingFang SC";
  511. font-size: 28rpx;
  512. font-weight: 400;
  513. }
  514. .submitBtn {
  515. width: 362rpx;
  516. height: 76rpx;
  517. border-radius: 16rpx;
  518. background: #0256FF;
  519. color: #FFF;
  520. font-size: 28rpx;
  521. font-weight: 500;
  522. margin: 0;
  523. }
  524. }
  525. }
  526. </style>