<template>
  <div :class="tip"
       v-if="isShow">
    <div class="title">
      <el-row :span='24'>
        <el-col :sm='15'
                style="color:red;font-size:20px">{{type}}</el-col>
        <el-col :sm='9'
                style="text-align:right;padding-right:10px;">
          等级：
          <span class="tip_level"
                v-if="level ==1"
                style="color:red">特别重大</span>
          <span class="tip_level"
                v-if="level ==2"
                style="color:red">重大</span>
          <span class="tip_level"
                v-if="level ==3">一般</span>
        </el-col>
      </el-row>
    </div>
    <el-divider></el-divider>
    <div class="tip_warp">
      <el-row class="tip_content"
              type='flex'
              justify="space-around">
        <el-col :span='15'>
          <el-row :span='24'>
            <el-col :span='24'
                    style="color:red">报警地点：{{occurrenceSite}} </el-col>
            <el-col :span='24'>报警时间：{{times}}</el-col>
            <el-col :title="type"
                    :span='24'>报警类型：{{type |substr}}</el-col>
            <el-col :title="explain"
                    :span='24'>报警说明：{{resourceName}}{{type}}</el-col>
          </el-row>
        </el-col>
        <el-col class="tip_imgwarp"
                :span='8'>
          <img :src='url'
               alt="">
        </el-col>
      </el-row>
      <el-row class="btn_warp"
              type='flex'
              justify="space-around">
        <el-col :span='3'
                :offset='1'>
          <el-button class="tip_btn"
                     type="primary"
                     size="medium"
                     round
                     @click="doBtn">去处理</el-button>
        </el-col>
        <el-col :span='4'>
          <el-button class="tip_btn"
                     type="info"
                     size="medium"
                     round
                     @click="closeTip">关闭</el-button>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      isShow: true,
      tip: 'tip1',
      id: '',
      level: '',
      times: '',
      type: 1,
      explain: '',
      url: '',
      router: null
    }
  },
  filters: {
    substr (val) {
      if (!val) return ''
      if (val.length > 10) {
        return val.slice(1, 10) + '...'
      }
      return val
    }
  },
  methods: {
    doBtn () {
      let urlStr = window.location.href
      this.isShow = false
      // if (urlStr.indexOf('setting') !== -1) {
      //     this.router.push({
      //         path: '/sys/log',
      //         query: { warningId: this.id }
      //     })
      // } else {
      //     this.router.push({
      //         path: '/sys/setting/sql',
      //         query: { warningId: this.id }
      //     })
      // }
    },
    closeTip () {
      this.isShow = false
      console.log(this, '+++++++++++')
      var ruleForm = {
        id: this.id,
        status: 2
      }
      this.$http({
        url: this.$http.adornUrlAlarm(
          `/alarmsInfo/update`
        ),
        method: 'post',
        data: ruleForm
      }).then(data => {
        console.log(data)
        if (data && data.code === 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.isShow = false
            }
          })
        } else {
          this.$message.error(data.msg)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.tip1 {
  width: 400px;
  height: 220px;
  position: fixed;
  z-index: 100;
  bottom: 80px;
  right: 10px;
  border: 1px solid #ccc;
  background: white;
  .title {
    height: 40px;
    line-height: 40px;
    text-indent: 15px;
    // color: #fff;
    background: #f1f5f8;
    span {
      font-size: 17px;
      font-weight: 400;
    }
  }
  .tip_warp {
    height: 180px;
    background: #f1f5f8;
    .tip_content {
      padding: 10px;
      color: #000000;
      .tip_level {
        font-size: 17px;
        color: red;
      }
    }
    .tip_imgwarp {
      img {
        width: 130px;
        height: 85px;
      }
    }
    .btn_warp {
      padding-top: 10px;
      .tip_btn {
        width: 80px;
      }
    }
  }
}

.tip2 {
  width: 400px;
  height: 220px;
  position: fixed;
  z-index: 100;
  bottom: 80px;
  right: 420px;
  border: 1px solid #ccc;
  background: white;
  .title {
    height: 40px;
    line-height: 40px;
    text-indent: 15px;
    // color: #fff;
    background: #f1f5f8;
    span {
      font-size: 17px;
      font-weight: 400;
    }
  }
  .tip_warp {
    height: 180px;
    background: #f1f5f8;

    .tip_content {
      padding: 10px;
      color: #000000;
      .tip_level {
        font-size: 17px;
        color: red;
      }
    }
    .tip_imgwarp {
      img {
        width: 130px;
        height: 85px;
      }
    }
    .btn_warp {
      padding-top: 10px;
      .tip_btn {
        width: 80px;
      }
    }
  }
}

.tip3 {
  width: 400px;
  height: 220px;
  position: fixed;
  z-index: 100;
  bottom: 80px;
  right: 830px;
  border: 1px solid #ccc;
  background: white;
  .title {
    height: 40px;
    line-height: 40px;
    text-indent: 15px;
    // color: #fff;
    background: f1f5f8;
    span {
      font-size: 17px;
      font-weight: 400;
    }
  }
  .tip_warp {
    height: 180px;
    background: #f1f5f8;

    .tip_content {
      padding: 10px;
      color: #000000;
      .tip_level {
        font-size: 17px;
        color: red;
      }
    }
    .tip_imgwarp {
      img {
        width: 130px;
        height: 85px;
      }
    }
    .btn_warp {
      padding-top: 10px;
      .tip_btn {
        width: 80px;
      }
    }
  }
}

.tip4 {
  width: 400px;
  height: 220px;
  position: fixed;
  z-index: 100;
  bottom: 80px;
  right: 1240px;
  border: 1px solid #ccc;
  background: white;
  .title {
    height: 40px;
    line-height: 40px;
    text-indent: 15px;
    // color: #fff;
    background: f1f5f8;
    span {
      font-size: 17px;
      font-weight: 400;
    }
  }
  .tip_warp {
    height: 180px;
    background: #f1f5f8;

    .tip_content {
      padding: 10px;
      color: #000000;
      .tip_level {
        font-size: 17px;
        color: red;
      }
    }
    .tip_imgwarp {
      img {
        width: 130px;
        height: 85px;
      }
    }
    .btn_warp {
      padding-top: 10px;
      .tip_btn {
        width: 80px;
      }
    }
  }
}

.el-divider--horizontal {
  margin: 1px 0;
  padding: 1px 1px;
  background: 0 0;
  border-top: 1px dashed;
}
</style>
