<template>
	<view>
		<view>
			<view>
				<select-cy :value="tvalinfo" placeholder="管控状态" name="name" :options="datalist" :showClearIcon="true"
					:zindex="zindex" @change="change_select_cy"></select-cy>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		qStatus
	} from '@/utils/requestahm.js';
	export default {
		name: 'selectLeg',
		data() {
			return {
				zindex: 99,
				// //模拟初始数据
				tvalinfo: [],
				// //模拟数据列表
				datalist: [{
						code: 'warn',
						label: '新警告',
						value: '新警告',					
					},
					{
						code: 'delay',
						label: '推迟处理',
						value: '推迟处理',	
						name: '推迟处理'
					},
					{
						code: 'troubleShooting',
						label: '排故中',
						value: '排故中',	
						name: '排故中'
					},
					{
						code: 'closeFault',
						label: '虚假信息关闭',
						value: '虚假信息关闭',	
						name: '虚假信息关闭'
					},
					{
						code: 'normalClose',
						label: '正常关闭',
						value: '正常关闭',	
						name: '正常关闭'
					},
					{
						code: 'monitor',
						label: '监控',
						value: '监控',	
						name: '监控'
					},
					// {
					// 	code: 'handleReserve',
					// 	label: '故障保留',
					// 	value: '故障保留',	
					// 	name: '故障保留'
					// },
					{
						code: 'close_overdue',
						label: '关闭（过期故障）',
						value: '关闭（过期故障）',	
						name: '关闭（过期故障）'
					},
					{
						code: 'reppearFault',
						name: '故障再现'
					},
					{
						code: 'DD',
						label: '故障保留(DD)',
						value: '故障保留(DD)',	
						name: '故障保留(DD)'
					},
					{
						code: 'FC',
						label: '故障保留(FC)',
						value: '故障保留(FC)',	
						name: '故障保留(FC)'
					}
				],
				listitem: [],
			}
		},
		props: {
			tval: {
				type: Array,
				default: [],
			},

		},
		watch: {

		},
		methods: {
			
			//下拉框改变
			change_select_cy(item, value) {
				this.tvalinfo = value;
				let itemtval = []
				let itemtval2 = []
				let itemtvalLast = []
				if (this.tvalinfo.length > 0) {
					for (var j = 0; j < this.tvalinfo.length; j++) {
						for (var i = 0; i < this.datalist.length; i++) {
							if (this.tvalinfo[j] == this.datalist[i].label) {
								itemtval.push(this.datalist[i].code)
							}
						}
					}
				}
			
				if ((itemtval.indexOf('DD') > -1) && (itemtval.indexOf('FC') > -1)) {
					
					for (var k = 0; k < itemtval.length; k++) {
						if (itemtval[k] != 'DD' && itemtval[k] != 'FC') {
							itemtval2.push(itemtval[k])
						} 
					}
					itemtval2.push('handleReserve')
					itemtvalLast = itemtval2
				} else {
					
					itemtvalLast = itemtval
				}
				
				this.$emit('changevalue', value)
				this.$emit('changevalueitem', itemtvalLast)
			},
		},
		created() {
			if (this.tval.length > 0) {
				this.tvalinfo = this.tval
			}
			
		}
	}
</script>

<style>
</style>
