SelectWarehouse.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <van-popup v-model:show="warehouseTrueFalseBy" position="center" round :close-on-click-overlay="false">
  3. <div class="select-warehouses">
  4. <div class="title">
  5. 工作仓库设置
  6. </div>
  7. <van-radio-group v-model="code">
  8. <van-cell-group inset>
  9. <van-cell :title="value" clickable v-for="(value, key) in warehousesMap" @click="groupChange(key)">
  10. <template #right-icon>
  11. <van-radio :name="key" />
  12. </template>
  13. </van-cell>
  14. </van-cell-group>
  15. </van-radio-group>
  16. <div class="btn" @click="onConfirm"> 确定</div>
  17. </div>
  18. </van-popup>
  19. </template>
  20. <script setup>
  21. import { ref, reactive } from 'vue'
  22. import { useStore } from '@/store/modules/user'
  23. // 创建响应式数据
  24. const warehouseTrueFalseBy = ref(false)
  25. const warehousesMap = ref({
  26. 'WH99': '测试仓库(WH99)',
  27. 'WH01': '九干仓(WH01)',
  28. 'WH02': '新浜一仓(WH02)',
  29. 'WH10': '新浜二仓(WH10)',
  30. })
  31. const code = ref('')
  32. const show = (warehouse) => {
  33. warehouseTrueFalseBy.value = true
  34. code.value = warehouse
  35. }
  36. const groupChange = (n) => {
  37. code.value = n
  38. }
  39. // 确认按钮事件
  40. const storeUser = useStore()
  41. const emit = defineEmits(['setWarehouse'])
  42. const onConfirm = () => {
  43. storeUser.setToken({ warehouse: code.value, token: storeUser.token })
  44. emit('setWarehouse', code.value)
  45. warehouseTrueFalseBy.value = false
  46. }
  47. defineExpose({ show })
  48. </script>
  49. <style scoped lang="sass">
  50. .select-warehouses
  51. padding: 10px 15px
  52. width: 300px
  53. .title
  54. font-size: 16px
  55. font-weight: 500
  56. padding-bottom: 10px
  57. .radio-item
  58. margin-bottom: 10px
  59. .btn
  60. color: #3c9cff
  61. line-height: 30px
  62. text-align: center
  63. cursor: pointer
  64. </style>