templateGroup.vue 31 KB

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