<template>
  <div class="mmc-filght-control-center mmc">
    <!-- cesium地图层 -->
    <cesiumLayout v-if="!cesiumViewer"></cesiumLayout>
    <!-- 地图切换组件 -->
    <mapImageSwitch></mapImageSwitch>
    <!-- 无人机应用 -->
    <uavApplications v-if="scene === 0"></uavApplications>
    <!-- 机库 -->
    <hangar v-else></hangar>
  </div>
</template>

<script>
import cesiumLayout from "./components/cesiumLayer";
import mapImageSwitch from "./components/mapImageSwitch";
import uavApplications from "./components/uavApplications";
import hangar from "./components/hangar";
import Vue from "vue";
import SymbolIcon from "../symbol-icon";

export default {
  name: "MMCFlightControlCenter",
  components: {
    cesiumLayout,
    mapImageSwitch,
    uavApplications,
    hangar,
  },
  props: {
    devMode: {
      // 开发环境
      type: Boolean,
      default: false,
    },
    // 天目将登录用户信息
    userInfo: {
      type: Object,
      default: null,
    },
    // 无人机任务列表
    uavTaskList: {
      type: Array,
      default() {
        return [
          /* {
            name: '任务',
            id: 1,
            children: [],
            airway: {
              name: '航线名称',
              id: 1
            }
          } */
        ];
      },
    },
    // 机库任务列表
    hangarTaskList: {
      type: Object,
      default() {
        return {
          // 常态
          normal: [
            /* {
              name: '任务',
              id: 1,
              status: '', 任务状态
              children: [],
              airway: {
                name: '航线名称',
                id: 1
              }
            } */
          ],
          // 定时
          Timed: [
            /* {
              name: '任务',
              id: 1,
              time: '', //定时与周期的时间
              status: '', 任务状态
              airway: {
                name: '航线名称',
                id: 1
              }
            } */
          ],
          // 周期
          period: [
            /* {
                name: '任务',
                id: 1,
                time: '', //定时与周期的时间
                status: '', 任务状态
                airway: {
                  name: '航线名称',
                  id: 1
                }
              } */
          ],
        };
      },
    },
    // 场景 0: 无人机 1: 机库
    scene: {
      type: Number,
      default: 0,
    },
    cesiumViewer: {
      type: Object,
      default: null
    }
  },
  provide() {
    return {
      rootNode: this, //根节点实例
      bus: new Vue(), //bus总线
    };
  },
  watch: {
    uavTaskList: {
      immediate: true,
      handler(newVal) {
        this.$store.commit("MMCFlightControlCenter/uav/setState", {
          key: "taskList",
          value: newVal,
        });
      },
    },
    hangarTaskList: {
      immediate: true,
      handler(newVal) {
        this.$store.commit("MMCFlightControlCenter/hangar/setState", {
          key: "taskList",
          value: newVal,
        });
      },
    },
  },
  beforeCreate() {
    Vue.component("SymbolIcon", SymbolIcon);
    if (!window.$mmc) {
      window.$mmc = {};
    }
    window.$mmc.$store = this.$store;
    window.$mmc.state = () => {
      return this.$store.state;
    };
  },
  created() {
    this.$store.commit("MMCFlightControlCenter/setState", {
      key: "devMode",
      value: this.devMode,
    });
    this.$store.commit("MMCFlightControlCenter/setState", {
      key: "token",
      value: this.userInfo.token,
    });
    this.$store.commit("MMCFlightControlCenter/setState", {
      key: "userInfo",
      value: this.userInfo,
    });

    if(this.cesiumViewer){
      this.$store.commit("MMCFlightControlCenter/setState", {
        key: "cesiumViewer",
        value: this.cesiumViewer
      })
      window.$mmc.viewer = this.cesiumViewer;
    }
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
.mmc-filght-control-center {
  overflow: hidden;
  position: relative;
  height: 100%;
  width: 100%;
}
</style>

<style lang="scss">
.mmc-filght-control-center {
  overflow: hidden;
  position: relative;
  height: 100%;
  width: 100%;

  .el-input__inner {
    background-color: #02173d;
    color: #00aacb;
    border: 1px solid #2b56b7;
  }

  .el-range-input {
    background-color: transparent;
    color: #fff;
  }

  .el-range-separator {
    color: #fff;
  }

  .el-dialog__body {
    button:nth-child(2) {
      box-shadow: inset 0 0 5px #00ffff;
      background: rgba(4, 227, 227, 0.1);
      opacity: 0.8;
    }
  }

  * {
    /* 滚动条整体样式 */
    &::-webkit-scrollbar {
      width: 10px; /* 滚动条宽度 */
    }

    /* 滚动条滑块样式 */
    &::-webkit-scrollbar-thumb {
      background-color: #02173d; /* 滑块颜色 */
    }

    /* 滚动条滑块悬停样式 */
    &::-webkit-scrollbar-thumb:hover {
      background-color: #112d5b; /* 悬停时滑块颜色 */
    }

    &::-webkit-scrollbar-track-piece {
      /* background-color: #182F5C; */
    }

    &::-webkit-scrollbar-track {
      background-color: #182f5c;
    }
  }

  .dialog1027 {
    z-index: 1;
    .dialog-header {
      box-sizing: border-box;
      padding-left: 35px;
      padding-right: 16px;
      background-position: 12px 4px;
      height: 32px;
      width: 100%;
      background: linear-gradient(
        180deg,
        #9198ff 0%,
        rgba(45, 81, 153, 0.45) 40%,
        #05091a 100%
      );
      box-shadow: inset 0px 0px 10px 2px #3f9dff;
      border-radius: 10px 10px 0px 0px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: relative;

      .dialog-header__icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translate(0, -50%);
        background-image: url("./assets/images/jinye.png");
        background-size: 100% 100%;
        width: 19px;
        height: 25px;
      }

      .dialog-header__title {
        display: flex;
        align-items: center;
        font-size: 20px;
        font-family: YouSheBiaoTiHei;
        background-image: -webkit-linear-gradient(
          right,
          #e3aa77,
          #f5cda9,
          #f9ecd3,
          #fcdbb1,
          #edb07a
        );
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        letter-spacing: 0;
        font-weight: 700;
      }

      .dialog-header__close {
        font-size: 14px;
        font-family: MicrosoftYaHei;
        color: #d2dfff;
        line-height: 19px;
        cursor: pointer;
      }
    }

    .dialog-content {
      background: rgba(12, 34, 73, 0.7);
      border-bottom-left-radius: 10px;
      border-bottom-right-radius: 10px;
      border: 1px solid rgba(26, 92, 246, 0.5);
      backdrop-filter: blur(1px);
      padding: 12px 12px 16px;
      width: 100%;
      font-size: 14px;
      font-family: SourceHanSansCN-Regular, SourceHanSansCN;
      font-weight: 400;
      color: #ffffff;
      box-sizing: border-box;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;

      .dialog-content-item {
        margin-bottom: 16px;
        display: flex;

        .dialog-content__label {
          padding-top: 7px;
          font-size: 14px;
          font-family: SourceHanSansCN-Regular, SourceHanSansCN;
          font-weight: 400;
          color: #ffffff;
          width: 110px;
          text-align: right;
        }

        .dialog-content__text {
          padding: 6px 12px;
          width: 228px;
          background: rgba(2, 23, 61, 1);
          border-radius: 2px;
          border: 1px solid #315ec7;
          font-size: 14px;
          font-family: MicrosoftYaHei;
          color: #00dfff;
          line-height: 19px;
        }
      }

      .el-input__inner {
        // height: 32px;
        background: #02173d !important;
        border-radius: 2px;
        border: 1px solid #315ec7 !important;
        font-size: 14px;
        font-family: MicrosoftYaHei;
        color: #ffffff;
      }

      .el-radio {
        color: #fff;
      }

      .el-scrollbar {
        background: #02173d !important;
        border: 1px solid #315ec7 !important;
      }

      .el-textarea {
        border: none !important;
      }

      .el-textarea__inner {
        background: #02173d !important;
        border: 1px solid #315ec7 !important;
      }

      .btn-box1027 {
        padding: 16px 16px;
        width: 100%;
      }
    }
  }

  .el-input-number {
    .el-input-number__decrease,
    .el-input-number__increase {
      bottom: 1px;
      background: #606266;
      color: #f5f7fa;
      border-radius: 0;
      border: none;
    }

    .el-input-number__decrease {
      left: 1px;
    }

    .el-input-number__increase {
      right: -1px;
    }
  }

  .el-form-item__label {
    color: #fff;
  }
}

.mmc {
  .popper__arrow::after {
    border-bottom-color: #161d2d !important;
  }
  // 所有下拉选择框样式
  &.el-select-dropdown {
    border: none !important;

    //item选项的hover样式
    .el-select-dropdown__item.hover,
    .el-select-dropdown__item:hover {
      background: #34466e !important;
    }

    .option.hover,
    .option:hover {
      background-image: linear-gradient(
        90deg,
        rgba(44, 135, 176, 0.7) 0%,
        rgba(26, 100, 139, 0.37) 51%,
        rgba(7, 61, 98, 0.7) 100%
      );
      font-family: MicrosoftYaHei;
      font-size: 12px;
      color: #00f5ff;
      letter-spacing: 0 !important;
      font-weight: 400 !important;
    }
    .el-select-dropdown__item {
      color: #00aeff !important;

      .selected {
        background-color: #606266 !important;
      }
    }

    .option {
      font-family: MicrosoftYaHei;
      font-size: 12px !important;
      color: rgba(146, 217, 255, 0.7) !important;
      letter-spacing: 0;
      font-weight: 400 !important;
    }

    .el-scrollbar {
      overflow: hidden;
      position: relative;
      background: #0d224f !important;

      border: 1px solid #178890;
    }

    &.is-multiple {
      .el-select-dropdown__item.selected {
        background-color: #34466e !important;
      }
    }

    .el-select-dropdown__empty {
      background: #02173d;
      border: 1px solid #315ec7;
    }
  }

  &.el-cascader__dropdown {
    border: 1px solid #315ec7 !important;

    .el-cascader-menu__list {
      background: rgba(9, 32, 87, 1) !important;
      max-height: 300px;
      max-width: 327px;
    }

    .el-cascader-node {
      background: rgba(9, 32, 87, 1) !important;
      color: #00aeff;
    }
  }

  &.el-dialog {
    background: transparent;

    .el-dialog__header {
      padding: 0;
    }

    .el-dialog__body {
      padding: 0;
    }
  }

  .el-popper {
    background: rgba(9, 32, 87, 1) !important;
  }
  // 日期选择器组件
  &.el-date-range-picker,
  &.el-date-picker {
    border: none !important;

    .el-picker-panel__body-wrapper {
      background: #0d224f;
      border: 1px solid #00aeff;
      color: #fff;

      .el-month-table td.current:not(.disabled) .cell {
        color: #00aeff !important;
      }

      .el-input__inner {
        color: #fff;
        border: 1px solid #00aeff;
      }

      .el-date-table td.disabled div {
        background-color: transparent;
      }

      .el-date-table th {
        // border-bottom: solid 1px #00aeff;
        color: #fff;
      }

      .el-date-table td.in-range div {
        background-color: #00aeff;
      }

      .el-date-picker__header-label {
        color: #fff;
      }

      .el-input--small .el-input__inner {
        background-color: #0d224f;
      }

      .el-picker-panel__icon-btn {
        color: #fff;
      }
    }

    .el-picker-panel__footer {
      background-color: #0d224f !important;
    }

    .popper__arrow {
      border-bottom-color: #00aeff !important;
      border-top-color: #00aeff !important;
    }

    .popper__arrow::after {
      border-top-color: #0d224f !important;
      border-bottom-color: #0d224f !important;
    }

    .el-button.el-button--mini.is-plain,
    .el-button.is-disabled.is-plain {
      background-color: transparent !important;
      border: none;
      color: #00aeff;
    }

    .el-time-spinner__item {
      color: #00eaff;
    }

    .el-time-panel__btn {
      color: #fff;

      &.confirm {
        color: #409eff;
      }
    }
  }
}
</style>