iceCold.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view>
  3. <u-navbar title="冰排释冷" autoBack placeholder></u-navbar>
  4. <view class="card_order_details">
  5. <view class="card_search">
  6. <view class="details_title">冰排编号 <span class="line_title">*</span></view>
  7. <view class="card_input">
  8. <u-input border="surround" v-model="frequencyCoding">
  9. <template slot="suffix">
  10. <u-icon name="scan" size="24" @click="sweep"></u-icon>
  11. </template>
  12. </u-input>
  13. </view>
  14. <view class="add_card center_in" @click="addIce">
  15. <u-icon name="plus" size="18"></u-icon>
  16. </view>
  17. </view>
  18. <view class="card_frequency">
  19. <view class="card_high space_between">
  20. <view class="card_frequency_title">已录入冰排编号</view>
  21. <view class="card_bottle">已扫<span>{{list.length}}</span></view>
  22. </view>
  23. <view style="width: 100%;" v-if="list.length > 0">
  24. <view class="item_coding" v-for="(item,index) in list" :key="index">
  25. <view class="title_coding">{{item}}</view>
  26. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  27. @click="removeWaybill(item)"></u-icon>
  28. </view>
  29. </view>
  30. </view>
  31. <view style="width: 100%;height: 120rpx;"></view>
  32. <view class="card_btn">
  33. <u-button style="margin-bottom: 20rpx;" type="primary" @click="submit">提交</u-button>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. frequencyCoding: '',
  43. list: [],
  44. }
  45. },
  46. methods: {
  47. submit() {
  48. },
  49. // 扫一扫
  50. sweep() {
  51. // 允许从相机和相册扫码
  52. uni.scanCode({
  53. scanType: ['barCode'],
  54. // scanType: ['qrCode'],
  55. autoZoom: false,
  56. success: (res) => {
  57. console.log(res);
  58. if (res.result) {
  59. let url = res.result;
  60. this.frequencyCoding = url
  61. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  62. if (res.code == 200) {
  63. this.list.push(url)
  64. function methods1(arr) {
  65. return Array.from(new Set(arr));
  66. }
  67. this.list = methods1(this.list)
  68. } else {
  69. uni.showToast({
  70. icon: 'none',
  71. title: res.msg,
  72. duration: 3000
  73. });
  74. }
  75. })
  76. } else {
  77. console.log('请重新扫描');
  78. return false;
  79. }
  80. },
  81. fail: (res) => {
  82. console.log('未识别到条形码');
  83. }
  84. })
  85. },
  86. // 添加冰排
  87. addIce() {
  88. if (this.frequencyCoding) {
  89. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  90. if (res.code == 200) {
  91. this.list.push(this.frequencyCoding)
  92. this.list = this.uniqueArray(this.list)
  93. this.frequencyCoding = ''
  94. } else {
  95. uni.showToast({
  96. icon: 'none',
  97. title: res.msg,
  98. duration: 3000
  99. });
  100. }
  101. })
  102. }
  103. },
  104. // 去重
  105. uniqueArray(arr) {
  106. return [...new Set(arr)];
  107. },
  108. // 移除错误运单号
  109. removeWaybill(value) {
  110. if (this.frequencyCoding == value) {
  111. this.frequencyCoding = ''
  112. }
  113. const arr = deleteElementById(this.list, value)
  114. this.list = arr
  115. function deleteElementById(arr, key) {
  116. return arr.filter((item) => item !== key);
  117. }
  118. },
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. page {
  124. background-color: #fff !important;
  125. }
  126. .card_order_details {
  127. margin: 10rpx 30rpx 30rpx 30rpx;
  128. }
  129. .card_search {
  130. display: flex;
  131. align-items: center;
  132. margin: 20rpx 0rpx;
  133. }
  134. .details_title {
  135. width: 150rpx;
  136. flex: none;
  137. color: #333;
  138. font-size: 32rpx;
  139. font-weight: 500;
  140. margin-bottom: 10rpx;
  141. // margin-right: 15rpx;
  142. }
  143. .line_title {
  144. color: red;
  145. }
  146. .card_input {
  147. width: 100%;
  148. margin-left: 30rpx;
  149. }
  150. .add_card {
  151. margin-left: 10rpx;
  152. width: 50rpx;
  153. height: 46rpx;
  154. border-radius: 8rpx;
  155. padding: 6px 9px;
  156. border: 1px solid #dadbde;
  157. }
  158. .card_high {
  159. margin-top: 20rpx;
  160. }
  161. .card_frequency {
  162. display: flex;
  163. flex-wrap: wrap;
  164. }
  165. .card_frequency_title {
  166. font-size: 32rpx;
  167. }
  168. .card_bottle {
  169. font-size: 30rpx;
  170. span {
  171. color: red;
  172. }
  173. }
  174. .item_coding {
  175. display: flex;
  176. justify-content: space-between;
  177. align-items: center;
  178. width: 100%;
  179. margin-top: 10px;
  180. padding: 25rpx 0rpx;
  181. border-bottom: 2rpx solid #dfdfdf;
  182. }
  183. .title_coding {
  184. font-size: 30rpx;
  185. }
  186. .card_btn {
  187. position: fixed;
  188. left: 0;
  189. right: 0;
  190. bottom: 0;
  191. padding-left: 30rpx;
  192. padding-right: 30rpx;
  193. padding-top: 20rpx;
  194. background-color: #fff;
  195. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  196. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  197. border-top: 1rpx solid #E4E7ED;
  198. }
  199. </style>