<template>
  <Dialog v-model="visibleModel" title="上传日历" width="700px">
    <el-calendar v-model="mon">
      <template
        slot="dateCell"
        slot-scope="{date, data}">
        <p :class="selDays.indexOf(data.day)!==-1 ? 'is-selected' : ''">
          {{ data.day.split('-').slice(1).join('-') }} {{ data.isSelected ? '✔️' : ''}}
        </p>
      </template>
    </el-calendar>
  </Dialog>
</template>

<script>
import Dialog from "@screen/components/Dialog/index.vue";
import request from "@/utils/request";
export default {
  name: "DialogCamera",
  components: {
    Dialog,
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    }
  },
  emit: ["close"],
  data() {
    return {
      mon: new Date(),
      selDays:[]
    };
  },
  watch: {
    mon: {
      handler(newValue, oldValue) {
        this.getData();
      },
      deep: true,
    }
  },
  computed: {
    visibleModel: {
      get() {
        if (this.visible) this.getData();
        return this.visible;
      },
      set(bool) {
        this.$emit("close", bool);
      },
    },
  },
  methods: {
    getData() {
      const month = moment(this.mon).format('YYYY-MM')
      request({
        url: `/business/sdhsEvent/getDataCalendar/${month}`,
        method: "get",
      }).then((result) => {
        if (result.code != 200) return Message.error(result?.msg);
        this.selDays = result.data;
      }).catch((err) => {
        Message.error("查询失败", err);
      })
    },
  },
};
</script>

<style lang="scss" scoped>
 .video-stream {
      width: 100%;
      height: 100%;
    }

</style>
