<template>
  <view>
	  	<view>
	  		<uni-data-select  v-if="item.dataType.type=='bool'" :clear="false" :localdata="[{value:0,text:item.dataType.falseText},{value:1,text:item.dataType.trueText}]"  v-model="item.value" @change="mqttPublish(item)" :disabled="isDisabled"></uni-data-select>
	  		<uni-data-select v-if="item.dataType.type=='enum'" :clear="false" :localdata="item.dataType.enumList"  v-model="item.value" @change="mqttPublish(item)" :disabled="isDisabled"></uni-data-select>
	  		<u-input v-if="item.dataType.type=='string'" v-model="item.value" :placeholder="'请输入字符串 '+(item.dataType.unit?'，单位：'+item.dataType.unit:'')" :disabled="isDisabled">
	  			<template slot="suffix">
	  				<u-button size="mini" @click="mqttPublish(item)" text="发送" :disabled="isDisabled"></u-button>
	  			</template>
	  		</u-input>
	  		<u-input v-if="item.dataType.type=='decimal'" v-model="item.value" type="number" :placeholder="'请输入小数 '+(item.dataType.unit?'，单位：'+item.dataType.unit:'')" :disabled="isDisabled">
	  			<template slot="suffix">
	  				<u-button size="mini" @click="mqttPublish(item)" text="发送" :disabled="isDisabled"></u-button>
	  			</template>
	  		</u-input>
	  		<u-input v-if="item.dataType.type=='integer'" v-model="item.value" type="number" :placeholder="'请输入整数 '+(item.dataType.unit?'，单位：'+item.dataType.unit:'')" :disabled="isDisabled">
	  			<template slot="suffix">
	  				<u-button size="mini" @click="mqttPublish(item)" text="发送" :disabled="isDisabled"></u-button>
	  			</template>
	  		</u-input>
	  	</view>
  </view>
</template>

<script>
export default {
  name: '',
  mixins: [],
  components: {},
  props: {
	  item:Object,
	  device:Object
  },
  data() {
    return{}
  },
  computed: {
	  isDisabled(){
	      //只读肯定禁用
	      if(this.item.isReadonly==1){
	          return true;
	      }
	      //在线 或者 影子模式 不禁用
	      else if(this.device.status==3 || this.device.isShadow==1){
	          return false;
	      }
	      else{
	          return true;
	      }
	  }   
  },
  watch: {},
  created() {},
  mounted() {},
  destroyed() {},
  methods: {
	  mqttPublish(item){
		  this.$emit('mqttPublish',item);
		  
	  }
  },
};
</script>
<style lang="scss" scoped>
</style>