<!-- vue 页面模板 -->
<template>
  <Tree :data="list"></Tree>
</template>

<script setup>
import { ref, onMounted } from 'vue';

import api from '../../api/index.js';

const list = ref([]);

onMounted(() => {});
get_list();

function get_list() {
  api.region_api().then(r => {
    list.value = tree_change(r || []);
  });
}


function tree_change(list) {
  const li = [];
  for (let i = 0; i < list.length; i++) {
    const v = list[i];
    v.title = v.name;
    v.value = v.regionId;
    v.expand = false;
    v.selected = false;
    v.checked = false;
    li.children = tree_change(v.children || []);
    li.push(v);
  }
  return li;
}
</script>

<style lang="scss"></style>
