loulijun2021
2023-01-04 0b1837e9b6d1ac8825e9c1acf6f0cd5b2b14a897
src/components/DatePicker/index.vue
@@ -49,6 +49,7 @@
                  slot="reference"
                  :class="[{select:isSelect(visibleDays[(i-1)*7+(j-1)])},
                           {dblDateStyle:isDblDate(visibleDays[(i-1)*7+(j-1)])}]"
                  :style="{background: isSelect(visibleDays[(i-1)*7+(j-1)])?$store.state.settings.theme:''}"
                >{{ visibleDays[(i - 1) * 7 + (j - 1)].getDate() }}</span>
              </el-popover>
@@ -129,6 +130,7 @@
  CapacityPlanningOnclickSelect,
  CapacityPlanningSetupSearch
} from '@/api/scgl'
import { handleDatetime } from '@/utils/global'
var time = null
export default {
@@ -361,15 +363,57 @@
    dblChooseDate(date) {
      if (!this.isPastDue(date)) {
        clearTimeout(time)
        this.dblDate = date
        this.isDbl = true
        this.changeTime = this.handleDatetime(date)
        this.getCapacityPlanningOnclickSelect({
          CaptPlanWorkShiftCode: this.defArr.find(item => item.name === this.changeTime).key,
          captplanid: this.rowData.CaptPlanId,
          datetime: this.handleDatetime(date)
        })
        this.getDblTime()
        time = setTimeout(() => {
          this.time = funsdates.getYearMonthDay(date)
          if (typeof this.value === 'string') {
            this.value = this.value.split(',')
          }
          // 可以点击的日期
          if (!this.isPastDue(date)) {
            if ((this.value.indexOf(this.handleDatetime(date)) < 0 && this.value !== '') || this.value === '') { // 数组添加
              this.value.push(this.handleDatetime(date)) // 新增到input里
              const data = {
                name: this.handleDatetime(date),
                key: this.rowData.CaptPlanWorkShiftCode
              }
              this.defArr.push(data) // 新增到 默认数组里
              this.dblDate = date
              this.isDbl = true // 右侧展开
              this.changeTime = this.handleDatetime(date)
              const DATA = {
                CaptPlanWorkShiftCode: this.defArr.find(item => item.name === this.changeTime).key,
                captplanid: this.rowData.CaptPlanId,
                datetime: this.handleDatetime(date)
              }
              this.getCapacityPlanningOnclickSelect(DATA)
              this.getDblTime()
            } else if (this.value.indexOf(this.handleDatetime(date)) >= 0) {
              this.dblDate = date
              this.isDbl = true // 右侧展开
              this.changeTime = this.handleDatetime(date)
              const DATA = {
                CaptPlanWorkShiftCode: this.defArr.find(item => item.name === this.changeTime).key,
                captplanid: this.rowData.CaptPlanId,
                datetime: this.handleDatetime(date)
              }
              this.getCapacityPlanningOnclickSelect(DATA)
              this.getDblTime()
              //   const indexV = this.value.indexOf(this.handleDatetime(date))
              //   this.value.splice(indexV, 1)
              //   for (const i in this.defArr) {
              //     if (this.defArr[i].name === this.handleDatetime(date)) {
              //       this.defArr.splice(i, 1)
              //     }
              //   }
            }
          }
          this.$emit('input', this.value)
        }, 300)
      }
    },
    isDblDate(date) {
@@ -472,7 +516,8 @@
    },
    getCapacityPlanningCalendar() {
      CapacityPlanningCalendar({ captplanid: this.rowData.CaptPlanId }).then((res) => {
        this.defArr = res.data
        const currentDate = handleDatetime(new Date())
        this.defArr = res.data.filter(i => i.name >= currentDate)
      })
    },
    closeCapacityPlanningCalendar() {