index.vue 10.0 KB

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