<template>
  <div class="cpt-command-airway-list" v-interact>
    <div class="hd">
      <div class="left ml8">
        <!-- <img src="../../../../assets/images/mount_head.png" /> -->
        <div class="title">航空航线</div>
      </div>
      <div @click="close" class="close">关闭</div>
    </div>

    <div class="list-box">
      <div class="tb-box">
        <div class="tb-hd-box">
          <div class="tb-hd">航线ID</div>
          <div class="tb-hd">航线名称</div>
          <div class="tb-hd">所属单位</div>
          <div class="tb-hd">空域状态</div>
          <div class="tb-hd">安全状态</div>
          <div class="tb-hd">航线标签</div>
          <div class="tb-hd last-tb-hd">操作</div>
        </div>
        <div class="tb-bd-box">
          <div class="tb-tr" v-for="item in airwayData.records" :key="item.id">
            <div class="td">{{ item.id || "暂无" }}</div>
            <div class="td">
              <div>{{ item.name || "暂无" }}</div>
            </div>
            <div class="td">{{ item.organizationName || "暂无" }}</div>
            <!-- 空域状态 -->
            <div class="td">
              <div class="status">{{item.status || "暂无"}}</div>
              <!-- <div v-if="item.status == 1" class="status">可用</div>
              <div v-else-if="item.status == 2" class="status" style="color: #2ca1e2">待申请</div>
              <div v-else-if="item.status == 3" class="status" style="color: #ffbd36">待审批</div>
              <div v-else-if="item.status == 4" class="status" style="color: #2bfdf1">通过</div>
              <div v-else-if="item.status == 5" class="status" style="color: #fb4a2d">驳回</div>
              <div v-else>暂无</div>-->
            </div>
            <!-- 安全状态 -->
            <div
              class="td"
              :style="{ color: item.safe == 1 ? '#19D864' : '' }"
            >{{ item.safe == 1 ? "安全" : "待确定" }}</div>
            <!-- 航线标签 -->
            <div class="td">
              <!-- <span v-for="item2 in item.labelList"
              :key="item2.labelId">{{ item2.labelName }}</span>-->
              {{ item.labelName ||"暂无" }}
            </div>
            <div class="td last-td" style="width: 15%">
              <div @click="changeLine(item)">选择航线</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <el-pagination
      layout="prev, pager, next"
      :total="airwayData.total"
      :pageSize="airwayData.pageSize"
      :currentPage.sync="airwayData.pageNo"
      @current-change="getAirway"
    ></el-pagination>
  </div>
</template>

<script>
import { mapState } from "vuex";
import { Control_API } from "../../../../../../../../../../api";

