<template>
	<view>
		<view>
			<select-cy :value="tval" :placeholder="placeholder" name="name" :options="datalist" :showClearIcon="true"
				:zindex="zindex" @change="change_select_cy1"></select-cy>
		</view>
	</view>

</template>

<script>
	import {
		querypnmcode3
	} from '@/utils/requestahm.js';
	export default {

		data() {
			return {
				//placeholder:'请选择起飞机场1',
				//模拟初始数据
				tval: [

				],
				// //模拟数据列表
				datalist: [],
			}
		},
		props: {
			zindex: Number,
			placeholder: String,

		},
		methods: {
			//下拉框改变
			change_select_cy1(item, value) {
				this.tval = value;
				this.$emit('changevalue', this.tval)
			},
			async getData() {
				const querypnmcode3arr = await querypnmcode3({
					type: 'arr'
				})

				let param = {}
				for (var i = 0; i < querypnmcode3arr.data.length; i++) {
					param = {
						label: querypnmcode3arr.data[i].threeCode,
						value: querypnmcode3arr.data[i].threeCode,
					}
					this.datalist.push(param)
				}

				this.sortlist()
			},
			//排序
			sortlist() {
				this.datalist.sort((a, b) => {
					return a.label.toString().localeCompare(b.label.toString())
				})
				console.log(this.datalist)
				// this.datalist.sort(function(a,b){
				//     	return a.value - b.value;



			}

		},
		created() {
			this.getData()
		}
	}
</script>

<style>
</style>