<template>
  <div id="management">
    <div class="side-area">
      <Title text="混凝土方量统计"></Title>
      <ShadowContainer>
        <div class="detail-status">
          <div class="count-details">
            <img src="@/assets/icon-short-bg.png" alt="" />
            <div class="count-detail">
              <div class="data">288.69</div>
              <div class="text">本月供应量/m³</div>
            </div>
            <div class="count-detail">
              <div class="data">288.69</div>
              <div class="text">今日计划量/m³</div>
            </div>
            <div class="count-detail">
              <div class="data">885.69</div>
              <div class="text">今日供应量/m³</div>
            </div>
          </div>
          <div class="divider">
            <div class="divider-line"></div>
            <div class="divider-text">今日任务单</div>
            <div class="divider-line"></div>
          </div>
        </div>

        <div class="quest-list">
          <div class="quest">
            <div class="quest-title">
              <img src="@/assets/management/quest.png" alt="" />
              PT20220824340320
              <span class="right">
                <i class="el-icon-caret-bottom"></i>
              </span>
            </div>
            <div class="quest-infos">
              <div class="quest-info">
                <div class="quest-count">1827.01</div>
                <div class="quest-text">计划供应</div>
              </div>
              <div class="quest-info">
                <div class="quest-count">946.72</div>
                <div class="quest-text">已供应</div>
              </div>
              <div class="quest-info">
                <div class="quest-count">6</div>
                <div class="quest-text">累计车次</div>
              </div>
            </div>
            <div class="quest-des">
              <div>任务需求：</div>
              <div>工程部位：</div>
            </div>
            <div class="car-list">
              <div class="car">
                <img src="@/assets/management/icon-car.png" alt="" />
                <div>
                  <div>浙A283747 / 第37车 / 王一 / 92m³</div>
                  <div>发车时间：未发车</div>
                </div>
              </div>
              <div class="car">
                <img src="@/assets/management/icon-car.png" alt="" />
                <div>
                  <div>浙A283747 / 第37车 / 王一 / 92m³</div>
                  <div>发车时间：未发车</div>
                </div>
              </div>
              <div class="car">
                <img src="@/assets/management/icon-car.png" alt="" />
                <div>
                  <div>浙A283747 / 第37车 / 王一 / 92m³</div>
                  <div>发车时间：未发车</div>
                </div>
              </div>
              <div class="car">
                <img src="@/assets/management/icon-car.png" alt="" />
                <div>
                  <div>浙A283747 / 第37车 / 王一 / 92m³</div>
                  <div>发车时间：未发车</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </ShadowContainer>
    </div>
    <div class="mid-area">
      <div class="status-container">
        <div class="rect">
          <div class="rect-count">
            1837.28
            <span>m³</span>
          </div>
          <div class="rect-text">累计使用方量</div>
        </div>
        <div class="rect" style="cursor: pointer" @click="preComVisible = true">
          <div class="rect-count">
            803.83
            <span>m³</span>
          </div>
          <div class="rect-text">未来三天预订单</div>
        </div>

        <div class="rect">
          <div class="rect-count">
            0
            <span>m³</span>
          </div>
          <div class="rect-text">今日预订单</div>
        </div>
        <pre-com-dialog
          :visible="preComVisible"
          @changeVisible="(val) => (preComVisible = val)"
        ></pre-com-dialog>
      </div>
      <div style="position: relative">
        <div class="carwindow" v-if="carVisible">
          <div class="car-description">
            <img src="@/assets/management/icon-car2.png" alt="" />
            浙A283747 / 第37车
            <span class="online">运输中</span>
          </div>
          <div class="car-info">
            <div>驾驶员：</div>
            <div>部位：</div>
            <div>标号/泵送方式：</div>
            <div>出厂时间：</div>
          </div>
        </div>
        <div class="swagger-container">
          <img class="lt" src="@/assets/lt.png" alt="" />
          <img class="rt" src="@/assets/rt.png" alt="" />
          <img class="rb" src="@/assets/rb.png" alt="" />
          <img class="lb" src="@/assets/lb.png" alt="" />
          <div id="amap-container"></div>
        </div>
      </div>
    </div>
    <div class="side-area">
      <Title text="见证取样"></Title>
      <ShadowContainer>
        <div class="detail-status">
          <div class="count-details">
            <img src="@/assets/icon-short-bg.png" alt="" />
            <div class="count-detail">
              <div class="data">231</div>
              <div class="text">取样总量</div>
            </div>
            <div class="count-detail">
              <div class="data">288.69</div>
              <div class="text">已取样</div>
            </div>
            <div class="count-detail">
              <div class="data">0</div>
              <div class="text">未取样</div>
            </div>
          </div>
          <div class="divider flex">
            <div
              :class="['tab-divider', active == 1 ? 'active' : '']"
              @click="changeActive(1)"
            >
              <div class="divider-line"></div>
              <div class="divider-text">未取样</div>
              <div class="divider-line"></div>
            </div>
            <div
              :class="['tab-divider', active == 2 ? 'active' : '']"
              @click="changeActive(2)"
            >
              <div class="divider-line"></div>
              <div class="divider-text">已取样</div>
              <div class="divider-line"></div>
            </div>
          </div>
        </div>
        <div class="sample-list">
          <div class="sample">
            <div class="sample-title">
              <img src="@/assets/management/sample.png" alt="" />
              PT20220824340320
            </div>
            <div class="sample-info">
              <div>养护条件：</div>
              <div>强度等级：</div>
              <div>结构部位：</div>
              <div>供应日期：</div>
            </div>
          </div>
        </div>
      </ShadowContainer>
      <sample-dialog
        :visible="sampleVisible"
        @changeVisible="(val) => (sampleVisible = val)"
      ></sample-dialog>
    </div>
  </div>