export default {
  inject: ["rootNode"],
  data() {
    return {
      keyword: null,
      airwayData: {
        pageNo: 1,
        records: [],
        pageSize: 10,
        total: 0,
      },
    };
  },
  computed: {
    ...mapState("MMCFlightControlCenter", ["useSTLAirway"]),
  },
  mounted() {
    this.getAirway();
  },
  methods: {
    async changeLine(item) {
      try {
        if (item.safe != 1) {
          await this.$confirm(
            "此航线为非安全航线，开始任务前请确认航线安全！",
            "安全确认",
            { customClass: "uav_controlPane", showClose: false }
          );
        }
        this.$emit("change", item);
        this.close();
      } catch (e) {}
    },
    close() {
      this.$emit("close");
    },
    async getAirway() {
      if (this.useSTLAirway) {
        let res = await Control_API.getUavRouteList({
          pageNo: this.airwayData.pageNo,
          pageSize: this.airwayData.pageSize,
        });
        if (res?.code === 0) {
          let statusMap = {
            1: "可用",
            2: "待申请",
            3: "待审批",
            4: "通过",
            5: "驳回",
          };
          this.airwayData = (res.data.list && {
            pageNo: this.airwayData.pageNo,
            records: res.data.list,
            pageSize: this.airwayData.pageSize,
            total: res.data.total,
          }) || {
            pageNo: this.airwayData.pageNo,
            records: [],
            pageSize: this.airwayData.pageSize,
            total: this.airwayData.total,
          };

          this.airwayData.records = this.airwayData.records?.map((item) => {
            let content = [];
            try {
              content = JSON.parse(item.content).content; // TODO 待确认字段
            } catch (e) {
              console.log(e);
            }
            return {
              ...item,
              status: statusMap[item.status],
              content,
            };
          });
        }
      } else {
        this.rootNode.$emit("airwayListGet", {
          pageNo: this.airwayData.pageNo,
          pageSize: this.airwayData.pageSize,
          callback: (data) => {
            this.airwayData = data || {
              pageNo: 1,
              records: [],
              pageSize: 10,
              total: 0,
            };
          },
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.cpt-command-airway-list {
  width: 600px;
  position: absolute;
  right: -213px;
  top: 300px;
  box-sizing: border-box;
  background: #222222;
  box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  border-radius: 2px;

  .hd {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 32px;
    background: #3c3c3c;
    border-radius: 2px 2px 0px 0px;

    .left {
      display: flex;
      align-items: center;
      .title {
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 14px;
        color: #ffffff;
      }
    }

    .close {
      font-size: 14px;
      font-family: MicrosoftYaHei;
      color: #d2dfff;
      margin-right: 8px;
      cursor: pointer;
    }
  }

  .list-box {
    // width: 1132px;
    height: calc(100% - 56px);
    box-sizing: border-box;
    .search-box {
      margin-left: 0 !important;
      // height: 80px;
      height: auto;
      margin: 24px 0 24px 0;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      .item-plan {
        width: 79px;
        height: 32px;
        background: rgba(28, 67, 191, 0.6) !important;
        box-shadow: 0px 2px 4px 0px rgba(23, 33, 60, 0.5),
          inset 0px 0px 16px 0px rgba(33, 137, 255, 0.4),
          inset 0px 0px 4px 0px #00a7ff;
        border: 1px solid;
        border-image: linear-gradient(
            180deg,
            rgba(138, 218, 255, 1),
            rgba(82, 179, 255, 0)
          )
          1 1;
        border-radius: 0px;
        font-size: 12px;
        font-family: MicrosoftYaHei;
        color: #43deff;
        line-height: 16px;
      }
      .item-plan:hover {
        opacity: 0.5;
      }
      .item-input {
        width: 168px;
        height: 40px;
        margin-left: 10px;
        // margin-right: 10px;
        color: #08c2d1;
        ::v-deep .el-input__inner {
          background: rgba(2, 31, 51, 0);
          border: 0px solid #06b6e0;
          border-radius: 4px;
          font-family: MicrosoftYaHeiUI;
          font-size: 16px;
          color: #08c2d1;
          font-weight: 400;
          padding-left: 0;
          &::placeholder {
            font-size: 14px;
            font-family: MicrosoftYaHei;
            color: #397c8b;
            line-height: 19px;
          }
        }
      }
      .andLinlineBtn {
        position: absolute;
        top: 65px;
        right: 160px;
        width: 130px;
        cursor: pointer;
        height: 32px;
        opacity: 0.8;
        font-family: PangMenZhengDao;
        font-size: 22px;
        color: #00ffff;
        text-align: center;
        font-weight: 400;
        line-height: 40px;
      }
      .routeLabelBtn {
        position: absolute;
        top: 65px;
        right: 20px;
        width: 130px;
        cursor: pointer;
        height: 40px;
        opacity: 0.8;
        font-family: PangMenZhengDao;
        font-size: 22px;
        color: #00ffff;
        text-align: center;
        font-weight: 400;
        line-height: 40px;
      }
      .routeLabelBtnDefault {
        background: rgba(0, 3, 36, 0.8);
        box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5),
          inset 0 0 15px 0 rgba(0, 182, 255, 0.9);
        border-radius: 6px;
      }
      .routeLabelBtnActive {
        background: rgba(0, 34, 140, 0.2);
        box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5), inset 0 0 10px 0 #00b6ff;
        border-radius: 6px;
      }
    }
    .tb-box {
      // overflow-x: scroll;
      // overflow-y: hidden;
      padding: 0 !important;
      .tb-hd-box {
        display: flex;
        background: #303133;
        // width: 1415.62px;
        border-top: 1px solid rgba(207, 234, 255, 0.33);
        border-bottom: 1px solid rgba(207, 234, 255, 0.33);
        height: 37.6px;

        .tb-hd {
          flex: 1;
          line-height: 37.6px;
          width: calc(100% / 8);
          white-space: nowrap;
          height: 100%;
          text-align: center;
          font-family: MicrosoftYaHei-Bold;
          font-size: 16px;
          color: #b5e5ff;
          letter-spacing: 0;
          font-weight: 700;
        }
      }
      .tb-bd-box {
        width: 100%;
        max-height: 280px;
        overflow: hidden;
        overflow-y: auto;
        .tb-tr {
          display: flex;
          color: #fff;
          align-items: center;
          font-size: 14px;
          width: 100%;
          margin: 5px 0 0 0;
          // border: 1px solid;
          background: #081a3a;
          cursor: pointer;
          // background-image: url("~@/assets/newImage/tiaokaung.png") !important;
          background-size: 100% 100%;
          // &:hover {
          //   // background: rgba(2, 19, 96, 0.2);
          //   box-shadow: inset 0px 0px 10px 2px #3fcbff;
          //   // border: 1px solid #70f6f9;
          // }
          &:nth-of-type(2n - 1) {
            background: #3c3c3c;
          }
          .td {
            // width: calc(100% / 7);
            flex: 1;
            text-align: center;
            overflow: hidden;
            text-overflow: ellipsis;
          }
          .last-td {
            width: 80px;
            height: 32px;
            text-align: center;
            line-height: 32px;
            margin: 0 auto;
            color: #fff;
            background: #3388ff;
            font-family: SourceHanSansCN, SourceHanSansCN;
            font-weight: 400;
            font-size: 14px;
          }
        }
      }
    }
  }
}
.toubu {
  display: flex;
  .tiao {
    width: 3px !important;
    height: 15px;
    background: #ffbd36;
    margin: 6px 5px 0 16px;
  }
  .hd-box {
    font-size: 18px;
    font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
    font-weight: bold;
    color: #ffffff;
    line-height: 24px;
    text-shadow: 0px 2px 4px #136791;
  }
}
.cpt-command-airway-list .tb-box {
  height: 100%;
}
.flex {
  display: flex;
}
.uavImg {
  width: 20px;
  height: 20px;
  margin: 0 6px 0 6px;
  img {
    width: 100%;
    height: 100%;
  }
}
.fangkuai {
  border: 1px solid #43deff;
  height: 32px;
  background: rgba(13, 50, 92, 0.7);
}
.duanxian {
  width: 1px;
  height: 22px;
  border-left: 1px solid;
  border-image: linear-gradient(
      180deg,
      rgba(67, 222, 255, 0),
      rgba(67, 222, 255, 1),
      rgba(67, 222, 255, 0)
    )
    1 1;
}
.el-input__suffix-inner::v-deep {
  i {
    color: #43deff;
  }
}
// 滚动动画
.animate {
  padding-left: 20px;
  // font-size: 12px;
  // color: #000;
  display: inline-block;
  white-space: nowrap;
  animation: 5s wordsLoop linear infinite normal;
}

@keyframes wordsLoop {
  0% {
    transform: translateX(100%);

    -webkit-transform: translateX(100%);
  }

  100% {
    transform: translateX(-100%);

    // -webkit-transform: translateX(-100%);
  }
}

// @-webkit-keyframes wordsLoop {
//   0% {
//     transform: translateX(100%);

//     -webkit-transform: translateX(100%);
//   }

//   100% {
//     transform: translateX(-100%);

//     -webkit-transform: translateX(-100%);
//   }
// }

// 提示框样式
.td::v-deep .el-tooltip {
  background: rgba(2, 19, 96, 0);
  border: 0px solid rgba(207, 234, 255, 0.33);
  font-family: MicrosoftYaHei;
  color: #ffffff;
  line-height: 19px;
}
// 空域状态
.status {
  font-size: 14px;
  font-family: MicrosoftYaHei;
  color: #00d45c;
  line-height: 19px;
}
//操作状态
.el-tooltip {
  opacity: 0.7;
}
.el-tooltip:hover {
  opacity: 1;
}
// 页签样式
.zongji {
  font-size: 12px;
  font-family: MicrosoftYaHei;
  color: #b5e5ff;
  line-height: 16px;
  .tiaoshu {
    color: #43deff;
  }
}
.douhao {
  margin: 0 5px 0 5px;
}
.dangqianye {
  margin: 0 20px 0 0;
}
.el-pager::v-deep .number:hover {
  background: #00b6ff !important;
  border-radius: 2px;
  color: #000 !important;
  width: 14px;
  height: 22px;
  line-height: 22px;
}
.el-pagination--small::v-deep .el-pager .number {
  font-size: 12px;
  font-family: MicrosoftYaHei;
  color: #889fb2;
}
.active::v-deep {
  color: #000 !important;
}
.btnqueding {
  margin: 0 0 0 8px;
  width: 79px;
  height: 32px;
  background: rgba(28, 67, 191, 0.6) !important;
  box-shadow: 0px 2px 4px 0px rgba(23, 33, 60, 0.5),
    inset 0px 0px 16px 0px rgba(33, 137, 255, 0.4),
    inset 0px 0px 4px 0px #00a7ff;
  border-radius: 0px;
  border: 1px solid;
  border-image: linear-gradient(
      180deg,
      rgba(138, 218, 255, 1),
      rgba(82, 179, 255, 0)
    )
    1 1;
  line-height: 1px;
  color: #43deff;
}
.btnqueding:hover {
  opacity: 0.5 !important;
}
.tb-pagination {
  margin: 0 0 19px 0;
}
.zhuan {
  font-size: 12px;
  font-family: MicrosoftYaHei;
  color: #889fb2;
  line-height: 16px;
  input {
    width: 48px;
    min-width: 48px;
    max-width: auto;
    text-align: center;
    height: 28px;
    background: rgba(12, 13, 20, 0.5);
    border-radius: 2px;
    border: 1px solid rgba(36, 146, 252, 0.3);
    margin: 0 5px 0 5px;
    color: #fff;
    outline: 0px solid;
  }
}
// 说明
.shuo {
  margin: 0 0 29px 0;
}
.shuoming {
  font-size: 12px;
  font-family: MicrosoftYaHei;
  color: #43deff;
  line-height: 16px;
}
.maohao {
  font-size: 12px;
  font-family: MicrosoftYaHei;
  color: #43deff;
  line-height: 16px;
  margin: 0 14px 0 5px;
}
.icons {
  font-size: 12px;
  font-family: MicrosoftYaHei;
  color: #b3bbc5;
  line-height: 16px;
  margin: 0 12px 0 0;
}
.cpt-command-flight-task-explain {
  display: flex;
  align-items: center;
  margin-left: 4px;
  // margin-top: 8px;
  padding: 0;
  margin: 28px 0 29px 0;

  .explain_title {
    font-family: MicrosoftYaHei;
    font-size: 14px;
    color: #08c2d1;
  }

  .explain_box {
    display: flex;
  }

  .explain_box_detail {
    margin-right: 15px;
    font-size: 12px;
    font-family: MicrosoftYaHei;
    color: #b3bbc5;
  }
}
.waixian {
  // border-radius: 6px;
  // border: 1px solid #8adaff;
}
.el-tooltip__popper::v-deep .is-dark {
  z-index: -100;
}

.el-pagination::v-deep {
  text-align: center;

  .btn-prev,
  .btn-next {
    color: #fff;
    background-color: transparent;
  }

  .el-pager {
    color: #fff;

    li {
      background-color: transparent;
    }
  }
}
</style>