churf
2023-09-05 2afb8337efcf437d6f98a1a31fb9510f85576aa5
eladmin-web-master/src/views/task/task/index.vue
@@ -69,8 +69,28 @@
        </div>
        <rrOperation :crud="crud" />
      </div>
      <el-dialog
        title="任务详情"
        :visible.sync="dialogVisible"
        width="800px"
        @closed="calendarLoading = true"
        @opened="monthClick('')"
      >
        <FullCalendar ref="fullCalendar" v-loading="calendarLoading" :options="calendarOptions" />
      </el-dialog>
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
      <crudOperation v-if="this.crud.query.flag" :permission="permission" />
      <crudOperation v-if="this.crud.query.flag" :permission="permission">
        <el-button
          slot="right"
          class="filter-item"
          size="mini"
          type="primary"
          :disabled="taskDetailDisabled"
          @click="draw"
        >任务详情</el-button>
      </crudOperation>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
@@ -243,11 +263,15 @@
import constant from '@/utils/constant'
import crudUser from '@/api/system/user'
import crudProject from '@/api/project/project'
import '@fullcalendar/core/vdom'
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import moment from 'moment'
const defaultForm = { id: null, name: null, projectId: null, userIdList: [], parent: { id: null }, priority: null, tagList: [], performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, version: null }
export default {
  name: 'Task',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, FullCalendar },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: [constant.PRIORITY, constant.TAST_CLASSIFICATION, constant.PERFORMANCE_TYPE, constant.STANDARD_WORKLOAD_UNIT, constant.TASK_STATUS],
  cruds() {
@@ -307,6 +331,89 @@
          { required: true, message: '任务状态不能为空', trigger: 'change' }
        ]
      },
      calendarOptions: {
        // 引入的插件
        plugins: [dayGridPlugin],
        // 日历头部按钮位置
        headerToolbar: {
          left: '',
          center: 'title',
          right: 'prev,today,next'
        },
        // 日历头部按钮中文转换
        buttonText: {
          today: '今天',
          month: '月',
          week: '周',
          day: '天'
        },
        initialView: 'dayGridMonth',
        locale: 'zh-ch',
        firstDay: '1',
        weekNumberCalculation: 'ISO',
        eventColor: '#3d8eec',
        timeGridEventMinHeight: '20',
        aspectRatio: '1.5',
        displayEventTime: false,
        validRange: {},
        allDaySlot: false,
        eventLimit: true,
        fixedWeekCount: false,
        // eslint-disable-next-line no-dupe-keys
        eventTimeFormat: {
          hour: 'numeric',
          minute: '2-digit',
          hour12: false
        },
        slotLabelFormat: {
          hour: '2-digit',
          minute: '2-digit',
          meridiem: false,
          hour12: false
        },
        businessHours: {
          dow: [1, 2, 3, 4, 5],
          start: '0:00',
          end: '24:00'
        },
        events: [],
        // 事件
        editable: false,
        eventStartEditable: false,
        eventDurationEditable: false,
        selectable: false,
        selectMirror: true,
        selectMinDistance: 0,
        weekends: true,
        navLinks: true,
        selectHelper: false,
        selectEventOverlap: false,
        dayMaxEvents: true,
        // dateClick: this.handleDateClick, // 点击日期触发
        // eventsSet: this.handleEvents,
        // eventClick: this.handleEventClick, // 点击日程触发
        // eventDrop: this.handleEventDrop,
        eventResize: this.eventResize,
        height: 'auto',
        customButtons: {
          prev: {
            click: () => {
              this.monthClick('prev')
            }
          },
          today: {
            text: '今天',
            click: () => {
              this.monthClick('')
            }
          },
          next: {
            click: () => {
              this.monthClick('next')
            }
          }
        }
      },
      queryTypeOptions: [
        { key: 'name', display_name: '名称' },
        { key: 'projectId', display_name: '所属项目' },
@@ -365,7 +472,9 @@
      options: [],
      selectedValue: [],
      queryUser: [],
      selectedValue_flag: false
      dialogVisible: false,
      taskDetailDisabled: true,
      calendarLoading: true
    }
  },
  watch: {
@@ -380,7 +489,18 @@
        }
      }
    },
    'crud.selections': function(newVal) {
      this.taskDetailDisabled = true
      if (newVal.length === undefined) {
        this.taskDetailDisabled = false
      }
      if (newVal.length > 1) {
        this.taskDetailDisabled = true
      }
      if (newVal.length === 1) {
        this.taskDetailDisabled = false
      }
    },
    'queryUser': function(newVal) {
      // this.query.userId = newVal[newVal.length - 1]
    }
@@ -462,6 +582,50 @@
      crudTask.getAll({ projectId: this.form.projectId }).then(res => {
        // 父级任务列表
        this.pidTasks = res
      })
    },
    // 日期点击
    handleDateClick(selectInfo) {
      console.log('handleDateClick.info:', selectInfo)
    },
    handleEventClick(info) {
      if (info.event._def.extendedProps.type === 1) {
        this.$router.push({
          path: '/attendance/attendance',
          query: { date: info.event._def.extendedProps.date1 }
        })
      } else {
        this.$router.push({ path: '/task/taskDaliy', query: { date: info.event._def.extendedProps.date1 }})
      }
    },
    // 箭头点击事件
    monthClick(type) {
      if (this.crud.selections[0].id !== null) {
        crudTask.getTaskValidRange(this.crud.selections[0].id).then(res => {
          this.calendarOptions.validRange = res
          const calendarApi = this.$refs['fullCalendar'].getApi()
          if (type === 'prev') {
            calendarApi.prev()
          } else if (type === 'next') {
            calendarApi.next()
          } else {
            calendarApi.gotoDate(res.start)
          }
          this.getTaskCalendarInfo(moment(calendarApi.view.currentStart).format('YYYY-MM-DD').toString())
          this.calendarLoading = false
        })
      }
    },
    // 获取任务信息
    getTaskCalendarInfo(month) {
      crudTask.getTaskCalendarInfo(month, this.crud.selections[0].id).then(res => {
        this.calendarOptions.events = res.map(function(obj) {
          return obj
        })
        setTimeout(() => {
          console.log(this.calendarOptions.events)
        }, 1000)
      })
    },
    queryByProjectId(project) {
@@ -593,6 +757,9 @@
        results = await crudTask.getNames({ projectId: this.crud.query.projectId, name: queryString })
        cb(results)
      }
    },
    draw() {
      this.dialogVisible = true
    }
  }
}