RegionNamePopup.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <popup
  3. v-model:show="showValue"
  4. round
  5. closeable
  6. class="region-name-popup"
  7. :close-on-click-overlay="false"
  8. teleport="body"
  9. >
  10. <div class="region-name-popup__content">
  11. <div class="region-name-popup__title">{{ $t('区域名称') }}</div>
  12. <el-input
  13. v-model="regionName"
  14. size="large"
  15. :placeholder="$t('请输入区域名称')"
  16. />
  17. <div class="region-name-popup__confirm" @click="handleConfirm">
  18. {{ $t('确认区域') }}
  19. </div>
  20. </div>
  21. </popup>
  22. </template>
  23. <script setup>
  24. import { ref, computed, watch } from "vue";
  25. import { Popup } from "vant";
  26. import { ElMessage } from "element-plus";
  27. const props = defineProps({
  28. show: {
  29. type: Boolean,
  30. default: false,
  31. },
  32. });
  33. const emit = defineEmits(["update:show", "confirm"]);
  34. const regionName = ref("");
  35. const showValue = computed({
  36. get: () => props.show,
  37. set: (value) => emit("update:show", value),
  38. });
  39. watch(
  40. () => props.show,
  41. (val) => {
  42. if (val) {
  43. regionName.value = "";
  44. }
  45. },
  46. );
  47. const handleConfirm = () => {
  48. const name = regionName.value.trim();
  49. if (!name) {
  50. ElMessage.warning("请输入区域名称");
  51. return;
  52. }
  53. emit("confirm", name);
  54. emit("update:show", false);
  55. };
  56. </script>
  57. <style scoped lang="scss">
  58. .region-name-popup {
  59. width: 100%;
  60. :deep(.van-popup__close-icon) {
  61. color: #333333;
  62. font-size: 18px;
  63. }
  64. &__content {
  65. padding: 24px 16px 20px;
  66. background: linear-gradient(360deg, #ffffff 74.2%, #d1ebff 100%);
  67. border-radius: 16px;
  68. box-sizing: border-box;
  69. }
  70. &__title {
  71. font-size: 16px;
  72. margin-bottom: 12px;
  73. }
  74. :deep(.el-input__wrapper) {
  75. border-radius: 4px;
  76. box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1) inset;
  77. }
  78. &__confirm {
  79. margin-top: 24px;
  80. padding: 8px;
  81. border-radius: 25px;
  82. background: #2199f8;
  83. color: #fff;
  84. font-size: 16px;
  85. text-align: center;
  86. }
  87. }
  88. </style>