</template>
<script>
import sampleDialog from "./sampleDialog";
import preComDialog from "./preComDialog";

import AMapLoader from "@amap/amap-jsapi-loader";
import { getBaseInfo } from "@/api/index";
export default {
  name: "Management",
  components: { sampleDialog, preComDialog },
  data() {
    return {
      active: 1,
      AMap: null,
      map: null,
      mapCenter: [],
      carVisible: false,
      sampleVisible: false,
      preComVisible: false,
    };
  },
  methods: {
    changeActive(index) {
      this.active = index;
    },
    initMap() {
      AMapLoader.load({
        key: "a7387204aeee9f238b217bad35460ba9",
        version: "1.4.15",
        plugins: ["AMap.MarkerClusterer", "AMap.DistrictSearch"],
      })
        .then((AMap) => {
          // 初始化地图
          this.AMap = AMap;
          this.map = new AMap.Map("amap-container", {
            viewMode: "2D",
            zoom: 19,
            center: this.mapCenter,
            resizeEnable: true,
            mapStyle: "amap://styles/1dda787b3ac1ce28f171d2f153726eb7",
          });
          this.map.on("click", () => {});
          this.$nextTick(() => {
            var scale = window.innerHeight / 1080;
            document.getElementById("amap-container").style.zoom = 1 / scale;
          });
        })

        .catch((e) => {
          console.log(e);
        });
    },
    setMarker() {
      this.monitors.map((marker) => {
        const mapMarkers = new this.AMap.Marker({
          //   icon: marker.is_online == 1 ? onlineIcon : offlineIcon,
          position: [marker.longitude, marker.latitude],
          offset: new this.AMap.Pixel(-25, -25),
          extData: {
            markerData: marker,
          },
        });
        mapMarkers.setMap(this.map);
        mapMarkers.on("click", (e) => {
          const markData = e.target.getExtData().markerData;
          this.map.setCenter([markData.longitude, markData.latitude]);
          this.windowData = markData;
          this.$nextTick(() => {
            this.towerWindowVisible = true;
          });
        });
      });
    },
  },
  mounted() {
    getBaseInfo().then((res) => {
      this.mapCenter = [res.data.longitude, res.data.latitude];
      this.$nextTick(() => {
        this.initMap();
      });
    });
  },
};
</script>
<style scoped lang="less">
#management {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  padding-bottom: 0;
}
.side-area {
  width: 25%;
}
.mid-area {
  width: calc(50% - 24px);
  margin: 0 20px;
  .status-container {
    display: flex;
    justify-content: space-between;
    .rect {
      width: 250px;
      height: 104px;
      background: url("@/assets/management/stat-bg.png") no-repeat;
      background-size: 100% 100%;
      padding: 34px 20px;
      text-align: center;
      .rect-count {
        font-size: 44px;
        color: rgba(198, 234, 249, 1);

        span {
          font-size: 14px;
        }
      }
      .rect-text {
        font-size: 22px;
        color: #27acfb;
      }
    }
  }
}
.divider {
  display: flex;
  justify-content: center;
  align-items: stretch;
  margin-bottom: 12px;
  .divider-line {
    width: calc(50% - 166px);
    border-top: 1px solid #f2af58;
    transform: translateY(50%);
  }
  .divider-text {
    text-align: center;
    width: 100px;
    font-size: 16px;
    padding: 0 8px;
    font-weight: 400;
    color: #27acfb;
  }
}
.construction-name {
  font-size: 20px;
  font-family: Source Han Sans CN;
  font-weight: 500;
  font-style: italic;
  color: #ffffff;
  text-align: center;
  margin: 20px 0;
  margin-top: 0;
}
.count-details {
  display: flex;
  justify-content: space-between;
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  padding-top: 20px;
  img {
    position: absolute;
    width: 100%;
    vertical-align: top;
    left: 0;
    top: 0;
    z-index: -1;
  }
  .count-detail {
    width: calc(100% / 3);
  }
  .data {
    font-size: 24px;

    font-weight: bold;
    color: #ffaf51;
    line-height: 24px;
    margin-bottom: 12px;
    &.unrecord {
      opacity: 0.2;
    }
    &.small {
      font-size: 12px;
      line-height: 12px;
    }
  }
  .text {
    font-size: 14px;

    font-weight: 400;
    color: #27acfb;
  }
}
.divider.flex {
  display: flex;
  justify-content: space-between;
}
.tab-divider {
  width: 45%;
  display: flex;
  justify-content: center;
  cursor: pointer;
  .divider-text {
    width: 50px;
    color: #c6def9;
  }
  .divider-line {
    width: calc(50% - 60px);
    border-top: 1px solid #c6def9;
    transform: translateY(50%);
  }
}
.tab-divider.active {
  .divider-text {
    color: #27acfb;
  }
  .divider-line {
    border-color: #f2af58;
  }
}
.sample-list {
  height: 720px;
  .sample {
    img {
      width: 20px;
      vertical-align: middle;
      margin-right: 6px;
    }
    font-size: 14px;
    color: #c6def9;
    .sample-title {
      background: rgba(44, 96, 162, 0.2);
      border-bottom: 1px solid rgba(122, 143, 173, 0.4);
      line-height: 40px;
      padding: 0 12px;
    }
    .sample-info {
      background: rgba(44, 96, 162, 0.1);
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      & > div {
        width: calc(50% - 48px);
        padding: 6px 12px;
      }
    }
    &:hover {
      color: #27acfb;
      .sample-title,
      .sample-info {
        background: rgba(44, 96, 162, 0.4);
      }
    }
  }
}

