put-storage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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. } from "@/common/request/apis/purchase";
  203. import { mapGetters } from "vuex";
  204. import blePrintMixin from "@/common/mixins/blePrintMixin.js";
  205. export default {
  206. mixins: [blePrintMixin],
  207. components: {
  208. goodItem,
  209. errorPop,
  210. successPop,
  211. scanedPop,
  212. goodsPop,
  213. categoryPopup,
  214. },
  215. data() {
  216. return {
  217. popText: {
  218. errorText: "实际入库数量与应入库数量有差异,是否确认提交?",
  219. successText: "入库成功!",
  220. },
  221. goodsShow: false,
  222. scanedShow: false,
  223. errorShow: false,
  224. successShow: false,
  225. value: 0,
  226. isUnfold: true, //是否展开
  227. info: {
  228. mark: "",
  229. url: "",
  230. },
  231. goodsList: [],
  232. orderInfo: {},
  233. id: "",
  234. calendarShow: false,
  235. value1: "",
  236. maxDate: Number(new Date()),
  237. chooseGoodsInfo: {},
  238. voucherPicture: "",
  239. scanIndex: -1,
  240. scanNum: 1,
  241. status: null,
  242. actionPop: {
  243. // 修改库位弹框状态
  244. showCategoryPop: false,
  245. originalLocation: "",
  246. },
  247. };
  248. },
  249. onLoad(e) {
  250. this.id = e.id;
  251. this.status = e.status;
  252. this.getOrderDetail(e.id);
  253. this.getOrderInfo(e.id);
  254. },
  255. onShow() {
  256. uni.$on("scanFinish", (data) => {
  257. if (this.goodsList.length == 0) return uni.$u.toast("该货物不属于该任务");
  258. let index = this.goodsList.findIndex((item) => item.barCode == data);
  259. if (index == -1) return uni.$u.toast("该货物不属于该任务");
  260. this.scanIndex = index;
  261. this.scanNum = this.goodsList[index].materialNumber;
  262. this.scanedShow = true;
  263. });
  264. },
  265. onHide() {
  266. uni.$off("scanFinish");
  267. },
  268. onUnload() {
  269. uni.$off("scanFinish");
  270. },
  271. computed: {
  272. ...mapGetters(["depotInfo"]),
  273. curDepotId() {
  274. return this.depotInfo ? this.depotInfo.id : "";
  275. },
  276. curDepotName() {
  277. return this.depotInfo ? this.depotInfo.depotName : "";
  278. },
  279. speciesNum() {
  280. let num = 0;
  281. if (this.goodsList.length == 0 || !this.goodsList) {
  282. num = 0;
  283. } else {
  284. num = this.goodsList.length;
  285. }
  286. return num;
  287. },
  288. // 手动输入的数量
  289. goodsNum() {
  290. let num = 0;
  291. if (this.goodsList.length == 0 || !this.goodsList) {
  292. num = 0;
  293. } else {
  294. this.goodsList.forEach((item) => {
  295. num += item.materialNumber;
  296. });
  297. }
  298. return num;
  299. },
  300. // 订单返回的数量
  301. orderGoodsNum() {
  302. let num = 0;
  303. if (this.goodsList.length == 0 || !this.goodsList) {
  304. num = 0;
  305. } else {
  306. this.goodsList.forEach((item) => {
  307. num += item.operNumber;
  308. });
  309. }
  310. return num;
  311. },
  312. },
  313. methods: {
  314. scanCode() {
  315. this.$scan.scanCode();
  316. },
  317. calendarConfirm(val) {
  318. this.goodsList.forEach((item) => {
  319. if (item.id == this.chooseGoodsInfo.id) {
  320. item.productionDate = this.$u.timeFormat(val.value, "yyyy-mm-dd");
  321. }
  322. });
  323. this.calendarShow = false;
  324. },
  325. calendarCole() {
  326. this.calendarShow = false;
  327. },
  328. calendarClick(item) {
  329. this.chooseGoodsInfo = item;
  330. if (item.productionDate) {
  331. this.value1 = Number(new Date(item.productionDate));
  332. } else {
  333. this.value1 = Number(new Date());
  334. }
  335. this.calendarShow = true;
  336. },
  337. getOrderInfo(id) {
  338. orderInfo(id).then((res) => {
  339. if (res.code == 200) {
  340. this.orderInfo = res.data;
  341. }
  342. });
  343. },
  344. getOrderDetail(id) {
  345. orderDetail(id).then((res) => {
  346. if (res.code == 200) {
  347. res.data.rows.forEach((item) => {
  348. item.materialNumber = 0;
  349. if (item.imgName && item.imgName.length > 0) {
  350. item.imgNameArr = item.imgName.split(",");
  351. } else {
  352. item.imgNameArr = [];
  353. }
  354. });
  355. this.goodsList = res.data.rows;
  356. }
  357. });
  358. },
  359. submitClick() {
  360. let num = 0;
  361. this.goodsList.forEach((item) => {
  362. if (item.materialNumber * 1 != item.operNumber) {
  363. num++;
  364. }
  365. });
  366. if (num > 0) {
  367. return (this.errorShow = true);
  368. }
  369. this.toOrderSubmit();
  370. },
  371. toOrderSubmit() {
  372. let materials = this.goodsList.map((item) => {
  373. return {
  374. barCode: item.barCode,
  375. materialNumber: item.materialNumber,
  376. productionDate: item.productionDate
  377. ? this.$u.timeFormat(item.productionDate, "yyyy-mm-dd")
  378. : "",
  379. position: item.position,
  380. };
  381. });
  382. let params = {
  383. id: this.id,
  384. materials: materials,
  385. voucherPicture: this.voucherPicture || "",
  386. remark: this.orderInfo.mark || "",
  387. };
  388. console.log("params", params);
  389. orderSubmit(params).then((res) => {
  390. console.log("res", res);
  391. if (res.code == 200) {
  392. if (this.errorShow) {
  393. this.errorShow = false;
  394. }
  395. this.successShow = true;
  396. } else {
  397. this.$u.toast(res.msg, 2000);
  398. }
  399. });
  400. },
  401. confirm() {
  402. this.toOrderSubmit();
  403. this.errorShow = false;
  404. },
  405. backClick() {
  406. uni.setStorageSync("orderRefresh", true);
  407. uni.navigateBack();
  408. },
  409. // 扫码确认
  410. scanConfirm(val) {
  411. this.goodsList[this.scanIndex].materialNumber = Number(val);
  412. this.scanedShow = false;
  413. },
  414. handleClickField(field, item) {
  415. console.log("field", field);
  416. console.log("item", item);
  417. this.chooseGoodsInfo = item;
  418. if (field == "position") {
  419. this.actionPop.showCategoryPop = true;
  420. this.actionPop.originalLocation = item.position;
  421. }
  422. },
  423. haandleComfirmLocation(val) {
  424. this.goodsList.forEach((item) => {
  425. if (item.id == this.chooseGoodsInfo.id) {
  426. item.position = val;
  427. }
  428. });
  429. this.actionPop.showCategoryPop = false;
  430. },
  431. toDetail(val) {
  432. uni.navigateTo({
  433. url: `/pages/goods/detail?id=${val.id}&name=${val.materialName}`,
  434. });
  435. },
  436. },
  437. };
  438. </script>
  439. <style lang="scss" scoped>
  440. .deliver-page {
  441. min-height: 100vh;
  442. background-color: #f0f6fb;
  443. padding-bottom: 130rpx;
  444. .container_main {
  445. padding: 24rpx;
  446. .info-box {
  447. background-color: #fff;
  448. border-radius: 16rpx 16rpx 0 0;
  449. padding: 24rpx 24rpx 0 24rpx;
  450. .info-line {
  451. border-bottom: 1px solid #f4f4f4;
  452. min-height: 92rpx;
  453. color: #333;
  454. font-family: "PingFang SC";
  455. font-size: 28rpx;
  456. font-weight: 400;
  457. display: flex;
  458. align-items: center;
  459. &-label {
  460. width: 162rpx;
  461. }
  462. .must-box {
  463. color: #ff3b1d;
  464. }
  465. }
  466. }
  467. .min-height {
  468. height: 300rpx;
  469. overflow: hidden;
  470. }
  471. .btn-box {
  472. height: 112rpx;
  473. display: flex;
  474. align-items: center;
  475. justify-content: center;
  476. background-color: #fff;
  477. border-radius: 0 0 16rpx 16rpx;
  478. .btn-cont {
  479. display: flex;
  480. align-items: center;
  481. justify-content: center;
  482. width: 154rpx;
  483. height: 56rpx;
  484. border-radius: 120rpx;
  485. border: 1px solid #d9d9d9;
  486. color: #666;
  487. font-family: "PingFang SC";
  488. font-size: 28rpx;
  489. font-weight: 400;
  490. }
  491. }
  492. .scan-box {
  493. margin-top: 24rpx;
  494. padding: 24rpx 0;
  495. border-radius: 16rpx;
  496. background: #fff;
  497. display: flex;
  498. .tips-text {
  499. color: #333;
  500. font-size: 28rpx;
  501. font-weight: 400;
  502. line-height: 48rpx;
  503. }
  504. .tips-text2 {
  505. color: #0256ff;
  506. font-size: 24rpx;
  507. font-weight: 400;
  508. display: flex;
  509. align-items: center;
  510. .radio-box {
  511. width: 32rpx;
  512. height: 32rpx;
  513. border-radius: 50%;
  514. border: 1px solid #d9d9d9;
  515. margin-right: 16rpx;
  516. }
  517. }
  518. .scan-box-l {
  519. width: 100%;
  520. display: flex;
  521. flex-direction: column;
  522. align-items: center;
  523. position: relative;
  524. &::after {
  525. content: "";
  526. display: block;
  527. width: 1px;
  528. height: 138rpx;
  529. background-color: #f4f4f4;
  530. position: absolute;
  531. top: 50%;
  532. right: 0;
  533. transform: translateY(-50%);
  534. }
  535. }
  536. .scan-box-r {
  537. width: 50%;
  538. display: flex;
  539. flex-direction: column;
  540. align-items: center;
  541. }
  542. }
  543. .cargo-list {
  544. padding: 24rpx 0;
  545. background-color: #fff;
  546. margin-top: 24rpx;
  547. border-radius: 16rpx;
  548. .cargo-list-title {
  549. font-family: "PingFang SC";
  550. font-size: 32rpx;
  551. font-style: normal;
  552. font-weight: bold;
  553. display: flex;
  554. align-items: center;
  555. position: relative;
  556. padding-left: 50rpx;
  557. &::after {
  558. content: "";
  559. display: block;
  560. width: 6rpx;
  561. height: 30rpx;
  562. border-radius: 100px;
  563. background: #0256ff;
  564. position: absolute;
  565. top: 50%;
  566. left: 24rpx;
  567. transform: translateY(-50%);
  568. }
  569. .cargo-list-title-tips {
  570. color: #0256ff;
  571. font-size: 24rpx;
  572. font-weight: 400;
  573. }
  574. }
  575. .num-box {
  576. display: flex;
  577. align-items: center;
  578. justify-content: space-between;
  579. padding: 0 48rpx 0 26rpx;
  580. .num-box-text {
  581. color: #666;
  582. font-family: "PingFang SC";
  583. font-size: 28rpx;
  584. font-weight: 400;
  585. }
  586. .input {
  587. width: 112rpx;
  588. text-align: center;
  589. border-bottom: 1px solid #0256ff;
  590. margin: 0 8rpx;
  591. }
  592. .minus {
  593. width: 40rpx;
  594. height: 40rpx;
  595. border-radius: 8rpx;
  596. border: 1px solid #0256ff;
  597. display: flex;
  598. align-items: center;
  599. justify-content: center;
  600. }
  601. .plus {
  602. width: 40rpx;
  603. height: 40rpx;
  604. border-radius: 8rpx;
  605. background-color: #0256ff;
  606. display: flex;
  607. align-items: center;
  608. justify-content: center;
  609. }
  610. }
  611. }
  612. }
  613. .footer-box {
  614. background-color: #fff;
  615. height: 126rpx;
  616. position: fixed;
  617. bottom: 0;
  618. left: 0;
  619. right: 0;
  620. display: flex;
  621. align-items: center;
  622. justify-content: space-between;
  623. padding: 0 40rpx 0 60rpx;
  624. .footer-box-l {
  625. color: #666;
  626. font-family: "PingFang SC";
  627. font-size: 28rpx;
  628. font-weight: 400;
  629. }
  630. .submitBtn {
  631. width: 362rpx;
  632. height: 76rpx;
  633. border-radius: 16rpx;
  634. background: #0256ff;
  635. color: #fff;
  636. font-size: 28rpx;
  637. font-weight: 500;
  638. margin: 0;
  639. }
  640. }
  641. }
  642. </style>