<template>
  <div class="detail">
    <div>
      <div class="relative">
        <div class="flex-st">
          <img
            v-if="baseInfo.attackResult == '成功'"
            class="audit-img"
            src="../../assets/image/detail/succes.png"
            alt=""
          />
          <img
            v-if="baseInfo.attackResult == '失败'"
            class="audit-img"
            src="../../assets/image/detail/error.png"
            alt=""
          />
          <img
            v-if="baseInfo.attackResult == '企图'"
            class="audit-img"
            src="../../assets/image/detail/attempt.png"
            alt=""
          />
          <div class="attark-header">
            <div class="attark-header-title">
              {{baseInfo.eventName || '-'}}
            </div>
            <div>
              <span class="attark-bg">源</span>
              <span class="ip">{{baseInfo.srcIp || '-'}}</span>
              <span>/ {{baseInfo.srcPort || '-'}} /</span>
              <span>{{baseInfo.srcLocation || '-'}}</span>
              <span class="attark"
                ><img src="../../assets/image/detail/attark.png" alt=""
              /></span>
              <span class="attark-bg">目的</span>
              <span class="ip"> {{baseInfo.destIp || '-'}}</span>
              <span>/ {{baseInfo.destPort || '-'}} /{{baseInfo.destLocation || '-'}}</span>
            </div>
          </div>
        </div>

        <div class="table-des">
          <el-descriptions :column="3" border>
            <el-descriptions-item
              label="生成时间"
              label-class-name="my-label"
              class-name="my-content"
              >{{baseInfo.alarmTime || '-'}}
            </el-descriptions-item>
            <el-descriptions-item
              label="事件类型"
              label-class-name="my-label"
              class-name="my-content"
              >{{baseInfo.eventType || '-'}}
            </el-descriptions-item>
            <el-descriptions-item
              label="威胁等级"
              label-class-name="my-label"
              class-name="my-content"
            >
              <div class="level-content" :class="baseInfo.threatLevel == '高危'? 'level-heigh': baseInfo.threatLevel == '中危'?'level-center':'level-low'">
                <svg
                  t="1679909150644"
                  class="icon level level-svg"
                  viewBox="0 0 1110 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="5101"
                  xmlns:xlink="http://www.w3.org/1999/xlink"
                  width="216.796875"
                  height="200"
                >
                  <path
                    d="M377.186816 739.199128L546.728412 446.029965a11.157723 11.157723 0 0 1 19.470226 0l169.262653 293.169163a11.157723 11.157723 0 0 1-9.707219 16.736584H386.949823a11.157723 11.157723 0 0 1-9.763007-16.736584zM882.743231 432.640697l2.845219 62.204304a16.011332 16.011332 0 0 0 7.419886 12.719804l51.437101 32.301607a11.157723 11.157723 0 0 1-3.570471 20.362844l-235.762681 51.325525a5.578861 5.578861 0 0 1-5.578861-9.205122l163.906946-176.682538a11.157723 11.157723 0 0 1 19.302861 6.973576zM615.459984 1022.661073l-54.393898-29.567965a15.843966 15.843966 0 0 0-14.672406 0l-54.282321 27.336421a11.157723 11.157723 0 0 1-15.565023-13.556633l78.104059-228.398584a5.578861 5.578861 0 0 1 10.599837 0L631.415527 1009.773904a11.157723 11.157723 0 0 1-15.955543 12.887169zM407.256878 614.4l-238.496322-51.939199a10.04195 10.04195 0 0 1-3.23574-18.298665l53.836012-33.8079a15.6766 15.6766 0 0 0 7.308308-12.775593l2.84522-61.367474a11.157723 11.157723 0 0 1 19.414437-7.085154l163.572215 176.23623a5.578861 5.578861 0 0 1-5.24413 9.037755z"
                    p-id="5102"
                  ></path>
                  <path
                    d="M1043.247072 1016.412749h-334.731681a66.946336 66.946336 0 1 1 0-133.892673h210.82517l-113.808771-173.725742a66.951915 66.951915 0 0 1 112.023536-73.362027L1099.035685 912.924871a66.946336 66.946336 0 0 1-55.788613 103.487878zM401.678017 1016.412749H66.946336a66.946336 66.946336 0 0 1-55.788613-103.487878l181.703514-277.325198a66.951915 66.951915 0 0 1 112.023536 73.362027l-114.031926 173.558376H401.678017a66.946336 66.946336 0 0 1 0 133.892673zM722.016235 428.177608a66.946336 66.946336 0 0 1-59.414873-36.095233l-95.789049-184.102424-103.208935 183.600327a66.946336 66.946336 0 0 1-116.765568-65.495832L510.744756 34.19842A66.946336 66.946336 0 0 1 569.043857 0h1.115773a66.946336 66.946336 0 0 1 58.299101 36.039444l152.916589 294.173359a66.946336 66.946336 0 0 1-59.359085 97.853228z"
                    p-id="5103"
                  ></path>
                </svg>
                {{baseInfo.threatLevel || '-'}}
              </div>
            </el-descriptions-item>
            <el-descriptions-item
              label="攻击链阶段"
              label-class-name="my-label"
              class-name="my-content"
              >{{baseInfo.killChain || '-'}}
            </el-descriptions-item>
            <el-descriptions-item
              label="攻击方向"
              label-class-name="my-label"
              class-name="my-content"
            >
              {{ baseInfo.attackDirection || '-' }}
            </el-descriptions-item>
            <el-descriptions-item
              label="处置状态"
              label-class-name="my-label"
              class-name="my-content"
            >
              <div class="status" :class="baseInfo.status == 1?'status-one':baseInfo.status == 2?'status-two':''">
                <span class="status-cli"></span>
                <span class="status-label">{{baseInfo.status == 0? '待研判':baseInfo.status == 1? '待下发':'已处置'}}</span>
              </div>
            </el-descriptions-item>
            <el-descriptions-item
              label="应用协议"
              label-class-name="my-label"
              class-name="my-content"
              > {{ baseInfo.protocol || '-' }}
            </el-descriptions-item>
            <el-descriptions-item
              label="规则ID"
              label-class-name="my-label"
              class-name="my-content"
              >{{baseInfo.sid || '-'}}
            </el-descriptions-item>
            <el-descriptions-item
              v-if="origin == 'situation'"
              span="1"
              label="探针IP"
              label-class-name="my-label"
              class-name="my-content"
            >
              <div>{{ baseInfo.devIp || '-' }}</div>
            </el-descriptions-item>
            <el-descriptions-item
              v-if="origin == 'situation'"
              span="1"
              label="攻击次数"
              label-class-name="my-label"
              class-name="my-content"
            >
              <div>{{ (detailType == 'base' ? baseInfo.mergeCount: baseInfo.count) || '-' }}</div>
            </el-descriptions-item>
          </el-descriptions>
        </div>
        <div class="table-des-item mt-24">
          <div class="table-des-item-header">
            <img src="../../assets/image/detail/load.png" alt="" />
            <span>载荷</span>
          </div>
          <div class="table-des-item-content mt-12">
            <div v-if="baseInfo.payload" style="white-space: pre-line;" v-html="baseInfo.payload"></div>
            <div v-else>-</div>
          </div>
        </div>
        <div class="table-des-item mt-24 pd-0" v-if="baseInfo.http">
          <div class="table-des-item-header">
            <img src="../../assets/image/detail/request.png" alt="" />
            <span>请求</span>
          </div>
          <div class="table-des-item-content flex-item">
            <div class="flex-item-item border-right">
              <div class="flex-item-item-pd-title">请求头</div>
              <div class="item-height">
                {{baseInfo.httpRequestHead || '-' }}
              </div>
            </div>
            <div class="flex-item-item flex-item-item-pd">
              <div class="flex-item-item-pd-title">请求体</div>
              <div class="item-height">
                {{baseInfo.httpRequestBody || '-' }}
              </div>
            </div>
          </div>
        </div>
        <div class="table-des-item mt-24 pd-0" v-if="baseInfo.http">
          <div class="table-des-item-header">
            <img src="../../assets/image/detail/response.png" alt="" />
            <span>响应</span>
          </div>
          <div class="table-des-item-content flex-item">
            <div class="flex-item-item border-right">
              <div class="flex-item-item-pd-title">响应头</div>
              <div class="item-height">
                {{baseInfo.httpResponseHead || '-' }}
              </div>
            </div>
            <div class="flex-item-item flex-item-item-pd">
              <div class="flex-item-item-pd-title">响应体</div>
              <div class="item-height">
                {{baseInfo.httpResponseBody || '-' }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, reactive, defineProps, defineEmits, defineExpose } from "vue";
