warehouse.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="warehouse-select">
  3. <view class="select-wrap" @click="showPicker = true">
  4. <text class="required-label">*</text>
  5. <text class="label">默认仓库</text>
  6. <view class="picker-value">
  7. <text :class="['value-text', !selectedWarehouse && 'placeholder']">
  8. {{ selectedWarehouse || '请选择仓库' }}
  9. </text>
  10. <u-icon name="arrow-right" color="#999" size="16"></u-icon>
  11. </view>
  12. </view>
  13. <!-- 仓库选择器 -->
  14. <u-picker :show="showPicker" :columns="[warehouseList]" @confirm="onConfirm" @cancel="showPicker = false"
  15. @close="showPicker = false" title="选择仓库" confirmText="确定" cancelText="取消"></u-picker>
  16. </view>
  17. </template>
  18. <script setup>
  19. import {
  20. ref
  21. } from 'vue'
  22. // 选择器显示状态
  23. const showPicker = ref(false)
  24. // 选中的仓库
  25. const selectedWarehouse = ref('')
  26. // 仓库列表
  27. const warehouseList = ref([{
  28. text: '北京仓库',
  29. value: '1'
  30. },
  31. {
  32. text: '上海仓库',
  33. value: '2'
  34. },
  35. {
  36. text: '广州仓库',
  37. value: '3'
  38. },
  39. {
  40. text: '深圳仓库',
  41. value: '4'
  42. },
  43. ])
  44. // 确认选择
  45. const onConfirm = (e) => {
  46. const [{
  47. value,
  48. text
  49. }] = e.value
  50. selectedWarehouse.value = text
  51. showPicker.value = false
  52. // 触发选择事件
  53. emit('change', value)
  54. }
  55. // 定义事件
  56. const emit = defineEmits(['change'])
  57. </script>
  58. <style lang="scss" scoped>
  59. .warehouse-select {
  60. padding: 20rpx;
  61. .select-wrap {
  62. display: flex;
  63. align-items: center;
  64. background: #FFFFFF;
  65. min-height: 88rpx;
  66. padding: 0 20rpx;
  67. position: relative;
  68. .required-label {
  69. color: #FF4D4F;
  70. font-size: 28rpx;
  71. margin-right: 4rpx;
  72. }
  73. .label {
  74. font-size: 28rpx;
  75. color: #333333;
  76. margin-right: 20rpx;
  77. white-space: nowrap;
  78. }
  79. .picker-value {
  80. flex: 1;
  81. display: flex;
  82. align-items: center;
  83. justify-content: space-between;
  84. .value-text {
  85. font-size: 28rpx;
  86. color: #333333;
  87. &.placeholder {
  88. color: #999999;
  89. }
  90. }
  91. .count {
  92. font-size: 24rpx;
  93. color: #999999;
  94. margin-right: 10rpx;
  95. }
  96. }
  97. &::after {
  98. content: '';
  99. position: absolute;
  100. left: 20rpx;
  101. right: 20rpx;
  102. bottom: 0;
  103. height: 1px;
  104. background: #EEEEEE;
  105. transform: scaleY(0.5);
  106. }
  107. &:active {
  108. background: #F5F5F5;
  109. }
  110. }
  111. }
  112. </style>