| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 | 
							- <template>
 
-   <div :style="calendarWidth">
 
-     <VCalender
 
-       ref="calendar"
 
-       :columns="layout.columns"
 
-       :rows="layout.rows"
 
-       :is-expanded="layout.isExpanded"
 
-       :attributes="attrs"
 
-       :min-date="startDate ? new Date(startDate) : new Date()"
 
-       :max-date="new Date()"    
 
-       v-model="selectedDate"
 
-       @dayclick="onSelect"
 
-     />
 
-   </div>
 
- </template>
 
- <script>
 
- import dayjs from "dayjs";
 
- //日历组件
 
-  import {Calendar as VCalender} from 'v-calendar';
 
- export default {
 
-   name: "Calendar",
 
-    components:{VCalender},
 
-   data() {
 
-     return {
 
-       selectedDate:this.defaultSelectedDate,
 
-       layout: {
 
-         columns: 3,
 
-         rows: 2,
 
-         isExpanded: true,
 
-       },
 
-       attrs: [
 
-         {
 
-           highlight: {
 
-             start: {
 
-               fillMode: "outline",
 
-             },
 
-             base: {
 
-               color: "gray",
 
-               fillMode: "light",
 
-             },
 
-             end: {
 
-               fillMode: "outline",
 
-             },
 
-           },
 
-           dates: { start: this.startDate?new Date(this.startDate):new Date(), end: new Date() }, 
 
-         },
 
-         {
 
-           dot: {
 
-             color: "green",
 
-             style: {
 
-               width: "16px",
 
-               height: "3px",
 
-               borderRadius: "0",
 
-             },
 
-             contentClass: "italic",
 
-           },
 
-           dates: this.full,
 
-         },
 
-         {
 
-           dot: {
 
-             color: "yellow",
 
-             style: {
 
-               backgroundColor: "orange",
 
-               width: "16px",
 
-               height: "3px",
 
-               borderRadius: "0",
 
-             },
 
-             contentClass: "italic",
 
-           },
 
-           dates: this.paritialLoss,
 
-         },
 
-         {
 
-           dot: {
 
-             color: "red",
 
-             style: {
 
-               width: "16px",
 
-               height: "3px",
 
-               borderRadius: "0",
 
-             },
 
-             contentClass: "italic",
 
-           },
 
-           dates: this.allLoss,
 
-         },
 
-       ],
 
-     };
 
-   },
 
-   props: {
 
-     startDate: {
 
-       isRequired: true,
 
-     },
 
-     endDate: {
 
-       default: () => {
 
-         return new Date();
 
-       },
 
-     },
 
-     full: {
 
-       isRequired: true,
 
-       type: Array,
 
-     },
 
-     paritialLoss: {
 
-       isRequired: true,
 
-       type: Array,
 
-     },
 
-     allLoss: {
 
-       isRequired: true,
 
-       type: Array,
 
-     },
 
-     defaultSelectedDate:{
 
-       type:Object
 
-     }
 
-   },
 
-   computed: {
 
-     calendarWidth() {
 
-       if (this.layout.columns === 0) {
 
-         return "display:none";
 
-       } else if (this.layout.columns === 1) {
 
-         return "width:33.3%";
 
-       } else if (this.layout.columns === 1) {
 
-         return "width:66.6%";
 
-       } else {
 
-         return "";
 
-       }
 
-     },
 
-   },
 
-   watch: {
 
-     startDate: {
 
-       immediate: true,
 
-       handler: function (v) {
 
-         this.setLayout(v);
 
-       },
 
-     },    
 
-   },
 
-   mounted() {
 
-     this.init();
 
-   },
 
-   methods: {
 
-     init() {
 
-       // this.setLayout();
 
-       // const calendar = this.$refs.calendar;
 
-       // setTimeout(() => {
 
-       //   calendar.move({ month: 1, year: 1983 });
 
-       // }, 3000);
 
-       //calendar.move({ month: 1, year: 1983 });
 
-       //this.setOps();
 
-     },
 
-     setLayout(startDate) {
 
-       if (startDate != null) {
 
-         let diff = Math.ceil(
 
-           dayjs(new Date()).diff(new Date(startDate), "months", true)
 
-         );
 
-         if (diff >= 3) {
 
-           this.layout.columns = 3;
 
-         } else {
 
-           this.layout.columns = diff;
 
-         }
 
-         this.layout.rows = Math.ceil(diff / 3);
 
-       }
 
-     },
 
-     onSelect(data){
 
-       this.$emit("select",data.date)
 
-     }
 
-   },
 
- };
 
- </script>
 
- <style scoped lang="scss"></style>
 
 
  |