index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="uni-column container" >
  3. <scroll-view class="scroll-container" scroll-y>
  4. <view v-for="(item, index) in listData" :key="index" :class="{'list-item':true,'selected':isSelected(item)}">
  5. <!-- @click="handleSelection(item,index)" -->
  6. <view class="title-container uni-row">
  7. <view class="title uni-row">
  8. <text class="label">{{ item['dictDataLabel'] }}</text>
  9. <text class="label code">{{ item['deptName'] }}</text>
  10. <text class="label code" style="margin-left: 16rpx;">→</text>
  11. <text class="label code" style="margin-left: 16rpx;">{{ item['deptName'] }}</text>
  12. </view>
  13. <view class="right-info uni-row">
  14. <view class="uni-row"><text class="label right" @click="handleDeleteTurnover(item)">删除</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="item-info uni-row"> <text class="label ">产品描述</text>
  19. <text class="label right" style="color: #000000;">{{ item['productDescription'] }}</text>
  20. </view>
  21. <view class="item-info uni-row"> <text class="label">批次</text>
  22. <text class="label right ">{{ item['lotCode'] }}</text>
  23. </view>
  24. <view class="item-info uni-row">
  25. <text class="label">箱数</text>
  26. <text class="label right">{{ item['carriers'] }}</text>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">箱号</text>
  30. <text class="label right">{{ item['carrierName']}}</text>
  31. </view>
  32. </view>
  33. </scroll-view>
  34. <view class="bottom uni-row">
  35. <button class="bottom-btn left-btn" @click="HandleScanCode">扫码添加</button>
  36. <button class="bottom-btn right-btn" @click="handleStartTurnover">确认周转</button>
  37. </view>
  38. <dialog-turnoverTask ref="turnoverTaskDialog" />
  39. </view>
  40. <dialog-turnoverTask ref="turnoverTask"></dialog-turnoverTask>
  41. </template>
  42. <script setup>
  43. import {
  44. ref
  45. } from 'vue'
  46. import {
  47. onLoad,
  48. } from '@dcloudio/uni-app'
  49. import { getDayworkItemByCarrierId } from '@/api/business/dayWorkItem.js'
  50. const active = ref(false)
  51. const selection = ref([])
  52. const turnoverTaskDialog = ref(null)
  53. const listData = ref([])
  54. const turnoverTask = ref(null)
  55. onLoad(() => {
  56. })
  57. function init(){
  58. }
  59. function HandleScanCode(){
  60. uni.scanCode({
  61. scanType: ['qrCode'],
  62. onlyFromCamera: true, // 只允许相机扫码
  63. success: function(res) {
  64. console.log(res.result)
  65. let vehicleObj = JSON.parse(res.result);
  66. getDayworkItemByCarrierId({
  67. carrierId: vehicleObj.carrierId,
  68. status: 4
  69. }).then(response => {
  70. for (let i = 0; i < listData.value.length; i++) {
  71. if (Object.entries(listData.value[i]).toString() === Object.entries(res.data).toString()) {
  72. uni.showToast({
  73. icon: "error",
  74. title: "该批次已存在"
  75. })
  76. console.log("该批次已存在")
  77. return;
  78. }
  79. }
  80. listData.value.push(response.data);
  81. for (let i = 0; i < listData.value.length; i++) {
  82. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  83. }
  84. console.log(listData.value)
  85. })
  86. }
  87. });
  88. }
  89. function handleStartTurnover() {
  90. // 调用子组件中的方法
  91. turnoverTask.value.open(listData.value);
  92. }
  93. function isSelected(item) {
  94. return selection.value.includes(item);
  95. }
  96. function handleSelection(item, index) {
  97. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  98. if (buttonIndex > -1) {
  99. selection.value.splice(buttonIndex, 1); // 取消选中
  100. } else {
  101. selection.value.push(item); // 选中
  102. }
  103. console.log(selection.value, "selection");
  104. }
  105. function handleDeleteTurnover(item) {
  106. uni.showModal({
  107. title: '提示', // 标题
  108. content: '是否删除此条周转', // 提示内容
  109. cancelText: "取消", // 取消按钮的文字
  110. confirmText: "确认", // 确认按钮的文字
  111. //点击确定之后执行的代码
  112. success(res) {
  113. if (res.confirm) {
  114. const checkIndex = listData.value.findIndex(selectedItem => selectedItem === item);
  115. if (checkIndex > -1) {
  116. listData.value.splice(checkIndex, 1);
  117. }
  118. }
  119. }
  120. });
  121. }
  122. </script>
  123. <style lang="scss">
  124. .container {
  125. height: 100%;
  126. background-color: #f5f5f5;
  127. }
  128. .scroll-container {
  129. position: absolute;
  130. top: 24rpx;
  131. right: 0;
  132. bottom: 160rpx;
  133. left: 0;
  134. }
  135. .selected {
  136. border: 1px solid #1684fc;
  137. }
  138. .list-item {
  139. background-color: #fff;
  140. position: relative;
  141. padding: 16rpx;
  142. padding-bottom: 24rpx;
  143. margin: 0 24rpx;
  144. margin-bottom: 24rpx;
  145. border-radius: 8rpx;
  146. .title-container {
  147. justify-content: space-between;
  148. margin-top: 8rpx;
  149. margin-bottom: 16rpx;
  150. .title {
  151. height: 48rpx;
  152. align-items: center;
  153. .label {
  154. color: #1684fc;
  155. font-size: 32rpx;
  156. font-weight: bold;
  157. &.code {
  158. color: #000000;
  159. margin-left: 32rpx;
  160. }
  161. }
  162. }
  163. }
  164. .item-info {
  165. margin-bottom: 16rpx;
  166. .label {
  167. font-size: 28rpx;
  168. width: 152rpx;
  169. color: #808080;
  170. &.right {
  171. flex: 1;
  172. color: #808080;
  173. }
  174. }
  175. }
  176. .right-info {
  177. justify-content: flex-end;
  178. margin-top: 2rpx;
  179. .label {
  180. font-size: 28rpx;
  181. color: #ff0000;
  182. }
  183. }
  184. }
  185. .bottom {
  186. position: fixed;
  187. right: 0;
  188. bottom: 0;
  189. left: 0;
  190. height: 100rpx;
  191. padding: 16rpx 24rpx;
  192. align-items: center;
  193. background-color: #FFFFFF;
  194. justify-content: space-between;
  195. .bottom-btn {
  196. flex: 1;
  197. font-size: 28rpx;
  198. color: #FFFFFF;
  199. &.left-btn {
  200. background-color: #1684fc;
  201. }
  202. &.right-btn {
  203. background-color: rgb(255, 121, 1);
  204. margin-left: 24rpx;
  205. }
  206. }
  207. }
  208. </style>