index.vue 13 KB

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