stocktaking.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. <template>
  2. <view class="nvue-page-root">
  3. <view class="head">
  4. <view class="header-wrap">
  5. <view class="index-header">
  6. <uni-icons class="fanhui" custom-prefix="iconfont" type="icon-fanhui"
  7. @click="leftClick"></uni-icons>
  8. <view class="input-wrap">
  9. <text class="iconfont">出库确认</text>
  10. </view>
  11. <view class="map-wrap">
  12. <uni-icons class="lanya"></uni-icons>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="blank"></view>
  17. </view>
  18. <view class="uni-common-mt" style="padding: 5px;">
  19. <view class="uni-input-wrapper" style="margin: 5px auto;">
  20. <input class="uni-input" auto-focus="true" :focus="firstFocus" placeholder="请扫描托盘码" v-model="viewText"
  21. @input="hideKeyboard" style="font-weight: bold;" />
  22. </view>
  23. <view class="uni-form-item uni-column">
  24. <view class="uni-input-wrapper" style="margin: 5px auto;">
  25. <text class="uni-form-item__title" style="width: 25%;">托盘码</text>
  26. <input class="uni-input" :value="container_code" disabled="true" />
  27. </view>
  28. <view class="uni-input-wrapper" style="margin: 5px auto;">
  29. <text class="uni-form-item__title" style="width: 25%;">入库口</text>
  30. <select-lay style="width: 75%;" :zindex="2" :value="port_sn" name="port_sn" placeholder="请选择入库口"
  31. :options="portList" @selectitem="selectPort">
  32. </select-lay>
  33. </view>
  34. <!-- <view class="uni-padding-wrap uni-common-mt">
  35. <button type="primary" @click="SelectProduct()">选择货物</button>
  36. </view> -->
  37. <view style="min-height:355px;overflow-y:auto;max-height:355px">
  38. <view class="cart-list">
  39. <!-- 滑动操作分区 -->
  40. <uni-swipe-action>
  41. <!-- 滑动操作项 -->
  42. <uni-swipe-action-item v-for="(item,index) in tableData" :key="index" class="cart-swipe">
  43. <!-- 商品信息 -->
  44. <view class="goods" style="border:1px solid #ccc">
  45. <view class="meta" style="padding-bottom:15px;">
  46. <view class="name">
  47. 货物名称:{{item.name}} 型号:{{item.model}} 品牌:{{item.brand}}
  48. 数量:{{item.detail_num}}{{item.unit}}
  49. </view>
  50. <br>
  51. </view>
  52. <!-- 商品数量 -->
  53. <view class="numGroup">
  54. <button type="primary" @click="Correct(item)">正确</button>
  55. <button type="primary" @click="Wrong(item)"
  56. style="margin-left: 5px;">错误</button>
  57. </view>
  58. </view>
  59. </uni-swipe-action-item>
  60. </uni-swipe-action>
  61. </view>
  62. </view>
  63. <view class="uni-input-wrapper button-sp-area" style="padding-bottom:5px;">
  64. <button type="primary" plain="true" @click="ReturnWarehouse()" :disabled="BtnDisabled">回库</button>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 单个出库提示窗示例 -->
  69. <uni-popup ref="outStoreDialog" type="dialog">
  70. <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="提示" :content="out_tips"
  71. @confirm="outStoreConfirm" @close="dialogClose"></uni-popup-dialog>
  72. </uni-popup>
  73. <!-- 回库提示窗示例 -->
  74. <uni-popup ref="groupDialogeturn" type="dialog">
  75. <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="提示" content="所需货物已盘点完成,确定回库?"
  76. @confirm="dialogReturnWarehouse" @close="dialogClose"></uni-popup-dialog>
  77. </uni-popup>
  78. <!-- 输入框示例 -->
  79. <uni-popup ref="inputDialog" type="dialog">
  80. <uni-popup-dialog ref="inputClose" mode="input" title="实物数量" value="" placeholder="请填写实物数量"
  81. @confirm="UpdateNum"></uni-popup-dialog>
  82. </uni-popup>
  83. </view>
  84. </template>
  85. <script>
  86. import CustomModal from "@/components/CustomModal/CustomModal.vue";
  87. let _this = null;
  88. import {
  89. mapGetters,
  90. mapActions
  91. } from 'vuex';
  92. import {
  93. GET_INFODATA,
  94. GET_CONNECTBLEDATA
  95. } from "@/store/gettersType.js";
  96. import {
  97. SET_CONNECTBLEDATA
  98. } from '@/store/actionsType.js';
  99. // #ifdef APP-PLUS
  100. const modal = uni.requireNativePlugin('modal');
  101. // #endif
  102. var reqRootUrl = plus.storage.getItem("reqRootUrl");
  103. var ParamreqRootUrl = reqRootUrl + "/wms/api";
  104. const SpeechTTS = uni.requireNativePlugin('MT-TTS-Speech');
  105. export default {
  106. components: {
  107. CustomModal
  108. },
  109. data() {
  110. return {
  111. container_code: "",
  112. out_tips: "",
  113. sn: "",
  114. firstFocus: false,
  115. viewText: "",
  116. tableData: [],
  117. BtnDisabled: false,
  118. title: "",
  119. port_sn: "",
  120. portList: [],
  121. warehouse_id: "",
  122. outNum: "",
  123. store_num: 0,
  124. }
  125. },
  126. computed: {
  127. ...mapGetters([GET_INFODATA, GET_CONNECTBLEDATA]),
  128. },
  129. methods: {
  130. onUnload() {
  131. SpeechTTS.destroy();
  132. },
  133. speak_init() {
  134. // console.log('>> TTS:init...')
  135. SpeechTTS.init((callback) => {
  136. // SpeechTTS.setEngine("com.iflytek.speechcloud"); // 设置引擎
  137. SpeechTTS.setEngine("com.google.android.tts"); // 设置引擎
  138. // console.log('>> tts: init success');
  139. SpeechTTS.setPitch(50); // 设置语调 setPitch(num) 0-100, 默认 50
  140. SpeechTTS.setSpeed(65); // 设置语速 setSpeed(num) 0-100, 默认 50
  141. });
  142. SpeechTTS.onDone((res) => {
  143. // console.log(">> tts: play end " + res)
  144. });
  145. },
  146. leftClick: function() {
  147. setTimeout(() => {
  148. uni.navigateBack();
  149. // uni.redirectTo({
  150. // url: '/pages/sample/main',
  151. // })
  152. }, 30);
  153. // this.$emit('change', this.value)
  154. },
  155. rightClick: function() {
  156. setTimeout(() => {
  157. uni.navigateTo({
  158. url: '/pages/sample/richAlert',
  159. })
  160. }, 30);
  161. // this.$emit("rightClick")
  162. },
  163. onLoad() {
  164. _this = this;
  165. _this.firstFocus = true;
  166. },
  167. onShow() {
  168. uni.hideKeyboard();
  169. setTimeout(() => {
  170. this.getUserInfoWareHouse();
  171. }, 300);
  172. setTimeout(() => {
  173. _this.firstFocus = true;
  174. this.getList();
  175. this.speak_init();
  176. this.CateGet();
  177. }, 500);
  178. },
  179. CateGet() {
  180. let warehouse_id = uni.getStorageSync("warehouse_id");
  181. _this.warehouse_id = warehouse_id;
  182. uni.request({
  183. url: ParamreqRootUrl + '/PortQuery',
  184. method: 'POST',
  185. headers: {
  186. 'Content-Type': 'application/json'
  187. },
  188. data: JSON.stringify({
  189. "warehouse_id": _this.warehouse_id,
  190. }),
  191. success: (ret) => {
  192. // console.log("ret", ret)
  193. if (ret.statusCode === 200) {
  194. this.portList = [];
  195. let rows = ret.data;
  196. // console.log("rows", rows[0]["addr"]["f"])
  197. for (var i = 0; i < rows.length; i++) {
  198. let lab = rows[i]["addr"]["f"] + "-" + rows[i]["addr"]["c"] +
  199. "-" + rows[i]["addr"]["r"]
  200. this.portList.push({
  201. label: lab,
  202. value: JSON.stringify(rows[i]["addr"])
  203. })
  204. }
  205. }
  206. },
  207. fail: (err) => {
  208. // console.log('request fail', err);
  209. },
  210. complete: () => {
  211. // console.log('complete');
  212. }
  213. })
  214. },
  215. selectPort(index, item) {
  216. if (index >= 0) {
  217. _this.port_sn = item.value;
  218. } else {
  219. _this.port_sn = ""
  220. }
  221. },
  222. hideKeyboard: function(event) {
  223. uni.hideKeyboard();
  224. let Value = event.detail.value;
  225. Value = Value.trim();
  226. _this.firstFocus = false;
  227. if (Value !== "" && Value !== null && Value !== undefined) {
  228. uni.request({
  229. url: ParamreqRootUrl + '/StocktakingGetByCode',
  230. method: 'POST',
  231. headers: {
  232. 'Content-Type': 'application/json'
  233. },
  234. data: JSON.stringify({
  235. "container_code": Value,
  236. }),
  237. success: (ret) => {
  238. console.log("ret ", ret)
  239. //处理成功逻辑
  240. if (ret.statusCode === 200) {
  241. let data = ret.data.data;
  242. _this.tableData = data;
  243. // 扫描到的码是托盘码
  244. // 用扫描到的码查询 组盘表托盘管理表
  245. // 优先显示查询到的组盘表的数据
  246. _this.alertInfo("扫码成功!")
  247. _this.BtnDisabled = false
  248. _this.container_code = Value;
  249. uni.setStorageSync("container_code", Value)
  250. _this.$nextTick(() => {
  251. _this.firstFocus = true;
  252. _this.viewText = "";
  253. })
  254. } else {
  255. _this.alertInfo("托盘码错误,请重新扫描!")
  256. // _this.getSn();
  257. _this.tableData = [];
  258. _this.$nextTick(() => {
  259. _this.firstFocus = true;
  260. _this.viewText = "";
  261. _this.container_code = "";
  262. uni.setStorageSync("container_code", "")
  263. })
  264. _this.$forceUpdate()
  265. }
  266. },
  267. fail: (err) => {
  268. // console.log('request fail', err);
  269. },
  270. complete: () => {
  271. // console.log('complete');
  272. }
  273. })
  274. }
  275. },
  276. Wrong(item) {
  277. _this.store_num = item["detail_num"]
  278. _this.sn = item["sn"]
  279. this.$refs.inputDialog.open()
  280. },
  281. UpdateNum(val) {
  282. setTimeout(() => {
  283. uni.hideLoading()
  284. if (parseFloat(val) < 0 || parseFloat(val) > parseFloat(_this.store_num)) {
  285. _this.alertInfo("请输入正确的数量!");
  286. return
  287. }
  288. uni.request({
  289. url: reqRootUrl + '/wms/api',
  290. method: 'POST',
  291. headers: {
  292. 'Content-Type': 'application/json'
  293. },
  294. data: JSON.stringify({
  295. "method": "StocktakingUpdate",
  296. "param": {
  297. "sn": _this.sn,
  298. "result": "错误",
  299. "stocktaking_num": parseFloat(val),
  300. "status": "status_yes",
  301. }
  302. }),
  303. success: (ret) => {
  304. this.$refs.inputDialog.close();
  305. _this.alertInfo("操作成功!");
  306. _this.sn = "";
  307. _this.store_num = 0;
  308. _this.getList();
  309. //处理成功逻辑
  310. },
  311. fail: (err) => {
  312. // console.log('request fail', err);
  313. },
  314. complete: () => {
  315. // console.log('complete');
  316. }
  317. })
  318. // 关闭窗口后,恢复默认内容
  319. this.$refs.inputDialog.close()
  320. }, 30)
  321. },
  322. Correct(item) {
  323. _this.sn = item["sn"]
  324. _this.outNum = item["detail_num"]
  325. this.out_tips = "数量确定正确?";
  326. this.$refs.outStoreDialog.open()
  327. },
  328. outStoreConfirm() {
  329. setTimeout(() => {
  330. uni.hideLoading()
  331. uni.request({
  332. url: ParamreqRootUrl + '/StocktakingUpdate',
  333. method: 'POST',
  334. headers: {
  335. 'Content-Type': 'application/json'
  336. },
  337. data: JSON.stringify({
  338. "sn": _this.sn,
  339. "result": "正确",
  340. "stocktaking_num": parseFloat(_this.outNum),
  341. "status": "status_yes",
  342. }),
  343. success: (ret) => {
  344. this.$refs.outStoreDialog.close();
  345. _this.alertInfo("操作成功!");
  346. _this.out_tips = "";
  347. _this.sn = "";
  348. _this.outNum = 0;
  349. _this.getList();
  350. //处理成功逻辑
  351. },
  352. fail: (err) => {
  353. // console.log('request fail', err);
  354. },
  355. complete: () => {
  356. // console.log('complete');
  357. }
  358. })
  359. }, 30)
  360. },
  361. dialogClose() {
  362. _this.getList();
  363. },
  364. getList() {
  365. _this.$forceUpdate()
  366. _this.tableData = [];
  367. if (_this.container_code === "") {
  368. return
  369. }
  370. uni.request({
  371. url: ParamreqRootUrl + '/StocktakingGetByCode',
  372. method: 'POST',
  373. headers: {
  374. 'Content-Type': 'application/json'
  375. },
  376. data: JSON.stringify({
  377. "container_code": _this.container_code,
  378. }),
  379. success: (ret) => {
  380. //处理成功逻辑
  381. if (ret.statusCode === 200) {
  382. let data = ret.data.data;
  383. _this.tableData = data;
  384. _this.BtnDisabled = false
  385. }
  386. },
  387. fail: (err) => {
  388. // console.log('request fail', err);
  389. },
  390. complete: () => {
  391. // console.log('complete');
  392. }
  393. })
  394. },
  395. ReturnWarehouse: function() {
  396. _this.firstFocus = false;
  397. setTimeout(() => {
  398. this.$refs.groupDialogeturn.open()
  399. }, 30)
  400. },
  401. dialogReturnWarehouse() {
  402. if (_this.isEmpty(_this.port_sn)) {
  403. _this.alertInfo("操作失败!请选择入库口")
  404. return
  405. }
  406. setTimeout(() => {
  407. uni.hideLoading()
  408. uni.request({
  409. url: ParamreqRootUrl + '/ReturnWarehouse',
  410. method: 'POST',
  411. headers: {
  412. 'Content-Type': 'application/json'
  413. },
  414. data: JSON.stringify({
  415. "warehouse_id": _this.warehouse_id,
  416. "srcAddr": JSON.parse(_this.port_sn),
  417. "container_code": _this.container_code,
  418. }),
  419. success: (ret) => {
  420. if (ret.statusCode === 200) {
  421. this.$refs.outStoreDialog.close();
  422. _this.alertInfo("回库操作成功!");
  423. _this.out_tips = "";
  424. _this.sn = "";
  425. _this.port_sn = "";
  426. _this.container_code = "";
  427. uni.setStorageSync("container_code", "")
  428. }
  429. _this.getList();
  430. //处理成功逻辑
  431. },
  432. fail: (err) => {
  433. // console.log('request fail', err);
  434. },
  435. complete: () => {
  436. // console.log('complete');
  437. }
  438. })
  439. }, 30)
  440. },
  441. getUserInfoWareHouse() {
  442. uni.request({
  443. url: ParamreqRootUrl + '/getUserInfoWareHouse',
  444. method: 'POST',
  445. async: false,
  446. success: (ret) => {
  447. _this.warehouse_id = ret.data;
  448. uni.setStorageSync("warehouse_id", ret.data)
  449. },
  450. fail: (err) => {
  451. // console.log('request fail', err);
  452. },
  453. complete: () => {
  454. // console.log('complete');
  455. }
  456. })
  457. },
  458. isEmpty: function(obj) {
  459. return typeof obj === undefined || obj == null || obj === "" || obj ===
  460. "000000000000000000000000" ||
  461. obj.length === 0;
  462. },
  463. alertInfo(str) {
  464. SpeechTTS.speak({
  465. text: str,
  466. });
  467. modal.toast({
  468. message: str,
  469. duration: 6,
  470. });
  471. },
  472. onNavigationBarButtonTap: function(e) {
  473. setTimeout(() => {
  474. uni.navigateTo({
  475. url: '/pages/sample/richAlert',
  476. })
  477. }, 500);
  478. },
  479. getSn() {
  480. // return;
  481. let today = new Date();
  482. let year = today.getFullYear();
  483. let month = today.getMonth() + 1;
  484. let date = today.getDate();
  485. let hours = today.getHours();
  486. let minutes = today.getMinutes();
  487. let seconds = today.getSeconds();
  488. let millisecond = today.getMilliseconds()
  489. if (month <= 9) {
  490. month = '0' + month
  491. }
  492. if (minutes <= 9) {
  493. minutes = '0' + minutes;
  494. }
  495. if (date <= 9) {
  496. date = '0' + date;
  497. }
  498. if (seconds <= 9) {
  499. seconds = '0' + seconds;
  500. }
  501. let sn = year + '' + month + '' + date + '' + hours + '' + minutes + '' + seconds + '' + millisecond
  502. uni.removeStorageSync('port_sn');
  503. return sn
  504. },
  505. formattedDate(d) {
  506. const date = new Date(d);
  507. const year = date.getFullYear();
  508. const month = String(date.getMonth() + 1).padStart(2, '0');
  509. const day = String(date.getDate()).padStart(2, '0');
  510. const hours = String(date.getHours()).padStart(2, '0');
  511. const minutes = String(date.getMinutes()).padStart(2, '0');
  512. const seconds = String(date.getSeconds()).padStart(2, '0');
  513. return `${year}-${month}-${day}`;
  514. },
  515. },
  516. }
  517. </script>
  518. <style scoped>
  519. .nvue-page-root {
  520. background-color: #F8F8F8;
  521. padding-bottom: 0px;
  522. }
  523. .uni-form-item__title {
  524. margin: 5px auto;
  525. }
  526. .uni-input-wrapper {
  527. /* #ifndef APP-NVUE */
  528. display: flex;
  529. /* #endif */
  530. flex-direction: row;
  531. flex-wrap: nowrap;
  532. background-color: #FFFFFF;
  533. }
  534. .uni-input {
  535. height: 28px;
  536. line-height: 28px;
  537. font-size: 15px;
  538. padding: 1px;
  539. flex: 1;
  540. border-radius: 5px;
  541. border: 1px solid #cfdadd;
  542. background-color: #FFFFFF;
  543. }
  544. .mini-btn {
  545. height: 30px;
  546. padding-left: 1px;
  547. padding-right: 1px;
  548. }
  549. .uni-eye-active {
  550. color: #007AFF;
  551. }
  552. .table-title {
  553. background-color: aliceblue;
  554. font-weight: 700;
  555. margin-top: 10px;
  556. height: 40px;
  557. }
  558. .table-data {
  559. background-color: aliceblue;
  560. font-weight: 700;
  561. margin-top: 1px;
  562. height: 40px;
  563. }
  564. .tab-tr {
  565. width: 25%;
  566. line-height: 50px;
  567. border-right: 1px solid #ccc;
  568. margin: auto;
  569. text-align: center;
  570. }
  571. .tab-tr-end {
  572. width: 25%;
  573. line-height: 50px;
  574. border-right: 0px solid #ccc;
  575. margin: auto;
  576. text-align: center;
  577. }
  578. </style>
  579. <style lang="scss">
  580. $color-base: #0039a6;
  581. $words-color-base: #333333;
  582. $words-color-light: #999999;
  583. .header-wrap {
  584. width: 100%;
  585. position: fixed;
  586. top: 0;
  587. z-index: 999;
  588. .index-header {
  589. height: 88upx;
  590. line-height: 88upx;
  591. padding: 0 30upx;
  592. padding-top: 40upx;
  593. background-color: $color-base;
  594. font-Size: 28upx;
  595. color: #fff;
  596. display: flex;
  597. align-items: center;
  598. justify-content: space-between;
  599. .fanhui {
  600. color: #fff !important;
  601. font-size: 28px;
  602. padding-top: 5px;
  603. font-weight: 700;
  604. }
  605. .lanya {
  606. color: #fff !important;
  607. font-size: 28px;
  608. padding-top: 5px;
  609. }
  610. .map-wrap {
  611. padding-top: 5px;
  612. }
  613. }
  614. }
  615. .blank {
  616. height: 126upx;
  617. }
  618. // 购物车列表
  619. .cart-list {
  620. padding: 0 5rpx;
  621. // 购物车商品
  622. .goods {
  623. display: flex;
  624. padding: 5rpx;
  625. border-radius: 10rpx;
  626. background-color: #fff;
  627. position: relative;
  628. .meta {
  629. // border:1px solid red;
  630. flex: 1;
  631. display: flex;
  632. flex-direction: column;
  633. justify-content: space-between;
  634. margin-left: 5rpx;
  635. }
  636. .name {
  637. height: auto;
  638. font-size: 18px;
  639. color: #000000;
  640. }
  641. // 商品数量
  642. .numGroup {
  643. // border: 1px solid green;
  644. position: absolute;
  645. bottom: 40rpx;
  646. right: 5rpx;
  647. display: flex;
  648. justify-content: space-between;
  649. align-items: center;
  650. // width: 100px;
  651. height: 30rpx;
  652. .text_1 {
  653. // border: 1px solid red;
  654. width: 50px;
  655. height: 100%;
  656. padding: 0 5rpx;
  657. font-size: 15px;
  658. color: #444;
  659. }
  660. .text {
  661. height: 100%;
  662. padding: 0 5rpx;
  663. font-size: 32rpx;
  664. color: #444;
  665. }
  666. }
  667. }
  668. .cart-swipe {
  669. display: block;
  670. margin: 20rpx 0;
  671. }
  672. }
  673. </style>