Merge branch 'zhaoss' of http://192.168.1.110:5678/r/pms-upgrade into master
4 files added
12 files modified
| | |
| | | String getProjectDistinguish(); |
| | | |
| | | BigDecimal getContractPrice(); |
| | | |
| | | String getProjectTypeName(); |
| | | } |
| | |
| | | */ |
| | | @Query(value = "SELECT project_distinguish AS projectDistinguish, COALESCE(sum(contract_price), 0) AS contractPrice FROM project WHERE plan_start_date LIKE concat(?1,'%') GROUP BY project_distinguish", nativeQuery = true) |
| | | List<ProjectSummary> findSubgroupTurnoverByTargetYear(String targetYear); |
| | | |
| | | /** |
| | | * 根据项目区分、目标年份查询类型营业额 |
| | | * @param projectDistinguish |
| | | * @param targetYear |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT pt.name AS projectTypeName, COALESCE(sum(p.contract_price), 0) AS contractPrice FROM project p LEFT JOIN project_type pt ON p.project_type_id = pt.id WHERE p.project_distinguish = ?1 AND p.plan_start_date LIKE concat(?2,'%') GROUP BY p.project_type_id", nativeQuery = true) |
| | | List<ProjectSummary> findTypeContractPriceByProjectDistinguishAndTargetYear(String projectDistinguish, String targetYear); |
| | | |
| | | /** |
| | | * 根据项目区分、目标年份查询项目 |
| | | * @param projectDistinguish |
| | | * @param targetYear |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT * FROM project WHERE project_distinguish = ?1 AND plan_start_date LIKE concat(?2,'%')", nativeQuery = true) |
| | | List<Project> findProjectByProjectDistinguishAndTargetYear(String projectDistinguish, String targetYear); |
| | | } |
| | |
| | | @GetMapping(value = "/subgroupTurnover") |
| | | @Log("查询项目分组营业额") |
| | | @ApiOperation("查询项目分组营业额") |
| | | @PreAuthorize("@el.check('project:list')") |
| | | @PreAuthorize("@el.check('project:chart')") |
| | | public ResponseEntity<Object> querySubgroupTurnover(ProjectQueryCriteria criteria){ |
| | | return new ResponseEntity<>(projectService.querySubgroupTurnover(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/subgroupWorkingHours") |
| | | @Log("查询项目分组工时") |
| | | @ApiOperation("查询项目分组工时") |
| | | @PreAuthorize("@el.check('project:chart')") |
| | | public ResponseEntity<Object> querySubgroupWorkingHours(ProjectQueryCriteria criteria){ |
| | | return new ResponseEntity<>(projectService.querySubgroupWorkingHours(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/projectWorkingHours") |
| | | @Log("查询项目工时") |
| | | @ApiOperation("查询项目工时") |
| | | @PreAuthorize("@el.check('project:chart')") |
| | | public ResponseEntity<Object> queryProjectWorkingHours(ProjectQueryCriteria criteria){ |
| | | return new ResponseEntity<>(projectService.queryProjectWorkingHours(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/typeContractPrice") |
| | | @Log("查询项目类型合同额") |
| | | @ApiOperation("查询项目类型合同额") |
| | | @PreAuthorize("@el.check('project:chart')") |
| | | public ResponseEntity<Object> queryTypeContractPrice(ProjectQueryCriteria criteria){ |
| | | return new ResponseEntity<>(projectService.queryTypeContractPrice(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/typeWorkingHours") |
| | | @Log("查询项目类型工时") |
| | | @ApiOperation("查询项目类型工时") |
| | | @PreAuthorize("@el.check('project:chart')") |
| | | public ResponseEntity<Object> queryTypeWorkingHours(ProjectQueryCriteria criteria){ |
| | | return new ResponseEntity<>(projectService.queryTypeWorkingHours(criteria),HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> querySubgroupTurnover(ProjectQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询项目分组工时 |
| | | * @param criteria |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> querySubgroupWorkingHours(ProjectQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询项目工时 |
| | | * @param criteria |
| | | * @return |
| | | */ |
| | | Map<String, Object> queryProjectWorkingHours(ProjectQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询项目类型合同额 |
| | | * @param criteria |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> queryTypeContractPrice(ProjectQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询项目类型工时 |
| | | * @param criteria |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> queryTypeWorkingHours(ProjectQueryCriteria criteria); |
| | | } |
| | |
| | | import me.zhengjie.modules.project.domain.*; |
| | | import me.zhengjie.modules.project.repository.*; |
| | | import me.zhengjie.modules.project.service.ProjectCostService; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeQueryCriteria; |
| | | import me.zhengjie.modules.system.domain.DictDetail; |
| | | import me.zhengjie.modules.system.domain.SysGoalSetting; |
| | | import me.zhengjie.modules.system.repository.SysGoalSettingRepository; |
| | |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskInterface; |
| | | import me.zhengjie.modules.task.service.TaskService; |
| | | import me.zhengjie.modules.task.service.dto.TaskDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import me.zhengjie.modules.task.service.mapstruct.TaskMapper; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private final CostRepository costRepository; |
| | | private final ContractProjectRepository contractProjectRepository; |
| | | private final SysGoalSettingService sysGoalSettingService; |
| | | private final TaskService taskService; |
| | | private final TaskMapper taskMapper; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(ProjectQueryCriteria criteria, Pageable pageable) { |
| | |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> querySubgroupWorkingHours(ProjectQueryCriteria criteria){ |
| | | // 根据字典名称查询 |
| | | List<DictDetail> dictDetailList = dictDetailRepository.findByDictName(Constant.PROJECT_DISTINGUISH); |
| | | // 查询项目列表 |
| | | List<Project> projectList = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)); |
| | | List<Long> projectIdList = projectList.stream().map(Project::getId).collect(Collectors.toList()); |
| | | // 查询任务列表 |
| | | List<TaskInterface> taskInterfaceList = taskRepository.findSubgroupWorkingHoursByProjectId(projectIdList); |
| | | // 返回列表 |
| | | List<Map<String, Object>> returnList = new ArrayList<>(); |
| | | // 循环项目区分 |
| | | for (int i = 0; i < dictDetailList.size(); i ++) { |
| | | // 已分配工时 |
| | | Double divideHours = 0D; |
| | | // 未完成工时 |
| | | Double incompleteHours = 0D; |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | // 当前项目区分 |
| | | DictDetail dictDetail = dictDetailList.get(i); |
| | | // 返回集合 |
| | | returnMap.put("projectDistinguish", dictDetail.getLabel()); |
| | | // 当前任务列表 |
| | | List<TaskInterface> currentTaskInterfaceList = taskInterfaceList.stream().filter(item -> item.getProjectDistinguish().equals(dictDetail.getValue())).collect(Collectors.toList()); |
| | | // 循环当前任务列表 |
| | | for (int j = 0; j < currentTaskInterfaceList.size(); j ++) { |
| | | // 当前任务 |
| | | TaskInterface currentTaskInterface = currentTaskInterfaceList.get(j); |
| | | Task task = taskRepository.findById(currentTaskInterface.getTaskId()).orElseGet(Task::new); |
| | | // 当前任务二次处理 |
| | | TaskDto taskDto = taskMapper.toDto(task); |
| | | taskDto = taskService.customHandle(taskDto); |
| | | // 已分配工时 |
| | | divideHours += taskDto.getDivideHours(); |
| | | // 未完成工时 |
| | | incompleteHours += (taskDto.getDivideHours() - taskDto.getCompletedHours()); |
| | | } |
| | | // 返回集合 |
| | | returnMap.put("divideHours", divideHours); |
| | | returnMap.put("incompleteHours", incompleteHours); |
| | | // 返回列表 |
| | | returnList.add(returnMap); |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> queryProjectWorkingHours(ProjectQueryCriteria criteria){ |
| | | // 查询任务列表 |
| | | List<Task> taskList = taskRepository.findByProjectId(criteria.getId()); |
| | | // 已分配工时 |
| | | Double divideHours = 0D; |
| | | // 未完成工时 |
| | | Double incompleteHours = 0D; |
| | | // 循环当前任务列表 |
| | | for (int i = 0; i < taskList.size(); i ++) { |
| | | // 当前任务 |
| | | Task task = taskList.get(i); |
| | | // 当前任务二次处理 |
| | | TaskDto taskDto = taskMapper.toDto(task); |
| | | taskDto = taskService.customHandle(taskDto); |
| | | // 已分配工时 |
| | | divideHours += taskDto.getDivideHours(); |
| | | // 未完成工时 |
| | | incompleteHours += (taskDto.getDivideHours() - taskDto.getCompletedHours()); |
| | | } |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("divideHours", divideHours); |
| | | returnMap.put("incompleteHours", incompleteHours); |
| | | return returnMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryTypeContractPrice(ProjectQueryCriteria criteria){ |
| | | // 根据项目区分、目标年份查询类型营业额 |
| | | List<ProjectSummary> projectSummaryList = projectRepository.findTypeContractPriceByProjectDistinguishAndTargetYear(criteria.getProjectDistinguish(), criteria.getTargetYear()); |
| | | // 返回列表 |
| | | List<Map<String, Object>> returnList = new ArrayList<>(); |
| | | // 循环类型营业额 |
| | | for (int i = 0; i < projectSummaryList.size(); i ++) { |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("name", projectSummaryList.get(i).getProjectTypeName()); |
| | | returnMap.put("value", projectSummaryList.get(i).getContractPrice()); |
| | | // 返回列表 |
| | | returnList.add(returnMap); |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryTypeWorkingHours(ProjectQueryCriteria criteria){ |
| | | // 根据项目区分、目标年份查询项目 |
| | | List<Project> projectList = projectRepository.findProjectByProjectDistinguishAndTargetYear(criteria.getProjectDistinguish(), criteria.getTargetYear()); |
| | | // 查询项目类型列表 |
| | | ProjectTypeQueryCriteria projectTypeQueryCriteria = new ProjectTypeQueryCriteria(); |
| | | List<ProjectType> projectTypeList = projectTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,projectTypeQueryCriteria,criteriaBuilder)); |
| | | // 返回列表 |
| | | List<Map<String, Object>> returnList = new ArrayList<>(); |
| | | // 循环项目类型列表 |
| | | for (int i = 0; i < projectTypeList.size(); i ++) { |
| | | // 项目类型 |
| | | ProjectType projectType = projectTypeList.get(i); |
| | | // 处理后项目列表 |
| | | List<Project> handleProjectList = projectList.stream().filter(item -> item.getProjectTypeId() == projectType.getId()).collect(Collectors.toList()); |
| | | // 判断处理后项目列表长度 |
| | | if (handleProjectList.size() != 0) { |
| | | // 处理后项目ID列表 |
| | | List<Long> handleProjectIdList = handleProjectList.stream().map(Project::getId).collect(Collectors.toList()); |
| | | // 根据项目ID查询总工时 |
| | | Double sumWorkingHours = taskRepository.sumWorkingHoursByProjectId(handleProjectIdList); |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("name", projectType.getName()); |
| | | returnMap.put("value", sumWorkingHours); |
| | | // 返回列表 |
| | | returnList.add(returnMap); |
| | | } |
| | | } |
| | | return returnList; |
| | | } |
| | | } |
| | |
| | | * 项目ID |
| | | */ |
| | | Timestamp getProjectId(); |
| | | |
| | | /** |
| | | * 项目区分 |
| | | */ |
| | | String getProjectDistinguish(); |
| | | } |
| | |
| | | * @param projectId |
| | | */ |
| | | void deleteByProjectId(Long projectId); |
| | | |
| | | /** |
| | | * 根据项目ID查询分组工时 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT t.id AS taskId, t.plan_hours AS planHours, p.id AS projectId, p.project_distinguish AS projectDistinguish FROM task t LEFT JOIN project p ON t.project_id = p.id WHERE t.project_id IN (?1)", nativeQuery = true) |
| | | List<TaskInterface> findSubgroupWorkingHoursByProjectId(List<Long> projectId); |
| | | |
| | | |
| | | /** |
| | | * 根据项目ID查询总工时 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT COALESCE(SUM(plan_hours), 0.0) FROM task WHERE project_id IN (?1)", nativeQuery = true) |
| | | Double sumWorkingHoursByProjectId(List<Long> projectId); |
| | | } |
| | |
| | | List<TaskDto> queryAll(TaskQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 任务二次处理 |
| | | * @param taskDto |
| | | * @return |
| | | */ |
| | | TaskDto customHandle(TaskDto taskDto); |
| | | |
| | | /** |
| | | * 查询子级数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<TaskDto> |
| | |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | private TaskDto customHandle(TaskDto taskDto) { |
| | | @Override |
| | | public TaskDto customHandle(TaskDto taskDto) { |
| | | // 根据项目ID查询项目信息 |
| | | Project project = projectRepository.findById(taskDto.getProjectId()).orElseGet(Project::new); |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskDto.getProjectId()); |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, editAdmit, editDisavow, getPartake, getRelevant, getSubgroupTurnover } |
| | | export function getSubgroupWorkingHours(params) { |
| | | return request({ |
| | | url: 'api/project/subgroupWorkingHours', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function getProjectWorkingHours(params) { |
| | | return request({ |
| | | url: 'api/project/projectWorkingHours', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function getTypeContractPrice(params) { |
| | | return request({ |
| | | url: 'api/project/typeContractPrice', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function getTypeWorkingHours(params) { |
| | | return request({ |
| | | url: 'api/project/typeWorkingHours', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, editAdmit, editDisavow, getPartake, getRelevant, getSubgroupTurnover, getSubgroupWorkingHours, getProjectWorkingHours, getTypeContractPrice, getTypeWorkingHours } |
| New file |
| | |
| | | <template> |
| | | <div :class="className" :style="{ height: height, width: width }" /> |
| | | </template> |
| | | |
| | | <script> |
| | | import echarts from 'echarts' |
| | | require('echarts/theme/macarons') // echarts theme |
| | | import { debounce } from '@/utils' |
| | | import crudProject from '@/api/project/project' |
| | | |
| | | export default { |
| | | props: { |
| | | className: { |
| | | type: String, |
| | | default: 'chart' |
| | | }, |
| | | width: { |
| | | type: String, |
| | | default: '100%' |
| | | }, |
| | | height: { |
| | | type: String, |
| | | default: '400px' |
| | | }, |
| | | projectId: { |
| | | type: String, |
| | | defalut: null |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | chart: null |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.initChart() |
| | | this.__resizeHandler = debounce(() => { |
| | | if (this.chart) { |
| | | this.chart.resize() |
| | | } |
| | | }, 100) |
| | | window.addEventListener('resize', this.__resizeHandler) |
| | | }, |
| | | beforeDestroy() { |
| | | if (!this.chart) { |
| | | return |
| | | } |
| | | window.removeEventListener('resize', this.__resizeHandler) |
| | | this.chart.dispose() |
| | | this.chart = null |
| | | }, |
| | | methods: { |
| | | initChart() { |
| | | this.chart = echarts.init(this.$el, 'macarons') |
| | | |
| | | crudProject.getProjectWorkingHours({ id: this.projectId }).then(res => { |
| | | // 绘制图表 |
| | | this.chart.setOption({ |
| | | title: { |
| | | text: '项目未完成工时与已分配工时对比', |
| | | subtext: '', |
| | | left: 'left' |
| | | }, |
| | | tooltip: { |
| | | trigger: 'item' |
| | | }, |
| | | legend: { |
| | | right: '10%' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '工时数', |
| | | type: 'pie', |
| | | radius: '50%', |
| | | data: [ |
| | | { name: '未完成工时', value: res.incompleteHours }, |
| | | { name: '已分配工时', value: res.divideHours } |
| | | ], |
| | | emphasis: { |
| | | itemStyle: { |
| | | shadowBlur: 10, |
| | | shadowOffsetX: 0, |
| | | shadowColor: 'rgba(0, 0, 0, 0.5)' |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| | |
| | | // 图表目标金额类目 |
| | | targetAmountData.push(res[i].targetAmount) |
| | | } |
| | | |
| | | // 绘制图表 |
| | | this.chart.setOption({ |
| | | title: { |
| | | text: '项目区分营业额与目标金额对比', |
| New file |
| | |
| | | <template> |
| | | <div :class="className" :style="{ height: height, width: width }" /> |
| | | </template> |
| | | |
| | | <script> |
| | | import echarts from 'echarts' |
| | | require('echarts/theme/macarons') // echarts theme |
| | | import { debounce } from '@/utils' |
| | | import constant from '../../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | |
| | | export default { |
| | | props: { |
| | | className: { |
| | | type: String, |
| | | default: 'chart' |
| | | }, |
| | | width: { |
| | | type: String, |
| | | default: '100%' |
| | | }, |
| | | height: { |
| | | type: String, |
| | | default: '400px' |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | chart: null |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.initChart() |
| | | this.__resizeHandler = debounce(() => { |
| | | if (this.chart) { |
| | | this.chart.resize() |
| | | } |
| | | }, 100) |
| | | window.addEventListener('resize', this.__resizeHandler) |
| | | }, |
| | | beforeDestroy() { |
| | | if (!this.chart) { |
| | | return |
| | | } |
| | | window.removeEventListener('resize', this.__resizeHandler) |
| | | this.chart.dispose() |
| | | this.chart = null |
| | | }, |
| | | methods: { |
| | | initChart() { |
| | | this.chart = echarts.init(this.$el, 'macarons') |
| | | |
| | | crudProject.getSubgroupWorkingHours({ projectStatus: constant.PROJECT_STATUS_UNDER_WAY }).then(res => { |
| | | // 图表项目区分类目 |
| | | const projectDistinguishData = [] |
| | | // 图表未完成工时类目 |
| | | const incompleteHoursData = [] |
| | | // 图表已分配工时类目 |
| | | const divideHoursData = [] |
| | | // 遍历资产收入数据 |
| | | for (let i = 0; i < res.length; i++) { |
| | | // 图表项目区分类目 |
| | | projectDistinguishData.push(res[i].projectDistinguish) |
| | | // 图表未完成工时类目 |
| | | incompleteHoursData.push(res[i].incompleteHours) |
| | | // 图表已分配工时类目 |
| | | divideHoursData.push(res[i].divideHours) |
| | | } |
| | | // 绘制图表 |
| | | this.chart.setOption({ |
| | | title: { |
| | | text: '项目区分未完成工时与已分配工时对比', |
| | | subtext: '', |
| | | left: 'left' |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'shadow' |
| | | } |
| | | }, |
| | | legend: { |
| | | data: ['未完成工时', '已分配工时'], |
| | | right: '10%' |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | type: 'category', |
| | | axisTick: { show: false }, |
| | | data: projectDistinguishData |
| | | } |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: 'value' |
| | | } |
| | | ], |
| | | series: [ |
| | | { |
| | | name: '未完成工时', |
| | | type: 'bar', |
| | | barGap: 0, |
| | | emphasis: { |
| | | focus: 'series' |
| | | }, |
| | | data: incompleteHoursData |
| | | }, |
| | | { |
| | | name: '已分配工时', |
| | | type: 'bar', |
| | | emphasis: { |
| | | focus: 'series' |
| | | }, |
| | | data: divideHoursData |
| | | } |
| | | ] |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <div :class="className" :style="{ height: height, width: width }" /> |
| | | </template> |
| | | |
| | | <script> |
| | | import echarts from 'echarts' |
| | | require('echarts/theme/macarons') // echarts theme |
| | | import { debounce } from '@/utils' |
| | | import crudProject from '@/api/project/project' |
| | | |
| | | export default { |
| | | props: { |
| | | className: { |
| | | type: String, |
| | | default: 'chart' |
| | | }, |
| | | width: { |
| | | type: String, |
| | | default: '100%' |
| | | }, |
| | | height: { |
| | | type: String, |
| | | default: '400px' |
| | | }, |
| | | projectDistinguish: { |
| | | type: String, |
| | | default: null |
| | | }, |
| | | targetYear: { |
| | | type: String, |
| | | default: null |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | chart: null |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.initChart() |
| | | this.__resizeHandler = debounce(() => { |
| | | if (this.chart) { |
| | | this.chart.resize() |
| | | } |
| | | }, 100) |
| | | window.addEventListener('resize', this.__resizeHandler) |
| | | }, |
| | | beforeDestroy() { |
| | | if (!this.chart) { |
| | | return |
| | | } |
| | | window.removeEventListener('resize', this.__resizeHandler) |
| | | this.chart.dispose() |
| | | this.chart = null |
| | | }, |
| | | methods: { |
| | | initChart() { |
| | | this.chart = echarts.init(this.$el, 'macarons') |
| | | |
| | | crudProject.getTypeContractPrice({ projectDistinguish: this.projectDistinguish, targetYear: this.targetYear }).then(res => { |
| | | // 绘制图表 |
| | | this.chart.setOption({ |
| | | title: { |
| | | text: '项目类型营业额对比', |
| | | subtext: '', |
| | | left: 'left' |
| | | }, |
| | | tooltip: { |
| | | trigger: 'item' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '营业额', |
| | | type: 'pie', |
| | | radius: '50%', |
| | | data: res, |
| | | emphasis: { |
| | | itemStyle: { |
| | | shadowBlur: 10, |
| | | shadowOffsetX: 0, |
| | | shadowColor: 'rgba(0, 0, 0, 0.5)' |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <div :class="className" :style="{ height: height, width: width }" /> |
| | | </template> |
| | | |
| | | <script> |
| | | import echarts from 'echarts' |
| | | require('echarts/theme/macarons') // echarts theme |
| | | import { debounce } from '@/utils' |
| | | import crudProject from '@/api/project/project' |
| | | |
| | | export default { |
| | | props: { |
| | | className: { |
| | | type: String, |
| | | default: 'chart' |
| | | }, |
| | | width: { |
| | | type: String, |
| | | default: '100%' |
| | | }, |
| | | height: { |
| | | type: String, |
| | | default: '400px' |
| | | }, |
| | | projectDistinguish: { |
| | | type: String, |
| | | default: null |
| | | }, |
| | | targetYear: { |
| | | type: String, |
| | | default: null |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | chart: null |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.initChart() |
| | | this.__resizeHandler = debounce(() => { |
| | | if (this.chart) { |
| | | this.chart.resize() |
| | | } |
| | | }, 100) |
| | | window.addEventListener('resize', this.__resizeHandler) |
| | | }, |
| | | beforeDestroy() { |
| | | if (!this.chart) { |
| | | return |
| | | } |
| | | window.removeEventListener('resize', this.__resizeHandler) |
| | | this.chart.dispose() |
| | | this.chart = null |
| | | }, |
| | | methods: { |
| | | initChart() { |
| | | this.chart = echarts.init(this.$el, 'macarons') |
| | | |
| | | crudProject.getTypeWorkingHours({ projectDistinguish: this.projectDistinguish, targetYear: this.targetYear }).then(res => { |
| | | // 绘制图表 |
| | | this.chart.setOption({ |
| | | title: { |
| | | text: '项目类型工时对比', |
| | | subtext: '', |
| | | left: 'left' |
| | | }, |
| | | tooltip: { |
| | | trigger: 'item' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '工时数', |
| | | type: 'pie', |
| | | radius: '50%', |
| | | data: res, |
| | | emphasis: { |
| | | itemStyle: { |
| | | shadowBlur: 10, |
| | | shadowOffsetX: 0, |
| | | shadowColor: 'rgba(0, 0, 0, 0.5)' |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| | |
| | | <div class="chart-wrapper" /> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="32"> |
| | | <el-col :xs="24" :sm="24" :lg="12"> |
| | | <div class="chart-wrapper"> |
| | | <div class="wrapper-div"> |
| | | <div style="height: 32px;" /> |
| | | </div> |
| | | <subgroup-working-hours /> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="24" :lg="12"> |
| | | <div class="chart-wrapper"> |
| | | <div class="wrapper-div"> |
| | | <el-select v-model="pwhProjectId" placeholder="目标项目" @change="pwhProjectIdChange"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </div> |
| | | <project-working-hours :key="pwhRandom" :project-id="pwhParameter" /> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="32"> |
| | | <el-col :xs="24" :sm="24" :lg="12"> |
| | | <div class="chart-wrapper"> |
| | | <div class="wrapper-div"> |
| | | <div style="height: 32px;" /> |
| | | </div> |
| | | <type-contract-price :key="tcpwhRandom" :project-distinguish="tcpwhParameterProjectDistinguish" :target-year="tcpwhParameterTargetYear" /> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="24" :lg="12"> |
| | | <div class="chart-wrapper"> |
| | | <div class="wrapper-div"> |
| | | <div style="height: 32px;"> |
| | | <el-select v-model="tcpwhProjectDistinguish" placeholder="项目区分" @change="tcpwhProjectDistinguishOrTargetYearChange"> |
| | | <el-option |
| | | v-for="item in projectDistinguishList" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-date-picker v-model="tcpwhTargetYear" type="year" clearable placeholder="目标年度" style="width: 185px;" @change="tcpwhProjectDistinguishOrTargetYearChange" /> |
| | | </div> |
| | | </div> |
| | | <type-working-hours :key="tcpwhRandom" :project-distinguish="tcpwhParameterProjectDistinguish" :target-year="tcpwhParameterTargetYear" /> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import constant from '../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | import { getDictMap } from '@/api/system/dictDetail' |
| | | import SubgroupTurnover from './chart/subgroupTurnover.vue' |
| | | import SubgroupWorkingHours from './chart/subgroupWorkingHours.vue' |
| | | import ProjectWorkingHours from './chart/projectWorkingHours.vue' |
| | | import TypeContractPrice from './chart/typeContractPrice.vue' |
| | | import TypeWorkingHours from './chart/typeWorkingHours.vue' |
| | | |
| | | export default { |
| | | name: 'ProjectChart', |
| | | components: { SubgroupTurnover }, |
| | | components: { SubgroupTurnover, SubgroupWorkingHours, ProjectWorkingHours, TypeContractPrice, TypeWorkingHours }, |
| | | data() { |
| | | return { |
| | | // 目标年度 |
| | | // 项目列表 |
| | | projectList: [], |
| | | // 项目区分列表 |
| | | projectDistinguishList: [], |
| | | // 分组营业额:目标年度 |
| | | stTargetYear: new Date(), |
| | | // 随机数 |
| | | // 分组营业额:随机数 |
| | | stRandom: 0, |
| | | // 传参 |
| | | stParameter: new Date().getFullYear().toString() |
| | | // 分组营业额:传参 |
| | | stParameter: new Date().getFullYear().toString(), |
| | | // 项目工时:目标项目 |
| | | pwhProjectId: null, |
| | | // 项目工时:随机数 |
| | | pwhRandom: 0, |
| | | // 项目工时:传参 |
| | | pwhParameter: null, |
| | | // 类型合同额、分组工时:项目区分 |
| | | tcpwhProjectDistinguish: null, |
| | | // 类型合同额、分组工时:目标年度 |
| | | tcpwhTargetYear: new Date(), |
| | | // 类型合同额、分组工时:随机数 |
| | | tcpwhRandom: 0, |
| | | // 类型合同额、分组工时:传参 |
| | | tcpwhParameterProjectDistinguish: null, |
| | | tcpwhParameterTargetYear: new Date().getFullYear().toString() |
| | | } |
| | | }, |
| | | created() { |
| | | |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取字典 |
| | | this.getDictDetail() |
| | | }, |
| | | methods: { |
| | | // 目标年度变更 |
| | | // 获取项目 |
| | | getProject() { |
| | | crudProject.getAll({ projectStatus: constant.PROJECT_STATUS_UNDER_WAY }).then(res => { |
| | | // 项目列表 |
| | | this.projectList = res |
| | | // 项目工时:目标项目 |
| | | this.pwhProjectId = res[0].id |
| | | // 项目工时:传参 |
| | | this.pwhParameter = res[0].id.toString() |
| | | // 项目工时:随机数 |
| | | this.pwhRandom = Math.random() |
| | | }) |
| | | }, |
| | | // 获取字典 |
| | | getDictDetail() { |
| | | getDictMap(constant.PROJECT_DISTINGUISH).then(res => { |
| | | // 项目区分列表 |
| | | this.projectDistinguishList = res[constant.PROJECT_DISTINGUISH] |
| | | // 类型合同额、分组工时:目标年度 |
| | | this.tcpwhProjectDistinguish = res[constant.PROJECT_DISTINGUISH][0].value |
| | | // 类型合同额、分组工时:传参 |
| | | this.tcpwhParameterProjectDistinguish = res[constant.PROJECT_DISTINGUISH][0].value.toString() |
| | | // 类型合同额、分组工时:随机数 |
| | | this.tcpwhRandom = Math.random() |
| | | }) |
| | | }, |
| | | // 分组营业额:目标年度变更 |
| | | stTargetYearChange() { |
| | | // 传参 |
| | | // 分组营业额:传参 |
| | | this.stParameter = this.stTargetYear.getFullYear().toString() |
| | | // 随机数 |
| | | // 分组营业额:随机数 |
| | | this.stRandom = Math.random() |
| | | }, |
| | | // 项目工时:目标项目变更 |
| | | pwhProjectIdChange() { |
| | | // 项目工时:传参 |
| | | this.pwhParameter = this.pwhProjectId.toString() |
| | | // 项目工时:随机数 |
| | | this.pwhRandom = Math.random() |
| | | }, |
| | | // 类型合同额、分组工时:项目区分/目标年度变更 |
| | | tcpwhProjectDistinguishOrTargetYearChange() { |
| | | // 类型合同额、分组工时:传参 |
| | | this.tcpwhParameterProjectDistinguish = this.tcpwhProjectDistinguish.toString() |
| | | this.tcpwhParameterTargetYear = this.tcpwhTargetYear.getFullYear().toString() |
| | | // 类型合同额、分组工时:随机数 |
| | | this.tcpwhRandom = Math.random() |
| | | } |
| | | } |
| | | } |