group.vue 33 KB

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