batch.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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" @click="rightClick">
  12. <uni-icons class="lanya" custom-prefix="iconfont" type="icon-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-form-item uni-column">
  20. <view class="uni-input-wrapper" style="margin: 5px auto;">
  21. <text class="uni-form-item__title">批次</text>
  22. <input class="uni-input" :value="query_code" @input="hideKeyboard" />
  23. </view>
  24. <view class="uni-input-wrapper table-title">
  25. <view class="tab-tr" style="width: 40%;">批次</view>
  26. <view class="tab-tr" style="width: 25%;font-size: 13px;">已入/待入(吨)</view>
  27. <view class="tab-tr" style="width: 20%;">状态</view>
  28. <view class="tab-tr-end" style="width: 15%;">操作</view>
  29. </view>
  30. <view style="min-height:335px;overflow-y:auto;max-height:335px">
  31. <view class="uni-input-wrapper table-data" v-for="(item,index) in tableData" :key="index">
  32. <view class="tab-tr"
  33. style="width: 40%;text-align: left;word-break: break-all;word-wrap: break-word;line-height: initial;">
  34. {{item.name}}
  35. </view>
  36. <view class="tab-tr" style="width: 25%; overflow-wrap: break-word; ">
  37. {{item.in_num}}/{{item.wait_num}}
  38. </view>
  39. <view class="tab-tr" style="width: 20%; overflow-wrap: break-word; ">{{item.default}}</view>
  40. <view class="tab-tr-end"
  41. style="width: 15%; overflow-wrap: break-word;color: #0039a6;font-size: 13px;"
  42. @click="SelectProduct(item)">设为默认</view>
  43. </view>
  44. </view>
  45. <view class="uni-input-wrapper button-sp-area">
  46. <button type="primary" plain="true" @click="batchGetNew()">添加</button>
  47. </view>
  48. </view>
  49. </view>
  50. <view>
  51. <!-- 提示窗示例 -->
  52. <uni-popup ref="alertDialog" type="dialog">
  53. <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="提示" :content="tips"
  54. @confirm="SelectConfirm" @close="dialogClose"></uni-popup-dialog>
  55. </uni-popup>
  56. </view>
  57. <!-- 引入自定义模态框 -->
  58. <custom-modal :visible="addBatchModalVisible">
  59. <!-- 模态框的内容 -->
  60. <view>
  61. <text>提示:创建新批次,会把上一批次待入库作废, 并把新批次设置为当前默认批次,请慎重操作</text>
  62. <view class="uni-input-wrapper" style="margin: 5px auto;">
  63. <text class="uni-form-item__title" style="width: 30%;">新批次号</text>
  64. <input class="uni-input" :value="newBatch" />
  65. </view>
  66. <br><br>
  67. <view>
  68. <button class="mini-btn" size="mini" @click="closeAddBatchModal"
  69. style="width: 50%;float: left;">关闭</button>
  70. <button class="mini-btn" type="primary" size="mini" @click="batchAdd"
  71. style="width: 50%;">确定</button>
  72. </view>
  73. </view>
  74. </custom-modal>
  75. </view>
  76. </template>
  77. <script>
  78. import CustomModal from "@/components/CustomModal/CustomModal.vue";
  79. const SpeechTTS = uni.requireNativePlugin('MT-TTS-Speech');
  80. const modal = uni.requireNativePlugin('modal');
  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. var reqRootUrl = plus.storage.getItem("reqRootUrl");
  94. const printModule = uni.requireNativePlugin('PrintModuleCPCL');
  95. export default {
  96. components: {
  97. CustomModal
  98. },
  99. data() {
  100. return {
  101. url: '',
  102. tableData: [],
  103. query_code: "",
  104. code: "",
  105. tips: "",
  106. addBatchModalVisible: false,
  107. newBatch: "",
  108. sn: "",
  109. name: ""
  110. }
  111. },
  112. methods: {
  113. leftClick: function() {
  114. setTimeout(() => {
  115. uni.navigateBack();
  116. // uni.redirectTo({
  117. // url: '/pages/sample/group',
  118. // })
  119. }, 30);
  120. // this.$emit('change', this.value)
  121. },
  122. onLoad() {
  123. this.platform = uni.getSystemInfoSync().platform
  124. // #ifdef APP-PLUS-NVUE
  125. this.isNvue = true
  126. // #endif
  127. _this = this;
  128. setTimeout(() => {
  129. this.getList();
  130. this.speak_init();
  131. }, 350);
  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. onShow() {
  147. uni.hideKeyboard();
  148. setTimeout(() => {
  149. // this.getList();
  150. }, 350);
  151. },
  152. SelectProduct(item) {
  153. this.code = item.code
  154. this.sn = item.sn
  155. this.name = item.name
  156. this.tips = "确定设置" + item.name + "为当前默认?";
  157. this.$refs.alertDialog.open()
  158. },
  159. dialogClose() {
  160. console.log('点击关闭')
  161. this.$refs.alertDialog.close()
  162. },
  163. SelectConfirm() {
  164. setTimeout(() => {
  165. setTimeout(() => {
  166. uni.request({
  167. url: reqRootUrl + '/wms/api',
  168. method: 'POST',
  169. headers: {
  170. 'Content-Type': 'application/json'
  171. },
  172. data: JSON.stringify({
  173. "method": "BatchUpdateDefault",
  174. "param": {
  175. [_this.sn]: {
  176. "default": true
  177. }
  178. }
  179. }),
  180. success: (ret) => {
  181. uni.setStorageSync("batch", _this.name)
  182. _this.getList()
  183. },
  184. fail: (err) => {
  185. // console.log('request fail', err);
  186. },
  187. complete: () => {
  188. // console.log('complete');
  189. }
  190. })
  191. }, 30);
  192. // 关闭窗口后,恢复默认内容
  193. this.$refs.alertDialog.close()
  194. }, 30)
  195. },
  196. rightClick: function() {
  197. setTimeout(() => {
  198. uni.navigateBack();
  199. // uni.navigateTo({
  200. // url: '/pages/sample/richAlert',
  201. // })
  202. }, 30);
  203. // this.$emit("rightClick")
  204. },
  205. containerAdd() {
  206. setTimeout(() => {
  207. uni.request({
  208. url: reqRootUrl + '/wms/api',
  209. method: 'POST',
  210. headers: {
  211. 'Content-Type': 'application/json'
  212. },
  213. data: JSON.stringify({
  214. "method": "ContainerAdd",
  215. "param": {
  216. "num": "1"
  217. }
  218. }),
  219. success: (ret) => {
  220. _this.getList()
  221. },
  222. fail: (err) => {
  223. // console.log('request fail', err);
  224. },
  225. complete: () => {
  226. // console.log('complete');
  227. }
  228. })
  229. }, 30);
  230. },
  231. printCode: function(code) {
  232. this.handlePrint(code)
  233. },
  234. hideKeyboard: function(event) {
  235. let Value = event.detail.value;
  236. Value.trim();
  237. this.query_code = Value;
  238. _this.ContainerQuery();
  239. },
  240. ContainerQuery() {
  241. if (this.query_code !== "" && this.query_code !== null && this.query_code !== undefined) {
  242. uni.request({
  243. url: reqRootUrl + '/wms/api',
  244. method: 'POST',
  245. headers: {
  246. 'Content-Type': 'application/json'
  247. },
  248. data: JSON.stringify({
  249. "method": "BatchQuery",
  250. "param": {
  251. "code": this.query_code,
  252. "model": "regex"
  253. }
  254. }),
  255. success: (ret) => {
  256. let rows = ret.data.data;
  257. if (!_this.isEmpty(rows)) {
  258. for (var i = 0; i < rows.length; i++) {
  259. let str = ""
  260. if (rows[i]["default"]) {
  261. str = "当前默认"
  262. }
  263. rows[i]["default"] = str;
  264. }
  265. }
  266. this.tableData = rows;
  267. },
  268. fail: (err) => {
  269. // console.log('request fail', err);
  270. },
  271. complete: () => {
  272. // console.log('complete');
  273. }
  274. })
  275. } else {
  276. _this.getList()
  277. }
  278. },
  279. getList() {
  280. uni.request({
  281. url: reqRootUrl + '/wms/api',
  282. method: 'POST',
  283. headers: {
  284. 'Content-Type': 'application/json'
  285. },
  286. data: JSON.stringify({
  287. "method": "BatchQuery",
  288. "param": {}
  289. }),
  290. success: (ret) => {
  291. let rows = ret.data.data;
  292. if (!_this.isEmpty(rows)) {
  293. for (var i = 0; i < rows.length; i++) {
  294. let str = ""
  295. if (rows[i]["default"]) {
  296. str = "当前默认"
  297. }
  298. rows[i]["default"] = str;
  299. }
  300. }
  301. this.tableData = rows;
  302. },
  303. fail: (err) => {
  304. // console.log('request fail', err);
  305. },
  306. complete: () => {
  307. // console.log('complete');
  308. }
  309. })
  310. },
  311. batchGetNew() {
  312. uni.request({
  313. url: reqRootUrl + '/wms/api',
  314. method: 'POST',
  315. headers: {
  316. 'Content-Type': 'application/json'
  317. },
  318. data: JSON.stringify({
  319. "method": "BatchGetNew",
  320. "param": {}
  321. }),
  322. success: (ret) => {
  323. if (ret.data.ret === "ok") {
  324. this.newBatch = ret.data.data
  325. this.addBatchModalVisible = true
  326. uni.setStorageSync("batch", _this.name)
  327. }
  328. },
  329. fail: (err) => {
  330. // console.log('request fail', err);
  331. },
  332. complete: () => {
  333. // console.log('complete');
  334. }
  335. })
  336. },
  337. closeAddBatchModal() {
  338. // 关闭模态框
  339. this.addBatchModalVisible = false;
  340. },
  341. batchAdd() {
  342. let batch = uni.getStorageSync("batch")
  343. console.log("AAA ", _this.newBatch, batch)
  344. // if (_this.newBatch === "" || _this.newBatch === batch) {
  345. // _this.alertInfo("添加失败,请填写新的批次号")
  346. // return;
  347. // }
  348. uni.request({
  349. url: reqRootUrl + '/wms/api',
  350. method: 'POST',
  351. headers: {
  352. 'Content-Type': 'application/json'
  353. },
  354. data: JSON.stringify({
  355. "method": "BatchAdd",
  356. "param": {
  357. "name": _this.newBatch,
  358. }
  359. }),
  360. success: (ret) => {
  361. if (ret.data.ret === "ok") {
  362. _this.batch = _this.newBatch;
  363. _this.newBatch = "";
  364. uni.setStorageSync("batch", _this.batch)
  365. _this.addBatchModalVisible = false
  366. _this.alertInfo("创建新批次成功!")
  367. _this.getList()
  368. }
  369. },
  370. fail: (err) => {
  371. // console.log('request fail', err);
  372. },
  373. complete: () => {
  374. // console.log('complete');
  375. }
  376. })
  377. // uni.setStorageSync(key, value)
  378. // uni.getStorageSync("batch")
  379. // uni.removeStorageSync(key)
  380. },
  381. // 打印机相关
  382. ...mapActions([SET_CONNECTBLEDATA]),
  383. // 连接打印机
  384. confirm_bluetooth(item) {
  385. // let {
  386. // name,
  387. // mac
  388. // } = item;
  389. uni.showLoading({
  390. title: "连接中...",
  391. mask: true
  392. })
  393. let mac = item.mac;
  394. try {
  395. printModule.connectionBT({
  396. 'address': mac
  397. }, result => {
  398. const msg = JSON.stringify(result);
  399. this.result = JSON.parse(msg).result;
  400. modal.toast({
  401. message: msg,
  402. duration: 6
  403. });
  404. uni.hideLoading()
  405. printModule.setDisConnectBTListener((ret) => {
  406. modal.toast({
  407. message: '蓝牙断开',
  408. duration: 6
  409. });
  410. })
  411. })
  412. } catch (e) {
  413. console.log(e)
  414. }
  415. },
  416. //搜索没匹配的蓝牙设备
  417. search_bluetooth(address) {
  418. let _this = this;
  419. //检查蓝牙是否开启
  420. this.$check_bluetooth_open().then(ores => {
  421. if (ores) {
  422. console.log(ores);
  423. //搜索蓝牙
  424. _this.$search_bluetooth().then(bres => {
  425. console.log(bres);
  426. if (bres.code) {
  427. _this.$search_pipei().then(pres => {
  428. console.log(pres);
  429. })
  430. }
  431. })
  432. }
  433. })
  434. },
  435. handlePrint(code) {
  436. printModule.printAreaSize({
  437. 'height': '400',
  438. 'number': '1'
  439. }, result => {})
  440. printModule.printBarCode({
  441. 'x_pos': '0',
  442. 'y_pos': '20',
  443. 'code_type': '128',
  444. 'ratio': '1',
  445. 'height': '250',
  446. 'width': '1',
  447. 'rotation': 'BARCODE',
  448. 'undertext': true,
  449. 'number': '4',
  450. 'offset': '5',
  451. "textAlign": "right",
  452. 'code_data': code
  453. });
  454. printModule.printForm()
  455. printModule.print()
  456. },
  457. closeBT() {
  458. printModule.closeBT();
  459. },
  460. isEmpty(obj) {
  461. return typeof obj === undefined || obj == null || obj === "" || obj === "000000000000000000000000" || obj
  462. .length === 0;
  463. },
  464. alertInfo(str) {
  465. SpeechTTS.speak({
  466. text: str,
  467. });
  468. modal.toast({
  469. message: str,
  470. duration: 6,
  471. });
  472. },
  473. },
  474. }
  475. </script>
  476. <style scoped>
  477. .nvue-page-root {
  478. background-color: #F8F8F8;
  479. padding-bottom: 0px;
  480. }
  481. .uni-form-item__title {
  482. margin: 5px auto;
  483. }
  484. .uni-input-wrapper {
  485. /* #ifndef APP-NVUE */
  486. display: flex;
  487. /* #endif */
  488. flex-direction: row;
  489. flex-wrap: nowrap;
  490. background-color: #FFFFFF;
  491. }
  492. .uni-input {
  493. height: 28px;
  494. line-height: 28px;
  495. font-size: 15px;
  496. padding: 1px;
  497. flex: 1;
  498. border-radius: 5px;
  499. border: 1px solid #cfdadd;
  500. background-color: #FFFFFF;
  501. }
  502. .mini-btn {
  503. height: 30px;
  504. padding-left: 1px;
  505. padding-right: 1px;
  506. }
  507. .uni-eye-active {
  508. color: #007AFF;
  509. }
  510. .table-title {
  511. background-color: aliceblue;
  512. font-weight: 700;
  513. margin-top: 10px;
  514. height: 40px;
  515. }
  516. .table-data {
  517. background-color: aliceblue;
  518. font-weight: 700;
  519. margin-top: 1px;
  520. height: 40px;
  521. }
  522. .tab-tr {
  523. width: 25%;
  524. height: 50px;
  525. line-height: 25px;
  526. border-right: 1px solid #ccc;
  527. margin: auto;
  528. text-align: center;
  529. }
  530. .tab-tr-end {
  531. width: 25%;
  532. height: 50px;
  533. line-height: 25px;
  534. border-right: 0px solid #ccc;
  535. margin: auto;
  536. text-align: center;
  537. }
  538. </style>
  539. <style lang="scss">
  540. $color-base: #0039a6;
  541. $words-color-base: #333333;
  542. $words-color-light: #999999;
  543. .header-wrap {
  544. width: 100%;
  545. position: fixed;
  546. top: 0;
  547. z-index: 999;
  548. .index-header {
  549. height: 88upx;
  550. line-height: 88upx;
  551. padding: 0 30upx;
  552. padding-top: 40upx;
  553. background-color: $color-base;
  554. font-Size: 28upx;
  555. color: #fff;
  556. display: flex;
  557. align-items: center;
  558. justify-content: space-between;
  559. .fanhui {
  560. color: #fff !important;
  561. font-size: 28px;
  562. padding-top: 5px;
  563. font-weight: 700;
  564. }
  565. .lanya {
  566. color: #fff !important;
  567. font-size: 28px;
  568. padding-top: 5px;
  569. }
  570. .map-wrap {
  571. padding-top: 5px;
  572. }
  573. }
  574. }
  575. .blank {
  576. height: 126upx;
  577. }
  578. </style>