select_product.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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. <text></text>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="blank"></view>
  17. </view>
  18. <view class="uni-common-mt" style="padding: 5px;">
  19. <view class="uni-form-item uni-column">
  20. <view class="uni-input-wrapper" style="margin: 5px auto;">
  21. <text class="uni-form-item__title">产品名称</text>
  22. <input class="uni-input" :value="query_code" @input="hideKeyboard" />
  23. </view>
  24. <view class="uni-input-wrapper table-title">
  25. <view class="tab-tr" style="width: 100%;">名称</view>
  26. </view>
  27. <view style="min-height:380px;overflow-y:auto;max-height:380px">
  28. <view class="uni-input-wrapper table-data" v-for="(item,index) in tableData" :key="index"
  29. @click="SelectProduct(item)">
  30. <view class="tab-tr"
  31. style="width: 100%; white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">
  32. {{item.name}}
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view>
  39. <!-- 引入自定义模态框 -->
  40. <custom-modal :visible="modalVisible">
  41. <!-- 模态框的内容 -->
  42. <view>
  43. <text>提示</text>
  44. <view class="uni-input-wrapper" style="margin: 5px auto;">
  45. <text class="uni-form-item__title" style="width: 30%;">产品名称</text>
  46. <input class="uni-input" :value="product_name" disabled="true" />
  47. </view>
  48. <view class="uni-input-wrapper" style="margin: 5px auto;">
  49. <text class="uni-form-item__title" style="width: 30%;">数量</text>
  50. <input type="number" class="uni-input" :value="product_num" @input="numChange" />
  51. </view>
  52. <view class="uni-input-wrapper" style="margin: 5px auto;">
  53. <text class="uni-form-item__title" style="width: 30%;">重量</text>
  54. <input type="number" class="uni-input" :value="product_weight" @input="weightChange" />
  55. </view>
  56. <view class="uni-input-wrapper" style="margin: 5px auto;">
  57. <text class="uni-form-item__title" style="width: 30%;">包装印刷</text>
  58. <select-lay :zindex="2" style="width: 70%;" :value="printed" name="printed"
  59. placeholder="请选择包装印刷" :options="printedList" @selectitem="printedChange">
  60. </select-lay>
  61. </view>
  62. <view class="uni-input-wrapper" style="margin: 5px auto;">
  63. <text class="uni-form-item__title" style="width: 30%;">生产线</text>
  64. <select-lay :zindex="1" style="width: 70%;" :value="production_line" name="production_line"
  65. placeholder="请选择生产线" :options="production_lineList" @selectitem="production_lineChange">
  66. </select-lay>
  67. </view>
  68. <view>
  69. <text style="width: 30%;float: left;height: 35px;line-height: 35px;">生产日期</text>
  70. <picker style="width: 70%;float: right;" mode="date" :value="plandate" :start="startDate"
  71. :end="endDate" @change="plandateChange">
  72. <view class="uni-input">{{plandate}}</view>
  73. </picker>
  74. </view>
  75. <br><br>
  76. <button class="mini-btn" size="mini" @click="closeModal" style="width: 50%;float: left;">关闭</button>
  77. <button class="mini-btn" type="primary" size="mini" @click="SelectConfirm"
  78. style="width: 50%;">添加</button>
  79. </view>
  80. </custom-modal>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. let _this = null;
  86. import CustomModal from "@/components/CustomModal/CustomModal.vue";
  87. const SpeechTTS = uni.requireNativePlugin('MT-TTS-Speech');
  88. const modal = uni.requireNativePlugin('modal');
  89. var reqRootUrl = plus.storage.getItem("reqRootUrl");
  90. export default {
  91. components: {
  92. CustomModal
  93. },
  94. data() {
  95. const currentDate = this.getDate({
  96. format: true
  97. });
  98. return {
  99. printedList: [],
  100. printed: "无印刷",
  101. production_lineList: [],
  102. production_line: "一期",
  103. query_code: "",
  104. tableData: [],
  105. product_code: "",
  106. modalVisible: false,
  107. plandate: currentDate,
  108. product_weight: 0,
  109. product_num: 0,
  110. product_name: "",
  111. }
  112. },
  113. computed: {
  114. startDate() {
  115. return this.getDate('start');
  116. },
  117. endDate() {
  118. return this.getDate('end');
  119. }
  120. },
  121. methods: {
  122. onUnload() {
  123. SpeechTTS.destroy();
  124. },
  125. speak_init() {
  126. // console.log('>> TTS:init...')
  127. SpeechTTS.init((callback) => {
  128. // SpeechTTS.setEngine("com.iflytek.speechcloud"); // 设置引擎
  129. SpeechTTS.setEngine("com.google.android.tts"); // 设置引擎
  130. // console.log('>> tts: init success');
  131. SpeechTTS.setPitch(50); // 设置语调 setPitch(num) 0-100, 默认 50
  132. SpeechTTS.setSpeed(65); // 设置语速 setSpeed(num) 0-100, 默认 50
  133. });
  134. SpeechTTS.onDone((res) => {
  135. // console.log(">> tts: play end " + res)
  136. });
  137. },
  138. leftClick: function() {
  139. setTimeout(() => {
  140. uni.navigateBack();
  141. // uni.redirectTo({
  142. // url: '/pages/sample/group',
  143. // })
  144. }, 30);
  145. // this.$emit('change', this.value)
  146. },
  147. onLoad() {
  148. this.platform = uni.getSystemInfoSync().platform
  149. // #ifdef APP-PLUS-NVUE
  150. this.isNvue = true
  151. // #endif
  152. _this = this;
  153. setTimeout(() => {
  154. this.getList();
  155. this.PrintedGet();
  156. this.ProductionLineGet();
  157. }, 350);
  158. },
  159. onShow() {
  160. uni.hideKeyboard();
  161. setTimeout(() => {
  162. this.speak_init();
  163. // this.getList();
  164. }, 350);
  165. },
  166. hideKeyboard: function(event) {
  167. let Value = event.detail.value;
  168. Value.trim();
  169. this.query_code = Value;
  170. _this.ContainerQuery();
  171. },
  172. ContainerQuery() {
  173. if (this.query_code !== "" && this.query_code !== null && this.query_code !== undefined) {
  174. uni.request({
  175. url: reqRootUrl + '/wms/api',
  176. method: 'POST',
  177. headers: {
  178. 'Content-Type': 'application/json'
  179. },
  180. data: JSON.stringify({
  181. "method": "ProductQuery",
  182. "param": {
  183. "name": this.query_code,
  184. "model": "regex"
  185. }
  186. }),
  187. success: (ret) => {
  188. let rows = ret.data.data;
  189. this.tableData = rows;
  190. },
  191. fail: (err) => {
  192. // console.log('request fail', err);
  193. },
  194. complete: () => {
  195. // console.log('complete');
  196. }
  197. })
  198. } else {
  199. _this.getList()
  200. }
  201. },
  202. SelectProduct(item) {
  203. this.product_code = item.code;
  204. this.product_name = item.name;
  205. this.modalVisible = true;
  206. this.product_num = parseFloat(item.ragnum);
  207. this.product_weight = parseFloat(item.weight) * parseFloat(item.ragnum);
  208. uni.setStorageSync("product_types", item.types)
  209. },
  210. plandateChange: function(e) {
  211. this.plandate = e.target.value
  212. },
  213. numChange: function(e) {
  214. this.product_num = e.target.value
  215. },
  216. printedChange(index, item) {
  217. if (index >= 0) {
  218. this.printed = item.value;
  219. }
  220. },
  221. production_lineChange(index, item) {
  222. if (index >= 0) {
  223. this.production_line = item.value;
  224. }
  225. },
  226. weightChange: function(e) {
  227. this.product_weight = e.target.value
  228. },
  229. getDate(type) {
  230. const date = new Date();
  231. let year = date.getFullYear();
  232. let month = date.getMonth() + 1;
  233. let day = date.getDate();
  234. if (type === 'start') {
  235. year = year - 60;
  236. } else if (type === 'end') {
  237. year = year + 2;
  238. }
  239. month = month > 9 ? month : '0' + month;
  240. day = day > 9 ? day : '0' + day;
  241. return `${year}-${month}-${day}`;
  242. },
  243. closeModal() {
  244. // 关闭模态框
  245. this.modalVisible = false;
  246. },
  247. SelectConfirm() {
  248. let receiptNum = uni.getStorageSync("receipt_num")
  249. let containerCode = uni.getStorageSync("container_code")
  250. setTimeout(() => {
  251. uni.request({
  252. url: reqRootUrl + '/wms/api',
  253. method: 'POST',
  254. headers: {
  255. 'Content-Type': 'application/json'
  256. },
  257. data: JSON.stringify({
  258. "method": "GroupDiskAdd",
  259. "param": {
  260. "product_code": _this.product_code,
  261. "num": parseFloat(_this.product_num),
  262. "weight": parseFloat(_this.product_weight),
  263. "plandate": new Date(_this.plandate).getTime(),
  264. "receipt_num": receiptNum,
  265. "container_code": containerCode,
  266. "printed": _this.printed,
  267. "production_line": _this.production_line,
  268. }
  269. }),
  270. success: (ret) => {
  271. if (ret.data.ret === "ok") {
  272. SpeechTTS.speak({
  273. text: "添加成功!",
  274. });
  275. modal.toast({
  276. message: "添加成功!",
  277. duration: 6
  278. });
  279. setTimeout(() => {
  280. uni.navigateBack();
  281. // uni.redirectTo({
  282. // url: '/pages/sample/group',
  283. // })
  284. }, 1000);
  285. }
  286. },
  287. fail: (err) => {
  288. // console.log('request fail', err);
  289. },
  290. complete: () => {
  291. // console.log('complete');
  292. }
  293. })
  294. // 关闭窗口后,恢复默认内容
  295. this.modalVisible = false;
  296. }, 30)
  297. },
  298. getList() {
  299. // uni.setStorageSync(key, value)
  300. // uni.removeStorageSync(key)
  301. let receiptNum = uni.getStorageSync("receipt_num")
  302. console.log("receiptNum ", receiptNum)
  303. uni.request({
  304. url: reqRootUrl + '/wms/api',
  305. method: 'POST',
  306. headers: {
  307. 'Content-Type': 'application/json'
  308. },
  309. data: JSON.stringify({
  310. "method": "ProductGetFilter",
  311. "param": {}
  312. }),
  313. success: (ret) => {
  314. let rows = ret.data.data;
  315. this.tableData = rows;
  316. },
  317. fail: (err) => {
  318. // console.log('request fail', err);
  319. },
  320. complete: () => {
  321. // console.log('complete');
  322. }
  323. })
  324. },
  325. ProductionLineGet() {
  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": "ProductionLineGet",
  334. "param": {
  335. "disable": false,
  336. }
  337. }),
  338. success: (ret) => {
  339. if (ret.data.ret === "ok") {
  340. let rows = ret.data.data;
  341. for (var i = 0; i < rows.length; i++) {
  342. this.production_lineList.push({
  343. label: rows[i].name,
  344. value: rows[i].name
  345. })
  346. }
  347. }
  348. },
  349. fail: (err) => {
  350. // console.log('request fail', err);
  351. },
  352. complete: () => {
  353. // console.log('complete');
  354. }
  355. })
  356. },
  357. PrintedGet() {
  358. uni.request({
  359. url: reqRootUrl + '/wms/api',
  360. method: 'POST',
  361. headers: {
  362. 'Content-Type': 'application/json'
  363. },
  364. data: JSON.stringify({
  365. "method": "PrintedGet",
  366. "param": {
  367. "disable": false,
  368. }
  369. }),
  370. success: (ret) => {
  371. if (ret.data.ret === "ok") {
  372. let rows = ret.data.data;
  373. for (var i = 0; i < rows.length; i++) {
  374. this.printedList.push({
  375. label: rows[i].name,
  376. value: rows[i].name
  377. })
  378. }
  379. }
  380. },
  381. fail: (err) => {
  382. // console.log('request fail', err);
  383. },
  384. complete: () => {
  385. // console.log('complete');
  386. }
  387. })
  388. },
  389. },
  390. }
  391. </script>
  392. <style scoped>
  393. .nvue-page-root {
  394. background-color: #F8F8F8;
  395. padding-bottom: 0px;
  396. }
  397. .uni-form-item__title {
  398. margin: 5px auto;
  399. }
  400. .uni-input-wrapper {
  401. /* #ifndef APP-NVUE */
  402. display: flex;
  403. /* #endif */
  404. flex-direction: row;
  405. flex-wrap: nowrap;
  406. background-color: #FFFFFF;
  407. }
  408. .uni-input {
  409. height: 28px;
  410. line-height: 28px;
  411. font-size: 15px;
  412. padding: 1px;
  413. flex: 1;
  414. border-radius: 5px;
  415. border: 1px solid #cfdadd;
  416. background-color: #FFFFFF;
  417. }
  418. .mini-btn {
  419. height: 30px;
  420. padding-left: 1px;
  421. padding-right: 1px;
  422. }
  423. .uni-eye-active {
  424. color: #007AFF;
  425. }
  426. .table-title {
  427. background-color: aliceblue;
  428. font-weight: 700;
  429. margin-top: 10px;
  430. height: 40px;
  431. }
  432. .table-data {
  433. background-color: aliceblue;
  434. font-weight: 700;
  435. margin-top: 1px;
  436. height: 40px;
  437. }
  438. .tab-tr {
  439. width: 25%;
  440. line-height: 25px;
  441. border-right: 1px solid #ccc;
  442. margin: auto;
  443. text-align: center;
  444. }
  445. .tab-tr-end {
  446. width: 25%;
  447. line-height: 25px;
  448. border-right: 0px solid #ccc;
  449. margin: auto;
  450. text-align: center;
  451. }
  452. </style>
  453. <style lang="scss">
  454. $color-base: #0039a6;
  455. $words-color-base: #333333;
  456. $words-color-light: #999999;
  457. .header-wrap {
  458. width: 100%;
  459. position: fixed;
  460. top: 0;
  461. z-index: 999;
  462. .index-header {
  463. height: 88upx;
  464. line-height: 88upx;
  465. padding: 0 30upx;
  466. padding-top: 40upx;
  467. background-color: $color-base;
  468. font-Size: 28upx;
  469. color: #fff;
  470. display: flex;
  471. align-items: center;
  472. justify-content: space-between;
  473. .fanhui {
  474. color: #fff !important;
  475. font-size: 28px;
  476. padding-top: 5px;
  477. font-weight: 700;
  478. }
  479. .lanya {
  480. color: #fff !important;
  481. font-size: 28px;
  482. padding-top: 5px;
  483. }
  484. .map-wrap {
  485. padding-top: 5px;
  486. }
  487. }
  488. }
  489. .blank {
  490. height: 126upx;
  491. }
  492. </style>