| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | |
| | | public ResponseEntity<Object> getRelevantTaskUser(String taskId){ |
| | | return new ResponseEntity<>(taskService.getRelevantTaskUser(taskId),HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getTaskValidRange") |
| | | public ResponseEntity<Object> getTaskValidRange(String taskId){ |
| | | return new ResponseEntity<>(taskService.getTaskValidRange(taskId),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/getTaskCalendarInfo") |
| | | public ResponseEntity<Object> getTaskCalendarInfo(String date,String taskId){ |
| | | return new ResponseEntity<>(taskService.getTaskCalendarInfo(date, taskId),HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserMongoDto; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | |
| | | List<TaskMongo> allOfDaily(Long projectId); |
| | | |
| | | List<TaskUserMongoDto> getRelevantTaskUser(String taskId); |
| | | |
| | | Map<String, Date> getTaskValidRange(String taskId); |
| | | |
| | | List<Map<String, Object>> getTaskCalendarInfo(String date,String taskId); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String,Date> getTaskValidRange(String taskId) { |
| | | TaskMongo byId = mongoTemplate.findById(taskId, TaskMongo.class); |
| | | Map<String,Date> hashMap = new HashMap<>(); |
| | | assert byId != null; |
| | | if(byId.getPlanStartTime() != null && byId.getPlanEndTime() != null){ |
| | | hashMap.put("start",byId.getPlanStartTime()); |
| | | hashMap.put("end",byId.getPlanEndTime()); |
| | | } else { |
| | | hashMap.put("start",null); |
| | | hashMap.put("end",null); |
| | | } |
| | | return hashMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getTaskCalendarInfo(String date,String taskId) { |
| | | List<String> colorList = new ArrayList<>(); |
| | | Collections.addAll(colorList,"#409EFF","#67C23A","#F56C6C","#909399","#E6A23C"); |
| | | List<Map<String,Object>> mapList = new ArrayList<>(); |
| | | List<TaskUserMongo> taskUserMongoList = mongoTemplate.find(Query.query(new Criteria("task._id").is(taskId)), TaskUserMongo.class); |
| | | for (TaskUserMongo taskUserMongo : taskUserMongoList) { |
| | | HashMap<String,Object> map = new HashMap<>(); |
| | | map.put("start",taskUserMongo.getTaskStartDate()); |
| | | map.put("end",taskUserMongo.getTaskEndDate()); |
| | | map.put("title",taskUserMongo.getName()); |
| | | map.put("type",1); |
| | | int index = new Random().nextInt(colorList.size()); |
| | | map.put("color",colorList.get(index)); |
| | | mapList.add(map); |
| | | } |
| | | return mapList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, String>> getAllNames(Long projectId, String name) { |
| | | if (name == null || name.trim().length() == 0) { |
| | | return Collections.emptyList(); |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, getTags, getNames, getProjects, getChildren, add, edit, del, divide, getPartake, getProjectTotal, ChildrenTaskAnyParent, getAllOfDaily, getRelevantTaskUser } |
| | | export function getTaskValidRange(param) { |
| | | return request({ |
| | | url: 'api/task/getTaskValidRange?taskId=' + param, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export function getTaskCalendarInfo(date, taskId) { |
| | | return request({ |
| | | url: 'api/task/getTaskCalendarInfo?date=' + date + '&taskId=' + taskId, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, getTags, getNames, getProjects, getChildren, add, edit, del, divide, getPartake, getProjectTotal, ChildrenTaskAnyParent, getAllOfDaily, getRelevantTaskUser, getTaskValidRange, getTaskCalendarInfo } |
| | |
| | | </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"> |
| | |
| | | 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() { |
| | |
| | | { 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: '所属项目' }, |
| | |
| | | options: [], |
| | | selectedValue: [], |
| | | queryUser: [], |
| | | selectedValue_flag: false |
| | | dialogVisible: false, |
| | | taskDetailDisabled: true, |
| | | calendarLoading: true |
| | | } |
| | | }, |
| | | watch: { |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | '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] |
| | | } |
| | |
| | | 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) { |
| | |
| | | results = await crudTask.getNames({ projectId: this.crud.query.projectId, name: queryString }) |
| | | cb(results) |
| | | } |
| | | }, |
| | | draw() { |
| | | this.dialogVisible = true |
| | | } |
| | | } |
| | | } |