group.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  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-input-wrapper" style="margin: 5px auto;">
  20. <input class="uni-input" auto-focus="true" :focus="firstFocus" placeholder="请扫描托盘码或产品码"
  21. v-model="viewText" @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-padding-wrap uni-common-mt">
  29. <button type="primary" @click="SelectProduct()">选择货物</button>
  30. </view>
  31. <view style="min-height:255px;overflow-y:auto;max-height:255px">
  32. <view class="cart-list">
  33. <!-- 滑动操作分区 -->
  34. <uni-swipe-action>
  35. <!-- 滑动操作项 -->
  36. <uni-swipe-action-item v-for="(item,index) in tableData" :key="index" class="cart-swipe">
  37. <!-- 商品信息 -->
  38. <view class="goods" style="border:1px solid #ccc">
  39. <view class="meta" style="padding-bottom:15px;" @click="Delete(item)">
  40. <view class="name">{{item.product_name}}</view>
  41. <view class="status_view">{{item.status_view}}</view>
  42. </view>·
  43. <!-- 商品数量 -->
  44. <view class="weightGroup" @click="Update(item)">
  45. <text class="text_1">重量</text>
  46. <text class="inputs">{{item.weight}}</text>
  47. <text class="text">Kg</text>
  48. </view>
  49. <!-- 商品数量 -->
  50. <view class="numGroup" @click="Update(item)">
  51. <text class="text_1">数量</text>
  52. <text class="inputs">{{item.num}}</text>
  53. <text class="text">个</text>
  54. </view>
  55. </view>
  56. </uni-swipe-action-item>
  57. </uni-swipe-action>
  58. </view>
  59. </view>
  60. <view class="uni-input-wrapper button-sp-area">
  61. <button type="primary" plain="true" @click="groupDisk()" :disabled="BtnDisabled">组盘</button>
  62. <button type="primary" plain="true" @click="in_stock()">入库单</button>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 提示窗示例 -->
  67. <uni-popup ref="deleteDialog" type="dialog">
  68. <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="提示" :content="del_tips"
  69. @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
  70. </uni-popup>
  71. <!-- 提示窗示例 -->
  72. <uni-popup ref="groupDialog" type="dialog">
  73. <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="提示" content="确定组盘?"
  74. @confirm="dialogGroup" @close="dialogClose"></uni-popup-dialog>
  75. </uni-popup>
  76. <!-- 引入自定义模态框 -->
  77. <custom-modal :visible="addModalVisible">
  78. <!-- 模态框的内容 -->
  79. <view>
  80. <text>提示</text>
  81. <view class="uni-input-wrapper" style="margin: 5px auto;">
  82. <text class="uni-form-item__title" style="width: 30%;">货物名称</text>
  83. <input class="uni-input" :value="product_name" disabled="true" />
  84. </view>
  85. <view class="uni-input-wrapper" style="margin: 5px auto;">
  86. <text class="uni-form-item__title" style="width: 30%;">数量</text>
  87. <input type="number" class="uni-input" :value="product_num" @input="numChange" />
  88. </view>
  89. <view class="uni-input-wrapper" style="margin: 5px auto;">
  90. <text class="uni-form-item__title" style="width: 30%;">重量</text>
  91. <input type="number" class="uni-input" :value="product_weight" @input="weightChange" />
  92. </view>
  93. <view>
  94. <text style="width: 30%;float: left;height: 35px;line-height: 35px;">生产日期</text>
  95. <picker style="width: 70%;float: right;" mode="date" :value="plandate" :start="startDate"
  96. :end="endDate" @change="plandateChange">
  97. <view class="uni-input">{{plandate}}</view>
  98. </picker>
  99. </view>
  100. <br><br>
  101. <view>
  102. <button class="mini-btn" size="mini" @click="closeAddModal"
  103. style="width: 50%;float: left;">关闭</button>
  104. <button class="mini-btn" type="primary" size="mini" @click="SelectConfirm"
  105. style="width: 50%;">添加</button>
  106. </view>
  107. </view>
  108. </custom-modal>
  109. <!-- 引入自定义模态框 -->
  110. <custom-modal :visible="updateModalVisible">
  111. <!-- 模态框的内容 -->
  112. <view>
  113. <text>提示</text>
  114. <view class="uni-input-wrapper" style="margin: 5px auto;">
  115. <text class="uni-form-item__title" style="width: 30%;">货物名称</text>
  116. <input class="uni-input" :value="product_name" disabled="true" />
  117. </view>
  118. <view class="uni-input-wrapper" style="margin: 5px auto;">
  119. <text class="uni-form-item__title" style="width: 30%;">数量</text>
  120. <input type="number" class="uni-input" :value="product_num" @input="numChange" />
  121. </view>
  122. <view class="uni-input-wrapper" style="margin: 5px auto;">
  123. <text class="uni-form-item__title" style="width: 30%;">重量</text>
  124. <input type="number" class="uni-input" :value="product_weight" @input="weightChange" />
  125. </view>
  126. <view>
  127. <text style="width: 30%;float: left;height: 35px;line-height: 35px;">生产日期</text>
  128. <picker style="width: 70%;float: right;" mode="date" :value="plandate" :start="startDate"
  129. :end="endDate" @change="plandateChange">
  130. <view class="uni-input">{{plandate}}</view>
  131. </picker>
  132. </view>
  133. <br><br>
  134. <view>
  135. <button class="mini-btn" size="mini" @click="closeUpdateModal"
  136. style="width: 50%;float: left;">关闭</button>
  137. <button class="mini-btn" type="primary" size="mini" @click="UpdateWeight"
  138. style="width: 50%;">修改</button>
  139. </view>
  140. </view>
  141. </custom-modal>
  142. </view>
  143. </template>
  144. <script>
  145. import CustomModal from "@/components/CustomModal/CustomModal.vue";
  146. let _this = null;
  147. import {
  148. mapGetters,
  149. mapActions
  150. } from 'vuex';
  151. import {
  152. GET_INFODATA,
  153. GET_CONNECTBLEDATA
  154. } from "@/store/gettersType.js";
  155. import {
  156. SET_CONNECTBLEDATA
  157. } from '@/store/actionsType.js';
  158. // #ifdef APP-PLUS
  159. const modal = uni.requireNativePlugin('modal');
  160. const printModule = uni.requireNativePlugin('PrintModuleCPCL');
  161. // #endif
  162. let print;
  163. var reqRootUrl = plus.storage.getItem("reqRootUrl");
  164. let rData = [];
  165. const SpeechTTS = uni.requireNativePlugin('MT-TTS-Speech');
  166. export default {
  167. components: {
  168. CustomModal
  169. },
  170. data() {
  171. const currentDate = this.getDate({
  172. format: true
  173. });
  174. return {
  175. container_code: "",
  176. product_code: "",
  177. product_name: "",
  178. product_weight: "",
  179. product_num: "",
  180. del_tips: "",
  181. sn: "",
  182. addModalVisible: false,
  183. updateModalVisible: false,
  184. item: {
  185. name: "HM",
  186. mac: "60:6E:41:C3:C8:8C",
  187. },
  188. result: -1,
  189. firstFocus: false,
  190. viewText: "",
  191. tableData: [],
  192. plandate: currentDate,
  193. BtnDisabled: false,
  194. }
  195. },
  196. computed: {
  197. ...mapGetters([GET_INFODATA, GET_CONNECTBLEDATA]),
  198. startDate() {
  199. return this.getDate('start');
  200. },
  201. endDate() {
  202. return this.getDate('end');
  203. },
  204. },
  205. methods: {
  206. onUnload() {
  207. SpeechTTS.destroy();
  208. },
  209. speak_init() {
  210. // console.log('>> TTS:init...')
  211. SpeechTTS.init((callback) => {
  212. // SpeechTTS.setEngine("com.iflytek.speechcloud"); // 设置引擎
  213. SpeechTTS.setEngine("com.google.android.tts"); // 设置引擎
  214. // console.log('>> tts: init success');
  215. SpeechTTS.setPitch(50); // 设置语调 setPitch(num) 0-100, 默认 50
  216. SpeechTTS.setSpeed(65); // 设置语速 setSpeed(num) 0-100, 默认 50
  217. });
  218. SpeechTTS.onDone((res) => {
  219. // console.log(">> tts: play end " + res)
  220. });
  221. },
  222. leftClick: function() {
  223. setTimeout(() => {
  224. uni.navigateBack();
  225. // uni.redirectTo({
  226. // url: '/pages/sample/main',
  227. // })
  228. }, 30);
  229. // this.$emit('change', this.value)
  230. },
  231. rightClick: function() {
  232. setTimeout(() => {
  233. uni.navigateTo({
  234. url: '/pages/sample/richAlert',
  235. })
  236. }, 30);
  237. // this.$emit("rightClick")
  238. },
  239. onLoad() {
  240. _this = this;
  241. _this.firstFocus = true;
  242. _this.getSn()
  243. // 打印相关
  244. /*
  245. setTimeout(() => {
  246. this.$init_bluetooth();
  247. }, 500);
  248. if (this.result !== 0) {
  249. this.closeBT()
  250. setTimeout(() => {
  251. let item = {
  252. name: "HM-A300-E093",
  253. mac: "60:6E:41:34:E0:93",
  254. };
  255. this.confirm_bluetooth(item)
  256. }, 1500);
  257. } else {
  258. // console.log("scssssss")
  259. }
  260. */
  261. },
  262. onShow() {
  263. uni.hideKeyboard();
  264. setTimeout(() => {
  265. _this.firstFocus = true;
  266. this.getList();
  267. this.speak_init();
  268. }, 500);
  269. },
  270. SelectProduct() {
  271. if (_this.tableData.length > 0) {
  272. _this.alertInfo("只能添加一种货物!")
  273. return
  274. }
  275. setTimeout(() => {
  276. _this.firstFocus = false;
  277. uni.navigateTo({
  278. url: '/pages/sample/select_product',
  279. })
  280. }, 30);
  281. },
  282. hideKeyboard: function(event) {
  283. uni.hideKeyboard();
  284. let Value = event.detail.value;
  285. Value.trim();
  286. _this.firstFocus = false;
  287. if (Value !== "" && Value !== null && Value !== undefined) {
  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": "CodeGet",
  296. "param": {
  297. "code": Value,
  298. }
  299. }),
  300. success: (ret) => {
  301. let rows = ret.data.data;
  302. if (_this.isEmpty(rows)) {
  303. _this.alertInfo("托盘码错误,请重新扫描!")
  304. _this.getSn();
  305. _this.rData = [];
  306. _this.tableData = [];
  307. _this.$nextTick(() => {
  308. _this.firstFocus = true;
  309. _this.viewText = "";
  310. _this.container_code = "";
  311. uni.setStorageSync("container_code", "")
  312. })
  313. _this.$forceUpdate()
  314. return
  315. }
  316. // 扫描到的码可能是入库单号(物料码)、产品码、托盘码
  317. // 用扫描到的码查询 组盘表、产品管理表、托盘管理表
  318. // 优先显示查询到的组盘表的数据
  319. _this.alertInfo("扫码成功!")
  320. _this.BtnDisabled = false
  321. if (!_this.isEmpty(rows["group_disk"])) {
  322. console.log("1", Value)
  323. let disk = [];
  324. for (var i = 0; i < rows["group_disk"].length; i++) {
  325. if (rows["group_disk"][i]["status"] === "status_wait") {
  326. rows["group_disk"][i]["status_view"] = "待组盘"
  327. }
  328. if (rows["group_disk"][i]["status"] === "status_yes") {
  329. _this.BtnDisabled = true
  330. rows["group_disk"][i]["status_view"] = "已组盘"
  331. }
  332. disk.push(rows["group_disk"][i])
  333. }
  334. rData = disk;
  335. if (rData.length > 0) {
  336. _this.product_name = rData[0]["product_name"];
  337. _this.product_code = rData[0]["product_code"];
  338. _this.container_code = rData[0]["container_code"];
  339. uni.setStorageSync("container_code", rData[0]["container_code"])
  340. uni.setStorageSync("receipt_num", rData[0]["receipt_num"])
  341. }
  342. this.tableData = disk;
  343. _this.$nextTick(() => {
  344. _this.firstFocus = true;
  345. _this.viewText = "";
  346. })
  347. }
  348. let containerCode = uni.getStorageSync("container_code")
  349. if (!_this.isEmpty(rows["container_code"])) {
  350. _this.container_code = Value;
  351. uni.removeStorageSync('container_code');
  352. uni.setStorageSync("container_code", Value)
  353. console.log("2", Value)
  354. // _this.getSn();
  355. // _this.getList();
  356. if (_this.tableData.length > 0) {
  357. for (let i = 0; i < _this.tableData.length; i++) {
  358. if (_this.tableData[i]["container_code"] === "") {
  359. uni.request({
  360. url: reqRootUrl + '/wms/api',
  361. method: 'POST',
  362. headers: {
  363. 'Content-Type': 'application/json'
  364. },
  365. data: JSON.stringify({
  366. "method": "GroupDiskUpdate",
  367. "param": {
  368. "sn": _this.tableData[i]["sn"],
  369. "container_code": Value,
  370. "product_code": _this.tableData[i][
  371. "product_code"
  372. ]
  373. }
  374. }),
  375. success: (ret) => {
  376. _this.alertInfo("更新成功!")
  377. _this.getList()
  378. //处理成功逻辑
  379. },
  380. })
  381. } else {
  382. if (_this.tableData[i]["container_code"] !== Value) {
  383. _this.getSn();
  384. _this.getList();
  385. }
  386. }
  387. }
  388. } else {
  389. _this.getSn();
  390. _this.getList();
  391. }
  392. _this.$nextTick(() => {
  393. _this.firstFocus = true;
  394. _this.viewText = "";
  395. })
  396. }
  397. if (!_this.isEmpty(rows["product"])) {
  398. _this.addModalVisible = true;
  399. _this.product_code = rows["product"]["code"];
  400. _this.product_name = rows["product"]["name"];
  401. _this.product_num = parseFloat(rows["product"]["ragnum"]);
  402. _this.product_weight = parseFloat(rows["product"]["weight"]) * parseFloat(
  403. rows["product"]["ragnum"]);
  404. _this.viewText = "";
  405. }
  406. },
  407. fail: (err) => {
  408. // console.log('request fail', err);
  409. },
  410. complete: () => {
  411. // console.log('complete');
  412. }
  413. })
  414. }
  415. },
  416. closeAddModal() {
  417. // 关闭模态框
  418. this.addModalVisible = false;
  419. },
  420. closeUpdateModal() {
  421. // 关闭模态框
  422. this.updateModalVisible = false;
  423. },
  424. plandateChange: function(e) {
  425. this.plandate = e.target.value
  426. },
  427. weightChange: function(e) {
  428. this.product_weight = e.target.value
  429. },
  430. numChange: function(e) {
  431. this.product_num = e.target.value
  432. },
  433. getDate(type) {
  434. const date = new Date();
  435. let year = date.getFullYear();
  436. let month = date.getMonth() + 1;
  437. let day = date.getDate();
  438. if (type === 'start') {
  439. year = year - 60;
  440. } else if (type === 'end') {
  441. year = year + 2;
  442. }
  443. month = month > 9 ? month : '0' + month;
  444. day = day > 9 ? day : '0' + day;
  445. return `${year}-${month}-${day}`;
  446. },
  447. SelectConfirm() {
  448. _this.firstFocus = false;
  449. setTimeout(() => {
  450. let receiptNum = uni.getStorageSync("receipt_num")
  451. let containerCode = uni.getStorageSync("container_code")
  452. uni.request({
  453. url: reqRootUrl + '/wms/api',
  454. method: 'POST',
  455. headers: {
  456. 'Content-Type': 'application/json'
  457. },
  458. data: JSON.stringify({
  459. "method": "GroupDiskAdd",
  460. "param": {
  461. "receipt_num": receiptNum,
  462. "product_code": _this.product_code,
  463. "container_code": _this.container_code,
  464. "weight": parseFloat(_this.product_weight),
  465. "num": parseFloat(_this.product_num),
  466. "plandate": new Date(_this.plandate).getTime(),
  467. "types": "normal",
  468. }
  469. }),
  470. success: (ret) => {
  471. console.log("AAAAAAAAAAAAAAAA ", ret)
  472. if (ret.data.ret === "ok") {
  473. setTimeout(() => {
  474. _this.alertInfo("添加成功!")
  475. _this.$nextTick(() => {
  476. _this.firstFocus = true;
  477. _this.viewText = "";
  478. _this.product_sn = "";
  479. _this.product_name = "";
  480. _this.product_weight = "";
  481. _this.product_num = "";
  482. // 关闭窗口后,恢复默认内容
  483. _this.addModalVisible = false;
  484. _this.getList();
  485. })
  486. }, 30);
  487. }
  488. },
  489. fail: (err) => {
  490. // console.log("BBBBBBBBBBBBBB ", err)
  491. // console.log('request fail', err);
  492. },
  493. complete: (DATE) => {
  494. // console.log("BBBBBBBBBBBBBB ", DATE)
  495. // console.log('complete');
  496. }
  497. })
  498. }, 30)
  499. },
  500. Delete(item) {
  501. this.sn = item["sn"]
  502. this.del_tips = "确定删除货物" + item["product_name"] + "?";
  503. this.$refs.deleteDialog.open()
  504. },
  505. dialogConfirm() {
  506. setTimeout(() => {
  507. uni.hideLoading()
  508. if (parseFloat() <= 0) {
  509. modal.toast({
  510. message: msg,
  511. duration: 6
  512. });
  513. return
  514. } else {
  515. uni.request({
  516. url: reqRootUrl + '/wms/api',
  517. method: 'POST',
  518. headers: {
  519. 'Content-Type': 'application/json'
  520. },
  521. data: JSON.stringify({
  522. "method": "GroupDiskDelete",
  523. "param": {
  524. [_this.sn]: {}
  525. }
  526. }),
  527. success: (ret) => {
  528. _this.alertInfo("删除成功!")
  529. _this.getList()
  530. //处理成功逻辑
  531. },
  532. fail: (err) => {
  533. // console.log('request fail', err);
  534. },
  535. complete: () => {
  536. // console.log('complete');
  537. }
  538. })
  539. }
  540. // 关闭窗口后,恢复默认内容
  541. this.$refs.deleteDialog.close()
  542. }, 30)
  543. },
  544. dialogClose() {
  545. _this.getList();
  546. },
  547. Update(item) {
  548. // console.log("item", item)
  549. _this.sn = item["sn"]
  550. _this.product_weight = item["weight"]
  551. _this.product_num = item["num"]
  552. _this.product_code = item["product_code"]
  553. _this.plandate = _this.formattedDate(item["plandate"])
  554. _this.updateModalVisible = true;
  555. },
  556. UpdateWeight() {
  557. setTimeout(() => {
  558. uni.request({
  559. url: reqRootUrl + '/wms/api',
  560. method: 'POST',
  561. headers: {
  562. 'Content-Type': 'application/json'
  563. },
  564. data: JSON.stringify({
  565. "method": "GroupDiskUpdate",
  566. "param": {
  567. "sn": _this.sn,
  568. "weight": parseFloat(_this.product_weight),
  569. "product_code": _this.product_code,
  570. "num": parseFloat(_this.product_num),
  571. "plandate": new Date(_this.plandate).getTime(),
  572. }
  573. }),
  574. success: (ret) => {
  575. _this.alertInfo("更新成功!")
  576. _this.getList()
  577. //处理成功逻辑
  578. },
  579. fail: (err) => {
  580. // console.log('request fail', err);
  581. },
  582. complete: () => {
  583. // console.log('complete');
  584. }
  585. })
  586. _this.updateModalVisible = false;
  587. // 关闭窗口后,恢复默认内容
  588. }, 30);
  589. },
  590. getList() {
  591. let receipt_num = uni.getStorageSync("receipt_num")
  592. console.log("receipt_num ", receipt_num)
  593. _this.$forceUpdate()
  594. rData = [];
  595. _this.tableData = [];
  596. uni.request({
  597. url: reqRootUrl + '/wms/api',
  598. method: 'POST',
  599. headers: {
  600. 'Content-Type': 'application/json'
  601. },
  602. data: JSON.stringify({
  603. "method": "GroupDiskGetByCode",
  604. "param": {
  605. "code": receipt_num,
  606. }
  607. }),
  608. success: (ret) => {
  609. //处理成功逻辑
  610. let rows = ret.data.data;
  611. if (rows != null) {
  612. rData = rows;
  613. if (rData[0]["receipt_num"] !== receipt_num) {
  614. rData = [];
  615. _this.tableData = [];
  616. return
  617. }
  618. _this.product_name = rData[0]["product_name"];
  619. _this.product_code = rData[0]["product_code"];
  620. for (var i = 0; i < rows.length; i++) {
  621. if (rows[i]["status"] === "status_success") {
  622. rows[i]["status_view"] = "已组盘"
  623. } else {
  624. rows[i]["status_view"] = "待组盘"
  625. }
  626. }
  627. _this.tableData = rows;
  628. } else {
  629. rData = [];
  630. _this.tableData = [];
  631. }
  632. },
  633. fail: (err) => {
  634. // console.log('request fail', err);
  635. },
  636. complete: () => {
  637. // console.log('complete');
  638. }
  639. })
  640. },
  641. groupDisk: function() {
  642. _this.firstFocus = false;
  643. // console.log("_this.BtnDisabled ", _this.BtnDisabled)
  644. if (_this.BtnDisabled) {
  645. _this.alertInfo("组盘失败,已组盘货物不能再次组盘")
  646. return;
  647. }
  648. if (_this.isEmpty(rData)) {
  649. _this.alertInfo("组盘失败,货物不能为空")
  650. return;
  651. }
  652. let str = _this.product_name;
  653. let containerCode = uni.getStorageSync("container_code")
  654. if (_this.isEmpty(containerCode)) {
  655. // 产品类别是铁桶的 不允许托盘码为空
  656. if (str.indexOf("铁桶") > -1) {
  657. _this.alertInfo("组盘失败,托盘码不能为空")
  658. return;
  659. }
  660. }
  661. setTimeout(() => {
  662. this.$refs.groupDialog.open()
  663. }, 30)
  664. },
  665. dialogGroup() {
  666. let sns = [];
  667. let productSn = rData[0]["product_sn"];
  668. if (rData.length > 1) {
  669. _this.alertInfo("组盘失败!只能添加一种货物")
  670. return
  671. }
  672. for (var i = 0; i < rData.length; i++) {
  673. if (rData[i]["status"] !== "status_wait") {
  674. continue
  675. }
  676. sns.push(rData[i].sn)
  677. }
  678. let str = _this.product_name;
  679. if (str.indexOf("木箱") > -1) {
  680. _this.container_code = ""
  681. uni.setStorageSync("container_code", "")
  682. }
  683. let receiptNum = uni.getStorageSync("receipt_num")
  684. let containerCode = uni.getStorageSync("container_code")
  685. uni.request({
  686. url: reqRootUrl + '/wms/api',
  687. method: 'POST',
  688. headers: {
  689. 'Content-Type': 'application/json'
  690. },
  691. data: JSON.stringify({
  692. "method": "ReceiptAdd",
  693. "param": {
  694. "receipt_num": receiptNum,
  695. "group_disk_sn_list": sns,
  696. "container_code": containerCode,
  697. "types": "normal",
  698. }
  699. }),
  700. success: (ret) => {
  701. this.$refs.groupDialog.close()
  702. if (ret.data.ret === "ok") {
  703. _this.alertInfo("组盘成功")
  704. _this.$nextTick(() => {
  705. _this.getSn()
  706. _this.firstFocus = false;
  707. _this.firstFocus = true;
  708. _this.viewText = "";
  709. _this.container_code = ""
  710. uni.setStorageSync("container_code", "")
  711. _this.getList()
  712. })
  713. _this.$forceUpdate()
  714. if (str.indexOf("木箱") > -1) {
  715. console.log("handlePrint ", receiptNum)
  716. this.handlePrint(receiptNum)
  717. }
  718. uni.setStorageSync("container_code", "")
  719. } else {
  720. _this.alertInfo("组盘失败!" + ret.data.msg)
  721. }
  722. },
  723. fail: (err) => {
  724. // console.log('request fail', err);
  725. },
  726. complete: () => {
  727. // console.log('complete');
  728. }
  729. })
  730. },
  731. in_stock: function(code) {
  732. setTimeout(() => {
  733. uni.navigateTo({
  734. url: '/pages/sample/in_stock',
  735. })
  736. }, 500);
  737. },
  738. isEmpty: function(obj) {
  739. return typeof obj === undefined || obj == null || obj === "" || obj === "000000000000000000000000" ||
  740. obj.length === 0;
  741. },
  742. alertInfo(str) {
  743. SpeechTTS.speak({
  744. text: str,
  745. });
  746. modal.toast({
  747. message: str,
  748. duration: 6,
  749. });
  750. },
  751. onNavigationBarButtonTap: function(e) {
  752. setTimeout(() => {
  753. uni.navigateTo({
  754. url: '/pages/sample/richAlert',
  755. })
  756. }, 500);
  757. },
  758. // 打印机相关
  759. ...mapActions([SET_CONNECTBLEDATA]),
  760. // 连接打印机
  761. confirm_bluetooth(item) {
  762. // let {
  763. // name,
  764. // mac
  765. // } = item;
  766. uni.showLoading({
  767. title: "连接中...",
  768. mask: true
  769. })
  770. let mac = item.mac;
  771. try {
  772. printModule.connectionBT({
  773. 'address': mac
  774. }, result => {
  775. // console.log("result ",result)
  776. const msg = JSON.stringify(result);
  777. this.result = JSON.parse(msg).result;
  778. modal.toast({
  779. message: msg,
  780. duration: 6
  781. });
  782. uni.hideLoading()
  783. printModule.setDisConnectBTListener((ret) => {
  784. modal.toast({
  785. message: '蓝牙断开',
  786. duration: 6
  787. });
  788. })
  789. })
  790. } catch (e) {
  791. console.log(e)
  792. }
  793. },
  794. //搜索没匹配的蓝牙设备
  795. search_bluetooth(address) {
  796. let _this = this;
  797. //检查蓝牙是否开启
  798. this.$check_bluetooth_open().then(ores => {
  799. if (ores) {
  800. console.log(ores);
  801. //搜索蓝牙
  802. _this.$search_bluetooth().then(bres => {
  803. console.log(bres);
  804. if (bres.code) {
  805. _this.$search_pipei().then(pres => {
  806. console.log(pres);
  807. })
  808. }
  809. })
  810. }
  811. })
  812. },
  813. handlePrint(code) {
  814. printModule.printAreaSize({
  815. 'height': '500',
  816. 'number': '1'
  817. }, result => {})
  818. printModule.printBarCode({
  819. 'x_pos': '10',
  820. 'y_pos': '100',
  821. 'code_type': '128',
  822. 'ratio': '1',
  823. 'height': '250',
  824. 'width': '2',
  825. 'rotation': 'BARCODE',
  826. 'undertext': false,
  827. 'number': '4',
  828. 'offset': '5',
  829. "textAlign": "right",
  830. 'code_data': code
  831. });
  832. printModule.printForm()
  833. printModule.print()
  834. },
  835. closeBT() {
  836. printModule.closeBT();
  837. },
  838. getSn() {
  839. let today = new Date();
  840. let year = today.getFullYear();
  841. let month = today.getMonth() + 1;
  842. let date = today.getDate();
  843. let hours = today.getHours();
  844. let minutes = today.getMinutes();
  845. let seconds = today.getSeconds();
  846. let millisecond = today.getMilliseconds()
  847. if (month <= 9) {
  848. month = '0' + month
  849. }
  850. if (minutes <= 9) {
  851. minutes = '0' + minutes;
  852. }
  853. if (date <= 9) {
  854. date = '0' + date;
  855. }
  856. if (seconds <= 9) {
  857. seconds = '0' + seconds;
  858. }
  859. let sn = year + '' + month + '' + date + '' + hours + '' + minutes + '' + seconds + '' + millisecond
  860. uni.removeStorageSync('receipt_num');
  861. uni.setStorageSync("receipt_num", sn)
  862. console.log("receipt_num ", sn)
  863. return sn
  864. },
  865. formattedDate(d) {
  866. const date = new Date(d);
  867. const year = date.getFullYear();
  868. const month = String(date.getMonth() + 1).padStart(2, '0');
  869. const day = String(date.getDate()).padStart(2, '0');
  870. const hours = String(date.getHours()).padStart(2, '0');
  871. const minutes = String(date.getMinutes()).padStart(2, '0');
  872. const seconds = String(date.getSeconds()).padStart(2, '0');
  873. return `${year}-${month}-${day}`;
  874. },
  875. },
  876. }
  877. </script>
  878. <style scoped>
  879. .nvue-page-root {
  880. background-color: #F8F8F8;
  881. padding-bottom: 0px;
  882. }
  883. .uni-form-item__title {
  884. margin: 5px auto;
  885. }
  886. .uni-input-wrapper {
  887. /* #ifndef APP-NVUE */
  888. display: flex;
  889. /* #endif */
  890. flex-direction: row;
  891. flex-wrap: nowrap;
  892. background-color: #FFFFFF;
  893. }
  894. .uni-input {
  895. height: 28px;
  896. line-height: 28px;
  897. font-size: 15px;
  898. padding: 1px;
  899. flex: 1;
  900. border-radius: 5px;
  901. border: 1px solid #cfdadd;
  902. background-color: #FFFFFF;
  903. }
  904. .mini-btn {
  905. height: 30px;
  906. padding-left: 1px;
  907. padding-right: 1px;
  908. }
  909. .uni-eye-active {
  910. color: #007AFF;
  911. }
  912. .table-title {
  913. background-color: aliceblue;
  914. font-weight: 700;
  915. margin-top: 10px;
  916. height: 40px;
  917. }
  918. .table-data {
  919. background-color: aliceblue;
  920. font-weight: 700;
  921. margin-top: 1px;
  922. height: 40px;
  923. }
  924. .tab-tr {
  925. width: 25%;
  926. line-height: 50px;
  927. border-right: 1px solid #ccc;
  928. margin: auto;
  929. text-align: center;
  930. }
  931. .tab-tr-end {
  932. width: 25%;
  933. line-height: 50px;
  934. border-right: 0px solid #ccc;
  935. margin: auto;
  936. text-align: center;
  937. }
  938. </style>
  939. <style lang="scss">
  940. $color-base: #0039a6;
  941. $words-color-base: #333333;
  942. $words-color-light: #999999;
  943. .header-wrap {
  944. width: 100%;
  945. position: fixed;
  946. top: 0;
  947. z-index: 999;
  948. .index-header {
  949. height: 88upx;
  950. line-height: 88upx;
  951. padding: 0 30upx;
  952. padding-top: 40upx;
  953. background-color: $color-base;
  954. font-Size: 28upx;
  955. color: #fff;
  956. display: flex;
  957. align-items: center;
  958. justify-content: space-between;
  959. .fanhui {
  960. color: #fff !important;
  961. font-size: 28px;
  962. padding-top: 5px;
  963. font-weight: 700;
  964. }
  965. .lanya {
  966. color: #fff !important;
  967. font-size: 28px;
  968. padding-top: 5px;
  969. }
  970. .map-wrap {
  971. padding-top: 5px;
  972. }
  973. }
  974. }
  975. .blank {
  976. height: 126upx;
  977. }
  978. // 购物车列表
  979. .cart-list {
  980. padding: 0 5rpx;
  981. // 购物车商品
  982. .goods {
  983. display: flex;
  984. padding: 5rpx;
  985. border-radius: 10rpx;
  986. background-color: #fff;
  987. position: relative;
  988. .meta {
  989. // border:1px solid red;
  990. flex: 1;
  991. display: flex;
  992. flex-direction: column;
  993. justify-content: space-between;
  994. margin-left: 5rpx;
  995. }
  996. .name {
  997. height: 72rpx;
  998. font-size: 18px;
  999. color: #000000;
  1000. }
  1001. .specs {
  1002. line-height: 2;
  1003. padding: 0 15rpx;
  1004. font-size: 16px;
  1005. align-self: flex-start;
  1006. border-radius: 4rpx;
  1007. color: #888;
  1008. background-color: #f7f7f8;
  1009. }
  1010. .status_view {
  1011. line-height: 1;
  1012. font-size: 18px;
  1013. color: #444;
  1014. margin-bottom: 2rpx;
  1015. color: #000000;
  1016. padding-top: 5px;
  1017. }
  1018. // 商品数量
  1019. .numGroup {
  1020. // border: 1px solid green;
  1021. position: absolute;
  1022. bottom: 70rpx;
  1023. right: 5rpx;
  1024. display: flex;
  1025. justify-content: space-between;
  1026. align-items: center;
  1027. width: 120px;
  1028. height: 48rpx;
  1029. .text_1 {
  1030. // border: 1px solid red;
  1031. width: 50px;
  1032. height: 100%;
  1033. padding: 0 5rpx;
  1034. font-size: 15px;
  1035. color: #444;
  1036. }
  1037. .text {
  1038. height: 100%;
  1039. padding: 0 5rpx;
  1040. font-size: 32rpx;
  1041. color: #444;
  1042. }
  1043. .inputs {
  1044. // border: 1px solid blue;
  1045. height: 100%;
  1046. padding-bottom: 10px;
  1047. text-align: center;
  1048. border-radius: 4rpx;
  1049. font-size: 20px;
  1050. color: #ff0000;
  1051. // background-color: #f6f6f6;
  1052. }
  1053. }
  1054. // 商品数量
  1055. .weightGroup {
  1056. // border: 1px solid green;
  1057. position: absolute;
  1058. bottom: 20rpx;
  1059. right: 5rpx;
  1060. display: flex;
  1061. justify-content: space-between;
  1062. align-items: center;
  1063. width: 120px;
  1064. height: 48rpx;
  1065. .text_1 {
  1066. // border: 1px solid red;
  1067. width: 50px;
  1068. height: 100%;
  1069. padding: 0 5rpx;
  1070. font-size: 15px;
  1071. color: #444;
  1072. }
  1073. .text {
  1074. height: 100%;
  1075. padding: 0 5rpx;
  1076. font-size: 32rpx;
  1077. color: #444;
  1078. }
  1079. .inputs {
  1080. // border: 1px solid blue;
  1081. height: 100%;
  1082. padding-bottom: 10px;
  1083. text-align: center;
  1084. border-radius: 4rpx;
  1085. font-size: 20px;
  1086. color: #ff0000;
  1087. // background-color: #f6f6f6;
  1088. }
  1089. }
  1090. }
  1091. .cart-swipe {
  1092. display: block;
  1093. margin: 20rpx 0;
  1094. }
  1095. }
  1096. </style>