WarehouseSelector.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <u-popup :show="show" @close="handleClose" mode="bottom" round="10">
  3. <view class="warehouse-selector">
  4. <view style="flex:1">
  5. <!-- 标题 -->
  6. <view class="header">
  7. <text class="title">绑定仓库</text>
  8. </view>
  9. <!-- 搜索框 -->
  10. <view class="search-box">
  11. <u-search v-model="searchKeyword" placeholder="搜索仓库" :show-action="true" action-text="搜索"
  12. action-style="color: #4CAF50" @search="handleSearch" @custom="handleSearch" />
  13. </view>
  14. <!-- 搜索结果 -->
  15. <view class="search-result" v-if="searchKeyword">
  16. <text class="section-title">搜索结果</text>
  17. <view class="tag-group">
  18. <u-tag v-for="item in searchResults" :key="item" :text="item" plain shape="circle"
  19. @click="selectWarehouse(item)" />
  20. </view>
  21. </view>
  22. <!-- 历史绑定 -->
  23. <view class="history-section">
  24. <text class="section-title">历史绑定</text>
  25. <view class="tag-group">
  26. <u-tag v-for="item in historyWarehouses" :key="item" :text="item" plain shape="circle"
  27. @click="selectWarehouse(item)" />
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 底部按钮 -->
  32. <view class="footer">
  33. <u-button @click="handleClose" text="取消" plain shape="circle" />
  34. <u-button type="primary" @click="handleConfirm" text="确定" shape="circle" />
  35. </view>
  36. </view>
  37. </u-popup>
  38. </template>
  39. <script setup>
  40. import {
  41. ref
  42. } from 'vue'
  43. const props = defineProps({
  44. show: {
  45. type: Boolean,
  46. default: false
  47. }
  48. })
  49. const emit = defineEmits(['update:show', 'warehouse-selected'])
  50. const searchKeyword = ref('')
  51. const searchResults = ref(['河南仓', '湖北仓', '河北仓', '涨涨涨', '涨涨', '河北仓', '涨涨涨', ])
  52. const historyWarehouses = ref(['河南仓'])
  53. const selectedWarehouse = ref('')
  54. const handleSearch = () => {
  55. // 实现搜索逻辑
  56. }
  57. const selectWarehouse = (warehouse) => {
  58. selectedWarehouse.value = warehouse
  59. }
  60. const handleClose = () => {
  61. emit('update:show', false)
  62. searchKeyword.value = ''
  63. }
  64. const handleConfirm = () => {
  65. if (selectedWarehouse.value) {
  66. emit('warehouse-selected', selectedWarehouse.value)
  67. handleClose()
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .warehouse-selector {
  73. padding: 30rpx;
  74. min-height: 35vh;
  75. max-height: 80vh;
  76. overflow: auto;
  77. background-color: #fff;
  78. display: flex;
  79. flex-direction: column;
  80. }
  81. .header {
  82. text-align: center;
  83. margin-bottom: 20px;
  84. .title {
  85. font-size: 16px;
  86. font-weight: 500;
  87. }
  88. }
  89. .search-box {
  90. margin-bottom: 30rpx;
  91. }
  92. .section-title {
  93. font-size: 14px;
  94. color: #666;
  95. margin-bottom: 10px;
  96. display: block;
  97. }
  98. .tag-group {
  99. display: flex;
  100. flex-wrap: wrap;
  101. gap: 10px;
  102. margin-bottom: 20px;
  103. }
  104. .footer {
  105. position: sticky;
  106. bottom: 0;
  107. padding: 20px 0;
  108. padding-bottom: 0;
  109. display: flex;
  110. justify-content: center;
  111. gap: 30rpx;
  112. }
  113. </style>