stocktaking.vue 17 KB

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