import { ElMessageBox, ElMessage, FormRules } from "element-plus";
import Upload from "../../components/upload/upload.vue";
import { addUploadFile } from "../../api/fileAnalysis/filesUpload";

interface Props {
  baseInfo?: Object, // 详情
  origin?: String, // // flow--探针  situation--感知平台
  detailType?: String; // base--基本信息 original--原始
}
const { baseInfo = {}, origin='situation', detailType = 'base' } = defineProps<Props>();
/**
 * @description 子组件传参
 */
const emit = defineEmits(["getValue"]);
emit("getValue", {
  status: 1,
  isDown: true,
});
</script>
<style lang="scss" scoped>
.relative {
  position: relative;
}

::v-deep .ya-layout-container {
  padding-top: 0 !important;
}
.detail {
  font-size: 16px;
  font-weight: 500;
  color: #174659;
  position: relative;
  .detail-header {
    position: sticky;
    top: -12px;
    z-index: 1;
    background-color: #f1f4f5;
    // box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.08);
    .detail-header-top {
      position: relative;
      top: 0px;
      height: 50px;
    }
  }
  .flex-bt {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .flex-st {
    display: flex;
    align-items: center;
  }
  .mr-56 {
    margin-right: 56px;
  }
  .check-btn {
    border-radius: 50%;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    background: #bac8cd;
    box-shadow: 0px 0px 8px 0px rgba(24, 90, 126, 0.24);
    margin-right: 28px;
    img {
      width: 24px;
      height: 24px;
      position: relative;
      top: 4px;
    }
  }
  .attark-header {
    margin-left: 22px;
    color: #174659;
    font-size: 14px;
    font-weight: 600;
    .attark-header-title {
      font-size: 18px;
      font-weight: 600;
      margin-bottom: 5px;
    }
    .attark {
      img {
        width: 14px;
        height: 12px;
        margin: 0 14px;
      }
    }
    .attark-bg {
      display: inline-block;
      text-align: center;
      padding: 0 5px;
      height: 21px;
      border-radius: 2px;
      border: 1px solid #bac8cd;
    }
    .ip {
      font-size: 14px;
      font-weight: 500;
      color: #1c92d0;
      margin-left: 5px;
      margin-right: 5px;
    }
  }
}

::v-deep .el-descriptions__cell.is-bordered-content,
::v-deep .el-descriptions__cell.is-bordered-label {
  border: 1px solid #bac8cd !important;
  font-weight: 500 !important;
  color: #174659;
}
::v-deep .my-label {
  height: 48px !important;
  width: 100px;
  text-align: center !important;
  border-color: #bac8cd !important;
  font-weight: 500 !important;
  color: #174659;
}
.table-des {
  margin-top: 24px;
  .flow {
    .attark-img {
      width: 14px;
      height: 12px;
      margin: 0 10px;
    }
  }
  .level-content {
    display: flex;
    align-items: center;
  }
  .level-svg {
    width: 15px;
    height: 15px;
    margin-right: 2px;
  }
  .level-heigh {
    color: var(--el-color-danger);
    svg {
      fill: var(--el-color-danger);
    }
  }
  .level-center {
    color: var(--el-color-warning);
    svg {
      fill: var(--el-color-warning);
    }
  }
  .level-low {
    color: #1c92d0;
    svg {
      fill: #1c92d0;
    }
  }
  .reliability {
    width: 32px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background: rgba(37, 159, 47, 0.05);
    border-radius: 2px;
    font-size: 14px;
  }
  .reliability-heigh {
    border: 1px solid var(--el-color-success);
    color: var(--el-color-success);
  }
  .reliability-center {
    border: 1px solid var(--el-color-warning);
    color: var(--el-color-warning);
  }
  .reliability-low {
    border: 1px solid var(--el-color-danger);
    color: var(--el-color-danger);
  }
}
.mt-24 {
  margin-top: 24px;
}
.table-des-item {
  border-radius: 2px;
  border: 1px solid #bac8cd;
  padding: 12px;
  .table-des-item-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #174659;
    font-size: 16px;
    border-bottom: 1px solid #bac8cd;
    padding-bottom: 13px;
    img {
      width: 20px;
      height: 20px;
      border-radius: 2px;
      background: #1c92d0;
      margin-right: 12px;
    }
  }
  .mt-12 {
    margin-top: 12px;
  }
  .table-des-item-content {
    word-break: break-all;
    font-size: 14px;
    font-weight: 400;
    color: rgba(23, 70, 89, 0.55);
  }

  .flex-item {
    display: flex;
    .flex-item-item {
      flex: 1;
    }
    .border-right {
      border-right: 1px solid #e6e6e6;
    }
  }
  .item-height {
    height: 200px;
    overflow-y: scroll;
    padding-bottom: 12px;
  }
  .flex-item-item-pd {
    padding: 0 20px;
    padding-right: 0;
  }
  .flex-item-item-pd-title {
    height: 24px;
    padding-top: 10px;
  }
}
.pd-0 {
  padding-bottom: 0;
}
.audit-img {
  width: 46px;
  height: 46px;
}
::v-deep .yaUpload .ya-upload {
  margin-bottom: 0;
}
.status {
  display: flex;
  align-items: center;
  font-weight: 400;
  font-size: 14px;
  span {
    display: block;
  }
  .status-cli {
    width: 10px;
    height: 10px;
    background: var(--el-color-primary);
    border-radius: 50%;
  }
  .status-label {
    color: var(--el-color-primary);
    margin-left: 8px;
  }
}
.status-one {
  .status-cli {
    background: var(--el-color-warning);
  }
  .status-label {
    color: var(--el-color-warning);
  }
}
.status-two {
  .status-cli {
    background: var(--el-color-success);
  }
  .status-label {
    color: var(--el-color-success);
  }
}
</style>
