speedy-check-add.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="container" style="padding-top: 84px;padding-bottom: 10px;">
  3. <u-navbar title="选择商品" :border="false" fixed safe-area-inset-top bgColor="#22ac38"
  4. titleStyle="font-size:36rpx;color:#fff">
  5. <template #left>
  6. <u-icon name="arrow-left" color="#fff" size="20" @click="goBack"></u-icon>
  7. </template>
  8. <template #right>
  9. <text style="color: #ffffff;" @click="onSubmit">确定</text>
  10. </template>
  11. </u-navbar>
  12. <!-- 库位显示 -->
  13. <view class="location-info">
  14. <text>库位: {{ location }}</text>
  15. <text v-if="godownName">仓库: {{ godownName }}</text>
  16. <text v-if="orderNum">订单号: {{ orderNum }}</text>
  17. </view>
  18. <!-- 订单列表 -->
  19. <view class="product-details">
  20. <LocationOrderItem isCheck v-for="(item, index) in products" :key="index" :item="item"
  21. @select="toggleItemSelect" :isLink="false" />
  22. </view>
  23. <!-- 底部全选栏 -->
  24. <view class="fixed-bottom">
  25. <view class="select-all" @click="toggleSelectAll">
  26. <u-icon :name="isAllSelected ? 'checkmark-circle-fill' : 'checkmark-circle'"
  27. :color="isAllSelected ? '#19be6b' : '#c8c9cc'" size="28"></u-icon>
  28. <text class="select-text">全选</text>
  29. </view>
  30. <text class="order-count">订单总数: {{ products.length }}</text>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import {
  36. ref,
  37. computed
  38. } from 'vue'
  39. import { onLoad,onUnload } from "@dcloudio/uni-app";
  40. import LocationOrderItem from './components/LocationOrderItem.vue'
  41. // 库位相关
  42. const location = ref('')
  43. const products = ref([])
  44. const orderNum = ref('')
  45. const godownName = ref('')
  46. // 获取库位订单
  47. const getOrderByPositionCode = (positionCode) => {
  48. uni.$u.http.get('/app/stock/getOrderByPositionCode?positionCode=' + positionCode).then(res => {
  49. if (res.code === 200) {
  50. const data = res.data
  51. orderNum.value = data.orderNum
  52. godownName.value = data.godownName
  53. products.value = data.godownStockLogResults || []
  54. // 初始化选中状态
  55. products.value.forEach(item => {
  56. item.checked = false
  57. })
  58. } else {
  59. uni.$u.toast(res.msg)
  60. }
  61. })
  62. }
  63. onLoad((options) => {
  64. if (options.location) {
  65. location.value = options.location
  66. getOrderByPositionCode(options.location)
  67. }
  68. })
  69. // 计算是否全选
  70. const isAllSelected = computed(() => {
  71. return products.value.length > 0 && products.value.every(item => item.checked)
  72. })
  73. // 切换单个选择
  74. const toggleItemSelect = (item) => {
  75. item.checked = !item.checked
  76. }
  77. // 切换全选
  78. const toggleSelectAll = () => {
  79. const newState = !isAllSelected.value
  80. products.value.forEach(item => {
  81. item.checked = newState
  82. })
  83. }
  84. // 确认选择
  85. const onSubmit = () => {
  86. const selectedItems = products.value.filter(item => item.checked)
  87. // 这里可以通过 uni.$emit 传递选中的数据到上一页
  88. uni.$emit('selectedProducts', selectedItems)
  89. goBack()
  90. }
  91. // 返回上一页
  92. const goBack = () => {
  93. uni.navigateBack({
  94. delta: 1
  95. })
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .location-info {
  100. background-color: #fff;
  101. padding: 20rpx;
  102. text-align: left;
  103. font-size: 32rpx;
  104. margin-bottom: 16rpx;
  105. text {
  106. display: block;
  107. margin-bottom: 10rpx;
  108. &:last-child {
  109. margin-bottom: 0;
  110. }
  111. }
  112. }
  113. .product-details {
  114. margin-bottom: 100rpx;
  115. }
  116. .fixed-bottom {
  117. position: fixed;
  118. bottom: 0;
  119. left: 0;
  120. right: 0;
  121. height: 100rpx;
  122. background: #ffffff;
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: center;
  126. padding: 0 30rpx;
  127. box-shadow: 0 -2rpx 6rpx rgba(0, 0, 0, 0.1);
  128. }
  129. .select-all {
  130. display: flex;
  131. align-items: center;
  132. .select-text {
  133. margin-left: 12rpx;
  134. font-size: 28rpx;
  135. }
  136. }
  137. .order-count {
  138. font-size: 28rpx;
  139. color: #666;
  140. }
  141. </style>