stocktaking_add_product.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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_name" @input="nameChange" />
  23. </view>
  24. <view class="uni-input-wrapper" style="margin: 5px auto;">
  25. <text class="uni-form-item__title">品牌:</text>
  26. <input class="uni-input" :value="query_brand" @input="brandChange" />
  27. </view>
  28. <view class="uni-input-wrapper" style="margin: 5px auto;">
  29. <text class="uni-form-item__title">型号:</text>
  30. <input class="uni-input" :value="query_model" @input="modelChange" />
  31. </view>
  32. <view style="min-height:600px;overflow-y:auto;max-height:600px">
  33. <view class="cart-list">
  34. <!-- 滑动操作分区 -->
  35. <uni-swipe-action>
  36. <!-- 滑动操作项 -->
  37. <uni-swipe-action-item v-for="(item,index) in tableData" :key="index" class="cart-swipe">
  38. <!-- 商品信息 -->
  39. <view class="goods" style="border:1px solid #ccc" @click="SelectProduct(item)">
  40. <view class="meta" style="padding-bottom:15px;">
  41. <view class="name">
  42. 名称:{{item.name}}
  43. 品牌:{{item.brand}}
  44. 型号:{{item.model}}
  45. 设备编号:{{item.deviceid}}
  46. 主类别:{{item.category_name}}
  47. 分类别:{{item.main_categoryid_name}}
  48. 公司:{{item.company_name}}
  49. 产品详情:{{item.remark}}
  50. </view>
  51. </view>
  52. <!-- 商品数量 -->
  53. <!-- <view class="numGroup">
  54. <text class="text_1"></text>
  55. <text class="inputs"></text>
  56. <text class="text"></text>
  57. </view> -->
  58. </view>
  59. </uni-swipe-action-item>
  60. </uni-swipe-action>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view>
  66. <!-- 引入自定义模态框 -->
  67. <custom-modal :visible="modalVisible">
  68. <!-- 模态框的内容 -->
  69. <view>
  70. <text>提示</text>
  71. <view class="uni-input-wrapper" style="margin: 5px auto;">
  72. <text class="uni-form-item__title" style="width: 30%;">名称</text>
  73. <input class="uni-input" :value="name" disabled="true" />
  74. </view>
  75. <view class="uni-input-wrapper" style="margin: 5px auto;">
  76. <text class="uni-form-item__title" style="width: 30%;">品牌</text>
  77. <input class="uni-input" :value="brand" disabled="true" />
  78. </view>
  79. <view class="uni-input-wrapper" style="margin: 5px auto;">
  80. <text class="uni-form-item__title" style="width: 30%;">型号</text>
  81. <input class="uni-input" :value="model" disabled="true" />
  82. </view>
  83. <view class="uni-input-wrapper" style="margin: 5px auto;">
  84. <text class="uni-form-item__title" style="width: 30%;">主类别</text>
  85. <input class="uni-input" :value="category_name" disabled="true" />
  86. </view>
  87. <view class="uni-input-wrapper" style="margin: 5px auto;">
  88. <text class="uni-form-item__title" style="width: 30%;">分类别</text>
  89. <input class="uni-input" :value="main_categoryid_name" disabled="true" />
  90. </view>
  91. <view class="uni-input-wrapper" style="margin: 5px auto;">
  92. <text class="uni-form-item__title" style="width: 30%;">公司</text>
  93. <select-lay style="width: 75%;" :zindex="3" :value="companyid" name="companyid" placeholder="请选择公司"
  94. :options="companyList" @selectitem="selectCompany">
  95. </select-lay>
  96. </view>
  97. <view class="uni-input-wrapper" style="margin: 5px auto;">
  98. <text class="uni-form-item__title" style="width: 30%;">产品详情</text>
  99. <input class="uni-input" :value="remark" disabled="true" />
  100. </view>
  101. <view class="uni-input-wrapper" style="margin: 5px auto;">
  102. <text class="uni-form-item__title" style="width: 30%;">数量</text>
  103. <input type="number" class="uni-input" :value="num" @input="numChange" />
  104. </view>
  105. <view class="uni-input-wrapper" style="margin: 5px auto;">
  106. <text class="uni-form-item__title" style="width: 30%;">设备编号</text>
  107. <input class="uni-input" :value="deviceid" @input="deviceidChange" />
  108. </view>
  109. <br><br>
  110. <button class="mini-btn" size="mini" @click="closeModal" style="width: 50%;float: left;">关闭</button>
  111. <button class="mini-btn" type="primary" size="mini" @click="SelectConfirm"
  112. style="width: 50%;">添加</button>
  113. </view>
  114. </custom-modal>
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. let _this = null;
  120. import CustomModal from "@/components/CustomModal/CustomModal.vue";
  121. const SpeechTTS = uni.requireNativePlugin('MT-TTS-Speech');
  122. const modal = uni.requireNativePlugin('modal');
  123. var reqRootUrl = plus.storage.getItem("reqRootUrl");
  124. var containerCode = ""
  125. export default {
  126. components: {
  127. CustomModal
  128. },
  129. data() {
  130. return {
  131. url: '',
  132. query_name: "",
  133. query_brand: "",
  134. query_model: "",
  135. tableData: [],
  136. modalVisible: false,
  137. name: "",
  138. model: "",
  139. deviceid: "",
  140. brand: "",
  141. num: 0,
  142. productid: "",
  143. companyid: "",
  144. company_name: "",
  145. category_name: "",
  146. main_categoryid_name: "",
  147. remark: "",
  148. companyList: [{
  149. label: "华力",
  150. value: "6477115e9708e4295690708b"
  151. },
  152. {
  153. label: "西曼克",
  154. value: "6465c853797066b5c4e0ab0e"
  155. }],
  156. }
  157. },
  158. computed: {},
  159. methods: {
  160. onUnload() {
  161. // SpeechTTS.destroy();
  162. },
  163. speak_init() {
  164. // console.log('>> TTS:init...')
  165. SpeechTTS.init((callback) => {
  166. // SpeechTTS.setEngine("com.iflytek.speechcloud"); // 设置引擎
  167. SpeechTTS.setEngine("com.google.android.tts"); // 设置引擎
  168. // console.log('>> tts: init success');
  169. SpeechTTS.setPitch(50); // 设置语调 setPitch(num) 0-100, 默认 50
  170. SpeechTTS.setSpeed(65); // 设置语速 setSpeed(num) 0-100, 默认 50
  171. });
  172. SpeechTTS.onDone((res) => {
  173. // console.log(">> tts: play end " + res)
  174. });
  175. },
  176. leftClick: function() {
  177. setTimeout(() => {
  178. uni.navigateBack();
  179. // uni.redirectTo({
  180. // url: '/pages/sample/group',
  181. // })
  182. }, 30);
  183. // this.$emit('change', this.value)
  184. },
  185. onLoad(options) {
  186. this.platform = uni.getSystemInfoSync().platform
  187. // #ifdef APP-PLUS-NVUE
  188. this.isNvue = true
  189. // #endif
  190. _this = this;
  191. containerCode = options.containerCode;
  192. setTimeout(() => {
  193. this.getList();
  194. }, 350);
  195. },
  196. // // 目标页面接收参数
  197. // onLoad: function(options) {
  198. // console.log('containerCode: ', options.containerCode);
  199. // }
  200. onShow() {
  201. uni.hideKeyboard();
  202. setTimeout(() => {
  203. this.getUserInfoWareHouse();
  204. }, 300);
  205. setTimeout(() => {
  206. this.speak_init();
  207. // this.getList();
  208. }, 350);
  209. },
  210. selectCompany(index, item) {
  211. if (index >= 0) {
  212. _this.companyid = item.value;
  213. } else {
  214. _this.companyid = ""
  215. }
  216. },
  217. nameChange: function(event) {
  218. let Value = event.detail.value;
  219. this.query_name = Value.trim();
  220. _this.ContainerQuery();
  221. },
  222. brandChange: function(event) {
  223. let Value = event.detail.value;
  224. this.query_brand = Value.trim();
  225. _this.ContainerQuery();
  226. },
  227. modelChange: function(event) {
  228. let Value = event.detail.value;
  229. this.query_model = Value.trim();
  230. _this.ContainerQuery();
  231. },
  232. ContainerQuery() {
  233. if (!_this.isEmpty(_this.query_name) || !_this.isEmpty(_this.query_brand) || !_this.isEmpty(_this
  234. .query_model)) {
  235. console.log("aaa ", _this.query_name, _this.query_brand, _this.query_model)
  236. _this.tableData = [];
  237. uni.request({
  238. url: reqRootUrl + '/ProductQuery',
  239. method: 'POST',
  240. headers: {
  241. 'Content-Type': 'application/json'
  242. },
  243. data: JSON.stringify({
  244. "name": this.query_name,
  245. "brand": this.query_brand,
  246. "model": this.query_model,
  247. "types": "regex",
  248. }),
  249. success: (ret) => {
  250. console.log("ret ", ret)
  251. if (ret.statusCode === 200) {
  252. if (!_this.isEmpty(ret.data)) {
  253. _this.tableData = ret.data;
  254. }
  255. }
  256. },
  257. fail: (err) => {
  258. // console.log('request fail', err);
  259. },
  260. complete: () => {
  261. // console.log('complete');
  262. }
  263. })
  264. } else {
  265. _this.getList()
  266. }
  267. },
  268. SelectProduct(item) {
  269. let source = uni.getStorageSync("source");
  270. if (source !== "stocktaking") {
  271. return
  272. }
  273. _this.productid = item._id;
  274. _this.name = item.name;
  275. _this.model = item.model;
  276. _this.deviceid = item.deviceid;
  277. _this.brand = item.brand;
  278. _this.company_name = item.company_name;
  279. _this.companyid = item.companyid
  280. _this.category_name = item.category_name;
  281. _this.main_categoryid_name = item.main_categoryid_name;
  282. _this.remark = item.remark;
  283. _this.num = 1;
  284. _this.modalVisible = true;
  285. },
  286. numChange: function(e) {
  287. this.num = e.target.value
  288. },
  289. deviceidChange: function(e) {
  290. this.deviceid = e.target.value
  291. },
  292. closeModal() {
  293. // 关闭模态框
  294. _this.productid = "";
  295. _this.name = "";
  296. _this.model = "";
  297. _this.deviceid = "";
  298. _this.brand = "";
  299. _this.companyid = "";
  300. _this.company_name = "";
  301. _this.category_name = "";
  302. _this.main_categoryid_name = "";;
  303. _this.remark = "";
  304. _this.num = 0;
  305. _this.deviceid = "";
  306. _this.modalVisible = false;
  307. },
  308. SelectConfirm() {
  309. let receiptNum = uni.getStorageSync("receipt_num");
  310. let containerCode = uni.getStorageSync("container_code");
  311. let warehouse_id = uni.getStorageSync("warehouse_id");
  312. let source = uni.getStorageSync("source");
  313. let data = {};
  314. if (parseInt(_this.num) === 0) {
  315. _this.alertInfo("请填写正确的入库数量")
  316. return
  317. }
  318. data["productid"] = _this.productid;
  319. data["num"] = parseInt(_this.num)
  320. data["container_code"] = containerCode;
  321. data["groupsn"] = "";
  322. data["types"] = "normal";
  323. data["receipt_num"] = receiptNum;
  324. data["warehouse_id"] = warehouse_id;
  325. data["stock_remark"] = "";
  326. data["purchaseid"] = "";
  327. data["deviceid"] = _this.deviceid;
  328. data["companyid"] = _this.companyid;
  329. let methods = "GroupDiskAdd"
  330. // if (source === "out") {
  331. // methods = "AddDetailAddRecord";
  332. // }
  333. setTimeout(() => {
  334. uni.request({
  335. url: reqRootUrl + '/StocktakingAddProduct',
  336. method: 'POST',
  337. async: false,
  338. headers: {
  339. 'Content-Type': 'application/json'
  340. },
  341. data: JSON.stringify(data),
  342. success: (ret) => {
  343. if (ret.statusCode === 200) {
  344. _this.alertInfo("添加成功");
  345. _this.getList();
  346. _this.productid = "";
  347. _this.name = "";
  348. _this.model = "";
  349. _this.deviceid = "";
  350. _this.brand = "";
  351. _this.company_name = "";
  352. _this.category_name = "";
  353. _this.main_categoryid_name = "";;
  354. _this.remark = "";
  355. _this.companyid = "";
  356. this.num = 0;
  357. setTimeout(() => {
  358. uni.navigateBack();
  359. uni.redirectTo({
  360. url: '/pages/sample/stocktaking?containerCode='+containerCode,
  361. })
  362. }, 1000);
  363. }else{
  364. _this.alertInfo("添加失败");
  365. setTimeout(() => {
  366. uni.navigateBack();
  367. uni.redirectTo({
  368. url: '/pages/sample/stocktaking?containerCode='+containerCode,
  369. })
  370. }, 1000);
  371. }
  372. },
  373. fail: (err) => {
  374. // console.log('request fail', err);
  375. },
  376. complete: () => {
  377. // console.log('complete');
  378. }
  379. })
  380. // 关闭窗口后,恢复默认内容
  381. this.modalVisible = false;
  382. }, 30)
  383. },
  384. getList() {
  385. uni.request({
  386. url: reqRootUrl + '/ProductQuery',
  387. method: 'POST',
  388. headers: {
  389. 'Content-Type': 'application/json'
  390. },
  391. data: JSON.stringify({}),
  392. success: (ret) => {
  393. if (ret.statusCode === 200) {
  394. if (!_this.isEmpty(ret.data)) {
  395. this.tableData = ret.data;
  396. }
  397. }
  398. },
  399. fail: (err) => {
  400. // console.log('request fail', err);
  401. },
  402. complete: () => {
  403. // console.log('complete');
  404. }
  405. })
  406. },
  407. getUserInfoWareHouse() {
  408. uni.request({
  409. url: reqRootUrl + '/getUserInfoWareHouse',
  410. method: 'POST',
  411. async: false,
  412. success: (ret) => {
  413. _this.warehouse_id = ret.data;
  414. uni.setStorageSync("warehouse_id", ret.data)
  415. },
  416. fail: (err) => {
  417. // console.log('request fail', err);
  418. },
  419. complete: () => {
  420. // console.log('complete');
  421. }
  422. })
  423. },
  424. alertInfo(str) {
  425. SpeechTTS.speak({
  426. text: str,
  427. });
  428. modal.toast({
  429. message: str,
  430. duration: 6,
  431. });
  432. },
  433. isEmpty: function(obj) {
  434. return typeof obj === undefined || obj == null || obj === "" || obj ===
  435. "000000000000000000000000" ||
  436. obj.length === 0;
  437. },
  438. },
  439. }
  440. </script>
  441. <style scoped>
  442. .nvue-page-root {
  443. background-color: #F8F8F8;
  444. padding-bottom: 0px;
  445. }
  446. .uni-form-item__title {
  447. margin: 5px auto;
  448. }
  449. .uni-input-wrapper {
  450. /* #ifndef APP-NVUE */
  451. display: flex;
  452. /* #endif */
  453. flex-direction: row;
  454. flex-wrap: nowrap;
  455. background-color: #FFFFFF;
  456. }
  457. .uni-input {
  458. height: 28px;
  459. line-height: 28px;
  460. font-size: 15px;
  461. padding: 1px;
  462. flex: 1;
  463. border-radius: 5px;
  464. border: 1px solid #cfdadd;
  465. background-color: #FFFFFF;
  466. }
  467. .mini-btn {
  468. height: 30px;
  469. padding-left: 1px;
  470. padding-right: 1px;
  471. }
  472. .uni-eye-active {
  473. color: #007AFF;
  474. }
  475. .table-title {
  476. background-color: aliceblue;
  477. font-weight: 700;
  478. margin-top: 10px;
  479. height: 40px;
  480. }
  481. .table-data {
  482. background-color: aliceblue;
  483. font-weight: 700;
  484. margin-top: 1px;
  485. height: 40px;
  486. }
  487. .tab-tr {
  488. width: 25%;
  489. line-height: 25px;
  490. border-right: 1px solid #ccc;
  491. margin: auto;
  492. text-align: center;
  493. }
  494. .tab-tr-end {
  495. width: 25%;
  496. line-height: 25px;
  497. border-right: 0px solid #ccc;
  498. margin: auto;
  499. text-align: center;
  500. }
  501. </style>
  502. <style lang="scss">
  503. $color-base: #0039a6;
  504. $words-color-base: #333333;
  505. $words-color-light: #999999;
  506. .header-wrap {
  507. width: 100%;
  508. position: fixed;
  509. top: 0;
  510. z-index: 999;
  511. .index-header {
  512. height: 88upx;
  513. line-height: 88upx;
  514. padding: 0 30upx;
  515. padding-top: 40upx;
  516. background-color: $color-base;
  517. font-Size: 28upx;
  518. color: #fff;
  519. display: flex;
  520. align-items: center;
  521. justify-content: space-between;
  522. .fanhui {
  523. color: #fff !important;
  524. font-size: 28px;
  525. padding-top: 5px;
  526. font-weight: 700;
  527. }
  528. .lanya {
  529. color: #fff !important;
  530. font-size: 28px;
  531. padding-top: 5px;
  532. }
  533. .map-wrap {
  534. padding-top: 5px;
  535. }
  536. }
  537. }
  538. .blank {
  539. height: 126upx;
  540. }
  541. // 购物车列表
  542. .cart-list {
  543. padding: 0 5rpx;
  544. // 购物车商品
  545. .goods {
  546. display: flex;
  547. padding: 5rpx;
  548. border-radius: 10rpx;
  549. background-color: #fff;
  550. position: relative;
  551. .meta {
  552. // border:1px solid red;
  553. flex: 1;
  554. display: flex;
  555. flex-direction: column;
  556. justify-content: space-between;
  557. margin-left: 5rpx;
  558. }
  559. .name {
  560. height: auto;
  561. font-size: 18px;
  562. color: #000000;
  563. }
  564. .specs {
  565. line-height: 2;
  566. padding: 0 15rpx;
  567. font-size: 16px;
  568. align-self: flex-start;
  569. border-radius: 4rpx;
  570. color: #888;
  571. background-color: #f7f7f8;
  572. }
  573. .status_view {
  574. line-height: 1;
  575. font-size: 18px;
  576. color: #444;
  577. margin-bottom: 2rpx;
  578. color: #000000;
  579. padding-top: 5px;
  580. }
  581. // 商品数量
  582. .numGroup {
  583. // border: 1px solid green;
  584. // position: absolute;
  585. // bottom: 70rpx;
  586. // right: 5rpx;
  587. display: flex;
  588. justify-content: space-between;
  589. align-items: center;
  590. // width: 120px;
  591. height: 48rpx;
  592. .text_1 {
  593. // border: 1px solid red;
  594. width: 50px;
  595. height: 100%;
  596. padding: 0 5rpx;
  597. font-size: 15px;
  598. color: #444;
  599. }
  600. .text {
  601. height: 100%;
  602. padding: 0 5rpx;
  603. font-size: 32rpx;
  604. color: #444;
  605. }
  606. .inputs {
  607. // border: 1px solid blue;
  608. height: 100%;
  609. padding-bottom: 10px;
  610. text-align: center;
  611. border-radius: 4rpx;
  612. font-size: 20px;
  613. color: #ff0000;
  614. // background-color: #f6f6f6;
  615. }
  616. }
  617. }
  618. .cart-swipe {
  619. display: block;
  620. margin: 20rpx 0;
  621. }
  622. }
  623. </style>