scancodeout.vue 10 KB

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