<template>
    <div class="app-region">
        <el-select v-model="provinceId" @change="provinceChange">
            <el-option :label="item.divisionname" :value="item.autoid" v-for="(item, index) in provinceList"
                :key="index" />
        </el-select>
        <el-select v-model="cityId" @change="cityChange">
            <el-option :label="item.divisionname" :value="item.autoid" v-for="(item, index) in cityList" :key="index" />
        </el-select>
        <el-select v-model="districtId" @change="districtChange">
            <el-option :label="item.divisionname" :value="item.autoid" v-for="(item, index) in districtList"
                :key="index" />
        </el-select>
    </div>
</template>

<script lang="ts" setup>
import { useRegion } from './index'

const props = defineProps({
    province: Number,
    city: Number,
    district: Number
})

const { provinceList, cityList, districtList, provinceId, cityId, districtId, provinceChange, cityChange, districtChange } = useRegion([props.province, props.city, props.district])
</script>