20 files added
2 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.business.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.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="business_expense") |
| | | public class BusinessExpense extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`expense_type`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "费用类型") |
| | | private String expenseType; |
| | | |
| | | @Column(name = "`business_plan_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "所属营业计划") |
| | | private Long businessPlanId; |
| | | |
| | | @Column(name = "`project_id`") |
| | | @ApiModelProperty(value = "所属项目") |
| | | private Long projectId; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(BusinessExpense 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.business.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 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="business_expense_reimbursement") |
| | | public class BusinessExpenseReimbursement extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @Column(name = "`business_expense_id`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "所属营业费用") |
| | | private Long businessExpenseId; |
| | | |
| | | @Column(name = "`reimbursement_content`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "报销内容") |
| | | private String reimbursementContent; |
| | | |
| | | @Column(name = "`reimbursement_amount`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "报销金额") |
| | | private BigDecimal reimbursementAmount; |
| | | |
| | | @Column(name = "`reimbursement_voucher`") |
| | | @ApiModelProperty(value = "报销凭证") |
| | | private String reimbursementVoucher; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(BusinessExpenseReimbursement 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.business.repository; |
| | | |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | public interface BusinessExpenseReimbursementRepository extends JpaRepository<BusinessExpenseReimbursement, Long>, JpaSpecificationExecutor<BusinessExpenseReimbursement> { |
| | | |
| | | // 根据营业费用ID查询 |
| | | List<BusinessExpenseReimbursement> findByBusinessExpenseId(Long businessExpenseId); |
| | | // 根据营业费用ID删除 |
| | | void deleteByBusinessExpenseId(Long businessExpenseId); |
| | | // 根据营业费用ID统计报销金额 |
| | | @Query(value = "SELECT SUM(reimbursement_amount) FROM business_expense_reimbursement WHERE business_expense_id = ?1", nativeQuery = true) |
| | | BigDecimal amountReimbursementAmountByBusinessExpenseId(Long businessExpenseId); |
| | | } |
| 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.business.repository; |
| | | |
| | | import me.zhengjie.modules.business.domain.BusinessExpense; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | public interface BusinessExpenseRepository extends JpaRepository<BusinessExpense, Long>, JpaSpecificationExecutor<BusinessExpense> { |
| | | } |
| | |
| | | * @date 2023-04-12 |
| | | **/ |
| | | public interface BusinessPlanPersonnelRepository extends JpaRepository<BusinessPlanPersonnel, Long>, JpaSpecificationExecutor<BusinessPlanPersonnel> { |
| | | |
| | | // 根据营业计划ID查询 |
| | | List<BusinessPlanPersonnel> findByBusinessPlanId(Long businessPlanId); |
| | | // 根据营业计划ID删除 |
| 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.business.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.business.domain.BusinessExpense; |
| | | import me.zhengjie.modules.business.service.BusinessExpenseService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria; |
| | | 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 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "营业费用管理") |
| | | @RequestMapping("/api/businessExpense") |
| | | public class BusinessExpenseController { |
| | | |
| | | private final BusinessExpenseService businessExpenseService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('businessExpense:download')") |
| | | public void exportBusinessExpense(HttpServletResponse response, BusinessExpenseQueryCriteria criteria) throws IOException { |
| | | businessExpenseService.download(businessExpenseService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询营业费用") |
| | | @ApiOperation("查询营业费用") |
| | | @PreAuthorize("@el.check('businessExpense:list')") |
| | | public ResponseEntity<Object> queryBusinessExpense(BusinessExpenseQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(businessExpenseService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询营业费用") |
| | | @ApiOperation("查询营业费用") |
| | | @PreAuthorize("@el.check('businessExpense:list')") |
| | | public ResponseEntity<Object> queryBusinessExpense(BusinessExpenseQueryCriteria criteria){ |
| | | return new ResponseEntity<>(businessExpenseService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增营业费用") |
| | | @ApiOperation("新增营业费用") |
| | | @PreAuthorize("@el.check('businessExpense:add')") |
| | | public ResponseEntity<Object> createBusinessExpense(@Validated @RequestBody BusinessExpenseDto resources){ |
| | | return new ResponseEntity<>(businessExpenseService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改营业费用") |
| | | @ApiOperation("修改营业费用") |
| | | @PreAuthorize("@el.check('businessExpense:edit')") |
| | | public ResponseEntity<Object> updateBusinessExpense(@Validated @RequestBody BusinessExpenseDto resources){ |
| | | businessExpenseService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除营业费用") |
| | | @ApiOperation("删除营业费用") |
| | | @PreAuthorize("@el.check('businessExpense:del')") |
| | | public ResponseEntity<Object> deleteBusinessExpense(@RequestBody Long[] ids) { |
| | | businessExpenseService.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.business.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | import me.zhengjie.modules.business.service.BusinessExpenseReimbursementService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementQueryCriteria; |
| | | 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 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "营业费用明细管理") |
| | | @RequestMapping("/api/businessExpenseReimbursement") |
| | | public class BusinessExpenseReimbursementController { |
| | | |
| | | private final BusinessExpenseReimbursementService businessExpenseReimbursementService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('businessExpenseReimbursement:download')") |
| | | public void exportBusinessExpenseReimbursement(HttpServletResponse response, BusinessExpenseReimbursementQueryCriteria criteria) throws IOException { |
| | | businessExpenseReimbursementService.download(businessExpenseReimbursementService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询营业费用明细") |
| | | @ApiOperation("查询营业费用明细") |
| | | @PreAuthorize("@el.check('businessExpenseReimbursement:list')") |
| | | public ResponseEntity<Object> queryBusinessExpenseReimbursement(BusinessExpenseReimbursementQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(businessExpenseReimbursementService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询营业费用明细") |
| | | @ApiOperation("查询营业费用明细") |
| | | @PreAuthorize("@el.check('businessExpenseReimbursement:list')") |
| | | public ResponseEntity<Object> queryBusinessExpenseReimbursement(BusinessExpenseReimbursementQueryCriteria criteria){ |
| | | return new ResponseEntity<>(businessExpenseReimbursementService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增营业费用明细") |
| | | @ApiOperation("新增营业费用明细") |
| | | @PreAuthorize("@el.check('businessExpenseReimbursement:add')") |
| | | public ResponseEntity<Object> createBusinessExpenseReimbursement(@Validated @RequestBody BusinessExpenseReimbursement resources){ |
| | | return new ResponseEntity<>(businessExpenseReimbursementService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改营业费用明细") |
| | | @ApiOperation("修改营业费用明细") |
| | | @PreAuthorize("@el.check('businessExpenseReimbursement:edit')") |
| | | public ResponseEntity<Object> updateBusinessExpenseReimbursement(@Validated @RequestBody BusinessExpenseReimbursement resources){ |
| | | businessExpenseReimbursementService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除营业费用明细") |
| | | @ApiOperation("删除营业费用明细") |
| | | @PreAuthorize("@el.check('businessExpenseReimbursement:del')") |
| | | public ResponseEntity<Object> deleteBusinessExpenseReimbursement(@RequestBody Long[] ids) { |
| | | businessExpenseReimbursementService.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.business.service; |
| | | |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementDto; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementQueryCriteria; |
| | | 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 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | public interface BusinessExpenseReimbursementService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(BusinessExpenseReimbursementQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<BusinessExpenseReimbursementDto> |
| | | */ |
| | | List<BusinessExpenseReimbursementDto> queryAll(BusinessExpenseReimbursementQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return BusinessExpenseReimbursementDto |
| | | */ |
| | | BusinessExpenseReimbursementDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return BusinessExpenseReimbursementDto |
| | | */ |
| | | BusinessExpenseReimbursementDto create(BusinessExpenseReimbursement resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(BusinessExpenseReimbursement resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<BusinessExpenseReimbursementDto> 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.business.service; |
| | | |
| | | import me.zhengjie.modules.business.domain.BusinessExpense; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria; |
| | | 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 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | public interface BusinessExpenseService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(BusinessExpenseQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<BusinessExpenseDto> |
| | | */ |
| | | List<BusinessExpenseDto> queryAll(BusinessExpenseQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return BusinessExpenseDto |
| | | */ |
| | | BusinessExpenseDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return BusinessExpenseDto |
| | | */ |
| | | BusinessExpenseDto create(BusinessExpenseDto resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(BusinessExpenseDto resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<BusinessExpenseDto> 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.business.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Data |
| | | public class BusinessExpenseDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 费用类型 */ |
| | | private String expenseType; |
| | | |
| | | /** 所属营业计划 */ |
| | | private Long businessPlanId; |
| | | |
| | | /** 所属营业计划内容 */ |
| | | private String businessPlanContent; |
| | | |
| | | /** 所属项目 */ |
| | | private Long projectId; |
| | | |
| | | /** 所属项目名称 */ |
| | | private String projectName; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | /** 营业费用明细列表 */ |
| | | private List<BusinessExpenseReimbursementDto> businessExpenseReimbursementDtoList; |
| | | |
| | | /** 报销金额总计 */ |
| | | private BigDecimal amountReimbursementAmount; |
| | | } |
| 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.business.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Data |
| | | public class BusinessExpenseQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private String expenseType; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long businessPlanId; |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long projectId; |
| | | } |
| 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.business.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 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Data |
| | | public class BusinessExpenseReimbursementDto extends BaseDTO implements Serializable { |
| | | |
| | | /** ID */ |
| | | private Long id; |
| | | |
| | | /** 所属营业费用 */ |
| | | private Long businessExpenseId; |
| | | |
| | | /** 所属营业费用类型 */ |
| | | private String businessExpenseType; |
| | | |
| | | /** 报销内容 */ |
| | | private String reimbursementContent; |
| | | |
| | | /** 报销金额 */ |
| | | private BigDecimal reimbursementAmount; |
| | | |
| | | /** 报销凭证 */ |
| | | private String reimbursementVoucher; |
| | | |
| | | /** 备注 */ |
| | | 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.business.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Data |
| | | public class BusinessExpenseReimbursementQueryCriteria{ |
| | | |
| | | /** 精确 */ |
| | | @Query |
| | | private Long businessExpenseId; |
| | | |
| | | /** 模糊 */ |
| | | @Query(type = Query.Type.INNER_LIKE) |
| | | private String reimbursementContent; |
| | | } |
| 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.business.service.impl; |
| | | |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | import me.zhengjie.modules.business.service.BusinessExpenseService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.business.repository.BusinessExpenseReimbursementRepository; |
| | | import me.zhengjie.modules.business.service.BusinessExpenseReimbursementService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementDto; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementQueryCriteria; |
| | | import me.zhengjie.modules.business.service.mapstruct.BusinessExpenseReimbursementMapper; |
| | | 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; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class BusinessExpenseReimbursementServiceImpl implements BusinessExpenseReimbursementService { |
| | | |
| | | private final BusinessExpenseReimbursementRepository businessExpenseReimbursementRepository; |
| | | private final BusinessExpenseReimbursementMapper businessExpenseReimbursementMapper; |
| | | private final BusinessExpenseService businessExpenseService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(BusinessExpenseReimbursementQueryCriteria criteria, Pageable pageable){ |
| | | Page<BusinessExpenseReimbursement> page = businessExpenseReimbursementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<BusinessExpenseReimbursement, BusinessExpenseReimbursementDto> func = new Function<BusinessExpenseReimbursement, BusinessExpenseReimbursementDto>(){ |
| | | @Override |
| | | public BusinessExpenseReimbursementDto apply(BusinessExpenseReimbursement t) { |
| | | // 将实体类转换成DTO |
| | | BusinessExpenseReimbursementDto businessExpenseReimbursementDto = businessExpenseReimbursementMapper.toDto(t); |
| | | |
| | | // 获取营业费用 |
| | | BusinessExpenseDto businessExpenseDto = businessExpenseService.findById(businessExpenseReimbursementDto.getBusinessExpenseId()); |
| | | businessExpenseReimbursementDto.setBusinessExpenseType(businessExpenseDto.getExpenseType()); |
| | | |
| | | // 返回处理好的DTO |
| | | return businessExpenseReimbursementDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<BusinessExpenseReimbursementDto> queryAll(BusinessExpenseReimbursementQueryCriteria criteria){ |
| | | return businessExpenseReimbursementMapper.toDto(businessExpenseReimbursementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public BusinessExpenseReimbursementDto findById(Long id) { |
| | | BusinessExpenseReimbursement businessExpenseReimbursement = businessExpenseReimbursementRepository.findById(id).orElseGet(BusinessExpenseReimbursement::new); |
| | | ValidationUtil.isNull(businessExpenseReimbursement.getId(),"BusinessExpenseReimbursement","id",id); |
| | | return businessExpenseReimbursementMapper.toDto(businessExpenseReimbursement); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BusinessExpenseReimbursementDto create(BusinessExpenseReimbursement resources) { |
| | | return businessExpenseReimbursementMapper.toDto(businessExpenseReimbursementRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(BusinessExpenseReimbursement resources) { |
| | | BusinessExpenseReimbursement businessExpenseReimbursement = businessExpenseReimbursementRepository.findById(resources.getId()).orElseGet(BusinessExpenseReimbursement::new); |
| | | ValidationUtil.isNull( businessExpenseReimbursement.getId(),"BusinessExpenseReimbursement","id",resources.getId()); |
| | | businessExpenseReimbursement.copy(resources); |
| | | businessExpenseReimbursementRepository.save(businessExpenseReimbursement); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | businessExpenseReimbursementRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<BusinessExpenseReimbursementDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (BusinessExpenseReimbursementDto businessExpenseReimbursement : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("所属营业费用", businessExpenseReimbursement.getBusinessExpenseId()); |
| | | map.put("报销内容", businessExpenseReimbursement.getReimbursementContent()); |
| | | map.put("报销金额", businessExpenseReimbursement.getReimbursementAmount()); |
| | | map.put("报销凭证", businessExpenseReimbursement.getReimbursementVoucher()); |
| | | map.put("备注", businessExpenseReimbursement.getRemarks()); |
| | | map.put("创建者", businessExpenseReimbursement.getCreateBy()); |
| | | map.put("创建时间", businessExpenseReimbursement.getCreateTime()); |
| | | map.put("更新者", businessExpenseReimbursement.getUpdateBy()); |
| | | map.put("更新时间", businessExpenseReimbursement.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| 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.business.service.impl; |
| | | |
| | | import me.zhengjie.modules.business.domain.BusinessExpense; |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | import me.zhengjie.modules.business.repository.BusinessExpenseReimbursementRepository; |
| | | import me.zhengjie.modules.business.service.BusinessPlanService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementDto; |
| | | import me.zhengjie.modules.business.service.dto.BusinessPlanDto; |
| | | import me.zhengjie.modules.business.service.mapstruct.BusinessExpenseReimbursementMapper; |
| | | import me.zhengjie.modules.project.service.ProjectService; |
| | | import me.zhengjie.modules.project.service.dto.ProjectDto; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.business.repository.BusinessExpenseRepository; |
| | | import me.zhengjie.modules.business.service.BusinessExpenseService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria; |
| | | import me.zhengjie.modules.business.service.mapstruct.BusinessExpenseMapper; |
| | | 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.math.BigDecimal; |
| | | 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; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class BusinessExpenseServiceImpl implements BusinessExpenseService { |
| | | |
| | | private final BusinessExpenseRepository businessExpenseRepository; |
| | | private final BusinessExpenseMapper businessExpenseMapper; |
| | | private final BusinessPlanService businessPlanService; |
| | | private final ProjectService projectService; |
| | | private final BusinessExpenseReimbursementRepository businessExpenseReimbursementRepository; |
| | | private final BusinessExpenseReimbursementMapper businessExpenseReimbursementMapper; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(BusinessExpenseQueryCriteria criteria, Pageable pageable){ |
| | | Page<BusinessExpense> page = businessExpenseRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<BusinessExpense, BusinessExpenseDto> func = new Function<BusinessExpense, BusinessExpenseDto>(){ |
| | | @Override |
| | | public BusinessExpenseDto apply(BusinessExpense t) { |
| | | // 将实体类转换成DTO |
| | | BusinessExpenseDto businessExpenseDto = businessExpenseMapper.toDto(t); |
| | | |
| | | // 获取营业计划 |
| | | BusinessPlanDto businessPlanDto = businessPlanService.findById(businessExpenseDto.getBusinessPlanId()); |
| | | businessExpenseDto.setBusinessPlanContent(businessPlanDto.getBusinessContent()); |
| | | // 获取项目 |
| | | if (businessExpenseDto.getProjectId() != null) { |
| | | ProjectDto projectDto = projectService.findById(businessExpenseDto.getProjectId()); |
| | | businessExpenseDto.setProjectName(projectDto.getName()); |
| | | } |
| | | // 获取营业费用明细 |
| | | List<BusinessExpenseReimbursement> businessExpenseReimbursementList = businessExpenseReimbursementRepository.findByBusinessExpenseId(businessExpenseDto.getId()); |
| | | businessExpenseDto.setBusinessExpenseReimbursementDtoList(businessExpenseReimbursementMapper.toDto(businessExpenseReimbursementList)); |
| | | // 获取报销金额总计 |
| | | BigDecimal amountReimbursementAmount = businessExpenseReimbursementRepository.amountReimbursementAmountByBusinessExpenseId(businessExpenseDto.getId()); |
| | | businessExpenseDto.setAmountReimbursementAmount(amountReimbursementAmount); |
| | | |
| | | // 返回处理好的DTO |
| | | return businessExpenseDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<BusinessExpenseDto> queryAll(BusinessExpenseQueryCriteria criteria){ |
| | | return businessExpenseMapper.toDto(businessExpenseRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public BusinessExpenseDto findById(Long id) { |
| | | BusinessExpense businessExpense = businessExpenseRepository.findById(id).orElseGet(BusinessExpense::new); |
| | | ValidationUtil.isNull(businessExpense.getId(),"BusinessExpense","id",id); |
| | | return businessExpenseMapper.toDto(businessExpense); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BusinessExpenseDto create(BusinessExpenseDto resources) { |
| | | // 保存营业费用 |
| | | BusinessExpense businessExpense = businessExpenseRepository.save(businessExpenseMapper.toEntity(resources)); |
| | | // 保存相关营业费用明细 |
| | | saveBusinessExpenseReimbursement(resources.getBusinessExpenseReimbursementDtoList(), businessExpense.getId()); |
| | | return findById(businessExpense.getId()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(BusinessExpenseDto resources) { |
| | | BusinessExpense businessExpense = businessExpenseRepository.findById(resources.getId()).orElseGet(BusinessExpense::new); |
| | | ValidationUtil.isNull( businessExpense.getId(),"BusinessExpense","id",resources.getId()); |
| | | businessExpense.copy(businessExpenseMapper.toEntity(resources)); |
| | | businessExpenseRepository.save(businessExpense); |
| | | // 保存相关营业费用明细 |
| | | saveBusinessExpenseReimbursement(resources.getBusinessExpenseReimbursementDtoList(), businessExpense.getId()); |
| | | } |
| | | |
| | | /** |
| | | * 保存相关营业费用明细 |
| | | * @param businessExpenseReimbursementDtoList |
| | | * @param businessExpenseId |
| | | */ |
| | | private void saveBusinessExpenseReimbursement(List<BusinessExpenseReimbursementDto> businessExpenseReimbursementDtoList, Long businessExpenseId) { |
| | | // 根据营业费用ID删除营业费用明细 |
| | | businessExpenseReimbursementRepository.deleteByBusinessExpenseId(businessExpenseId); |
| | | // 营业费用明细列表 |
| | | List<BusinessExpenseReimbursement> businessExpenseReimbursementList = businessExpenseReimbursementMapper.toEntity(businessExpenseReimbursementDtoList); |
| | | // 循环营业费用明细列表 |
| | | for (BusinessExpenseReimbursement businessExpenseReimbursement : businessExpenseReimbursementList) { |
| | | // 营业费用明细 |
| | | businessExpenseReimbursement.setBusinessExpenseId(businessExpenseId); |
| | | // 保存营业费用明细 |
| | | businessExpenseReimbursementRepository.save(businessExpenseReimbursement); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | businessExpenseRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<BusinessExpenseDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (BusinessExpenseDto businessExpense : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("费用类型", businessExpense.getExpenseType()); |
| | | map.put("所属营业计划", businessExpense.getBusinessPlanId()); |
| | | map.put("所属项目", businessExpense.getProjectId()); |
| | | map.put("备注", businessExpense.getRemarks()); |
| | | map.put("创建者", businessExpense.getCreateBy()); |
| | | map.put("创建时间", businessExpense.getCreateTime()); |
| | | map.put("更新者", businessExpense.getUpdateBy()); |
| | | map.put("更新时间", businessExpense.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| 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.business.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.business.domain.BusinessExpense; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface BusinessExpenseMapper extends BaseMapper<BusinessExpenseDto, BusinessExpense> { |
| | | |
| | | } |
| 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.business.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.business.domain.BusinessExpenseReimbursement; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author 赵士淞 |
| | | * @date 2023-04-13 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface BusinessExpenseReimbursementMapper extends BaseMapper<BusinessExpenseReimbursementDto, BusinessExpenseReimbursement> { |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/businessExpense/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/businessExpense', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/businessExpense/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/businessExpense', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/businessExpenseReimbursement/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/businessExpenseReimbursement', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/businessExpenseReimbursement/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/businessExpenseReimbursement', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del } |
| | |
| | | // 营业状态 |
| | | export const BUSINESS_STATUS = 'business_status' |
| | | |
| | | // 费用类型 |
| | | export const EXPENSE_TYPE = 'expense_type' |
| | | |
| | | export default { |
| | | ROLE_LEVEL_SUPER, |
| | | ROLE_LEVEL_GENERAL, |
| | |
| | | ACCOUNT_TYPE_YIHENG, |
| | | ACCOUNT_TYPE_ZIXUN, |
| | | ACCOUNT_TYPE_HENGZHEN, |
| | | BUSINESS_STATUS |
| | | BUSINESS_STATUS, |
| | | EXPENSE_TYPE |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.expenseType" clearable placeholder="费用类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[expenseType]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.businessPlanId" clearable placeholder="所属营业计划" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in businessPlanList" |
| | | :key="item.id" |
| | | :label="item.businessContent" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.projectId" clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | | </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="600px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> |
| | | <el-form-item label="费用类型" prop="expenseType"> |
| | | <el-select v-model="form.expenseType" placeholder="请选择" filterable clearable style="width: 440px;"> |
| | | <el-option |
| | | v-for="item in dict[expenseType]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属营业计划" prop="businessPlanId"> |
| | | <el-select v-model="form.businessPlanId" placeholder="请选择" filterable clearable style="width: 440px;"> |
| | | <el-option |
| | | v-for="item in businessPlanList" |
| | | :key="item.id" |
| | | :label="item.businessContent" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属项目"> |
| | | <el-select v-model="form.projectId" placeholder="请选择" filterable clearable style="width: 440px;"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-button size="mini" type="primary" icon="el-icon-plus" style="position: relative; left: 464px;" @click="reimbursementAdd()" /> |
| | | <el-table ref="table" :data="form.businessExpenseReimbursementDtoList" size="small" style="width: 100%;"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.reimbursementAmount) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证"> |
| | | <template slot-scope="scope"> |
| | | <el-image |
| | | :src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''" |
| | | :preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []" |
| | | style="width: 100px;" |
| | | > |
| | | <div slot="placeholder" class="image-slot"> |
| | | 加载中... |
| | | </div> |
| | | <div slot="error" class="image-slot"> |
| | | 暂无图片 |
| | | </div> |
| | | </el-image> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-button size="mini" type="primary" icon="el-icon-edit" @click="reimbursementEdit(scope.row)" /> |
| | | <el-button size="mini" type="danger" icon="el-icon-delete" @click="reimbursementDelete(scope.row)" /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-form-item label="备注" style="margin-top: 20px;"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 440px;" /> |
| | | </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 type="expand"> |
| | | <template slot-scope="props"> |
| | | <el-table :data="props.row.businessExpenseReimbursementDtoList" style="margin: 10px 20px 10px 105px; width: calc(100% - 20px - 105px);"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.reimbursementAmount) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证"> |
| | | <template slot-scope="scope"> |
| | | <el-image |
| | | :src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''" |
| | | :preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []" |
| | | style="width: 100px;" |
| | | > |
| | | <div slot="placeholder" class="image-slot"> |
| | | 加载中... |
| | | </div> |
| | | <div slot="error" class="image-slot"> |
| | | 暂无图片 |
| | | </div> |
| | | </el-image> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" /> |
| | | </el-table> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="expenseType" label="费用类型"> |
| | | <template slot-scope="scope"> |
| | | {{ dict.label[expenseType][scope.row.expenseType] }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="businessPlanContent" label="所属营业计划" /> |
| | | <el-table-column prop="projectName" label="所属项目" /> |
| | | <el-table-column prop="amountReimbursementAmount" label="报销总金额"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.amountReimbursementAmount) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" /> |
| | | <el-table-column prop="createTime" label="创建时间" /> |
| | | <el-table-column v-if="checkPer(['admin','businessExpense:edit','businessExpense:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="reimbursementCancel" :visible.sync="reimbursementStatus" :title="reimbursementTitle" width="600px"> |
| | | <el-form ref="reimbursementForm" :model="reimbursementForm" :rules="reimbursementRules" size="small" label-width="140px"> |
| | | <el-form-item label="报销内容" prop="reimbursementContent"> |
| | | <el-input v-model="reimbursementForm.reimbursementContent" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="报销金额" prop="reimbursementAmount"> |
| | | <money-input :key="random" v-model="reimbursementForm.reimbursementAmount" :width="340" /> |
| | | </el-form-item> |
| | | <el-form-item label="报销凭证"> |
| | | <image-upload ref="imageUpload" :key="random" :image-url="reimbursementForm.reimbursementVoucher == null || reimbursementForm.reimbursementVoucher === '' ? null : reimbursementForm.reimbursementVoucher" :limit="3" @imageInfo="getImageInfo" /> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="reimbursementForm.remarks" :rows="3" type="textarea" style="width: 340px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="reimbursementCancel">取消</el-button> |
| | | <el-button :loading="reimbursementLoading" type="primary" @click="reimbursementSubmit('reimbursementForm')">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudBusinessExpense from '@/api/business/expense' |
| | | 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 constant from '../../../utils/constant' |
| | | import crudBusinessPlan from '@/api/business/plan' |
| | | import crudProject from '@/api/project/project' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import imageUpload from '../../assembly/imageUpload/index.vue' |
| | | import { mapGetters } from 'vuex' |
| | | |
| | | const defaultForm = { id: null, expenseType: null, businessPlanId: null, projectId: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, businessExpenseReimbursementDtoList: [] } |
| | | export default { |
| | | name: 'BusinessExpense', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput, imageUpload }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: [constant.EXPENSE_TYPE], |
| | | cruds() { |
| | | return CRUD({ title: '营业费用', url: 'api/businessExpense', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessExpense }}) |
| | | }, |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'businessExpense:add'], |
| | | edit: ['admin', 'businessExpense:edit'], |
| | | del: ['admin', 'businessExpense:del'], |
| | | download: ['admin', 'businessExpense:download'] |
| | | }, |
| | | rules: { |
| | | expenseType: [ |
| | | { required: true, message: '费用类型不能为空', trigger: 'change' } |
| | | ], |
| | | businessPlanId: [ |
| | | { required: true, message: '所属营业计划不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'expenseType', display_name: '费用类型' }, |
| | | { key: 'businessPlanId', display_name: '所属营业计划' }, |
| | | { key: 'projectId', display_name: '所属项目' } |
| | | ], |
| | | // 字典:费用类型 |
| | | expenseType: constant.EXPENSE_TYPE, |
| | | // 随机数 |
| | | random: 0, |
| | | // 营业计划列表 |
| | | businessPlanList: [], |
| | | // 项目列表 |
| | | projectList: [], |
| | | // 营业费用明细弹窗状态 |
| | | reimbursementStatus: false, |
| | | // 营业费用明细弹窗标题 |
| | | reimbursementTitle: '营业费用明细', |
| | | // 营业费用明细弹窗表单 |
| | | reimbursementForm: {}, |
| | | // 营业费用明细弹窗验证 |
| | | reimbursementRules: { |
| | | businessExpenseId: [ |
| | | { required: true, message: '所属营业费用不能为空', trigger: 'change' } |
| | | ], |
| | | reimbursementContent: [ |
| | | { required: true, message: '报销内容不能为空', trigger: 'blur' }, |
| | | { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' } |
| | | ], |
| | | reimbursementAmount: [ |
| | | { required: true, message: '报销金额不能为空', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | // 营业费用明细弹窗操作 |
| | | reimbursementExecute: {}, |
| | | // 营业费用明细弹窗加载 |
| | | reimbursementLoading: false |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'baseApi' |
| | | ]) |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取营业计划 |
| | | this.getBusinessPlan() |
| | | // 获取项目 |
| | | this.getProject() |
| | | return true |
| | | }, |
| | | // 获取营业计划 |
| | | getBusinessPlan() { |
| | | // 获取营业计划 |
| | | crudBusinessPlan.getAll().then(res => { |
| | | // 营业计划列表 |
| | | this.businessPlanList = res |
| | | }) |
| | | }, |
| | | // 获取项目 |
| | | getProject() { |
| | | // 获取项目 |
| | | crudProject.getAll().then(res => { |
| | | // 项目列表 |
| | | this.projectList = res |
| | | }) |
| | | }, |
| | | // 营业费用明细弹窗新增 |
| | | reimbursementAdd() { |
| | | // 指针重定义 |
| | | const _this = this |
| | | // 营业费用明细弹窗表单 |
| | | this.reimbursementForm = {} |
| | | // 营业费用明细弹窗状态 |
| | | this.reimbursementStatus = true |
| | | // 营业费用明细弹窗操作 |
| | | this.reimbursementExecute = {} |
| | | // 表单清空 |
| | | setTimeout(function() { |
| | | _this.$refs['reimbursementForm'].clearValidate() |
| | | }, 3) |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 营业费用明细弹窗修改 |
| | | reimbursementEdit(data) { |
| | | // 营业费用明细弹窗表单 |
| | | this.reimbursementForm = JSON.parse(JSON.stringify(data)) |
| | | // 营业费用明细弹窗状态 |
| | | this.reimbursementStatus = true |
| | | // 营业费用明细弹窗操作 |
| | | this.reimbursementExecute = JSON.parse(JSON.stringify(data)) |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 营业费用明细弹窗删除 |
| | | reimbursementDelete(data) { |
| | | // 筛选费用明细人员 |
| | | const reimbursementInfo = this.crud.form.businessExpenseReimbursementDtoList.filter(function(item) { |
| | | return item.reimbursementContent === data.reimbursementContent && item.reimbursementAmount === data.reimbursementAmount |
| | | }) |
| | | // 获取下标 |
| | | const subscript = this.crud.form.businessExpenseReimbursementDtoList.indexOf(reimbursementInfo[0]) |
| | | // 营业费用明细移除元素 |
| | | this.crud.form.businessExpenseReimbursementDtoList.splice(subscript, 1) |
| | | }, |
| | | // 营业费用明细弹窗关闭 |
| | | reimbursementCancel() { |
| | | // 营业费用明细弹窗状态 |
| | | this.reimbursementStatus = false |
| | | }, |
| | | // 营业费用明细弹窗提交 |
| | | reimbursementSubmit(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | // 通过“this.$refs.imageUpload”找到子页面,“submit”是子页面的方法。 |
| | | this.$refs.imageUpload.submit() |
| | | } else { |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | // 获取图片信息 |
| | | getImageInfo(info) { |
| | | // 判断返回数据 |
| | | if (info.length === 0) { |
| | | // 表单图片路径赋值 |
| | | this.reimbursementForm.reimbursementVoucher = null |
| | | // 表单提交 |
| | | this.reimbursementSubmitCU() |
| | | // 终止 |
| | | return |
| | | } |
| | | // 循环返回数据 |
| | | for (let i = 0; i < info.length; i++) { |
| | | // 判断循环下标 |
| | | if (i === 0) { |
| | | // 表单图片路径赋值 |
| | | this.reimbursementForm.reimbursementVoucher = info[i].response == null || info[i].response === '' ? info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : '/file/' + info[i].response.type + '/' + info[i].response.realName |
| | | } else { |
| | | // 表单图片路径赋值 |
| | | this.reimbursementForm.reimbursementVoucher += info[i].response == null || info[i].response === '' ? ',' + info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : ',/file/' + info[i].response.type + '/' + info[i].response.realName |
| | | } |
| | | // 判断循环是否结束 |
| | | if (i === info.length - 1) { |
| | | // 表单提交 |
| | | this.reimbursementSubmitCU() |
| | | } |
| | | } |
| | | }, |
| | | // 表单提交 |
| | | reimbursementSubmitCU() { |
| | | // 判断营业费用明细弹窗操作 |
| | | if (this.reimbursementExecute.reimbursementContent !== undefined) { |
| | | // 营业费用明细弹编辑 |
| | | // 指针重定义 |
| | | const _this = this |
| | | // 筛选营业费用明细弹 |
| | | const reimbursementInfo = this.crud.form.businessExpenseReimbursementDtoList.filter(function(item) { |
| | | return item.reimbursementContent === _this.reimbursementExecute.reimbursementContent && item.reimbursementAmount === _this.reimbursementExecute.reimbursementAmount |
| | | }) |
| | | // 营业费用明细弹更新 |
| | | reimbursementInfo[0].reimbursementContent = this.reimbursementForm.reimbursementContent |
| | | reimbursementInfo[0].reimbursementAmount = this.reimbursementForm.reimbursementAmount |
| | | reimbursementInfo[0].reimbursementVoucher = this.reimbursementForm.reimbursementVoucher |
| | | reimbursementInfo[0].remarks = this.reimbursementForm.remarks |
| | | } else { |
| | | // 营业费用明细新增 |
| | | this.crud.form.businessExpenseReimbursementDtoList.push(this.reimbursementForm) |
| | | } |
| | | // 营业费用明细弹窗关闭 |
| | | this.reimbursementCancel() |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.businessExpenseId" clearable placeholder="所属营业费用" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in businessExpenseList" |
| | | :key="item.id" |
| | | :label="dict.label[expenseType][item.expenseType]" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-input v-model="query.reimbursementContent" clearable placeholder="报销内容" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <rrOperation :crud="crud" /> |
| | | </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="110px"> |
| | | <el-form-item label="所属营业费用" prop="businessExpenseId"> |
| | | <el-select v-model="form.businessExpenseId" placeholder="请选择" filterable clearable style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in businessExpenseList" |
| | | :key="item.id" |
| | | :label="dict.label[expenseType][item.expenseType]" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="报销内容" prop="reimbursementContent"> |
| | | <el-input v-model="form.reimbursementContent" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="报销金额" prop="reimbursementAmount"> |
| | | <money-input :key="random" v-model="form.reimbursementAmount" :width="340" /> |
| | | </el-form-item> |
| | | <el-form-item label="报销凭证"> |
| | | <image-upload ref="imageUpload" :key="random" :image-url="form.reimbursementVoucher == null || form.reimbursementVoucher === '' ? null : form.reimbursementVoucher" :limit="3" @imageInfo="getImageInfo" /> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" /> |
| | | </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="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 :show-overflow-tooltip="true" prop="businessExpenseId" label="所属营业费用"> |
| | | <template slot-scope="scope"> |
| | | {{ dict.label[expenseType][scope.row.businessExpenseType] }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.reimbursementAmount) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证"> |
| | | <template slot-scope="scope"> |
| | | <el-image |
| | | :src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''" |
| | | :preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []" |
| | | style="width: 100px;" |
| | | > |
| | | <div slot="placeholder" class="image-slot"> |
| | | 加载中... |
| | | </div> |
| | | <div slot="error" class="image-slot"> |
| | | 暂无图片 |
| | | </div> |
| | | </el-image> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" /> |
| | | <el-table-column v-if="checkPer(['admin','businessExpenseReimbursement:edit','businessExpenseReimbursement: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 crudBusinessExpenseReimbursement from '@/api/business/expenseReimbursement' |
| | | 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 constant from '../../../utils/constant' |
| | | import crudBusinessExpense from '@/api/business/expense' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import imageUpload from '../../assembly/imageUpload/index.vue' |
| | | import { mapGetters } from 'vuex' |
| | | |
| | | const defaultForm = { id: null, businessExpenseId: null, reimbursementContent: null, reimbursementAmount: null, reimbursementVoucher: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'BusinessExpenseReimbursement', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput, imageUpload }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: [constant.EXPENSE_TYPE], |
| | | cruds() { |
| | | return CRUD({ title: '营业费用明细', url: 'api/businessExpenseReimbursement', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessExpenseReimbursement }}) |
| | | }, |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'businessExpenseReimbursement:add'], |
| | | edit: ['admin', 'businessExpenseReimbursement:edit'], |
| | | del: ['admin', 'businessExpenseReimbursement:del'], |
| | | download: ['admin', 'businessExpenseReimbursement:download'] |
| | | }, |
| | | rules: { |
| | | businessExpenseId: [ |
| | | { required: true, message: '所属营业费用不能为空', trigger: 'change' } |
| | | ], |
| | | reimbursementContent: [ |
| | | { required: true, message: '报销内容不能为空', trigger: 'blur' }, |
| | | { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' } |
| | | ], |
| | | reimbursementAmount: [ |
| | | { required: true, message: '报销金额不能为空', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'businessExpenseId', display_name: '所属营业费用' }, |
| | | { key: 'reimbursementContent', display_name: '报销内容' } |
| | | ], |
| | | // 字典:费用类型 |
| | | expenseType: constant.EXPENSE_TYPE, |
| | | // 随机数 |
| | | random: 0, |
| | | // 营业费用列表 |
| | | businessExpenseList: [] |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'baseApi' |
| | | ]) |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取营业费用 |
| | | this.getBusinessExpense() |
| | | return true |
| | | }, |
| | | // 获取营业费用 |
| | | getBusinessExpense() { |
| | | // 获取营业费用 |
| | | crudBusinessExpense.getAll().then(res => { |
| | | // 营业费用列表 |
| | | this.businessExpenseList = res |
| | | }) |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [CRUD.HOOK.beforeToCU]() { |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 表单提交 |
| | | submitCU() { |
| | | // 通过“this.$refs.imageUpload”找到子页面,“submit”是子页面的方法。 |
| | | this.$refs.imageUpload.submit() |
| | | }, |
| | | // 获取图片信息 |
| | | getImageInfo(info) { |
| | | // 判断返回数据 |
| | | if (info.length === 0) { |
| | | // 表单图片路径赋值 |
| | | this.crud.form.reimbursementVoucher = null |
| | | // 表单提交 |
| | | this.crud.submitCU() |
| | | // 终止 |
| | | return |
| | | } |
| | | // 循环返回数据 |
| | | for (let i = 0; i < info.length; i++) { |
| | | // 判断循环下标 |
| | | if (i === 0) { |
| | | // 表单图片路径赋值 |
| | | this.crud.form.reimbursementVoucher = info[i].response == null || info[i].response === '' ? info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : '/file/' + info[i].response.type + '/' + info[i].response.realName |
| | | } else { |
| | | // 表单图片路径赋值 |
| | | this.crud.form.reimbursementVoucher += info[i].response == null || info[i].response === '' ? ',' + info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : ',/file/' + info[i].response.type + '/' + info[i].response.realName |
| | | } |
| | | // 判断循环是否结束 |
| | | if (i === info.length - 1) { |
| | | // 表单提交 |
| | | this.crud.submitCU() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |