<template>
  <div class="No-Item" :class="{ selected: isSelected }" @click="selectNo">
    <!-- 新增选中标识，增强视觉反馈 -->
    <span class="selected-icon" v-if="isSelected">✓</span>
    {{ props.No }}
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from "vue";

const props = defineProps<{
  No: string;
  resetSelected?: boolean;
}>();

const isSelected = ref(false);
const emit = defineEmits<{
  (e: "addNo", sateNo: string): void;
  (e: "delNo", sateNo: string): void;
}>();

const selectNo = () => {
  isSelected.value = !isSelected.value;
  isSelected.value ? emit("addNo", props.No) : emit("delNo", props.No);
};
watch(
  () => props.resetSelected,
  (newVal) => {
    if (newVal) isSelected.value = false;
  },
  { immediate: true }
);
</script>

<style scoped>
.No-Item {
  width: 100% !important;
  letter-spacing: 6px;
  background-color: #e8f4f8;
  font-size: 16px;
  font-weight: 600;
  color: #192a3e;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-sizing: border-box;
  user-select: none;
  border: 1px solid transparent;
}

.No-Item:not(.selected):hover {
  background-color: #f0f8fb;
  border-color: #4299e1;
}

.selected {
  background-color: #4299e1;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
  border-color: #2563eb;
}

.selected-icon {
  margin-right: 8px;
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;
}
</style>
