scancodeout.vue 10 KB

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