<template>
    <div class="app-container">

        <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" row-key="id"
            style="width: 100%;margin-bottom: 20px;" border>

            <el-table-column label="区域名称" prop="name" />

            <el-table-column label="区域类型" prop="type">
                <template #default="scope">
                    {{ typeMap[scope.row.type] }}
                </template>
            </el-table-column>

            <el-table-column label="区域编码" prop="code" />

        </el-table>

    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { listRegion } from '@/services/api/market/region'

let typeMap = {
    '1': '省',
    '2': '市',
    '3': '区'
} as any


let list = ref([])
let listLoading = ref(true)

let getList = () => {
    listLoading.value = true
    listRegion().then((res: any) => {
        if (res.code === 200) {
            list.value = res.data.list
            listLoading.value = false
        }
    }).catch(() => {
        list.value = []
        listLoading.value = false
    })
}

getList()
</script>