.swagger-container {
  position: relative;
  margin-top: 20px;
  height: 770px;

  .lt,
  .lb,
  .rb,
  .rt {
    position: absolute;
    width: 20px;
    height: 20px;
  }
  .lt {
    top: -2px;
    left: -2px;
  }
  .lb {
    left: -2px;
    bottom: -2px;
  }
  .rb {
    right: -2px;
    bottom: -2px;
  }
  .rt {
    right: -2px;
    top: -2px;
  }
}
.quest-list {
  .quest {
    color: #c6def9;
    background: rgba(44, 96, 162, 0.2);
    .quest-title {
      font-size: 14px;
      color: #c6def9;
      line-height: 40px;
      padding: 0 10px;
      border-bottom: 1px solid rgba(122, 143, 173, 0.4);
      img {
        width: 20px;
        vertical-align: middle;
      }
      .right {
        float: right;
      }
    }
    .quest-infos {
      display: flex;
      justify-content: space-between;
      margin-top: 10px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(122, 143, 173, 0.4);
      .quest-info {
        width: calc(100% / 3);
        border-right: 1px solid rgba(122, 143, 173, 0.4);
        padding: 8px;
        text-align: center;
        &:last-child {
          border-right: none;
        }
        .quest-text {
          margin-top: 10px;
        }
      }
    }
    .quest-des {
      display: flex;
      justify-content: space-between;
      line-height: 44px;
      padding: 0 10px;
      & > div {
        width: 50%;
      }
    }
    .car-list {
      border-top: 1px solid rgba(122, 143, 173, 0.4);
      .car {
        display: flex;
        justify-content: flex-start;
        padding: 10px;
        border-bottom: 1px solid rgba(122, 143, 173, 0.4);
        &:last-child {
          border-bottom: none;
        }
        &:hover {
          background: rgba(44, 96, 162, 0.5);
          color: #27acfb;
        }
        img {
          width: 20px;
          margin-right: 10px;
        }
      }
    }
  }
}
#amap-container {
  width: 100%;
  height: 100%;
}
.carwindow {
  width: 460px;
  height: 180px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: url("@/assets/safecap/cap-window-bg.png") no-repeat;
  background-size: 100% 100%;
  padding: 20px;
  z-index: 1000;
}
.car-info {
  font-size: 16px;
  color: #c6def9;
  line-height: 30px;
  margin-top: 12px;
}

.car-description {
  line-height: 32px;
  font-size: 18px;
  color: #c6def9;
  padding-bottom: 16px;
  border-bottom: 1px solid #7a8fad;
  img {
    width: 32px;
    vertical-align: top;
  }
  .online {
    color: rgba(62, 236, 111, 1);
    float: right;
  }
}
</style>