10 files added
1 files modified
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.math.BigDecimal; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="project_type") |
| | | public class ProjectType extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`name`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "名称;例:国内二次开发,对日包人月,维保,评估报告,绩效评审") |
| | | private String name; |
| | | |
| | | @Column(name = "`standard_unit_currency`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "标准单价币种;字典:人民币、美元、日元") |
| | | private String standardUnitCurrency; |
| | | |
| | | @Column(name = "`standard_unit_price`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "标准单价金额") |
| | | private BigDecimal standardUnitPrice; |
| | | |
| | | @Column(name = "`standard_profit_price`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "标准利润金额") |
| | | private BigDecimal standardProfitPrice; |
| | | |
| | | @Column(name = "`standard_workload_unit`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "标准工作量单位;字典:个,本,行") |
| | | private String standardWorkloadUnit; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(ProjectType source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.repository; |
| | | |
| | | import me.zhengjie.modules.project.domain.ProjectType; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | public interface ProjectTypeRepository extends JpaRepository<ProjectType, Long>, JpaSpecificationExecutor<ProjectType> { |
| | | |
| | | /** |
| | | * 根据名称查询数据 |
| | | * @return |
| | | * @author 华喆 |
| | | */ |
| | | List<ProjectType> findByName(String name); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.project.domain.ProjectType; |
| | | import me.zhengjie.modules.project.service.ProjectTypeService; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "项目类型管理") |
| | | @RequestMapping("/api/projectType") |
| | | public class ProjectTypeController { |
| | | |
| | | private final ProjectTypeService projectTypeService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('projectType:download')") |
| | | public void exportProjectType(HttpServletResponse response, ProjectTypeQueryCriteria criteria) throws IOException { |
| | | projectTypeService.download(projectTypeService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询项目类型") |
| | | @ApiOperation("查询项目类型") |
| | | @PreAuthorize("@el.check('projectType:list')") |
| | | public ResponseEntity<Object> queryProjectType(ProjectTypeQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(projectTypeService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询项目类型") |
| | | @ApiOperation("查询项目类型") |
| | | @PreAuthorize("@el.check('projectType:list')") |
| | | public ResponseEntity<Object> queryProjectTypeAll(ProjectTypeQueryCriteria criteria){ |
| | | return new ResponseEntity<>(projectTypeService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增项目类型") |
| | | @ApiOperation("新增项目类型") |
| | | @PreAuthorize("@el.check('projectType:add')") |
| | | public ResponseEntity<Object> createProjectType(@Validated @RequestBody ProjectType resources){ |
| | | return new ResponseEntity<>(projectTypeService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改项目类型") |
| | | @ApiOperation("修改项目类型") |
| | | @PreAuthorize("@el.check('projectType:edit')") |
| | | public ResponseEntity<Object> updateProjectType(@Validated @RequestBody ProjectType resources){ |
| | | projectTypeService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除项目类型") |
| | | @ApiOperation("删除项目类型") |
| | | @PreAuthorize("@el.check('projectType:del')") |
| | | public ResponseEntity<Object> deleteProjectType(@RequestBody Long[] ids) { |
| | | projectTypeService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.service; |
| | | |
| | | import me.zhengjie.modules.project.domain.ProjectType; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeDto; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | public interface ProjectTypeService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(ProjectTypeQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<ProjectTypeDto> |
| | | */ |
| | | List<ProjectTypeDto> queryAll(ProjectTypeQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return ProjectTypeDto |
| | | */ |
| | | ProjectTypeDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return ProjectTypeDto |
| | | */ |
| | | ProjectTypeDto create(ProjectType resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(ProjectType resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<ProjectTypeDto> all, HttpServletResponse response) throws IOException; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.math.BigDecimal; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @Data |
| | | public class ProjectTypeDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 名称;例:国内二次开发,对日包人月,维保,评估报告,绩效评审 */ |
| | | private String name; |
| | | |
| | | /** 标准单价币种;字典:人民币、美元、日元 */ |
| | | private String standardUnitCurrency; |
| | | |
| | | /** 标准单价金额 */ |
| | | private BigDecimal standardUnitPrice; |
| | | |
| | | /** 标准利润金额 */ |
| | | private BigDecimal standardProfitPrice; |
| | | |
| | | /** 标准工作量单位;字典:个,本,行 */ |
| | | private String standardWorkloadUnit; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @Data |
| | | public class ProjectTypeQueryCriteria{ |
| | | |
| | | /** 模糊 */ |
| | | @Query(type = Query.Type.INNER_LIKE) |
| | | private String name; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String standardUnitCurrency; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.project.domain.ProjectType; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.project.repository.ProjectTypeRepository; |
| | | import me.zhengjie.modules.project.service.ProjectTypeService; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeDto; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeQueryCriteria; |
| | | import me.zhengjie.modules.project.service.mapstruct.ProjectTypeMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ProjectTypeServiceImpl implements ProjectTypeService { |
| | | |
| | | private final ProjectTypeRepository projectTypeRepository; |
| | | private final ProjectTypeMapper projectTypeMapper; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(ProjectTypeQueryCriteria criteria, Pageable pageable){ |
| | | Page<ProjectType> page = projectTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | return PageUtil.toPage(page.map(projectTypeMapper::toDto)); |
| | | } |
| | | |
| | | @Override |
| | | public List<ProjectTypeDto> queryAll(ProjectTypeQueryCriteria criteria){ |
| | | return projectTypeMapper.toDto(projectTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public ProjectTypeDto findById(Long id) { |
| | | ProjectType projectType = projectTypeRepository.findById(id).orElseGet(ProjectType::new); |
| | | ValidationUtil.isNull(projectType.getId(),"ProjectType","id",id); |
| | | return projectTypeMapper.toDto(projectType); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ProjectTypeDto create(ProjectType resources) { |
| | | checkAddProject(resources); |
| | | return projectTypeMapper.toDto(projectTypeRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(ProjectType resources) { |
| | | checkUpdateProject(resources); |
| | | ProjectType projectType = projectTypeRepository.findById(resources.getId()).orElseGet(ProjectType::new); |
| | | ValidationUtil.isNull( projectType.getId(),"ProjectType","id",resources.getId()); |
| | | projectType.copy(resources); |
| | | projectTypeRepository.save(projectType); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | projectTypeRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<ProjectTypeDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (ProjectTypeDto projectType : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("名称;例:国内二次开发,对日包人月,维保,评估报告,绩效评审", projectType.getName()); |
| | | map.put("标准单价币种;字典:人民币、美元、日元", projectType.getStandardUnitCurrency()); |
| | | map.put("标准单价金额", projectType.getStandardUnitPrice()); |
| | | map.put("标准利润金额", projectType.getStandardProfitPrice()); |
| | | map.put("标准工作量单位;字典:个,本,行", projectType.getStandardWorkloadUnit()); |
| | | map.put("备注", projectType.getRemarks()); |
| | | map.put("创建者", projectType.getCreateBy()); |
| | | map.put("创建时间", projectType.getCreateTime()); |
| | | map.put("更新者", projectType.getUpdateBy()); |
| | | map.put("更新时间", projectType.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | // 判断是否拥有同名的项目名称 |
| | | public void checkAddProject(ProjectType resources){ |
| | | // 根据项目类型的名称查询项目类型 |
| | | List<ProjectType> opeDeliveryMethodList = projectTypeRepository.findByName(resources.getName()); |
| | | // 判断是否存在同名的项目类型 |
| | | if(opeDeliveryMethodList.size()>0){ |
| | | // 存在返回错误 |
| | | throw new BadRequestException("已存在此项目名称"); |
| | | } |
| | | } |
| | | |
| | | // 判断修改是否拥有同名的项目名称 |
| | | public void checkUpdateProject(ProjectType resources){ |
| | | // 根据项目类型的名称查询项目类型 |
| | | List<ProjectType> opeDeliveryMethodList = projectTypeRepository.findByName(resources.getName()); |
| | | // 判断是否存在同名的项目类型 |
| | | if(opeDeliveryMethodList.size() == 1){ |
| | | // 根据id判断是否是同一条 |
| | | if(opeDeliveryMethodList.get(0).getId() != resources.getId()){ |
| | | throw new BadRequestException("已存在此项目名称"); |
| | | } else { |
| | | |
| | | } |
| | | } else if(opeDeliveryMethodList.size()<1) { |
| | | |
| | | } else { |
| | | // 存在返回错误 |
| | | throw new BadRequestException("已存在此项目名称"); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.project.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.project.domain.ProjectType; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author HuaZhe |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface ProjectTypeMapper extends BaseMapper<ProjectTypeDto, ProjectType> { |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(data) { |
| | | return request({ |
| | | url: 'api/projectType/all', |
| | | method: 'get', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/projectType', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/projectType/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/projectType', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del } |
| | |
| | | // 默认岗位 |
| | | export const DEFAULT_JOBS = 1 |
| | | |
| | | // 国家:中国 |
| | | export const COUNTRY_CHINA = '中国' |
| | | // 国家:日本 |
| | | export const COUNTRY_JAPAN = '日本' |
| | | // 标准单价币种 |
| | | export const STANDARD_UNIT_CURRENCY = 'standard_unit_currency' |
| | | // 标准单价币种:人民币 |
| | | export const STANDARD_UNIT_CURRENCY_RENMINBI = 'standard_unit_currency_renminbi' |
| | | // 标准单价币种:美元 |
| | | export const STANDARD_UNIT_CURRENCY_DOLLAR = 'standard_unit_currency_dollar' |
| | | // 标准单价币种:日元 |
| | | export const STANDARD_UNIT_CURRENCY_YEN = 'standard_unit_currency_yen' |
| | | |
| | | // 配置:寄件码打印标题 |
| | | export const CONFIG_PRINT_TITLE = '寄件码打印标题' |
| | | |
| | | // 使用情况 |
| | | export const USE_CASE = 'use_case' |
| | | |
| | | // 使用状态 |
| | | export const USAGE_STATUS = 'usage_status' |
| | | // 使用状态:使用中 |
| | | export const USAGE_STATUS_USED = 'usage_status_used' |
| | | // 使用状态:已停用 |
| | | export const USAGE_STATUS_DEACTIVATED = 'usage_status_deactivated' |
| | | |
| | | // 包裹状态 |
| | | export const PACKAGE_STATUS = 'package_status' |
| | | // 包裹状态:等待处理 |
| | | export const PACKAGE_STATUS_WAITING = 'package_status_waiting' |
| | | // 包裹状态:已取件 |
| | | export const PACKAGE_STATUS_PICKED = 'package_status_picked' |
| | | // 包裹状态:已入库 |
| | | export const PACKAGE_STATUS_WAREHOUSING = 'package_status_warehousing' |
| | | // 包裹状态:已发货 |
| | | export const PACKAGE_STATUS_SHIPPED = 'package_status_shipped' |
| | | |
| | | // 预约状态 |
| | | export const APPOINTMENT_STATUS = 'appointment_status' |
| | | // 预约状态:等待处理 |
| | | export const APPOINTMENT_STATUS_WAITING = 'appointment_status_waiting' |
| | | // 预约状态:已取消 |
| | | export const APPOINTMENT_STATUS_CANCELED = 'appointment_status_canceled' |
| | | // 预约状态:预约成功 |
| | | export const APPOINTMENT_STATUS_SUCCESS = 'appointment_status_success' |
| | | // 预约状态:已完成 |
| | | export const APPOINTMENT_STATUS_COMPLETED = 'appointment_status_completed' |
| | | |
| | | // 地址类型 |
| | | export const ADDRESS_TYPE = 'address_type' |
| | | // 地址类型:中国地址 |
| | | export const ADDRESS_TYPE_CHINA = 'address_type_china' |
| | | // 地址类型:日本地址 |
| | | export const ADDRESS_TYPE_JAPEN = 'address_type_japen' |
| | | // 地址类型:国际地址 |
| | | export const ADDRESS_TYPE_INTERNATIONAL = 'address_type_international' |
| | | |
| | | // 包裹分类:XX杂货(用于模糊查询判定是否为杂货) |
| | | export const PACKAGE_CLASSIFICATION_GROCERY = '杂货' |
| | | // 标准工作量单位 |
| | | export const STANDARD_WORKLOAD_UNIT = 'standard_workload_unit' |
| | | // 标准工作量单位:个 |
| | | export const STANDARD_WORKLOAD_UNIT_NUMBER = 'standard_workload_unit_number' |
| | | // 标准工作量单位:本 |
| | | export const STANDARD_WORKLOAD_UNIT_BOOK = 'standard_workload_unit_book' |
| | | // 标准工作量单位:行 |
| | | export const STANDARD_WORKLOAD_UNIT_LINE = 'standard_workload_unit_line' |
| | | |
| | | export default { |
| | | MAX_PAGE, |
| | |
| | | FALSE, |
| | | DEFAULT_DEPT, |
| | | DEFAULT_JOBS, |
| | | COUNTRY_CHINA, |
| | | COUNTRY_JAPAN, |
| | | CONFIG_PRINT_TITLE, |
| | | USE_CASE, |
| | | USAGE_STATUS, |
| | | USAGE_STATUS_USED, |
| | | USAGE_STATUS_DEACTIVATED, |
| | | PACKAGE_STATUS, |
| | | PACKAGE_STATUS_WAITING, |
| | | PACKAGE_STATUS_PICKED, |
| | | PACKAGE_STATUS_WAREHOUSING, |
| | | PACKAGE_STATUS_SHIPPED, |
| | | APPOINTMENT_STATUS, |
| | | APPOINTMENT_STATUS_WAITING, |
| | | APPOINTMENT_STATUS_CANCELED, |
| | | APPOINTMENT_STATUS_SUCCESS, |
| | | APPOINTMENT_STATUS_COMPLETED, |
| | | ADDRESS_TYPE, |
| | | ADDRESS_TYPE_CHINA, |
| | | ADDRESS_TYPE_JAPEN, |
| | | ADDRESS_TYPE_INTERNATIONAL, |
| | | PACKAGE_CLASSIFICATION_GROCERY |
| | | STANDARD_UNIT_CURRENCY, |
| | | STANDARD_UNIT_CURRENCY_RENMINBI, |
| | | STANDARD_UNIT_CURRENCY_DOLLAR, |
| | | STANDARD_UNIT_CURRENCY_YEN, |
| | | STANDARD_WORKLOAD_UNIT, |
| | | STANDARD_WORKLOAD_UNIT_NUMBER, |
| | | STANDARD_WORKLOAD_UNIT_BOOK, |
| | | STANDARD_WORKLOAD_UNIT_LINE |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-input v-model="query.name" clearable placeholder="请输入名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.standardUnitCurrency" filterable placeholder="请选择标准单价币种" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[standardUnitCurrency]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <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="120px"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" maxlength="100" style="width: 330px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准单价币种" prop="standardUnitCurrency"> |
| | | <el-select v-model="form.standardUnitCurrency" filterable placeholder="请选择" style="width: 330px;"> |
| | | <el-option |
| | | v-for="item in dict[standardUnitCurrency]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="标准单价金额" prop="standardUnitPrice"> |
| | | <money-input :key="random" v-model="form.standardUnitPrice" :width="330" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准利润金额" prop="standardProfitPrice"> |
| | | <money-input :key="random" v-model="form.standardProfitPrice" :width="330" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准工作量单位" prop="standardWorkloadUnit"> |
| | | <el-select v-model="form.standardWorkloadUnit" filterable placeholder="请选择" style="width: 330px;"> |
| | | <el-option |
| | | v-for="item in dict[standardWorkloadUnit]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" maxlength="1000" style="width: 330px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="name" label="名称" show-overflow-tooltip /> |
| | | <el-table-column prop="standardUnitCurrency" label="标准单价币种"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][scope.row.standardUnitCurrency] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardUnitPrice" label="标准单价金额"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.standardUnitPrice) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardProfitPrice" label="标准利润金额"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.standardProfitPrice) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardWorkloadUnit" label="标准工作量单位"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[standardWorkloadUnit][scope.row.standardWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column v-if="checkPer(['admin','projectType:edit','projectType:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudProjectType from '@/api/project/projectType' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { id: null, name: null, standardUnitCurrency: null, standardUnitPrice: null, standardProfitPrice: null, standardWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'ProjectType', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: ['standard_unit_currency', 'standard_workload_unit'], |
| | | cruds() { |
| | | return CRUD({ title: '项目类型', url: 'api/projectType', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectType }}) |
| | | }, |
| | | data() { |
| | | var checkStandardUnitPricet = (rule, value, callback) => { |
| | | if (value !== null) { |
| | | if (isNaN(Number(value))) { |
| | | callback(new Error('标准单价金额必须是数字')) |
| | | } else { |
| | | if (value <= 0) { |
| | | callback(new Error('标准单价金额必须大于0')) |
| | | } else if (value >= 10000000000) { |
| | | callback(new Error('标准单价金额必须小于1百亿')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | } else { |
| | | callback(new Error('标准单价金额不能为空')) |
| | | } |
| | | } |
| | | var checkStandardProfitPrice = (rule, value, callback) => { |
| | | if (value !== null) { |
| | | if (isNaN(Number(value))) { |
| | | callback(new Error('标准利润金额必须是数字')) |
| | | } else { |
| | | if (value <= 0) { |
| | | callback(new Error('标准利润金额必须大于0')) |
| | | } else if (value >= 10000000000) { |
| | | callback(new Error('标准利润金额必须小于1百亿')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | } else { |
| | | callback(new Error('标准利润金额不能为空')) |
| | | } |
| | | } |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'projectType:add'], |
| | | edit: ['admin', 'projectType:edit'], |
| | | del: ['admin', 'projectType:del'], |
| | | download: ['admin', 'projectType:download'] |
| | | }, |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { min: 1, max: 100, message: '长度不超过100个字符', trigger: 'blur' } |
| | | ], |
| | | standardUnitCurrency: [ |
| | | { required: true, message: '标准单价币种不能为空', trigger: 'blur' } |
| | | ], |
| | | standardUnitPrice: [ |
| | | { required: true, validator: checkStandardUnitPricet, trigger: 'blur' } |
| | | ], |
| | | standardProfitPrice: [ |
| | | { required: true, validator: checkStandardProfitPrice, trigger: 'blur' } |
| | | ], |
| | | standardWorkloadUnit: [ |
| | | { required: true, message: '标准工作量单位不能为空', trigger: 'blur' } |
| | | ], |
| | | remarks: [ |
| | | { min: 1, max: 1000, message: '长度不超过1000个字符', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'name', display_name: '名称' }, |
| | | { key: 'standardUnitCurrency', display_name: '标准单价币种' } |
| | | ], |
| | | // 标准单价币种 |
| | | standardUnitCurrency: constant.STANDARD_UNIT_CURRENCY, |
| | | // 标准工作量单位 |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // 随机数 |
| | | random: 0 |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | return true |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [CRUD.HOOK.afterToCU](crud, form) { |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |