根据月份选择 生成这个月的每一天

monthDayTotal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
//月份选择  (例2020年4月 - 2020年5月)
    changeMonth(val) {
      if (this.ruleForm.monthRange && this.ruleForm.monthRange.length > 0) {
        let year = parseInt(this.ruleForm.monthRange[0].split("-")[0]);
        let month = parseInt(this.ruleForm.monthRange[0].split("-")[1]);
        // this.listNum = this.monthDayTotal[month - 1];
        this.listNum = [];
        this.listNum.data = this.monthDayTotal[month - 1];
        if (
          ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) &&
          month == 2
        ) {
          // this.listNum = this.listNum + 1;
          this.listNum.data = this.listNum + 1;
        }
        //循环出每一行项的值
        for (let i = 0; i < this.listNum.data; i++) {
          this.listNum.push({
            personId: "",
            name: "",
            workType: "",
            workTypeName: "",
            workDate:
              this.ruleForm.monthRange[0] +
              "-" +
              (i >= 9 ? i + 1 : "0" + (i + 1))
          });
        }
        // console.log("this.listNum", this.listNum);
      }
    },

 

posted @ 2020-04-23 16:42  abcByme  阅读(301)  评论(0编辑  收藏  举报