put-storage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <view class="deliver-page">
  3. <u-navbar
  4. height="40px"
  5. title="采购入库"
  6. bgColor="#0256FF"
  7. :titleStyle="{ color: '#fff' }"
  8. leftIconColor="#fff"
  9. autoBack
  10. placeholder
  11. >
  12. </u-navbar>
  13. <view class="container_main">
  14. <view class="info-box" :class="isUnfold ? '' : 'min-height'">
  15. <view class="info-line">
  16. <view class="info-line-label">
  17. <text>收入仓库</text>
  18. </view>
  19. <view class="info-line-value">
  20. {{ curDepotName }}
  21. </view>
  22. </view>
  23. <view class="info-line">
  24. <view class="info-line-label">
  25. <text>供应商</text>
  26. </view>
  27. <view class="info-line-value">
  28. {{ orderInfo.supplierName }}
  29. </view>
  30. </view>
  31. <view class="info-line">
  32. <view class="info-line-label">
  33. <text>入库类型</text>
  34. </view>
  35. <view class="info-line-value">
  36. {{ orderInfo.subType }}
  37. </view>
  38. </view>
  39. <view class="info-line">
  40. <view class="info-line-label">
  41. <text>入库日期</text>
  42. </view>
  43. <view class="info-line-value">
  44. {{ orderInfo.operTime }}
  45. </view>
  46. </view>
  47. <view class="info-line">
  48. <view class="info-line-label">
  49. <text>上传凭证</text>
  50. </view>
  51. <view class="info-line-value ss-p-y-24">
  52. <upload-image
  53. v-model="voucherPicture"
  54. width="196rpx"
  55. height="196rpx"
  56. ></upload-image>
  57. </view>
  58. </view>
  59. <view class="info-line">
  60. <view class="info-line-label">
  61. <text>备注信息</text>
  62. </view>
  63. <view class="info-line-value">
  64. <u-input
  65. v-model="orderInfo.mark"
  66. placeholder="请输入备注信息"
  67. border="none"
  68. ></u-input>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="btn-box">
  73. <view class="btn-cont" @click="isUnfold = !isUnfold">
  74. <text>{{ isUnfold ? "收起" : "展开" }}</text>
  75. <u-icon :name="isUnfold ? 'arrow-up' : 'arrow-down'"></u-icon>
  76. </view>
  77. </view>
  78. <view class="scan-box">
  79. <view class="scan-box-l" @click="scanCode">
  80. <u-image
  81. width="120rpx"
  82. height="120rpx"
  83. src="@/static/image/zidong-saoma-img.png"
  84. ></u-image>
  85. <view class="tips-text">扫描快速识别货物</view>
  86. <view class="tips-text2">
  87. <u-icon name="checkmark-circle-fill" color="#0256FF"></u-icon>
  88. <text>连续扫描</text>
  89. </view>
  90. </view>
  91. </view>
  92. <!-- 货物清单 -->
  93. <view class="cargo-list">
  94. <view class="cargo-list-title">
  95. <view>入库货物清单</view>
  96. <view class="cargo-list-title-tips">(轻触货物查看详情)</view>
  97. </view>
  98. <block v-for="(item, i) in goodsList" :key="i">
  99. <good-item
  100. :item="item"
  101. @toDetail="toDetail"
  102. @calendarClick="calendarClick"
  103. @handleClickField="handleClickField"
  104. :show-print="true"
  105. @print="(e) => handlePrint(e.id, '1', status)"
  106. >
  107. <view class="num-box">
  108. <view class="num-box-text">已确认入库数量</view>
  109. <u-number-box
  110. v-model="item.materialNumber"
  111. :min="0"
  112. :inputWidth="56"
  113. >
  114. </u-number-box>
  115. </view>
  116. </good-item>
  117. </block>
  118. </view>
  119. </view>
  120. <view class="footer-box">
  121. <view class="footer-box-l">
  122. <view>货物种类:{{ speciesNum }}种</view>
  123. <view>货物总数:{{ orderGoodsNum }}件</view>
  124. </view>
  125. <button class="submitBtn" @tap="submitClick">提交</button>
  126. </view>
  127. <error-pop
  128. v-model="errorShow"
  129. @close="errorShow = false"
  130. @confirm="confirm"
  131. :content="popText.errorText"
  132. ></error-pop>
  133. <success-pop
  134. v-model="successShow"
  135. @close="successShow = false"
  136. @backClick="backClick"
  137. :content="popText.successText"
  138. ></success-pop>
  139. <!-- 扫码之后弹窗 -->
  140. <scaned-pop
  141. v-if="scanedShow"
  142. v-model="scanedShow"
  143. :scanNum="scanNum"
  144. @close="scanedShow = false"
  145. @confirm="scanConfirm"
  146. ></scaned-pop>
  147. <goods-pop
  148. v-model="goodsShow"
  149. @close="goodsShow = false"
  150. type="caigou"
  151. ></goods-pop>
  152. <u-datetime-picker
  153. :show="calendarShow"
  154. v-model="value1"
  155. :maxDate="maxDate"
  156. mode="date"
  157. :closeOnClickOverlay="true"
  158. @confirm="calendarConfirm"
  159. @cancel="calendarShow = false"
  160. ></u-datetime-picker>
  161. <!-- 修改库位 -->
  162. <categoryPopup
  163. :show.sync="actionPop.showCategoryPop"
  164. :original-location="actionPop.originalLocation"
  165. @confirm="haandleComfirmLocation"
  166. />
  167. <!-- 打印条码弹框 -->
  168. <print-pop
  169. :show.sync="blePrintPop.show"
  170. :info="blePrintPop.data"
  171. @confirm="startPrint"
  172. ></print-pop>
  173. <!-- 选择蓝牙设备弹框 -->
  174. <ble-pop
  175. :show.sync="bleSelectPop.show"
  176. :list="discoveredDevices"
  177. @close="closeBleSelectPop"
  178. @refresh="refreshBleDevice"
  179. @selectItem="handleSelectBle"
  180. ></ble-pop>
  181. <ble-tip-pop
  182. v-model="bleErrorTipPop.show"
  183. :is-center="true"
  184. @confirm="bleErrorTipConfirm"
  185. :content="bleErrorTipPop.content"
  186. :extraText="bleErrorTipPop.extraText"
  187. >
  188. </ble-tip-pop>
  189. </view>
  190. </template>
  191. <script>
  192. import goodItem from "@/components/good-item/good-item.vue";
  193. import errorPop from "@/components/error-pop/error-pop.vue";
  194. import successPop from "@/components/success-pop/success-pop.vue";
  195. import scanedPop from "@/components/scaned-pop/scaned-pop.vue";
  196. import goodsPop from "@/components/goods-pop/goods-pop.vue";
  197. import categoryPopup from "@/pages/inventory-task/components/categoryPopup.vue";
  198. import {
  199. orderDetail,
  200. orderInfo,
  201. orderSubmit,
  202. getSkuByUpc,
  203. } from "@/common/request/apis/purchase";
  204. import { mapGetters } from "vuex";
  205. import blePrintMixin from "@/common/mixins/blePrintMixin.js";
  206. export default {
  207. mixins: [blePrintMixin],
  208. components: {
  209. goodItem,
  210. errorPop,
  211. successPop,
  212. scanedPop,
  213. goodsPop,
  214. categoryPopup,
  215. },
  216. data() {
  217. return {
  218. popText: {
  219. errorText: "实际入库数量与应入库数量有差异,是否确认提交?",
  220. successText: "您的采购入库任务已提交,审核后方可生效!",
  221. },
  222. goodsShow: false,
  223. scanedShow: false,
  224. errorShow: false,
  225. successShow: false,
  226. value: 0,
  227. isUnfold: true, //是否展开
  228. info: {
  229. mark: "",
  230. url: "",
  231. },
  232. goodsList: [],
  233. orderInfo: {},
  234. id: "",
  235. calendarShow: false,
  236. value1: "",
  237. maxDate: Number(new Date()),
  238. chooseGoodsInfo: {},
  239. voucherPicture: "",
  240. scanIndex: -1,
  241. scanNum: 1,
  242. status: null,
  243. actionPop: {
  244. // 修改库位弹框状态
  245. showCategoryPop: false,
  246. originalLocation: "",
  247. },
  248. };
  249. },
  250. onLoad(e) {
  251. this.id = e.id;
  252. this.getOrderDetail(e.id);
  253. this.getOrderInfo(e.id);
  254. },
  255. onShow() {
  256. uni.$on("scanFinish", async (data) => {
  257. try {
  258. const params = {
  259. upc: data,
  260. };
  261. console.log("params===", params);
  262. const res = await getSkuByUpc(params);
  263. console.log("getSkuByUpc====", res);
  264. if (res.code === 200) {
  265. const sku = res.data;
  266. if (this.goodsList.length == 0)
  267. return uni.$u.toast("该货物不属于该任务");
  268. let index = this.goodsList.findIndex((item) => item.sku == sku);
  269. if (index == -1) return uni.$u.toast("该货物不属于该任务");
  270. this.scanIndex = index;
  271. this.scanNum = this.goodsList[index].materialNumber;
  272. this.scanedShow = true;
  273. } else {
  274. uni.$u.toast(res.msg);
  275. }
  276. } catch (error) {}
  277. });
  278. },
  279. onHide() {
  280. uni.$off("scanFinish");
  281. },
  282. onUnload() {
  283. uni.$off("scanFinish");
  284. },
  285. computed: {
  286. ...mapGetters(["depotInfo"]),
  287. curDepotId() {
  288. return this.depotInfo ? this.depotInfo.id : "";
  289. },
  290. curDepotName() {
  291. return this.depotInfo ? this.depotInfo.depotName : "";
  292. },
  293. speciesNum() {
  294. let num = 0;
  295. if (this.goodsList.length == 0 || !this.goodsList) {
  296. num = 0;
  297. } else {
  298. num = this.goodsList.length;
  299. }
  300. return num;
  301. },
  302. // 订单返回的数量
  303. orderGoodsNum() {
  304. let num = 0;
  305. if (this.goodsList.length == 0 || !this.goodsList) {
  306. num = 0;
  307. } else {
  308. this.goodsList.forEach((item) => {
  309. num += item.operNumber;
  310. });
  311. }
  312. return num;
  313. },
  314. },
  315. methods: {
  316. scanCode() {
  317. this.$scan.scanCode();
  318. },
  319. calendarConfirm(val) {
  320. this.goodsList.forEach((item) => {
  321. if (item.id == this.chooseGoodsInfo.id) {
  322. item.productionDate = this.$u.timeFormat(val.value, "yyyy-mm-dd");
  323. }
  324. });
  325. this.calendarShow = false;
  326. },
  327. calendarClick(item) {
  328. this.chooseGoodsInfo = item;
  329. if (item.productionDate) {
  330. this.value1 = Number(new Date(item.productionDate));
  331. } else {
  332. this.value1 = Number(new Date());
  333. }
  334. this.calendarShow = true;
  335. },
  336. getOrderInfo(id) {
  337. orderInfo(id).then((res) => {
  338. if (res.code == 200) {
  339. this.orderInfo = res.data;
  340. this.status = res.data.status;
  341. console.log("this.orderInfo====", this.orderInfo);
  342. }
  343. });
  344. },
  345. getOrderDetail(id) {
  346. orderDetail(id).then((res) => {
  347. if (res.code == 200) {
  348. res.data.rows.forEach((item) => {
  349. item.materialNumber = 0;
  350. if (item.imgName && item.imgName.length > 0) {
  351. item.imgNameArr = item.imgName.split(",");
  352. } else {
  353. item.imgNameArr = [];
  354. }
  355. });
  356. console.log("2333333333");
  357. console.log("res.data====", res.data);
  358. this.goodsList = res.data.rows;
  359. }
  360. });
  361. },
  362. submitClick() {
  363. let num = 0;
  364. this.goodsList.forEach((item) => {
  365. if (item.materialNumber * 1 != item.operNumber) {
  366. num++;
  367. }
  368. });
  369. if (num > 0) {
  370. return (this.errorShow = true);
  371. }
  372. this.toOrderSubmit();
  373. },
  374. toOrderSubmit() {
  375. let materials = this.goodsList.map((item) => {
  376. return {
  377. barCode: item.sku,
  378. materialNumber: item.materialNumber,
  379. productionDate: item.productionDate
  380. ? this.$u.timeFormat(item.productionDate, "yyyy-mm-dd")
  381. : "",
  382. position: item.position,
  383. };
  384. });
  385. let params = {
  386. id: this.id,
  387. materials: materials,
  388. voucherPicture: this.voucherPicture || "",
  389. remark: this.orderInfo.mark || "",
  390. number: this.orderInfo.number,
  391. };
  392. console.log("params", params);
  393. orderSubmit(params).then((res) => {
  394. console.log("res", res);
  395. if (res.code == 200) {
  396. if (this.errorShow) {
  397. this.errorShow = false;
  398. }
  399. this.successShow = true;
  400. } else {
  401. this.$u.toast(res.msg, 2000);
  402. }
  403. });
  404. },
  405. confirm() {
  406. this.toOrderSubmit();
  407. this.errorShow = false;
  408. },
  409. backClick() {
  410. uni.setStorageSync("orderRefresh", true);
  411. uni.navigateBack();
  412. },
  413. // 扫码确认
  414. scanConfirm(val) {
  415. this.goodsList[this.scanIndex].materialNumber = Number(val);
  416. this.scanedShow = false;
  417. },
  418. handleClickField(field, item) {
  419. console.log("field", field);
  420. console.log("item", item);
  421. this.chooseGoodsInfo = item;
  422. if (field == "position") {
  423. this.actionPop.showCategoryPop = true;
  424. this.actionPop.originalLocation = item.position;
  425. }
  426. },
  427. haandleComfirmLocation(val) {
  428. this.goodsList.forEach((item) => {
  429. if (item.id == this.chooseGoodsInfo.id) {
  430. item.position = val;
  431. }
  432. });
  433. this.actionPop.showCategoryPop = false;
  434. },
  435. toDetail(val) {
  436. uni.navigateTo({
  437. url: `/pages/goods/detail?id=${val.id}&name=${val.materialName}`,
  438. });
  439. },
  440. },
  441. };
  442. </script>
  443. <style lang="scss" scoped>
  444. .deliver-page {
  445. min-height: 100vh;
  446. background-color: #f0f6fb;
  447. padding-bottom: 130rpx;
  448. .container_main {
  449. padding: 24rpx;
  450. .info-box {
  451. background-color: #fff;
  452. border-radius: 16rpx 16rpx 0 0;
  453. padding: 24rpx 24rpx 0 24rpx;
  454. .info-line {
  455. border-bottom: 1px solid #f4f4f4;
  456. padding: 24rpx 0;
  457. color: #333;
  458. font-family: "PingFang SC";
  459. font-size: 28rpx;
  460. line-height: 1.5;
  461. font-weight: 400;
  462. display: flex;
  463. align-items: center;
  464. &-label {
  465. flex: 0 0 162rpx;
  466. width: 162rpx;
  467. }
  468. &-value {
  469. word-break: break-all;
  470. }
  471. .must-box {
  472. color: #ff3b1d;
  473. }
  474. }
  475. }
  476. .min-height {
  477. height: 300rpx;
  478. overflow: hidden;
  479. }
  480. .btn-box {
  481. height: 112rpx;
  482. display: flex;
  483. align-items: center;
  484. justify-content: center;
  485. background-color: #fff;
  486. border-radius: 0 0 16rpx 16rpx;
  487. .btn-cont {
  488. display: flex;
  489. align-items: center;
  490. justify-content: center;
  491. width: 154rpx;
  492. height: 56rpx;
  493. border-radius: 120rpx;
  494. border: 1px solid #d9d9d9;
  495. color: #666;
  496. font-family: "PingFang SC";
  497. font-size: 28rpx;
  498. font-weight: 400;
  499. }
  500. }
  501. .scan-box {
  502. margin-top: 24rpx;
  503. padding: 24rpx 0;
  504. border-radius: 16rpx;
  505. background: #fff;
  506. display: flex;
  507. .tips-text {
  508. color: #333;
  509. font-size: 28rpx;
  510. font-weight: 400;
  511. line-height: 48rpx;
  512. }
  513. .tips-text2 {
  514. color: #0256ff;
  515. font-size: 24rpx;
  516. font-weight: 400;
  517. display: flex;
  518. align-items: center;
  519. .radio-box {
  520. width: 32rpx;
  521. height: 32rpx;
  522. border-radius: 50%;
  523. border: 1px solid #d9d9d9;
  524. margin-right: 16rpx;
  525. }
  526. }
  527. .scan-box-l {
  528. width: 100%;
  529. display: flex;
  530. flex-direction: column;
  531. align-items: center;
  532. position: relative;
  533. &::after {
  534. content: "";
  535. display: block;
  536. width: 1px;
  537. height: 138rpx;
  538. background-color: #f4f4f4;
  539. position: absolute;
  540. top: 50%;
  541. right: 0;
  542. transform: translateY(-50%);
  543. }
  544. }
  545. .scan-box-r {
  546. width: 50%;
  547. display: flex;
  548. flex-direction: column;
  549. align-items: center;
  550. }
  551. }
  552. .cargo-list {
  553. padding: 24rpx 0;
  554. background-color: #fff;
  555. margin-top: 24rpx;
  556. border-radius: 16rpx;
  557. .cargo-list-title {
  558. font-family: "PingFang SC";
  559. font-size: 32rpx;
  560. font-style: normal;
  561. font-weight: bold;
  562. display: flex;
  563. align-items: center;
  564. position: relative;
  565. padding-left: 50rpx;
  566. &::after {
  567. content: "";
  568. display: block;
  569. width: 6rpx;
  570. height: 30rpx;
  571. border-radius: 100px;
  572. background: #0256ff;
  573. position: absolute;
  574. top: 50%;
  575. left: 24rpx;
  576. transform: translateY(-50%);
  577. }
  578. .cargo-list-title-tips {
  579. color: #0256ff;
  580. font-size: 24rpx;
  581. font-weight: 400;
  582. }
  583. }
  584. .num-box {
  585. display: flex;
  586. align-items: center;
  587. justify-content: space-between;
  588. padding: 0 48rpx 0 26rpx;
  589. .num-box-text {
  590. color: #666;
  591. font-family: "PingFang SC";
  592. font-size: 28rpx;
  593. font-weight: 400;
  594. }
  595. .input {
  596. width: 112rpx;
  597. text-align: center;
  598. border-bottom: 1px solid #0256ff;
  599. margin: 0 8rpx;
  600. }
  601. .minus {
  602. width: 40rpx;
  603. height: 40rpx;
  604. border-radius: 8rpx;
  605. border: 1px solid #0256ff;
  606. display: flex;
  607. align-items: center;
  608. justify-content: center;
  609. }
  610. .plus {
  611. width: 40rpx;
  612. height: 40rpx;
  613. border-radius: 8rpx;
  614. background-color: #0256ff;
  615. display: flex;
  616. align-items: center;
  617. justify-content: center;
  618. }
  619. }
  620. }
  621. }
  622. .footer-box {
  623. background-color: #fff;
  624. height: 126rpx;
  625. position: fixed;
  626. bottom: 0;
  627. left: 0;
  628. right: 0;
  629. display: flex;
  630. align-items: center;
  631. justify-content: space-between;
  632. padding: 0 40rpx 0 60rpx;
  633. .footer-box-l {
  634. color: #666;
  635. font-family: "PingFang SC";
  636. font-size: 28rpx;
  637. font-weight: 400;
  638. }
  639. .submitBtn {
  640. width: 362rpx;
  641. height: 76rpx;
  642. border-radius: 16rpx;
  643. background: #0256ff;
  644. color: #fff;
  645. font-size: 28rpx;
  646. font-weight: 500;
  647. margin: 0;
  648. }
  649. }
  650. }
  651. </style>