template.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <view class="nvue-page-root">
  3. <view class="head">
  4. <view class="header-wrap">
  5. <view class="index-header">
  6. <uni-icons class="fanhui" custom-prefix="iconfont" type="icon-fanhui"
  7. @click="leftClick"></uni-icons>
  8. <view class="input-wrap">
  9. <text class="iconfont">入库模版</text>
  10. </view>
  11. <view class="map-wrap">
  12. <!-- <uni-icons class="lanya" 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. <text class="uni-form-item__title" style="width: 25%;">货物名称: </text>
  21. <select-lay :zindex="3" class="uni-input" :value="product_code" name="product_code" placeholder="请选择货物名称"
  22. :options="productList" @selectitem="selectProduct">
  23. </select-lay>
  24. </view>
  25. <view class="uni-input-wrapper" style="margin: 5px auto;">
  26. <text class="uni-form-item__title" style="width: 25%;">包装印刷</text>
  27. <select-lay :zindex="2" style="width: 75%;" :value="printed" name="printed" placeholder="请选择包装印刷"
  28. :options="printedList" @selectitem="printedChange">
  29. </select-lay>
  30. </view>
  31. <view class="uni-input-wrapper" style="margin: 5px auto;">
  32. <text class="uni-form-item__title" style="width: 25%;">生产线</text>
  33. <select-lay :zindex="1" style="width: 75%;" :value="production_line" name="production_line"
  34. placeholder="请选择生产线" :options="production_lineList" @selectitem="production_lineChange">
  35. </select-lay>
  36. </view>
  37. <view class="uni-input-wrapper" style="margin: 5px auto;">
  38. <text class="uni-form-item__title" style="width: 25%;">数量:</text>
  39. <input class="uni-input" :value="num" @input="tmp_num" />
  40. </view>
  41. <view class="uni-input-wrapper" style="margin: 5px auto;">
  42. <text class="uni-form-item__title" style="width: 25%;">重量:</text>
  43. <input class="uni-input" :value="weight" @input="tmp_weight" />
  44. </view>
  45. <view class="uni-input-wrapper" style="margin: 5px auto;">
  46. <text class="uni-form-item__title" style="width: 25%;">生产日期</text>
  47. <picker style="width: 70%;float: right;" mode="date" :value="plandate" :start="startDate" :end="endDate"
  48. @change="plandateChange">
  49. <view class="uni-input">{{plandate}}</view>
  50. </picker>
  51. </view>
  52. <view class="uni-form-item uni-column">
  53. <view class="uni-input-wrapper button-sp-area">
  54. <button type="primary" plain="true" @click="SelectProductAll()">保存</button>
  55. <button type="primary" plain="true" @click="returns()">返回</button>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. let _this = null;
  63. import {
  64. mapGetters,
  65. mapActions
  66. } from 'vuex';
  67. import {
  68. GET_INFODATA,
  69. GET_CONNECTBLEDATA
  70. } from "@/store/gettersType.js";
  71. import {
  72. SET_CONNECTBLEDATA
  73. } from '@/store/actionsType.js';
  74. // #ifdef APP-PLUS
  75. const modal = uni.requireNativePlugin('modal');
  76. // #endif
  77. let reqRootUrl = plus.storage.getItem("reqRootUrl");
  78. let rData = [];
  79. const SpeechTTS = uni.requireNativePlugin('MT-TTS-Speech');
  80. export default {
  81. data() {
  82. const currentDate = this.getDate({
  83. format: true
  84. });
  85. return {
  86. printedList: [],
  87. printed: "",
  88. production_lineList: [],
  89. production_line: "一期",
  90. productList: [],
  91. product_code: "",
  92. weight: "",
  93. num: "",
  94. product_name: "",
  95. del_tips: "",
  96. plandate: currentDate,
  97. }
  98. },
  99. computed: {
  100. ...mapGetters([GET_INFODATA, GET_CONNECTBLEDATA]),
  101. startDate() {
  102. return this.getDate('start');
  103. },
  104. endDate() {
  105. return this.getDate('end');
  106. },
  107. },
  108. methods: {
  109. onUnload() {
  110. SpeechTTS.destroy();
  111. },
  112. speak_init() {
  113. // console.log('>> TTS:init...')
  114. SpeechTTS.init((callback) => {
  115. // SpeechTTS.setEngine("com.iflytek.speechcloud"); // 设置引擎
  116. SpeechTTS.setEngine("com.google.android.tts"); // 设置引擎
  117. // console.log('>> tts: init success');
  118. SpeechTTS.setPitch(50); // 设置语调 setPitch(num) 0-100, 默认 50
  119. SpeechTTS.setSpeed(65); // 设置语速 setSpeed(num) 0-100, 默认 50
  120. });
  121. SpeechTTS.onDone((res) => {
  122. // console.log(">> tts: play end " + res)
  123. });
  124. },
  125. leftClick: function() {
  126. setTimeout(() => {
  127. uni.vibrateShort();
  128. uni.navigateTo({
  129. // url: '/pages/sample/tts',
  130. url: '/pages/sample/main',
  131. })
  132. }, 30);
  133. },
  134. onLoad() {
  135. _this = this;
  136. },
  137. onShow() {
  138. uni.hideKeyboard();
  139. setTimeout(() => {
  140. this.PrintedGet();
  141. this.ProductionLineGet();
  142. this.speak_init();
  143. this.CateGet();
  144. }, 500);
  145. },
  146. returns() {
  147. setTimeout(() => {
  148. uni.vibrateShort();
  149. uni.navigateTo({
  150. // url: '/pages/sample/tts',
  151. url: '/pages/sample/templateGroup',
  152. })
  153. }, 500);
  154. },
  155. SelectProductAll() {
  156. if (_this.isEmpty(_this.product_name)) {
  157. _this.alertInfo("请选择货物")
  158. return
  159. }
  160. if (_this.isEmpty(_this.weight)) {
  161. _this.alertInfo("请填写重量")
  162. return
  163. }
  164. if (_this.isEmpty(_this.num)) {
  165. _this.alertInfo("请填写数量")
  166. return
  167. }
  168. if (_this.isEmpty(_this.production_line)) {
  169. _this.alertInfo("请选择生产线")
  170. return
  171. }
  172. if (_this.isEmpty(_this.printed)) {
  173. _this.alertInfo("请选择包product_name装印刷")
  174. return
  175. }
  176. setTimeout(() => {
  177. uni.setStorageSync("tmp_product_name", _this.product_name)
  178. uni.setStorageSync("tmp_product_code", _this.product_code)
  179. uni.setStorageSync("tmp_weight", _this.weight)
  180. uni.setStorageSync("tmp_num", _this.num)
  181. uni.setStorageSync("tmp_printed", _this.printed)
  182. uni.setStorageSync("tmp_production_line", _this.production_line)
  183. uni.setStorageSync("tmp_plandate", _this.plandate)
  184. _this.alertInfo("模版保存成功")
  185. }, 30)
  186. },
  187. tmp_num: function(event) {
  188. this.num = event.detail.value;
  189. },
  190. tmp_weight: function(event) {
  191. this.weight = event.detail.value;
  192. },
  193. printedChange(index, item) {
  194. if (index >= 0) {
  195. this.printed = item.value;
  196. }
  197. },
  198. plandateChange: function(e) {
  199. this.plandate = e.target.value
  200. },
  201. getDate(type) {
  202. const date = new Date();
  203. let year = date.getFullYear();
  204. let month = date.getMonth() + 1;
  205. let day = date.getDate();
  206. if (type === 'start') {
  207. year = year - 60;
  208. } else if (type === 'end') {
  209. year = year + 2;
  210. }
  211. month = month > 9 ? month : '0' + month;
  212. day = day > 9 ? day : '0' + day;
  213. return `${year}-${month}-${day}`;
  214. },
  215. production_lineChange(index, item) {
  216. if (index >= 0) {
  217. this.production_line = item.value;
  218. }
  219. },
  220. selectProduct(index, item) {
  221. if (index >= 0) {
  222. this.product_code = item.value;
  223. this.product_name = item.label;
  224. } else {
  225. this.product_code = ""
  226. this.product_name = ""
  227. }
  228. },
  229. ProductionLineGet() {
  230. uni.request({
  231. url: reqRootUrl + '/wms/api',
  232. method: 'POST',
  233. headers: {
  234. 'Content-Type': 'application/json'
  235. },
  236. data: JSON.stringify({
  237. "method": "ProductionLineGet",
  238. "param": {
  239. "disable": false,
  240. }
  241. }),
  242. success: (ret) => {
  243. if (ret.data.ret === "ok") {
  244. let rows = ret.data.data;
  245. for (var i = 0; i < rows.length; i++) {
  246. this.production_lineList.push({
  247. label: rows[i].name,
  248. value: rows[i].name
  249. })
  250. }
  251. }
  252. },
  253. fail: (err) => {
  254. // console.log('request fail', err);
  255. },
  256. complete: () => {
  257. // console.log('complete');
  258. }
  259. })
  260. },
  261. PrintedGet() {
  262. uni.request({
  263. url: reqRootUrl + '/wms/api',
  264. method: 'POST',
  265. headers: {
  266. 'Content-Type': 'application/json'
  267. },
  268. data: JSON.stringify({
  269. "method": "PrintedGet",
  270. "param": {
  271. "disable": false,
  272. }
  273. }),
  274. success: (ret) => {
  275. if (ret.data.ret === "ok") {
  276. let rows = ret.data.data;
  277. for (var i = 0; i < rows.length; i++) {
  278. this.printedList.push({
  279. label: rows[i].name,
  280. value: rows[i].name
  281. })
  282. }
  283. }
  284. },
  285. fail: (err) => {
  286. // console.log('request fail', err);
  287. },
  288. complete: () => {
  289. // console.log('complete');
  290. }
  291. })
  292. },
  293. CateGet() {
  294. uni.request({
  295. url: reqRootUrl + '/wms/api',
  296. method: 'POST',
  297. headers: {
  298. 'Content-Type': 'application/json'
  299. },
  300. data: JSON.stringify({
  301. "method": "ProductGetFilter",
  302. "param": {
  303. "disable": false,
  304. }
  305. }),
  306. success: (ret) => {
  307. if (ret.data.ret === "ok") {
  308. this.productList = [];
  309. let rows = ret.data.data;
  310. for (var i = 0; i < rows.length; i++) {
  311. if (rows[i].types === "合托"||rows[i].name === "空托盘") {
  312. continue
  313. }
  314. this.productList.push({
  315. label: rows[i].name,
  316. value: rows[i].code
  317. })
  318. }
  319. }
  320. },
  321. fail: (err) => {
  322. // console.log('request fail', err);
  323. },
  324. complete: () => {
  325. // console.log('complete');
  326. }
  327. })
  328. let product_name = uni.getStorageSync("tmp_product_name")
  329. let product_code = uni.getStorageSync("tmp_product_code")
  330. let weight = uni.getStorageSync("tmp_weight")
  331. let num = uni.getStorageSync("tmp_num")
  332. let printed = uni.getStorageSync("tmp_printed")
  333. let production_line = uni.getStorageSync("tmp_production_line")
  334. let plandate = uni.getStorageSync("tmp_plandate")
  335. _this.product_code = product_code;
  336. _this.product_name = product_name;
  337. _this.weight = weight;
  338. _this.num = num;
  339. _this.printed = printed;
  340. _this.production_line = production_line;
  341. _this.plandate = _this.formattedDate(plandate)
  342. },
  343. formattedDate(d) {
  344. const date = new Date(d);
  345. const year = date.getFullYear();
  346. const month = String(date.getMonth() + 1).padStart(2, '0');
  347. const day = String(date.getDate()).padStart(2, '0');
  348. const hours = String(date.getHours()).padStart(2, '0');
  349. const minutes = String(date.getMinutes()).padStart(2, '0');
  350. const seconds = String(date.getSeconds()).padStart(2, '0');
  351. return `${year}-${month}-${day}`;
  352. },
  353. isEmpty: function(obj) {
  354. return typeof obj === undefined || obj == null || obj === "" || obj ===
  355. "000000000000000000000000" ||
  356. obj.length === 0;
  357. },
  358. alertInfo(str) {
  359. SpeechTTS.speak({
  360. text: str,
  361. });
  362. modal.toast({
  363. message: str,
  364. duration: 6,
  365. });
  366. },
  367. },
  368. }
  369. </script>
  370. <style scoped>
  371. .nvue-page-root {
  372. background-color: #F8F8F8;
  373. padding-bottom: 0px;
  374. }
  375. .uni-form-item__title {
  376. margin: 5px auto;
  377. }
  378. .uni-input-wrapper {
  379. /* #ifndef APP-NVUE */
  380. display: flex;
  381. /* #endif */
  382. flex-direction: row;
  383. flex-wrap: nowrap;
  384. background-color: #FFFFFF;
  385. }
  386. .uni-input {
  387. height: 28px;
  388. line-height: 28px;
  389. font-size: 15px;
  390. padding: 1px;
  391. flex: 1;
  392. border-radius: 5px;
  393. border: 1px solid #cfdadd;
  394. background-color: #FFFFFF;
  395. }
  396. .mini-btn {
  397. height: 30px;
  398. padding-left: 1px;
  399. padding-right: 1px;
  400. }
  401. .uni-eye-active {
  402. color: #007AFF;
  403. }
  404. .table-title {
  405. background-color: aliceblue;
  406. font-weight: 700;
  407. margin-top: 10px;
  408. height: 40px;
  409. }
  410. .table-data {
  411. background-color: aliceblue;
  412. font-weight: 700;
  413. margin-top: 1px;
  414. height: 40px;
  415. }
  416. .tab-tr {
  417. width: 25%;
  418. line-height: 50px;
  419. border-right: 1px solid #ccc;
  420. margin: auto;
  421. text-align: center;
  422. }
  423. .tab-tr-end {
  424. width: 25%;
  425. line-height: 50px;
  426. border-right: 0px solid #ccc;
  427. margin: auto;
  428. text-align: center;
  429. }
  430. </style>
  431. <style lang="scss">
  432. $color-base: #0039a6;
  433. $words-color-base: #333333;
  434. $words-color-light: #999999;
  435. .header-wrap {
  436. width: 100%;
  437. position: fixed;
  438. top: 0;
  439. z-index: 999;
  440. .index-header {
  441. height: 88upx;
  442. line-height: 88upx;
  443. padding: 0 30upx;
  444. padding-top: 40upx;
  445. background-color: $color-base;
  446. font-Size: 28upx;
  447. color: #fff;
  448. display: flex;
  449. align-items: center;
  450. justify-content: space-between;
  451. .fanhui {
  452. color: #fff !important;
  453. font-size: 28px;
  454. padding-top: 5px;
  455. font-weight: 700;
  456. }
  457. .lanya {
  458. color: #fff !important;
  459. font-size: 28px;
  460. padding-top: 5px;
  461. }
  462. .map-wrap {
  463. padding-top: 5px;
  464. }
  465. }
  466. }
  467. .blank {
  468. height: 126upx;
  469. }
  470. // 购物车列表
  471. .cart-list {
  472. padding: 0 5rpx;
  473. // 购物车商品
  474. .goods {
  475. display: flex;
  476. padding: 5rpx;
  477. border-radius: 10rpx;
  478. background-color: #fff;
  479. position: relative;
  480. .meta {
  481. // border:1px solid red;
  482. flex: 1;
  483. display: flex;
  484. flex-direction: column;
  485. justify-content: space-between;
  486. margin-left: 5rpx;
  487. }
  488. .name {
  489. height: 72rpx;
  490. font-size: 18px;
  491. color: #000000;
  492. }
  493. .specs {
  494. line-height: 2;
  495. padding: 0 15rpx;
  496. font-size: 16px;
  497. align-self: flex-start;
  498. border-radius: 4rpx;
  499. color: #888;
  500. background-color: #f7f7f8;
  501. }
  502. .status_view {
  503. line-height: 1;
  504. font-size: 18px;
  505. color: #444;
  506. margin-bottom: 2rpx;
  507. color: #000000;
  508. padding-top: 5px;
  509. }
  510. // 商品数量
  511. .numGroup {
  512. // border: 1px solid green;
  513. position: absolute;
  514. bottom: 70rpx;
  515. right: 5rpx;
  516. display: flex;
  517. justify-content: space-between;
  518. align-items: center;
  519. width: 120px;
  520. height: 48rpx;
  521. .text_1 {
  522. // border: 1px solid red;
  523. width: 150px;
  524. height: 100%;
  525. padding: 0 5rpx;
  526. font-size: 15px;
  527. color: #444;
  528. }
  529. .text {
  530. height: 100%;
  531. padding: 0 5rpx;
  532. font-size: 32rpx;
  533. color: #444;
  534. }
  535. .inputs {
  536. // border: 1px solid blue;
  537. height: 100%;
  538. padding-bottom: 10px;
  539. text-align: center;
  540. border-radius: 4rpx;
  541. font-size: 20px;
  542. color: #ff0000;
  543. // background-color: #f6f6f6;
  544. }
  545. }
  546. // 商品数量
  547. .weightGroup {
  548. // border: 1px solid green;
  549. position: absolute;
  550. bottom: 20rpx;
  551. right: 5rpx;
  552. display: flex;
  553. justify-content: space-between;
  554. align-items: center;
  555. width: 120px;
  556. height: 48rpx;
  557. .text_1 {
  558. // border: 1px solid red;
  559. width: 50px;
  560. height: 100%;
  561. padding: 0 5rpx;
  562. font-size: 15px;
  563. color: #444;
  564. }
  565. .text {
  566. height: 100%;
  567. padding: 0 5rpx;
  568. font-size: 32rpx;
  569. color: #444;
  570. }
  571. .inputs {
  572. // border: 1px solid blue;
  573. height: 100%;
  574. padding-bottom: 10px;
  575. text-align: center;
  576. border-radius: 4rpx;
  577. font-size: 20px;
  578. color: #ff0000;
  579. // background-color: #f6f6f6;
  580. }
  581. }
  582. }
  583. .cart-swipe {
  584. display: block;
  585. margin: 20rpx 0;
  586. }
  587. }
  588. </style>