product.vue 16 KB

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