index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. let sum = 0; //总箱数
  76. for (let i = 0; i < products.value.length; i++) {
  77. products.value[i].carriers = products.value[i].carrierName.split('、').length;
  78. sum += products.value[i].carriers;
  79. }
  80. title.value = products.value[0].deptName + ' (' + sum + '箱)';
  81. console.log(products.value)
  82. })
  83. }
  84. });
  85. }
  86. function handleConfirmReceipt() {
  87. if (products.value.length > 0) {
  88. let msg = "是否确认接收";
  89. confirm.value.open(msg);
  90. }
  91. }
  92. function handleDoReceipt() {
  93. // 设置周转状态
  94. for (var i = 0; i < products.value.length; i++) {
  95. products.value[i].status = '7';
  96. products.value[i].recipientId = store.userInfo.userId;
  97. }
  98. updateDayWorkItemBatch(products.value).then(res => {
  99. if (res.code === 200) {
  100. uni.showToast({
  101. icon: 'success',
  102. title: '操作成功',
  103. duration: 2000
  104. });
  105. init();
  106. } else {
  107. uni.showToast({
  108. icon: 'error',
  109. title: '操作失败',
  110. duration: 2000
  111. });
  112. }
  113. })
  114. products.value = [];
  115. }
  116. function handleDoIt() {
  117. handleDoReceipt();
  118. }
  119. </script>
  120. <style lang="scss">
  121. .container {
  122. height: 100%;
  123. overflow: auto;
  124. background-color: rgba(245, 245, 245, 1);
  125. .content {
  126. width: 94%;
  127. /* height: auto; */
  128. background-color: rgba(255, 255, 255, 1);
  129. margin: 50rpx auto;
  130. border-radius: 12rpx;
  131. .title {
  132. margin: 10rpx auto;
  133. width: 90%;
  134. font-size: 36rpx;
  135. font-weight: bold;
  136. }
  137. .item-table {
  138. margin: 10rpx auto;
  139. width: 90%;
  140. .table-layout {
  141. background-color: rgba(236, 245, 255, 1);
  142. align-items: center;
  143. .tbhead {
  144. background-color: rgba(236, 245, 255, 1);
  145. font-size: 28rpx;
  146. height: 56rpx;
  147. line-height: 56rpx;
  148. padding-left: 6rpx;
  149. border-bottom: 1px solid lightgray;
  150. }
  151. .tbbody {
  152. font-size: 28rpx;
  153. background-color: rgba(238, 240, 245, 1);
  154. width: 70%;
  155. height: 56rpx;
  156. line-height: 56rpx;
  157. padding-left: 6rpx;
  158. border-bottom: 1px solid lightgray;
  159. }
  160. .left {
  161. color: rgba(136, 136, 136, 1);
  162. flex: 1;
  163. }
  164. .right {
  165. flex: 3;
  166. }
  167. }
  168. }
  169. }
  170. .btn {
  171. position: fixed;
  172. right: 0;
  173. bottom: 0;
  174. left: 0;
  175. height: 100rpx;
  176. padding: 16rpx 24rpx;
  177. align-items: center;
  178. background-color: #FFFFFF;
  179. justify-content: space-between;
  180. .bottom-btn {
  181. flex: 1;
  182. font-size: 28rpx;
  183. color: #FFFFFF;
  184. &.left-btn {
  185. // background-color: #a4adb3;
  186. }
  187. &.right-btn {
  188. background-color: #1684fc;
  189. margin-left: 24rpx;
  190. }
  191. }
  192. }
  193. }
  194. </style>