<script setup>

import {inject, onMounted, ref} from "vue"
import TOption from "@/components/ui/TOption.vue";
import TSelect from "@/components/ui/TSelect.vue";

const Tea = inject("$Tea")

const props = defineProps(["v-route-code"])

const {routeCode, routes} = (function () {
	let routeCode = props.vRouteCode
	if (routeCode == null) {
		routeCode = ""
	}
	return {
		routeCode: ref(routeCode),
		routes: ref([])
	}
})()

onMounted(() => {
	Tea.action("/ns/routes/options")
		.post()
		.success(function (resp) {
			routes.value = resp.data.routes
		})
})

</script>

<template>
	<div>
		<div v-if="routes.length > 0">
			<TSelect name="routeCode" v-model="routeCode">
				<TOption value="">[线路]</TOption>
				<TOption v-for="route in routes" :value="route.code">{{ route.name }}</TOption>
			</TSelect>
		</div>
	</div>
</template>

<style scoped>
</style>
