赵士淞
2023-04-13 307a3116b05b67cabe7f0416eec9736d7c89e52f
营业计划
20 files added
1 files modified
1689 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/domain/BusinessPlan.java 68 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/domain/BusinessPlanPersonnel.java 73 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/repository/BusinessPlanPersonnelRepository.java 34 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/repository/BusinessPlanRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessPlanController.java 96 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessPlanPersonnelController.java 95 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessPlanPersonnelService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessPlanService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanDto.java 51 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanPersonnelDto.java 56 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanPersonnelQueryCriteria.java 37 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanQueryCriteria.java 41 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessPlanPersonnelServiceImpl.java 137 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessPlanServiceImpl.java 168 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/mapstruct/BusinessPlanMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/mapstruct/BusinessPlanPersonnelMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/business/plan.js 35 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/business/planPersonnel.js 35 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/utils/constant.js 6 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/business/plan/index.vue 321 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/business/planPersonnel/index.vue 178 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/domain/BusinessPlan.java
New file
@@ -0,0 +1,68 @@
/*
*  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-12
**/
@Entity
@Data
@Table(name="business_plan")
public class BusinessPlan extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;
    @Column(name = "`business_place`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "营业地")
    private String businessPlace;
    @Column(name = "`business_content`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "营业内容")
    private String businessContent;
    @Column(name = "`business_status`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "营业状态")
    private String businessStatus;
    @Column(name = "`remarks`")
    @ApiModelProperty(value = "备注")
    private String remarks;
    public void copy(BusinessPlan source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/domain/BusinessPlanPersonnel.java
New file
@@ -0,0 +1,73 @@
/*
*  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-12
**/
@Entity
@Data
@Table(name="business_plan_personnel")
public class BusinessPlanPersonnel extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;
    @Column(name = "`business_plan_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "所属营业计划")
    private Long businessPlanId;
    @Column(name = "`user_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "所属用户")
    private Long userId;
    @Column(name = "`business_plan_start_date`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "营业计划开始日期")
    private Timestamp businessPlanStartDate;
    @Column(name = "`business_plan_end_date`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "营业计划结束日期")
    private Timestamp businessPlanEndDate;
    @Column(name = "`remarks`")
    @ApiModelProperty(value = "备注")
    private String remarks;
    public void copy(BusinessPlanPersonnel source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/repository/BusinessPlanPersonnelRepository.java
New file
@@ -0,0 +1,34 @@
/*
*  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.BusinessPlanPersonnel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @website https://eladmin.vip
* @author 赵士淞
* @date 2023-04-12
**/
public interface BusinessPlanPersonnelRepository extends JpaRepository<BusinessPlanPersonnel, Long>, JpaSpecificationExecutor<BusinessPlanPersonnel> {
    // 根据营业计划ID查询
    List<BusinessPlanPersonnel> findByBusinessPlanId(Long businessPlanId);
    // 根据营业计划ID删除
    void deleteByBusinessPlanId(Long businessPlanId);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/repository/BusinessPlanRepository.java
New file
@@ -0,0 +1,28 @@
/*
*  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.BusinessPlan;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author 赵士淞
* @date 2023-04-12
**/
public interface BusinessPlanRepository extends JpaRepository<BusinessPlan, Long>, JpaSpecificationExecutor<BusinessPlan> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessPlanController.java
New file
@@ -0,0 +1,96 @@
/*
*  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.BusinessPlan;
import me.zhengjie.modules.business.service.BusinessPlanService;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
import me.zhengjie.modules.business.service.dto.BusinessPlanQueryCriteria;
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-12
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "营业计划管理")
@RequestMapping("/api/businessPlan")
public class BusinessPlanController {
    private final BusinessPlanService businessPlanService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('businessPlan:download')")
    public void exportBusinessPlan(HttpServletResponse response, BusinessPlanQueryCriteria criteria) throws IOException {
        businessPlanService.download(businessPlanService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询营业计划")
    @ApiOperation("查询营业计划")
    @PreAuthorize("@el.check('businessPlan:list')")
    public ResponseEntity<Object> queryBusinessPlan(BusinessPlanQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(businessPlanService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @GetMapping(value = "/all")
    @Log("查询营业计划")
    @ApiOperation("查询营业计划")
    @PreAuthorize("@el.check('businessPlan:list')")
    public ResponseEntity<Object> queryBusinessPlan(BusinessPlanQueryCriteria criteria){
        return new ResponseEntity<>(businessPlanService.queryAll(criteria),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增营业计划")
    @ApiOperation("新增营业计划")
    @PreAuthorize("@el.check('businessPlan:add')")
    public ResponseEntity<Object> createBusinessPlan(@Validated @RequestBody BusinessPlanDto resources){
        return new ResponseEntity<>(businessPlanService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改营业计划")
    @ApiOperation("修改营业计划")
    @PreAuthorize("@el.check('businessPlan:edit')")
    public ResponseEntity<Object> updateBusinessPlan(@Validated @RequestBody BusinessPlanDto resources){
        businessPlanService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除营业计划")
    @ApiOperation("删除营业计划")
    @PreAuthorize("@el.check('businessPlan:del')")
    public ResponseEntity<Object> deleteBusinessPlan(@RequestBody Long[] ids) {
        businessPlanService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessPlanPersonnelController.java
New file
@@ -0,0 +1,95 @@
/*
*  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.BusinessPlanPersonnel;
import me.zhengjie.modules.business.service.BusinessPlanPersonnelService;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelQueryCriteria;
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-12
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "营业计划人员管理")
@RequestMapping("/api/businessPlanPersonnel")
public class BusinessPlanPersonnelController {
    private final BusinessPlanPersonnelService businessPlanPersonnelService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('businessPlanPersonnel:download')")
    public void exportBusinessPlanPersonnel(HttpServletResponse response, BusinessPlanPersonnelQueryCriteria criteria) throws IOException {
        businessPlanPersonnelService.download(businessPlanPersonnelService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询营业计划人员")
    @ApiOperation("查询营业计划人员")
    @PreAuthorize("@el.check('businessPlanPersonnel:list')")
    public ResponseEntity<Object> queryBusinessPlanPersonnel(BusinessPlanPersonnelQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(businessPlanPersonnelService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @GetMapping(value = "/all")
    @Log("查询营业计划人员")
    @ApiOperation("查询营业计划人员")
    @PreAuthorize("@el.check('businessPlanPersonnel:list')")
    public ResponseEntity<Object> queryBusinessPlanPersonnel(BusinessPlanPersonnelQueryCriteria criteria){
        return new ResponseEntity<>(businessPlanPersonnelService.queryAll(criteria),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增营业计划人员")
    @ApiOperation("新增营业计划人员")
    @PreAuthorize("@el.check('businessPlanPersonnel:add')")
    public ResponseEntity<Object> createBusinessPlanPersonnel(@Validated @RequestBody BusinessPlanPersonnel resources){
        return new ResponseEntity<>(businessPlanPersonnelService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改营业计划人员")
    @ApiOperation("修改营业计划人员")
    @PreAuthorize("@el.check('businessPlanPersonnel:edit')")
    public ResponseEntity<Object> updateBusinessPlanPersonnel(@Validated @RequestBody BusinessPlanPersonnel resources){
        businessPlanPersonnelService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除营业计划人员")
    @ApiOperation("删除营业计划人员")
    @PreAuthorize("@el.check('businessPlanPersonnel:del')")
    public ResponseEntity<Object> deleteBusinessPlanPersonnel(@RequestBody Long[] ids) {
        businessPlanPersonnelService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessPlanPersonnelService.java
New file
@@ -0,0 +1,83 @@
/*
*  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.BusinessPlanPersonnel;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelDto;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelQueryCriteria;
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-12
**/
public interface BusinessPlanPersonnelService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(BusinessPlanPersonnelQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<BusinessPlanPersonnelDto>
    */
    List<BusinessPlanPersonnelDto> queryAll(BusinessPlanPersonnelQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return BusinessPlanPersonnelDto
     */
    BusinessPlanPersonnelDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return BusinessPlanPersonnelDto
    */
    BusinessPlanPersonnelDto create(BusinessPlanPersonnel resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(BusinessPlanPersonnel resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<BusinessPlanPersonnelDto> all, HttpServletResponse response) throws IOException;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessPlanService.java
New file
@@ -0,0 +1,83 @@
/*
*  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.BusinessPlan;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
import me.zhengjie.modules.business.service.dto.BusinessPlanQueryCriteria;
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-12
**/
public interface BusinessPlanService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(BusinessPlanQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<BusinessPlanDto>
    */
    List<BusinessPlanDto> queryAll(BusinessPlanQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return BusinessPlanDto
     */
    BusinessPlanDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return BusinessPlanDto
    */
    BusinessPlanDto create(BusinessPlanDto resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(BusinessPlanDto resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<BusinessPlanDto> all, HttpServletResponse response) throws IOException;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanDto.java
New file
@@ -0,0 +1,51 @@
/*
*  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.io.Serializable;
import java.util.List;
/**
* @website https://eladmin.vip
* @description /
* @author 赵士淞
* @date 2023-04-12
**/
@Data
public class BusinessPlanDto extends BaseDTO implements Serializable {
    /** ID */
    private Long id;
    /** 营业地 */
    private String businessPlace;
    /** 营业内容 */
    private String businessContent;
    /** 营业状态 */
    private String businessStatus;
    /** 备注 */
    private String remarks;
    /** 营业计划人员列表 */
    private List<BusinessPlanPersonnelDto> businessPlanPersonnelDtoList;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanPersonnelDto.java
New file
@@ -0,0 +1,56 @@
/*
*  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.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author 赵士淞
* @date 2023-04-12
**/
@Data
public class BusinessPlanPersonnelDto extends BaseDTO implements Serializable {
    /** ID */
    private Long id;
    /** 所属营业计划 */
    private Long businessPlanId;
    /** 所属营业计划内容 */
    private String businessPlanContent;
    /** 所属用户 */
    private Long userId;
    /** 所属用户昵称 */
    private String userNickName;
    /** 营业计划开始日期 */
    private Timestamp businessPlanStartDate;
    /** 营业计划结束日期 */
    private Timestamp businessPlanEndDate;
    /** 备注 */
    private String remarks;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanPersonnelQueryCriteria.java
New file
@@ -0,0 +1,37 @@
/*
*  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-12
**/
@Data
public class BusinessPlanPersonnelQueryCriteria{
    /** 精确 */
    @Query
    private Long businessPlanId;
    /** 精确 */
    @Query
    private Long userId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessPlanQueryCriteria.java
New file
@@ -0,0 +1,41 @@
/*
*  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-12
**/
@Data
public class BusinessPlanQueryCriteria{
    /** 模糊 */
    @Query(type = Query.Type.INNER_LIKE)
    private String businessPlace;
    /** 模糊 */
    @Query(type = Query.Type.INNER_LIKE)
    private String businessContent;
    /** 精确 */
    @Query
    private String businessStatus;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessPlanPersonnelServiceImpl.java
New file
@@ -0,0 +1,137 @@
/*
*  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.BusinessPlanPersonnel;
import me.zhengjie.modules.business.service.BusinessPlanService;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.business.repository.BusinessPlanPersonnelRepository;
import me.zhengjie.modules.business.service.BusinessPlanPersonnelService;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelDto;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelQueryCriteria;
import me.zhengjie.modules.business.service.mapstruct.BusinessPlanPersonnelMapper;
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-12
**/
@Service
@RequiredArgsConstructor
public class BusinessPlanPersonnelServiceImpl implements BusinessPlanPersonnelService {
    private final BusinessPlanPersonnelRepository businessPlanPersonnelRepository;
    private final BusinessPlanPersonnelMapper businessPlanPersonnelMapper;
    private final BusinessPlanService businessPlanService;
    private final UserService userService;
    @Override
    public Map<String,Object> queryAll(BusinessPlanPersonnelQueryCriteria criteria, Pageable pageable){
        Page<BusinessPlanPersonnel> page = businessPlanPersonnelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        // 将实体类转换为DTO(重写)
        Function<BusinessPlanPersonnel, BusinessPlanPersonnelDto> func = new Function<BusinessPlanPersonnel, BusinessPlanPersonnelDto>(){
            @Override
            public BusinessPlanPersonnelDto apply(BusinessPlanPersonnel t) {
                // 将实体类转换成DTO
                BusinessPlanPersonnelDto businessPlanPersonnelDto = businessPlanPersonnelMapper.toDto(t);
                // 获取营业计划
                BusinessPlanDto businessPlanDto = businessPlanService.findById(businessPlanPersonnelDto.getBusinessPlanId());
                businessPlanPersonnelDto.setBusinessPlanContent(businessPlanDto.getBusinessContent());
                // 获取用户
                UserDto userDto = userService.findById(businessPlanPersonnelDto.getUserId());
                businessPlanPersonnelDto.setUserNickName(userDto.getNickName());
                // 返回处理好的DTO
                return businessPlanPersonnelDto;
            }
        };
        return PageUtil.toPage(page.map(func));
    }
    @Override
    public List<BusinessPlanPersonnelDto> queryAll(BusinessPlanPersonnelQueryCriteria criteria){
        return businessPlanPersonnelMapper.toDto(businessPlanPersonnelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public BusinessPlanPersonnelDto findById(Long id) {
        BusinessPlanPersonnel businessPlanPersonnel = businessPlanPersonnelRepository.findById(id).orElseGet(BusinessPlanPersonnel::new);
        ValidationUtil.isNull(businessPlanPersonnel.getId(),"BusinessPlanPersonnel","id",id);
        return businessPlanPersonnelMapper.toDto(businessPlanPersonnel);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public BusinessPlanPersonnelDto create(BusinessPlanPersonnel resources) {
        return businessPlanPersonnelMapper.toDto(businessPlanPersonnelRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(BusinessPlanPersonnel resources) {
        BusinessPlanPersonnel businessPlanPersonnel = businessPlanPersonnelRepository.findById(resources.getId()).orElseGet(BusinessPlanPersonnel::new);
        ValidationUtil.isNull( businessPlanPersonnel.getId(),"BusinessPlanPersonnel","id",resources.getId());
        businessPlanPersonnel.copy(resources);
        businessPlanPersonnelRepository.save(businessPlanPersonnel);
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            businessPlanPersonnelRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<BusinessPlanPersonnelDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (BusinessPlanPersonnelDto businessPlanPersonnel : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("所属营业计划", businessPlanPersonnel.getBusinessPlanId());
            map.put("所属用户", businessPlanPersonnel.getUserId());
            map.put("营业计划开始日期", businessPlanPersonnel.getBusinessPlanStartDate());
            map.put("营业计划结束日期", businessPlanPersonnel.getBusinessPlanEndDate());
            map.put("备注", businessPlanPersonnel.getRemarks());
            map.put("创建者", businessPlanPersonnel.getCreateBy());
            map.put("创建时间", businessPlanPersonnel.getCreateTime());
            map.put("更新者", businessPlanPersonnel.getUpdateBy());
            map.put("更新时间", businessPlanPersonnel.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessPlanServiceImpl.java
New file
@@ -0,0 +1,168 @@
/*
*  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.BusinessPlan;
import me.zhengjie.modules.business.domain.BusinessPlanPersonnel;
import me.zhengjie.modules.business.repository.BusinessPlanPersonnelRepository;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelDto;
import me.zhengjie.modules.business.service.mapstruct.BusinessPlanPersonnelMapper;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.business.repository.BusinessPlanRepository;
import me.zhengjie.modules.business.service.BusinessPlanService;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
import me.zhengjie.modules.business.service.dto.BusinessPlanQueryCriteria;
import me.zhengjie.modules.business.service.mapstruct.BusinessPlanMapper;
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-12
**/
@Service
@RequiredArgsConstructor
public class BusinessPlanServiceImpl implements BusinessPlanService {
    private final BusinessPlanRepository businessPlanRepository;
    private final BusinessPlanMapper businessPlanMapper;
    private final BusinessPlanPersonnelRepository businessPlanPersonnelRepository;
    private final BusinessPlanPersonnelMapper businessPlanPersonnelMapper;
    private final UserService userService;
    @Override
    public Map<String,Object> queryAll(BusinessPlanQueryCriteria criteria, Pageable pageable){
        Page<BusinessPlan> page = businessPlanRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        // 将实体类转换为DTO(重写)
        Function<BusinessPlan, BusinessPlanDto> func = new Function<BusinessPlan, BusinessPlanDto>(){
            @Override
            public BusinessPlanDto apply(BusinessPlan t) {
                // 将实体类转换成DTO
                BusinessPlanDto businessPlanDto = businessPlanMapper.toDto(t);
                // 根据营业计划ID查询营业计划人员
                List<BusinessPlanPersonnelDto> businessPlanPersonnelDtoList = businessPlanPersonnelMapper.toDto(businessPlanPersonnelRepository.findByBusinessPlanId(businessPlanDto.getId()));
                // 循环营业计划人员
                for (BusinessPlanPersonnelDto businessPlanPersonnelDto : businessPlanPersonnelDtoList) {
                    // 获取用户
                    UserDto userDto = userService.findById(businessPlanPersonnelDto.getUserId());
                    businessPlanPersonnelDto.setUserNickName(userDto.getNickName());
                }
                // DTO
                businessPlanDto.setBusinessPlanPersonnelDtoList(businessPlanPersonnelDtoList);
                // 返回处理好的DTO
                return businessPlanDto;
            }
        };
        return PageUtil.toPage(page.map(func));
    }
    @Override
    public List<BusinessPlanDto> queryAll(BusinessPlanQueryCriteria criteria){
        return businessPlanMapper.toDto(businessPlanRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public BusinessPlanDto findById(Long id) {
        BusinessPlan businessPlan = businessPlanRepository.findById(id).orElseGet(BusinessPlan::new);
        ValidationUtil.isNull(businessPlan.getId(),"BusinessPlan","id",id);
        return businessPlanMapper.toDto(businessPlan);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public BusinessPlanDto create(BusinessPlanDto resources) {
        // 保存营业计划
        BusinessPlan businessPlan = businessPlanRepository.save(businessPlanMapper.toEntity(resources));
        // 保存相关营业计划人员
        saveBusinessPlanPersonnel(resources.getBusinessPlanPersonnelDtoList(), businessPlan.getId());
        return findById(businessPlan.getId());
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(BusinessPlanDto resources) {
        BusinessPlan businessPlan = businessPlanRepository.findById(resources.getId()).orElseGet(BusinessPlan::new);
        ValidationUtil.isNull( businessPlan.getId(),"BusinessPlan","id",resources.getId());
        businessPlan.copy(businessPlanMapper.toEntity(resources));
        businessPlanRepository.save(businessPlan);
        // 保存相关营业计划人员
        saveBusinessPlanPersonnel(resources.getBusinessPlanPersonnelDtoList(), businessPlan.getId());
    }
    /**
     * 保存相关营业计划人员
     * @param businessPlanPersonnelDtoList
     * @param businessPlanId
     */
    private void saveBusinessPlanPersonnel(List<BusinessPlanPersonnelDto> businessPlanPersonnelDtoList, Long businessPlanId) {
        // 根据营业计划ID删除营业计划人员
        businessPlanPersonnelRepository.deleteByBusinessPlanId(businessPlanId);
        // 营业计划人员列表
        List<BusinessPlanPersonnel> businessPlanPersonnelList = businessPlanPersonnelMapper.toEntity(businessPlanPersonnelDtoList);
        // 循环营业计划人员列表
        for (BusinessPlanPersonnel businessPlanPersonnel : businessPlanPersonnelList) {
            // 营业计划人员
            businessPlanPersonnel.setBusinessPlanId(businessPlanId);
            // 保存营业计划人员
            businessPlanPersonnelRepository.save(businessPlanPersonnel);
        }
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            businessPlanRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<BusinessPlanDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (BusinessPlanDto businessPlan : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("营业地", businessPlan.getBusinessPlace());
            map.put("营业内容", businessPlan.getBusinessContent());
            map.put("营业状态", businessPlan.getBusinessStatus());
            map.put("备注", businessPlan.getRemarks());
            map.put("创建者", businessPlan.getCreateBy());
            map.put("创建时间", businessPlan.getCreateTime());
            map.put("更新者", businessPlan.getUpdateBy());
            map.put("更新时间", businessPlan.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/mapstruct/BusinessPlanMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  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.BusinessPlan;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author 赵士淞
* @date 2023-04-12
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface BusinessPlanMapper extends BaseMapper<BusinessPlanDto, BusinessPlan> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/mapstruct/BusinessPlanPersonnelMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  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.BusinessPlanPersonnel;
import me.zhengjie.modules.business.service.dto.BusinessPlanPersonnelDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author 赵士淞
* @date 2023-04-12
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface BusinessPlanPersonnelMapper extends BaseMapper<BusinessPlanPersonnelDto, BusinessPlanPersonnel> {
}
eladmin-web-master/src/api/business/plan.js
New file
@@ -0,0 +1,35 @@
import request from '@/utils/request'
export function getAll(params) {
  return request({
    url: 'api/businessPlan/all',
    method: 'get',
    params
  })
}
export function add(data) {
  return request({
    url: 'api/businessPlan',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/businessPlan/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/businessPlan',
    method: 'put',
    data
  })
}
export default { getAll, add, edit, del }
eladmin-web-master/src/api/business/planPersonnel.js
New file
@@ -0,0 +1,35 @@
import request from '@/utils/request'
export function getAll(params) {
  return request({
    url: 'api/businessPlanPersonnel/all',
    method: 'get',
    params
  })
}
export function add(data) {
  return request({
    url: 'api/businessPlanPersonnel',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/businessPlanPersonnel/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/businessPlanPersonnel',
    method: 'put',
    data
  })
}
export default { getAll, add, edit, del }
eladmin-web-master/src/utils/constant.js
@@ -335,6 +335,9 @@
// 账户类型:恒臻
export const ACCOUNT_TYPE_HENGZHEN = 'account_type_hengzhen'
// 营业状态
export const BUSINESS_STATUS = 'business_status'
export default {
  ROLE_LEVEL_SUPER,
  ROLE_LEVEL_GENERAL,
@@ -486,5 +489,6 @@
  ACCOUNT_TYPE_QIYUAN,
  ACCOUNT_TYPE_YIHENG,
  ACCOUNT_TYPE_ZIXUN,
  ACCOUNT_TYPE_HENGZHEN
  ACCOUNT_TYPE_HENGZHEN,
  BUSINESS_STATUS
}
eladmin-web-master/src/views/business/plan/index.vue
New file
@@ -0,0 +1,321 @@
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="query.businessPlace" clearable placeholder="营业地" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-input v-model="query.businessContent" clearable placeholder="营业内容" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="query.businessStatus" filterable clearable placeholder="营业状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in dict[businessStatus]"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </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="80px">
          <el-form-item label="营业地" prop="businessPlace">
            <el-input v-model="form.businessPlace" style="width: 470px;" />
          </el-form-item>
          <el-form-item label="营业内容" prop="businessContent">
            <el-input v-model="form.businessContent" :rows="3" type="textarea" style="width: 470px;" />
          </el-form-item>
          <el-form-item label="营业状态" prop="businessStatus">
            <el-select v-model="form.businessStatus" filterable placeholder="请选择" style="width: 470px;">
              <el-option
                v-for="item in dict[businessStatus]"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-button size="mini" type="primary" icon="el-icon-plus" style="position: relative; left: 464px;" @click="personnelAdd()" />
          <el-table ref="table" :data="form.businessPlanPersonnelDtoList" size="small" style="width: 100%;">
            <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" />
            <el-table-column :show-overflow-tooltip="true" prop="businessPlanStartDate" label="营业计划开始日期">
              <template slot-scope="scope">
                {{ crud.toDate(scope.row.businessPlanStartDate) }}
              </template>
            </el-table-column>
            <el-table-column :show-overflow-tooltip="true" prop="businessPlanEndDate" label="营业计划结束日期">
              <template slot-scope="scope">
                {{ crud.toDate(scope.row.businessPlanEndDate) }}
              </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="personnelEdit(scope.row)" />
                <el-button size="mini" type="danger" icon="el-icon-delete" @click="personnelDelete(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: 470px;" />
          </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.businessPlanPersonnelDtoList" style="margin: 10px 20px 10px 105px; width: calc(100% - 20px - 105px);">
              <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" />
              <el-table-column :show-overflow-tooltip="true" prop="businessPlanStartDate" label="营业计划开始日期">
                <template slot-scope="scope">
                  {{ crud.toDate(scope.row.businessPlanStartDate) }}
                </template>
              </el-table-column>
              <el-table-column :show-overflow-tooltip="true" prop="businessPlanEndDate" label="营业计划结束日期">
                <template slot-scope="scope">
                  {{ crud.toDate(scope.row.businessPlanEndDate) }}
                </template>
              </el-table-column>
              <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
            </el-table>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="businessPlace" label="营业地" />
        <el-table-column :show-overflow-tooltip="true" prop="businessContent" label="营业内容" />
        <el-table-column :show-overflow-tooltip="true" prop="businessStatus" label="营业状态">
          <template slot-scope="scope">
            <el-tag>{{ dict.label[businessStatus][scope.row.businessStatus] }}</el-tag>
          </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','businessPlan:edit','businessPlan: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="personnelCancel" :visible.sync="personnelStatus" :title="personnelTitle" width="600px">
        <el-form ref="personnelForm" :model="personnelForm" :rules="personnelRules" size="small" label-width="140px">
          <el-form-item label="所属用户" prop="userId">
            <el-select v-model="personnelForm.userId" placeholder="请选择" filterable clearable style="width: 410px;" @change="personnelFormUserIdChange">
              <el-option
                v-for="item in userList"
                :key="item.id"
                :label="item.nickName"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="营业计划开始日期" prop="businessPlanStartDate">
            <el-date-picker v-model="personnelForm.businessPlanStartDate" type="date" style="width: 410px;" />
          </el-form-item>
          <el-form-item label="营业计划结束日期" prop="businessPlanEndDate">
            <el-date-picker v-model="personnelForm.businessPlanEndDate" type="date" style="width: 410px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="personnelForm.remarks" :rows="3" type="textarea" style="width: 410px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="personnelCancel">取消</el-button>
          <el-button :loading="personnelLoading" type="primary" @click="personnelSubmit('personnelForm')">确认</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import crudBusinessPlan from '@/api/business/plan'
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 crudUser from '@/api/system/user'
const defaultForm = { id: null, businessPlace: null, businessContent: null, businessStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, businessPlanPersonnelDtoList: [] }
export default {
  name: 'BusinessPlan',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: [constant.BUSINESS_STATUS],
  cruds() {
    return CRUD({ title: '营业计划', url: 'api/businessPlan', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessPlan }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'businessPlan:add'],
        edit: ['admin', 'businessPlan:edit'],
        del: ['admin', 'businessPlan:del'],
        download: ['admin', 'businessPlan:download']
      },
      rules: {
        businessPlace: [
          { required: true, message: '营业地不能为空', trigger: 'blur' },
          { min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
        ],
        businessContent: [
          { required: true, message: '营业内容不能为空', trigger: 'blur' }
        ],
        businessStatus: [
          { required: true, message: '营业状态不能为空', trigger: 'change' }
        ]
      },
      queryTypeOptions: [
        { key: 'businessPlace', display_name: '营业地' },
        { key: 'businessContent', display_name: '营业内容' },
        { key: 'businessStatus', display_name: '营业状态' }
      ],
      // 字典:营业状态
      businessStatus: constant.BUSINESS_STATUS,
      // 营业计划人员弹窗状态
      personnelStatus: false,
      // 营业计划人员弹窗标题
      personnelTitle: '营业计划人员',
      // 营业计划人员弹窗表单
      personnelForm: {},
      // 营业计划人员弹窗验证
      personnelRules: {
        businessPlanId: [
          { required: true, message: '所属营业计划不能为空', trigger: 'change' }
        ],
        userId: [
          { required: true, message: '所属用户不能为空', trigger: 'change' }
        ],
        businessPlanStartDate: [
          { required: true, message: '营业计划开始日期不能为空', trigger: 'change' }
        ],
        businessPlanEndDate: [
          { required: true, message: '营业计划结束日期不能为空', trigger: 'change' }
        ]
      },
      // 营业计划人员弹窗操作
      personnelExecute: {},
      // 营业计划人员弹窗加载
      personnelLoading: false,
      // 用户列表
      userList: []
    }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 获取用户
      this.getUser()
      return true
    },
    // 获取用户
    getUser() {
      // 获取用户
      crudUser.getAll().then(res => {
        // 用户列表
        this.userList = res
      })
    },
    // 营业计划人员弹窗用户ID变更
    personnelFormUserIdChange() {
      // 指针重定义
      const _this = this
      // 筛选用户列表
      const personnelInfo = this.userList.filter(function(item) {
        return item.id === _this.personnelForm.userId
      })
      // 营业计划人员弹窗表单
      this.personnelForm.userNickName = personnelInfo[0].nickName
    },
    // 营业计划人员弹窗新增
    personnelAdd() {
      // 指针重定义
      const _this = this
      // 营业计划人员弹窗表单
      this.personnelForm = {}
      // 营业计划人员弹窗状态
      this.personnelStatus = true
      // 营业计划人员弹窗操作
      this.personnelExecute = {}
      // 表单清空
      setTimeout(function() {
        _this.$refs['personnelForm'].clearValidate()
      }, 3)
    },
    // 营业计划人员弹窗修改
    personnelEdit(data) {
      // 营业计划人员弹窗表单
      this.personnelForm = JSON.parse(JSON.stringify(data))
      // 营业计划人员弹窗状态
      this.personnelStatus = true
      // 营业计划人员弹窗操作
      this.personnelExecute = JSON.parse(JSON.stringify(data))
    },
    // 营业计划人员弹窗删除
    personnelDelete(data) {
      // 指针重定义
      const _this = this
      // 筛选营业计划人员
      const personnelInfo = this.crud.form.businessPlanPersonnelDtoList.filter(function(item) {
        return item.userId === data.userId && _this.crud.toDate(item.businessPlanStartDate) === _this.crud.toDate(data.businessPlanStartDate) && _this.crud.toDate(item.businessPlanEndDate) === _this.crud.toDate(data.businessPlanEndDate)
      })
      // 获取下标
      const subscript = this.crud.form.businessPlanPersonnelDtoList.indexOf(personnelInfo[0])
      // 营业计划人员移除元素
      this.crud.form.businessPlanPersonnelDtoList.splice(subscript, 1)
    },
    // 营业计划人员弹窗关闭
    personnelCancel() {
      // 营业计划人员弹窗状态
      this.personnelStatus = false
    },
    // 营业计划人员弹窗提交
    personnelSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // 判断营业计划人员弹窗操作
          if (this.personnelExecute.userId !== undefined) {
            // 营业计划人员弹编辑
            // 指针重定义
            const _this = this
            // 筛选营业计划人员弹
            const personnelInfo = this.crud.form.businessPlanPersonnelDtoList.filter(function(item) {
              return item.userId === _this.personnelExecute.userId && _this.crud.toDate(item.businessPlanStartDate) === _this.crud.toDate(_this.personnelExecute.businessPlanStartDate) && _this.crud.toDate(item.businessPlanEndDate) === _this.crud.toDate(_this.personnelExecute.businessPlanEndDate)
            })
            // 营业计划人员弹更新
            personnelInfo[0].userId = this.personnelForm.userId
            personnelInfo[0].userNickName = this.personnelForm.userNickName
            personnelInfo[0].businessPlanStartDate = this.personnelForm.businessPlanStartDate
            personnelInfo[0].businessPlanEndDate = this.personnelForm.businessPlanEndDate
            personnelInfo[0].remarks = this.personnelForm.remarks
          } else {
            // 营业计划人员新增
            this.crud.form.businessPlanPersonnelDtoList.push(this.personnelForm)
          }
          // 营业计划人员弹窗关闭
          this.personnelCancel()
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style scoped>
</style>
eladmin-web-master/src/views/business/planPersonnel/index.vue
New file
@@ -0,0 +1,178 @@
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <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.userId" clearable placeholder="所属用户" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in userList"
            :key="item.id"
            :label="item.nickName"
            :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="140px">
          <el-form-item label="所属营业计划" prop="businessPlanId">
            <el-select v-model="form.businessPlanId" placeholder="请选择" filterable clearable style="width: 410px;">
              <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="所属用户" prop="userId">
            <el-select v-model="form.userId" placeholder="请选择" filterable clearable style="width: 410px;">
              <el-option
                v-for="item in userList"
                :key="item.id"
                :label="item.nickName"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="营业计划开始日期" prop="businessPlanStartDate">
            <el-date-picker v-model="form.businessPlanStartDate" type="date" style="width: 410px;" />
          </el-form-item>
          <el-form-item label="营业计划结束日期" prop="businessPlanEndDate">
            <el-date-picker v-model="form.businessPlanEndDate" type="date" style="width: 410px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 410px;" />
          </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 :show-overflow-tooltip="true" prop="businessPlanContent" label="所属营业计划" />
        <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" />
        <el-table-column :show-overflow-tooltip="true" prop="businessPlanStartDate" label="营业计划开始日期">
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.businessPlanStartDate) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="businessPlanEndDate" label="营业计划结束日期">
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.businessPlanEndDate) }}
          </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','businessPlanPersonnel:edit','businessPlanPersonnel: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 crudBusinessPlanPersonnel from '@/api/business/planPersonnel'
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 crudBusinessPlan from '@/api/business/plan'
import crudUser from '@/api/system/user'
const defaultForm = { id: null, businessPlanId: null, userId: null, businessPlanStartDate: null, businessPlanEndDate: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'BusinessPlanPersonnel',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '营业计划人员', url: 'api/businessPlanPersonnel', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessPlanPersonnel }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'businessPlanPersonnel:add'],
        edit: ['admin', 'businessPlanPersonnel:edit'],
        del: ['admin', 'businessPlanPersonnel:del'],
        download: ['admin', 'businessPlanPersonnel:download']
      },
      rules: {
        businessPlanId: [
          { required: true, message: '所属营业计划不能为空', trigger: 'change' }
        ],
        userId: [
          { required: true, message: '所属用户不能为空', trigger: 'change' }
        ],
        businessPlanStartDate: [
          { required: true, message: '营业计划开始日期不能为空', trigger: 'change' }
        ],
        businessPlanEndDate: [
          { required: true, message: '营业计划结束日期不能为空', trigger: 'change' }
        ]
      },
      queryTypeOptions: [
        { key: 'businessPlanId', display_name: '所属营业计划' },
        { key: 'userId', display_name: '所属用户' }
      ],
      // 营业计划列表
      businessPlanList: [],
      // 用户列表
      userList: []
    }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 获取营业计划
      this.getBusinessPlan()
      // 获取用户
      this.getUser()
      return true
    },
    // 获取营业计划
    getBusinessPlan() {
      // 获取营业计划
      crudBusinessPlan.getAll().then(res => {
        // 营业计划列表
        this.businessPlanList = res
      })
    },
    // 获取用户
    getUser() {
      // 获取用户
      crudUser.getAll().then(res => {
        // 用户列表
        this.userList = res
      })
    }
  }
}
</script>
<style scoped>
</style>