speedy-check-add.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="container">
  3. <u-navbar title="选择商品" :border="false" fixed safe-area-inset-top>
  4. <template #left>
  5. <u-icon name="arrow-left" color="#333333" size="20" @click="goBack"></u-icon>
  6. </template>
  7. <template #right>
  8. <u-text type="primary" text="确定" @click="onSubmit"></u-text>
  9. </template>
  10. </u-navbar>
  11. <!-- 库位显示 -->
  12. <view class="location-info">
  13. <text>{{ location }}</text>
  14. </view>
  15. <!-- 订单列表 -->
  16. <view class="product-details">
  17. <LocationOrderItem isCheck v-for="(item, index) in products" :key="index" :item="item"
  18. @select="toggleItemSelect" />
  19. </view>
  20. <!-- 底部全选栏 -->
  21. <view class="fixed-bottom">
  22. <view class="select-all" @click="toggleSelectAll">
  23. <u-icon :name="isAllSelected ? 'checkmark-circle-fill' : 'checkmark-circle'"
  24. :color="isAllSelected ? '#19be6b' : '#c8c9cc'" size="28"></u-icon>
  25. <text class="select-text">全选</text>
  26. </view>
  27. <text class="order-count">订单总数: {{ products.length }}</text>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import {
  33. ref,
  34. computed
  35. } from 'vue'
  36. import LocationOrderItem from './components/LocationOrderItem.vue'
  37. // 库位相关
  38. const location = ref('k01-01-4A')
  39. // 其他数据
  40. const searchValue = ref('')
  41. const products = ref([{
  42. orderNo: '4846464',
  43. logisticsNo: "DPK2023497491611",
  44. inspectionDate: "2024-11-14",
  45. badCount: 5,
  46. operator: '李程雪',
  47. checked: false
  48. },
  49. {
  50. orderNo: '4846464',
  51. logisticsNo: "DPK2023497491611",
  52. inspectionDate: "2024-11-14",
  53. badCount: 5,
  54. operator: '李程雪',
  55. checked: false
  56. }
  57. ])
  58. // 计算是否全选
  59. const isAllSelected = computed(() => {
  60. return products.value.length > 0 && products.value.every(item => item.checked)
  61. })
  62. // 切换单个选择
  63. const toggleItemSelect = (item) => {
  64. item.checked = !item.checked
  65. }
  66. // 切换全选
  67. const toggleSelectAll = () => {
  68. const newState = !isAllSelected.value
  69. products.value.forEach(item => {
  70. item.checked = newState
  71. })
  72. }
  73. // 确认选择
  74. const onSubmit = () => {
  75. const selectedItems = products.value.filter(item => item.checked)
  76. // 这里可以通过 uni.$emit 传递选中的数据到上一页
  77. uni.$emit('selectedProducts', selectedItems)
  78. uni.navigateBack()
  79. }
  80. // 返回上一页
  81. const goBack = () => {
  82. uni.navigateBack()
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .location-info {
  87. background-color: #fff;
  88. padding: 20rpx;
  89. text-align: center;
  90. font-size: 32rpx;
  91. margin-bottom: 16rpx;
  92. }
  93. .product-details {
  94. margin-bottom: 100rpx;
  95. }
  96. .fixed-bottom {
  97. position: fixed;
  98. bottom: 0;
  99. left: 0;
  100. right: 0;
  101. height: 100rpx;
  102. background: #ffffff;
  103. display: flex;
  104. justify-content: space-between;
  105. align-items: center;
  106. padding: 0 30rpx;
  107. box-shadow: 0 -2rpx 6rpx rgba(0, 0, 0, 0.1);
  108. }
  109. .select-all {
  110. display: flex;
  111. align-items: center;
  112. .select-text {
  113. margin-left: 12rpx;
  114. font-size: 28rpx;
  115. }
  116. }
  117. .order-count {
  118. font-size: 28rpx;
  119. color: #666;
  120. }
  121. </style>