index.vue 13 KB

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