<!-- 文本标签 -->
<template>
      <div
            @click="openMenu()"
            class="definedScreen__item_text"
            :style="{
               height:'100%',
                wordBreak:item.isLine?'normal':'',
                wordWrap:item.isLine?'break-word':'',
                'line-height':item.lineHeight + 'px',
                fontSize:(item.fontSize||'12')+'px',
                color:isShowBigScreen?'#fff':(item.fontColor||'#999') ,
                textAlign:item.textAlign || 'left',
                fontWeight:item.fontWeight?'blod':'500',
                backgroundImage:this.backgroundColor
                }"
          >  {{areaName}}  {{ item.controlName||'标签'}}
          </div>
</template>

<script>
export default {
    name:'biText',
  data () {
    return {
      areaName:'',
      backgroundColor:'',
    };
  },
  props:{
    isShowBigScreen:{
      type:Boolean,
      default:false
    },
      item:{
          type:[Object],
          default:()=>{
              return {}
          }
      },
         isEditable: {
      // 是否编辑
      type: Boolean,
      default: false
    },
  },

  components: {},

  computed: {},

  watch:{
    item:{
      handler(n){
        if(n&&n.backgroundColor){
           let topBottom = '#fff'
            if(n.backgroundColor2){
              topBottom = n.backgroundColor2
            }
             this.backgroundColor = "linear-gradient("+topBottom+", "+ n.backgroundColor +", "+topBottom+")"
        }

      },
      deep:true
    }
  },

  mounted() {
      this.$eventBus.$on(
        'refreshBiText' +this.item.id + false,
        this.getDatas
      ) // 为方便进行筛选器联动
      if(this.item&&this.item.backgroundColor){
        let topBottom = '#fff'
            if(this.item.backgroundColor2){
              topBottom = this.item.backgroundColor2
            }
             this.backgroundColor = "linear-gradient("+topBottom+", "+ this.item.backgroundColor +", "+topBottom+")"
        }
  },
  // deactivated(){
  //     this.$eventBus.$off(
  //     'refreshBiTarget' +
  //       (this.config ? this.config.id : '') +
  //       this.$parent.formId +
  //       this.isEditable,
  //      this.getDatas
  //     ) // 为方便进行筛选器联动
  // },
  // beforeDestroy(){
  //     this.$eventBus.$off(
  //     'refreshBiTarget' +
  //       (this.item ? this.item.id : '') +
  //       this.isEditable,
  //     this.getDatas
  //   ) // 为方便进行筛选器联动
  // },

  created() {}, 

  methods: {
    openMenu(){
      if(this.item.alink){
         if (this.item.alink.indexOf('http') == 0) { // 外网链接，直接跳转走
         window.open(url)
            return
        }
        this.$router.push({
           path:this.item.alink
        })
      }
    },
    getDatas(params){
      if(params&&params.orgIds){
        let data = sessionStorage.getItem('childArea')
         let valueList = []
      let allValue ='00'
        if(data){
          data =JSON.parse(sessionStorage.getItem('childArea'))  
             let childAreaSingle = data.length>0?data.map(res=>{
        valueList.push(res.code)
        return{value:res.code,text:res.name}
        }):[]
         if(valueList.length>0){
             allValue = valueList.join(',')
        }
      
      childAreaSingle.length>0?childAreaSingle.unshift({value:allValue,text:'全院'}):[]
      this.areaName = childAreaSingle.find(res=>res.value==params.orgIds).text
        }
      
      }
      
      
    }
  }
}

</script>
<style lang='scss' scoped>

</style>