index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <!-- 入库扫码 -->
  2. <template>
  3. <view class="content">
  4. <view class="text-area">
  5. <scan @getCode="getScanCode" />
  6. </view>
  7. <view class="stripe"></view>
  8. <view class="roll">
  9. <view>
  10. <view @click="show =! show">
  11. <u-icon name="edit-pen"></u-icon>手动录入
  12. </view>
  13. <view class="lnput" v-if="show==false">
  14. <input type="text" v-model="number_a" :placeholder="content" clearable="true" focus="true"/>
  15. <u-button type="primary" size="medium" @click="manualentry">确认录入</u-button>
  16. </view>
  17. <view class="" v-else>
  18. <view>{{tips}}:{{number}}</view>
  19. </view>
  20. </view>
  21. <view>
  22. <view></view>
  23. <view></view>
  24. <view style="width: 94%;height: 20px;background-color: #FFFFFF;margin: 0 auto;margin-top: -3rpx;border-radius: 0;">
  25. <image src="../../../static/sailun/line.png" style="width: 96%;height: 1rpx;;" mode=""></image>
  26. </view>
  27. </view>
  28. <view class="generate">
  29. <u-table font-size="24" border-color="#ffffff" bg-color="#fff">
  30. <u-tr class="u-tr">
  31. <u-th class="u-th" width="30%">胎号</u-th>
  32. <u-th class="u-th">规格</u-th>
  33. <u-th class="u-th" width="15%">操作</u-th>
  34. </u-tr>
  35. <u-tr class="u-tr" v-for="(item, index) in lisi" :key="index">
  36. <u-td class="u-td" width="30%">{{item.tireNumber}}</u-td>
  37. <u-td class="u-td">{{item.maktx}}</u-td>
  38. <u-td class="u-td" width="15%"><text @click="confirm(index)" style="color: #FA3534;">删除</text></u-td>
  39. </u-tr>
  40. </u-table>
  41. <u-divider color="rgb(144, 147, 153)" half-width="200" border-color="rgb(144, 147, 153)" margin-top="40">没有更多了</u-divider>
  42. </view>
  43. </view>
  44. <view class="determine">
  45. <u-button type="primary" shape="circle" @click="scancodein">扫码确认</u-button>
  46. </view>
  47. <view>
  48. </view>
  49. <u-toast ref="repeat" position="bottom" />
  50. <u-popup mode="bottom" v-model="show_s" :mask-close-able="false" :safe-area-inset-bottom="true">
  51. <view class="confrim-btn">
  52. <u-button @click="show_s = false;" style="float: left;border: none;" :hair-line="false" :plain="false">取消</u-button>
  53. <u-button @click="container" style="float: right;border: none;" :hair-line="false" :plain="false">确定</u-button>
  54. </view>
  55. <view class="content_s">
  56. <scroll-view scroll-y="true" style="height: 200rpx;">
  57. {{regular}}
  58. </scroll-view>
  59. </view>
  60. </u-popup>
  61. <u-popup mode="bottom" v-model="show_d" :mask-close-able="false" :safe-area-inset-bottom="true">
  62. <view class="confrim-btn">
  63. <u-button @click="show_d = false;" style="float: left;border: none;" :hair-line="false" :plain="false">取消</u-button>
  64. <u-button @click="container_s" style="float: right;border: none;" :hair-line="false" :plain="false">确定</u-button>
  65. </view>
  66. <view class="content_s">
  67. <scroll-view scroll-y="true" style="height: 200rpx;">
  68. {{regular}}
  69. </scroll-view>
  70. </view>
  71. </u-popup>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. request
  77. } from '../../../common/request/request'
  78. require("promise.prototype.finally").shim()
  79. export default {
  80. data() {
  81. return {
  82. tips: '提示',
  83. number: '请扫码入库',
  84. nbTitle: '扫码标题',
  85. content: '请输入轮胎胎号',
  86. number_s: '',
  87. number_a: '',
  88. regular: '轮胎非正规是否入库',
  89. lisi: [],
  90. background: {
  91. backgroundColor: '#0094fe',
  92. },
  93. show: true,
  94. show_s: false,
  95. show_d: false,
  96. res: '',
  97. }
  98. },
  99. onBackPress(options) {
  100. console.log(options)
  101. if (options.from == 'backbutton') {
  102. this.$u.route({
  103. type: 'switchTab',
  104. url: 'pages/home/index'
  105. })
  106. }
  107. return true;
  108. },
  109. onLaunch() {
  110. uni.$on('update', data => {
  111. this.lisi = data.lisi
  112. console.log(this.lisi)
  113. })
  114. },
  115. created() {
  116. uni.getNetworkType({
  117. success: function(res) {
  118. let none = res.networkType
  119. console.log(res.networkType);
  120. if (none == 'none') {
  121. uni.showToast({
  122. icon: 'none',
  123. title: '无网络,请连接网络后再试~',
  124. position: "bottom"
  125. })
  126. }
  127. }
  128. });
  129. uni.$on('data', res => {
  130. this.lisi = res.lisi
  131. console.log(res.lisi)
  132. })
  133. const innerAudioContext = uni.createInnerAudioContext();
  134. innerAudioContext.autoplay = true;
  135. innerAudioContext.src = '../../../static/mp3/startscan.mp3';
  136. innerAudioContext.onPlay(() => {
  137. console.log('开始播放');
  138. });
  139. innerAudioContext.onError((res) => {
  140. console.log(res.errMsg);
  141. console.log(res.errCode);
  142. });
  143. },
  144. methods: {
  145. //手动录入调用
  146. manualentry() {
  147. request({
  148. url: '/storeScan/storeScanGetTyre',
  149. method: 'Post',
  150. data: {
  151. storeId: this.$store.state.storeInfo.storeId,
  152. userId: this.$store.state.storeInfo.userId,
  153. tyreNum: this.number_a
  154. }
  155. }).then(res => {
  156. console.log(res.data.code)
  157. if (res.data.code == 500) {
  158. this.$refs.repeat.show({
  159. title: '请扫描或输入正确的胎号',
  160. type: 'default',
  161. position: 'bottom'
  162. })
  163. return
  164. }
  165. this.res = res
  166. console.log(res.data.data[0].isRegular)
  167. for (let i = 0; i < this.lisi.length; i++) {
  168. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  169. this.$refs.repeat.show({
  170. title: '请勿重复录入',
  171. type: 'default',
  172. position: 'bottom'
  173. })
  174. return
  175. }
  176. }
  177. if (res.data.data[0].isRegular == 1) {
  178. console.log(res.data.data[0].isRegular)
  179. // this.$refs.repeat.show({
  180. // title: '轮胎非正规',
  181. // type: 'default',
  182. // position: 'bottom'
  183. // })
  184. this.show_s = true
  185. return
  186. }
  187. this.container()
  188. console.log(this.lisi)
  189. }).catch(err => {
  190. this.$refs.repeat.show({
  191. title: "无网络,请连接网络后再试~",
  192. type: 'default',
  193. position: 'bottom'
  194. })
  195. console.log(err)
  196. })
  197. .finally(() => {
  198. // Loading.close()
  199. })
  200. },
  201. container() {
  202. this.$refs.repeat.show({
  203. title: '录入成功',
  204. type: 'success',
  205. position: 'bottom'
  206. })
  207. console.log(this.res.data.data[0].specs)
  208. this.show_s = false
  209. console.log(this.show_s)
  210. this.number_a = ''
  211. console.log("我成功啦.")
  212. this.lisi.push({
  213. specs: this.res.data.data[0].specs,
  214. flagRegular: this.res.data.data[0].isRegular,
  215. diameter: this.res.data.data[0].diameter,
  216. maktx: this.res.data.data[0].maktx,
  217. pattern: this.res.data.data[0].pattern,
  218. soldToPartyKunnr: this.res.data.data[0].soldToPartyKunnr,
  219. matnr: this.res.data.data[0].matnr,
  220. tireNumber: this.res.data.data[0].tirenumber,
  221. brand: this.res.data.data[0].brand,
  222. shippedDate: this.res.data.data[0].shippedDate,
  223. plyRating: this.res.data.data[0].plyRating,
  224. scanWay: '0'
  225. })
  226. console.log(this.lisi)
  227. },
  228. //获取扫码控件
  229. getScanCode(val) {
  230. uni.getNetworkType({
  231. success: function(res) {
  232. let none = res.networkType
  233. console.log(res.networkType);
  234. if (none == 'none') {
  235. uni.showToast({
  236. icon: 'none',
  237. title: '无网络,请连接网络后再试~',
  238. position: "bottom"
  239. })
  240. }
  241. }
  242. });
  243. console.log(val)
  244. this.number = val
  245. this.number_s = val
  246. request({
  247. url: '/storeScan/storeScanGetTyre',
  248. method: 'Post',
  249. data: {
  250. storeId: this.$store.state.storeInfo.storeId,
  251. userId: this.$store.state.storeInfo.userId,
  252. tyreNum: this.number_s
  253. }
  254. }).then(res => {
  255. this.res_s = res
  256. this.tips = "胎号"
  257. for (let i = 0; i < this.lisi.length; i++) {
  258. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  259. this.$refs.repeat.show({
  260. title: '请勿重复扫码',
  261. type: 'default',
  262. position: 'bottom'
  263. })
  264. this.repeated()
  265. return
  266. }
  267. }
  268. if (res.data.code == 500) {
  269. this.$refs.repeat.show({
  270. title: '请扫描或输入正确的胎号',
  271. type: 'default',
  272. position: 'bottom'
  273. })
  274. const innerAudioContext = uni.createInnerAudioContext();
  275. innerAudioContext.autoplay = true;
  276. innerAudioContext.src = '../../../static/mp3/scanfailed.mp3';
  277. innerAudioContext.onPlay(() => {
  278. console.log('开始播放');
  279. });
  280. innerAudioContext.onError((res) => {
  281. console.log(res.errMsg);
  282. console.log(res.errCode);
  283. });
  284. return
  285. }
  286. if (res.data.data[0].isRegular == 1) {
  287. console.log(res.data.data[0].isRegular)
  288. // this.$refs.repeat.show({
  289. // title: '轮胎非正规',
  290. // type: 'default',
  291. // position: 'bottom'
  292. // })
  293. this.show_d = true
  294. return
  295. }
  296. this.container_s()
  297. console.log(this.lisi)
  298. }).catch(err => {
  299. if (code == 400) {
  300. this.$refs.repeat.show({
  301. title: "无网络",
  302. type: 'default',
  303. position: 'bottom'
  304. })
  305. } else {
  306. this.$refs.repeat.show({
  307. title: "请重新扫码",
  308. type: 'default',
  309. position: 'bottom'
  310. })
  311. this.repeated()
  312. }
  313. console.log(err)
  314. })
  315. .finally(() => {
  316. // Loading.close()
  317. })
  318. },
  319. container_s() {
  320. this.show_d = false
  321. console.log(this.show_s)
  322. console.log("什么????")
  323. this.number_s = ''
  324. console.log("我成功啦")
  325. console.log(this.res_s)
  326. this.lisi.push({
  327. specs: this.res_s.data.data[0].specs,
  328. flagRegular: this.res_s.data.data[0].isRegular,
  329. diameter: this.res_s.data.data[0].diameter,
  330. maktx: this.res_s.data.data[0].maktx,
  331. pattern: this.res_s.data.data[0].pattern,
  332. soldToPartyKunnr: this.res_s.data.data[0].soldToPartyKunnr,
  333. matnr: this.res_s.data.data[0].matnr,
  334. tireNumber: this.res_s.data.data[0].tirenumber,
  335. brand: this.res_s.data.data[0].brand,
  336. shippedDate: this.res_s.data.data[0].shippedDate,
  337. plyRating: this.res_s.data.data[0].plyRating,
  338. scanWay: '1'
  339. })
  340. console.log(this.lisi)
  341. const innerAudioContext = uni.createInnerAudioContext();
  342. innerAudioContext.autoplay = true;
  343. innerAudioContext.src = '../../../static/mp3/scansuccess.mp3';
  344. innerAudioContext.onPlay(() => {
  345. console.log('开始播放');
  346. });
  347. innerAudioContext.onError((res) => {
  348. console.log(res.errMsg);
  349. console.log(res.errCode);
  350. });
  351. this.$refs.repeat.show({
  352. title: '扫码成功',
  353. type: 'success',
  354. position: 'bottom'
  355. })
  356. },
  357. confirm(index) {
  358. console.log(index + "什么情况")
  359. this.lisi.splice(index, 1)
  360. },
  361. scancodein() {
  362. if (this.lisi == '') {
  363. this.$refs.repeat.show({
  364. title: '请扫码或录入后再点击!',
  365. type: 'default',
  366. position: 'bottom'
  367. })
  368. } else {
  369. this.$u.route({
  370. type: 'redirectTo',
  371. url: 'pages/home/Scan-code-in/index'
  372. })
  373. uni.$emit('update', {
  374. materialList: this.lisi
  375. })
  376. }
  377. },
  378. repeated() {
  379. const innerAudioContext = uni.createInnerAudioContext();
  380. innerAudioContext.autoplay = true;
  381. innerAudioContext.src = '../../../static/mp3/rescan.mp3';
  382. innerAudioContext.onPlay(() => {
  383. console.log('开始播放');
  384. });
  385. innerAudioContext.onError((res) => {
  386. console.log(res.errMsg);
  387. console.log(res.errCode);
  388. });
  389. }
  390. }
  391. }
  392. </script>
  393. <style lang="scss" scoped>
  394. .lnput>input {
  395. background-color: none;
  396. width: 60%;
  397. font-size: 42rpx;
  398. float: left;
  399. margin-top: 10rpx;
  400. margin-left: 20rpx;
  401. }
  402. .generate {
  403. width: 98%;
  404. height: 300rpx;
  405. overflow: auto;
  406. margin: 0 auto;
  407. margin-top: 120rpx;
  408. }
  409. .determine {
  410. width: 690rpx;
  411. margin-top: 30rpx;
  412. }
  413. .content {
  414. display: flex;
  415. flex-direction: column;
  416. align-items: center;
  417. justify-content: center;
  418. // background-color: #F29100;
  419. padding-top: 400px;
  420. }
  421. .content_s {
  422. padding: 24rpx;
  423. text-align: center;
  424. }
  425. .logo {
  426. height: 200rpx;
  427. width: 200rpx;
  428. margin-top: 200rpx;
  429. margin-left: auto;
  430. margin-right: auto;
  431. margin-bottom: 50rpx;
  432. }
  433. .stripe {
  434. width: 740rpx;
  435. height: 30rpx;
  436. background-color: #00A0EA;
  437. border-radius: 12rpx;
  438. margin: 0 auto;
  439. margin-top: -100rpx;
  440. }
  441. .text-area {
  442. width: 100%;
  443. display: flex;
  444. background-color: #000000;
  445. position: static;
  446. justify-content: center;
  447. padding-top: 180rpx;
  448. }
  449. .title {
  450. font-size: 36rpx;
  451. color: #8f8f94;
  452. }
  453. .roll {
  454. width: 710rpx;
  455. height: auto;
  456. background: #FFFFFF;
  457. margin: 0 auto;
  458. margin-top: -15rpx;
  459. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(101, 176, 249, 0.3);
  460. border-bottom-left-radius: 10rpx;
  461. border-bottom-right-radius: 10rpx;
  462. padding-top: 50rpx;
  463. padding-bottom: 50rpx;
  464. }
  465. .roll>view:nth-child(1)>view:nth-child(2) {
  466. font-size: 42rpx;
  467. font-weight: bold;
  468. color: #0192FD;
  469. text-align: center;
  470. margin-bottom: 50rpx;
  471. }
  472. .roll>view:nth-child(1)>view:nth-child(1) {
  473. width: 200rpx;
  474. color: #0094FE;
  475. position: relative;
  476. top: -40rpx;
  477. left: 500rpx;
  478. font-size: 32rpx;
  479. text-align: center;
  480. }
  481. .roll>view:nth-child(2)>view {
  482. width: 40rpx;
  483. height: 40rpx;
  484. background-color: #F4F4F4;
  485. border-radius: 100%;
  486. float: right;
  487. margin-right: -20rpx;
  488. }
  489. .roll>view:nth-child(2)>view:nth-child(1) {
  490. float: left;
  491. margin-left: -20rpx;
  492. }
  493. .status_bar {
  494. height: var(--status-bar-height);
  495. width: 100%;
  496. background-color: #0095FF;
  497. }
  498. </style>