index.vue 11 KB

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