<script setup>
import { computed, ref } from 'vue'
import { ElMessage } from 'element-plus'

const taskOptions = [
  { label: '壶天镇确权任务', value: '106' },
  { label: '翻江镇确权任务', value: '107' },
  { label: '月山镇确权任务', value: '110' }
]

const selectedTask = ref(taskOptions[0]?.value || '')
const selectedLabel = computed(() => taskOptions.find((o) => o.value === selectedTask.value)?.label || '')

function handleChange() {
  ElMessage.success(`已切换：${selectedLabel.value || '未选择'}`)
}
</script>

<template>
  <div class="h-full w-full bg-white p-4">
    <div class="max-w-3xl">
      <div class="flex items-center gap-3">
        <div class="text-sm text-gray-700 whitespace-nowrap">选择任务</div>
        <el-select v-model="selectedTask" class="!w-80" placeholder="请选择" @change="handleChange">
          <el-option v-for="o in taskOptions" :key="o.value" :label="o.label" :value="o.value" />
        </el-select>
      </div>
      <div class="mt-4 text-sm text-gray-600">当前选择：{{ selectedLabel || '未选择' }}</div>
    </div>
  </div>
</template>
