scancodeout.vue 13 KB

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