index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class='container '>
  3. <view class='content'>
  4. <view class='item-table' scroll-y v-for="(item,index) in products" :key='index'>
  5. <text class='title'>{{title}}</text>
  6. <view class="uni-row table-layout">
  7. <text class='tbhead left'>产品描述</text>
  8. <text class='tbhead right'>{{item['productDescription']}}</text>
  9. </view>
  10. <view class="uni-row table-layout">
  11. <text class='tbbody left'>批次</text>
  12. <text class='tbbody right'>{{item['lotCode']}}</Text>
  13. </view>
  14. <view class="uni-row table-layout">
  15. <text class='tbbody left'>箱数</text>
  16. <text class='tbbody right'>{{item['carriers']}}</Text>
  17. </view>
  18. <view class="uni-row table-layout">
  19. <text class='tbbody left'>箱号</text>
  20. <text class='tbbody right'>{{item['carrierName']}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class='btn uni-row'>
  25. <button class='bottom-btn left-btn' type="primary" @click="handleScanCode">扫码添加</button>
  26. <button class='bottom-btn right-btn' type="primary" @click="handleConfirmReceipt">确定接收</button>
  27. </view>
  28. </view>
  29. <dialog-confirm ref="confirm" @submit="handleDoIt"></dialog-confirm>
  30. </template>
  31. <script setup>
  32. import {
  33. ref
  34. } from 'vue'
  35. import {
  36. onLoad
  37. } from '@dcloudio/uni-app'
  38. import {
  39. getDayworkItemByCarrierId,
  40. updateDayWorkItemBatch
  41. } from '@/api/business/dayWorkItem.js'
  42. import {
  43. store
  44. } from '@/store/index.js'
  45. const title = ref('热处理')
  46. const sum = ref(0)
  47. const products = ref([])
  48. const confirm = ref(null)
  49. onLoad(() => {
  50. })
  51. function handleScanCode() {
  52. uni.scanCode({
  53. scanType: ['qrCode'],
  54. onlyFromCamera: true, // 只允许相机扫码
  55. success: function(res) {
  56. console.log(res.result)
  57. let vehicleObj = JSON.parse(res.result);
  58. getDayworkItemByCarrierId({
  59. carrierId: vehicleObj.carrierId,
  60. status: 6
  61. }).then(response => {
  62. for (let i = 0; i < products.value.length; i++) {
  63. if (Object.entries(products.value[i]).toString() === Object.entries(res
  64. .data)
  65. .toString()) {
  66. uni.showToast({
  67. icon: "error",
  68. title: "该批次已存在"
  69. })
  70. console.log("该批次已存在")
  71. return;
  72. }
  73. }
  74. products.value.push(response.data);
  75. for (let i = 0; i < products.value.length; i++) {
  76. products.value[i].carriers = products.value[i].carrierName.split('、')
  77. .length;
  78. }
  79. console.log(products.value)
  80. })
  81. }
  82. });
  83. }
  84. function handleConfirmReceipt() {
  85. if (products.value.length > 0) {
  86. let msg = "是否确认接收";
  87. confirm.value.open(msg);
  88. }
  89. }
  90. function handleDoReceipt() {
  91. // 设置周转状态
  92. for (var i = 0; i < products.value.length; i++) {
  93. products.value[i].status = '7';
  94. products.value[i].recipientId = store.userInfo.userId;
  95. }
  96. updateDayWorkItemBatch(products.value).then(res => {
  97. if (res.code === 200) {
  98. uni.showToast({
  99. icon: 'success',
  100. title: '操作成功',
  101. duration: 2000
  102. });
  103. init();
  104. } else {
  105. uni.showToast({
  106. icon: 'error',
  107. title: '操作失败',
  108. duration: 2000
  109. });
  110. }
  111. })
  112. products.value = [];
  113. }
  114. function handleDoIt() {
  115. handleDoReceipt();
  116. }
  117. </script>
  118. <style lang="scss">
  119. .container {
  120. height: 100%;
  121. overflow: auto;
  122. background-color: rgba(245, 245, 245, 1);
  123. .content {
  124. width: 94%;
  125. /* height: auto; */
  126. background-color: rgba(255, 255, 255, 1);
  127. margin: 50rpx auto;
  128. border-radius: 12rpx;
  129. .title {
  130. margin: 10rpx auto;
  131. width: 90%;
  132. font-size: 36rpx;
  133. font-weight: bold;
  134. }
  135. .item-table {
  136. margin: 10rpx auto;
  137. width: 90%;
  138. .table-layout {
  139. background-color: rgba(236, 245, 255, 1);
  140. align-items: center;
  141. .tbhead {
  142. background-color: rgba(236, 245, 255, 1);
  143. font-size: 28rpx;
  144. height: 56rpx;
  145. line-height: 56rpx;
  146. padding-left: 6rpx;
  147. border-bottom: 1px solid lightgray;
  148. }
  149. .tbbody {
  150. font-size: 28rpx;
  151. background-color: rgba(238, 240, 245, 1);
  152. width: 70%;
  153. height: 56rpx;
  154. line-height: 56rpx;
  155. padding-left: 6rpx;
  156. border-bottom: 1px solid lightgray;
  157. }
  158. .left {
  159. color: rgba(136, 136, 136, 1);
  160. flex: 1;
  161. }
  162. .right {
  163. flex: 3;
  164. }
  165. }
  166. }
  167. }
  168. .btn {
  169. position: fixed;
  170. right: 0;
  171. bottom: 0;
  172. left: 0;
  173. height: 100rpx;
  174. padding: 16rpx 24rpx;
  175. align-items: center;
  176. background-color: #FFFFFF;
  177. justify-content: space-between;
  178. .bottom-btn {
  179. flex: 1;
  180. font-size: 28rpx;
  181. color: #FFFFFF;
  182. &.left-btn {
  183. // background-color: #a4adb3;
  184. }
  185. &.right-btn {
  186. background-color: #1684fc;
  187. margin-left: 24rpx;
  188. }
  189. }
  190. }
  191. }
  192. </style>