<template>
	<view>
		<uni-data-select v-model="selVaule" :localdata="range" :placeholder="placeholder" :disabled="disabled" @change="onchange"></uni-data-select>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import * as api from '@/utils/api.js';
	const selVaule = defineModel({
		type: String
	});
	
	const props = defineProps(["placeholder","disabled"]);
	const range = ref([]);
	api.callOperateApi("ebikeOperateSystem/ebikeComponentTypeInfo",{},"get").then((res) => {
		if (res.code === 200) {
			for (let i = 0, len = res.data.length; i < len; i++) {
				const item = res.data[i];
				let stext = item.name;
				if(item.brand != '电池' && item.brand != '头盔'){
					stext = item.brand + '-' + item.name;
				}
				const sitem = {
					value: item.id,
					text: stext
				}
				range.value.push(sitem);
			}
		}
	})
	
	const onchange = (value) => {
		if (value == "") return;
		selVaule.value = value;
	}
</script>

<style>
</style>