<template>
  <div class="cpt-nest-logger dialog1027" v-interact>
    <div class="title-box dialog-header">
      <img class="dialog-header__icon" src="../../../../assets/images/mount_head.png" />
      <div class="dialog-header__title">运行监控日志</div>
      <div class="dialog-header__close" style="display: flex">
        <div class="icon-box" @click="onClear">
          <span class="iconfont icon-qingchushuju"></span>
          <!-- <span class="icon-text pr20">清除数据</span> -->
        </div>
        <div class="close" @click="$emit('close')">关闭</div>
      </div>
    </div>
    <div class="ctx-box dialog-content">
      <div class="head mt7">
        <div class="text">消息等级</div>
        <div class="text con">消息内容</div>
        <div class="time">时间</div>
      </div>
      <div class="list-box mt7">
        <div class="item-box" v-for="(item,index) in msgList" :key="index">
          <div class="text-box">
            <span class="grade">{{ item.grade }}</span>
            <div class="text">{{ item.text }}</div>
            <div class="time">{{ item.time }}</div>
          </div>
        </div>
      </div>
      <div class="wih10 mt20 h10"></div>
    </div>
  </div>
</template>

<script>
import { Control_API } from "../../../../../../../../../../api";
import { mapState } from "vuex";
import dayjs from "dayjs";
export default {
  data() {
    return {
      Time: null,
    };
  },
  computed: {
    ...mapState("MMCFlightControlCenter/uav", ["uav", "uavRealTimeData"]),
    msgList() {
      return this.uavRealTimeData.msgList.slice().reverse();
    },
  },
  watch: {},
  async created() {},
  beforeDestroy() {
    if (this.Time) clearInterval(this.Time);
  },
  methods: {
    onClose() {
      this.$emit("onCloseOperationLog");
    },
    onClear() {
      let dataSet = this.$store.state.MMCMQTT.dataSet;
      dataSet[this.uav.deviceId][270] = null;
      this.$store.commit("MMCMQTT/setState", {
        key: "dataSet",
        value: {
          ...dataSet,
        },
      });

      this.$store.commit("MMCFlightControlCenter/uav/setState", {
        key: "uavRealTimeData",
        value: {
          ...this.uavRealTimeData,
          msgList: [],
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.cpt-nest-logger {
  position: absolute;
  width: 630px;
  height: 250px;
  top: 170px;
  right: 560px;
  z-index: 5;
  display: flex;
  background: rgba(9, 32, 87, 0.7);
  // border: 1px solid #70DAF9;
  border-radius: 10px 10px 0 0;
  flex-direction: column;

  .title-box {

    .title {
      display: flex;
      align-items: center;
      .font {
        font-size: 20px;
        font-family: YouSheBiaoTiHei;
        color: #14faff;
        line-height: 26px;
        text-shadow: 0px 1px 1px rgba(2, 32, 56, 0.2);
        background: linear-gradient(
          135deg,
          #e3aa77 0%,
          #f5cda9 38%,
          #f9ecd3 58%,
          #fcdbb1 79%,
          #edb07a 100%
        );
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }

    .icon-box {
      display: flex;
      align-items: center;
      cursor: pointer;

      .iconfont {
        font-size: 18px;
        color: #00ffff;
        margin-right: 4px;
      }

      .icon-text {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ccedff;
        font-weight: 400;
      }
    }
  }

  .ctx-box {
    height: calc(100% - 32px);
    // flex: 1;
    // overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    width: 100%;

    &.dialog-content {
      flex-wrap: initial;
    }
    .head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-family: SourceHanSansCN-Bold;
      font-size: 16px;
      color: #ffffff;
      letter-spacing: 1px;
      line-height: 22px;
      font-weight: 700;
      width: 100%;
      .text,
      .time {
        width: 20%;
        text-align: center;
      }
      .time {
        width: 35%;
      }
      .con {
        width: 50%;
      }
    }
    .list-box {
      overflow: auto;
      overflow-x: hidden;
      box-sizing: border-box;
      .item-box {
        display: flex;
        align-items: center;
        color: #fff;
        padding: 11px 0;

        .text-box {
          width: 100%;
          display: flex;
          justify-content: space-between;
          align-items: center;

          .grade {
            width: 20%;
            height: 20px;
            text-align: center;
            font-family: SourceHanSansCN-Medium;
            font-size: 14px;
            color: #ebf9ff;
            letter-spacing: 0;
            text-align: center;
            font-weight: 500;
            display: flex;
            justify-content: center;
            align-items: center;
          }

          .text {
            width: 50%;
            text-align: center;
            font-family: SourceHanSansCN-Medium;
            font-size: 14px;
            color: #ebf9ff;
            letter-spacing: 0;
            text-align: center;
            font-weight: 500;
          }
          .time {
            width: 35%;
            text-align: center;
            font-family: SourceHanSansCN-Medium;
            font-size: 14px;
            color: #ffffff;
            letter-spacing: 0;
            text-align: center;
            font-weight: 500;
          }
        }
      }
      .item-box:nth-of-type(2n - 1) {
        background: rgba(73, 135, 210, 0.2);
      }
    }
  }

  .xb {
    transform: rotate(-180deg);
    background: rgba(1, 10, 46, 0.63);
    border-radius: 10px 10px 0 0;
  }
}
.c70d {
  color: #70daf9;
}

.close {
  margin-left: 20px;
  margin-right: 10px;
  cursor: pointer;
  font-size: 14px;
  font-family: MicrosoftYaHei;
  color: #d2dfff;
}
</style>
