<template>
  <div class="g-cnt">
    <div class="m-cal">
      <div class="sizer">
        <div class="sizer-year">
          <el-date-picker
            v-model="currentYearStr"
            value-format="yyyy"
            type="year"
            placeholder="选择年"
            size="small"
            style="width: 150px"
          >
          </el-date-picker>
        </div>
        <div class="sizer-month">
          <div
            class="month-item"
            :class="{ 'z-on': m - 1 == currentMonth }"
            :key="'month' + m"
            @click="currentMonth = m - 1"
            v-for="m in 12"
          >
            <el-badge :value="12" :hidden="m != 3" class="item">
              <div class="month-text">{{ m }}月</div>
            </el-badge>
          </div>
        </div>
        <div class="sizer-btn"></div>
      </div>
      <calendar
        :currentYear="currentYear"
        :currentMonth="currentMonth"
        @clickDate="handleChangeDate"
      >
        <template v-slot:date-item="{ info }">
          <div class="tip">
            <div class="tip-text">
              <span class="z-on">主题当日</span> (已发布)
            </div>
            <div class="tip-cnt">巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉</div>
          </div>
          <div class="corn">
            <div class="corn-num">8</div>
            <div class="corn-text">日程</div>
          </div>
        </template>
      </calendar>
    </div>
  </div>
</template>

<script>
import { requestPost, requestGet } from "@/js/dai/request";
import nextTick from "dai-js/tools/nextTick";
import calendar from "./cpts/calendar";

export default {
  name: "party-calendar",
  components: {
    calendar,
  },
  data() {
    let todayObj = new Date();

    return {
      currentYearStr: todayObj.getFullYear() + "",
      currentMonth: todayObj.getMonth(),
    };
  },
  computed: {
    currentYear() {
      return parseInt(this.currentYearStr);
    },
  },
  async mounted() {
    // await this.getPartyOggList()
  },
  methods: {
    handleChangeDate(item) {
      console.log("handleChangeDate");
      this.currentYearStr = item.year + "";
      this.currentMonth = item.month;
    },

    async getPartyOggList() {
      const url = "/resi/partymember/icPartyOrg/getSearchTreelist";
      let params = {
        agencyId: this.$store.state.user.agencyId,
      };
      const { data, code, msg } = await requestGet(url, params);
      console.log("data-orgparty----o", data);
      if (code === 0) {
        this.partyOrgList = this.deepArrTOnull(data);
      } else {
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/c/config.scss";
@import "@/assets/scss/c/function.scss";

.g-cnt {
  background-color: #ffffff;
  padding: 20px;
}
.m-cal {
  .sizer {
    display: flex;
    margin-bottom: 20px;

    .sizer-month {
      display: flex;

      .month-item {
        position: relative;
        margin-left: 10px;

        /deep/ .el-badge__content {
          z-index: 1;
        }

        &.z-on {
          .month-text {
            background-color: #3e8ef7;
            color: #ffffff;
          }
        }
        .month-text {
          position: relative;
          z-index: 0;
          width: 40px;
          height: 30px;
          text-align: center;
          background-color: #eeeeee;
          border-radius: 8px;
          line-height: 30px;
          font-size: 14px;
          cursor: pointer;
        }
      }
    }
  }

  .tip {
    position: relative;
    margin: 0 3px;
    padding: 3px 2px 3px 12px;
    line-height: 16px;
    box-shadow: 0 0 5px 1px #eee;
    background-color: #ffffff;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    color: #999999;
    .z-on {
      color: #ff3333;
    }
    .tip-text {
      @include toe;
      text-align: left;
    }
    .tip-cnt {
      @include toe;
      text-align: left;
      font-size: 10px;
    }

    &::before {
      position: absolute;
      content: "";
      left: 4px;
      top: 0;
      bottom: 0;
      margin: auto;
      display: block;
      width: 4px;
      height: 4px;
      border-radius: 100%;
      background-color: #ff3333;
    }
  }

  .corn {
    position: absolute;
    right: 0;
    top: 0;
    color: #ffffff;
    cursor: pointer;
    .corn-num {
      position: absolute;
      z-index: 10;
      top: -7px;
      right: -7px;
      border-radius: 100%;
      width: 14px;
      height: 14px;
      line-height: 14px;
      text-align: center;
      font-size: 10px;
      text-align: center;
      color: #ffffff;
      background-color: #f1ba06;
    }
    .corn-text {
      position: relative;
      z-index: 1;
      font-size: 12px;
      line-height: 18px;
      padding-right: 3px;
    }

    &::before {
      content: "";
      display: block;
      position: absolute;
      z-index: 0;
      top: 0;
      right: 0;
      width: 0px;
      height: 0;
      border-top: 17px solid #f33;
      border-right: 25px solid #f33;
      border-bottom: 17px solid transparent;
      border-left: 25px solid transparent;
    }
  }
}
</style>
