index.vue 10 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: this.$store.state.storeInfo.storeId,
  93. userId: this.$store.state.storeInfo.userId,
  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: this.$store.state.storeInfo.storeId,
  167. userId: this.$store.state.storeInfo.userId,
  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. this.repeated()
  180. return
  181. }
  182. }
  183. if (res.data.code == 500) {
  184. this.$refs.repeat.show({
  185. title: res.data.msg,
  186. type: 'default',
  187. position: 'bottom'
  188. })
  189. const innerAudioContext = uni.createInnerAudioContext();
  190. innerAudioContext.autoplay = true;
  191. innerAudioContext.src = '../../../static/mp3/scanfailed.mp3';
  192. innerAudioContext.onPlay(() => {
  193. console.log('开始播放');
  194. });
  195. innerAudioContext.onError((res) => {
  196. console.log(res.errMsg);
  197. console.log(res.errCode);
  198. });
  199. return
  200. }
  201. this.number_s = ""
  202. console.log("我成功啦")
  203. console.log(res)
  204. this.lisi.push({
  205. specs: res.data.data[0].specs,
  206. flagRegular: res.data.data[0].isRegular,
  207. diameter: res.data.data[0].diameter,
  208. maktx: res.data.data[0].maktx,
  209. pattern: res.data.data[0].pattern,
  210. soldToPartyKunnr: res.data.data[0].soldToPartyKunnr,
  211. matnr: res.data.data[0].matnr,
  212. tireNumber: res.data.data[0].tirenumber,
  213. brand: res.data.data[0].brand,
  214. shippedDate: res.data.data[0].shippedDate,
  215. plyRating: res.data.data[0].plyRating,
  216. scanWay: '1'
  217. })
  218. const innerAudioContext = uni.createInnerAudioContext();
  219. innerAudioContext.autoplay = true;
  220. innerAudioContext.src = '../../../static/mp3/scansuccess.mp3';
  221. innerAudioContext.onPlay(() => {
  222. console.log('开始播放');
  223. });
  224. innerAudioContext.onError((res) => {
  225. console.log(res.errMsg);
  226. console.log(res.errCode);
  227. });
  228. this.$refs.repeat.show({
  229. title: '扫码成功',
  230. type: 'success',
  231. position: 'bottom'
  232. })
  233. console.log(this.lisi)
  234. }).catch(err => {
  235. if (code == 400) {
  236. this.$refs.repeat.show({
  237. title: "无网络",
  238. type: 'default',
  239. position: 'bottom'
  240. })
  241. } else {
  242. this.$refs.repeat.show({
  243. title: "请重新扫码",
  244. type: 'default',
  245. position: 'bottom'
  246. })
  247. this.repeated()
  248. }
  249. console.log(err)
  250. })
  251. .finally(() => {
  252. // Loading.close()
  253. })
  254. },
  255. confirm(index) {
  256. console.log(index + "什么情况")
  257. this.lisi.splice(index, 1)
  258. },
  259. scancodein() {
  260. if (this.lisi == '') {
  261. this.$refs.repeat.show({
  262. title: '请扫码或录入后再点击!',
  263. type: 'default',
  264. position: 'bottom'
  265. })
  266. } else {
  267. this.$u.route({
  268. type: 'redirectTo',
  269. url: 'pages/home/Scan-code-in/index'
  270. })
  271. uni.$emit('update', {
  272. materialList: this.lisi
  273. })
  274. this.lisi = []
  275. }
  276. },
  277. repeated() {
  278. const innerAudioContext = uni.createInnerAudioContext();
  279. innerAudioContext.autoplay = true;
  280. innerAudioContext.src = '../../../static/mp3/rescan.mp3';
  281. innerAudioContext.onPlay(() => {
  282. console.log('开始播放');
  283. });
  284. innerAudioContext.onError((res) => {
  285. console.log(res.errMsg);
  286. console.log(res.errCode);
  287. });
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="scss" scoped>
  293. .lnput>input {
  294. background-color: none;
  295. width: 60%;
  296. font-size: 42rpx;
  297. float: left;
  298. margin-top: 10rpx;
  299. margin-left: 20rpx;
  300. }
  301. .generate {
  302. width: 98%;
  303. height: 300rpx;
  304. overflow: auto;
  305. margin: 0 auto;
  306. margin-top: 120rpx;
  307. }
  308. .determine {
  309. width: 690rpx;
  310. margin-top: 30rpx;
  311. }
  312. .content {
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. justify-content: center;
  317. // background-color: #F29100;
  318. padding-top: 400px;
  319. }
  320. .logo {
  321. height: 200rpx;
  322. width: 200rpx;
  323. margin-top: 200rpx;
  324. margin-left: auto;
  325. margin-right: auto;
  326. margin-bottom: 50rpx;
  327. }
  328. .stripe {
  329. width: 740rpx;
  330. height: 30rpx;
  331. background-color: #00A0EA;
  332. border-radius: 12rpx;
  333. margin: 0 auto;
  334. margin-top: -100rpx;
  335. }
  336. .text-area {
  337. width: 100%;
  338. display: flex;
  339. background-color: #000000;
  340. position: static;
  341. justify-content: center;
  342. padding-top: 180rpx;
  343. }
  344. .title {
  345. font-size: 36rpx;
  346. color: #8f8f94;
  347. }
  348. .roll {
  349. width: 710rpx;
  350. height: auto;
  351. background: #FFFFFF;
  352. margin: 0 auto;
  353. margin-top: -15rpx;
  354. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(101, 176, 249, 0.3);
  355. border-bottom-left-radius: 10rpx;
  356. border-bottom-right-radius: 10rpx;
  357. padding-top: 50rpx;
  358. padding-bottom: 50rpx;
  359. }
  360. .roll>view:nth-child(1)>view:nth-child(2) {
  361. font-size: 42rpx;
  362. font-weight: bold;
  363. color: #0192FD;
  364. text-align: center;
  365. margin-bottom: 50rpx;
  366. }
  367. .roll>view:nth-child(1)>view:nth-child(1) {
  368. width: 200rpx;
  369. color: #0094FE;
  370. position: relative;
  371. top: -40rpx;
  372. left: 500rpx;
  373. font-size: 32rpx;
  374. text-align: center;
  375. }
  376. .roll>view:nth-child(2)>view {
  377. width: 40rpx;
  378. height: 40rpx;
  379. background-color: #F4F4F4;
  380. border-radius: 100%;
  381. float: right;
  382. margin-right: -20rpx;
  383. }
  384. .roll>view:nth-child(2)>view:nth-child(1) {
  385. float: left;
  386. margin-left: -20rpx;
  387. }
  388. .status_bar {
  389. height: var(--status-bar-height);
  390. width: 100%;
  391. background-color: #0095FF;
  392. }
  393. </style>