<!-- 气象站短信预警 -->
<template>
  <div class=''>
    <div class="equipId">设备ID：{{equipId}}</div>
	<div>
		<div>
			<div class="title">预警手机号</div>
			<div>
				<el-input
					v-model="tel"
					type="number"
					ref="input"
					placeholder="请填写手机号"
					clearable
				></el-input>
			</div>
		</div>
		<div v-for="item in data" :key="item[5]">
			<div class="hint">
				<span>{{item[0]}}</span>
				{{item[1]}} ( {{item[4]}} )
			</div>
			<div>
				<el-select v-model="item[2]" placeholder="请选择类型">
					<el-option label="小于" value="0"></el-option>
					<el-option label="大于" value="1"></el-option>
				</el-select>
				<el-input
					v-model="item[3]"
					type="number"
					ref="input"
					placeholder="请填写阈值"
					clearable
				></el-input>
			</div>
		</div>
		<div class="subBtn">
			<el-button type="blueInfo" @click="submitData()">提交</el-button>
			<el-button type="grayInfo">重置</el-button>
		</div>
	</div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
props: ["equipId", "equipType","d_id"],
//import引入的组件需要注入到对象中才能使用
components: {},
data() {
//这里存放数据
return {
	  data:[],
	  tel:''
};
},
//监听属性 类似于data概念
computed: {

},
//监控data中的数据变化
watch: {},
//方法集合
methods: {
	getQxzAlarm(){
		this.$axios({
			method: "POST",
			url: "/api/api_gateway?method=weather.weather.qxz_status",
			data: this.qs.stringify({
				device_id: this.equipId,
			}),
		}).then((res) => {
			if (res.data.message == "") {
				this.data = []
				var alarm = {
					dat:{
						"e1":"1#2",
						"e2":"0#20",
						"e3":"1#2",
						"e4":"1#2",
						"e5":"0#2",
						"e6":"1#2",
						"e7":"1#2",
						"e8":"1#2",
						"e9":"1#2",
					}
				}
				var conf = res.data.data.conf;
				for(var key in conf){
					if(conf[key]){
						var ekey = parseInt(key.substring(1));
						var txt = conf[key].split('#')[0];
						var unit = conf[key].split('#')[1];
						var way = alarm.dat[key].split('#')[0];
						var val = alarm.dat[key].split('#')[1];
						this.data.push([key,txt,way,val,unit,ekey])
					}
				}
				this.data.sort((a,b)=>{
					return a[5] - b[5];
				})
				console.log(this.data);
				
			} else {
				this.$message.err("操作失败");
			}
		});
	}
},
//生命周期 - 创建完成（可以访问当前this实例）
created() {

},
//生命周期 - 挂载完成（可以访问DOM元素）
mounted() {
	this.getQxzAlarm()
},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
destroyed() {}, //生命周期 - 销毁完成
activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped lang="less">
.equipId{
  line-height: 33px;
  text-align: center;
  background: #eee;
}
.handAddFormBtn{
  margin-top: 20px;
  text-align: right;
}
.el-select{
	width: 100%;
	margin: 10px 0;
}
.hint {
	line-height: 26px;
	font-size: 14px;
	position: relative;
	color: #606060;
	margin-top: 20px;
	span {
		color: #000;
		font-weight: bold;
		background: #0295ff;
		// display: inline-block;
		color: #fff;
		border-radius: 50%;
    	padding: 3px 4px;
	}
}
.title{
	position: relative;
	margin-left: 5px;
	padding-left: 12px;
	font-size: 14px;
	line-height: 41px;
}
.title::before{
	position: absolute;
    content: "";
    width: 7px;
    height: 7px;
    background: #0295ff;
    left: 0;
    top: 17px;
}
.subBtn{
	margin-top: 20px;
	text-align: right;
}
</style>