From 4156a5baafda2f44244eedcee842ef95bc2513ca Mon Sep 17 00:00:00 2001
From: 赵士淞 <zhaoss@yhzhg.cn>
Date: Mon, 26 Dec 2022 07:59:18 +0000
Subject: [PATCH] 用户级别保险
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelInsuranceRepository.java | 37 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelInsuranceServiceImpl.java | 239 +++++++++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysUserLevelInsuranceMapper.java | 32 +
eladmin-web-master/src/views/system/user/index.vue | 16
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysUserLevelInsuranceController.java | 95 +++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysUserLevelInsuranceService.java | 83 +++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysUserLevelInsurance.java | 163 ++++++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java | 63 ++
eladmin-web-master/src/api/system/userLevelInsurance.js | 35 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceQueryCriteria.java | 37 +
eladmin-web-master/src/views/system/userLevelInsurance/index.vue | 515 +++++++++++++++++++++
eladmin-web-master/src/views/system/userLevelWage/index.vue | 6
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceDto.java | 111 ++++
13 files changed, 1,429 insertions(+), 3 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysUserLevelInsurance.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysUserLevelInsurance.java
new file mode 100644
index 0000000..9aa00c3
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysUserLevelInsurance.java
@@ -0,0 +1,163 @@
+/*
+* 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.system.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 2022-12-26
+**/
+@Entity
+@Data
+@Table(name="sys_user_level_insurance")
+public class SysUserLevelInsurance extends BaseEntity implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "`id`")
+ @ApiModelProperty(value = "ID")
+ private Long id;
+
+ @Column(name = "`user_id`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "用户ID")
+ private Long userId;
+
+ @Column(name = "`level_id`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "级别ID")
+ private Long levelId;
+
+ @Column(name = "`start_date`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "开始日期")
+ private Timestamp startDate;
+
+ @Column(name = "`end_date`")
+ @ApiModelProperty(value = "结束日期")
+ private Timestamp endDate;
+
+ @Column(name = "`accumulation_radix`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "公积金基数")
+ private BigDecimal accumulationRadix;
+
+ @Column(name = "`accumulation_personal_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "公积金个人缴纳比例")
+ private Double accumulationPersonalProportion;
+
+ @Column(name = "`accumulation_company_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "公积金公司缴纳比例")
+ private Double accumulationCompanyProportion;
+
+ @Column(name = "`pension_radix`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "养老险基数")
+ private BigDecimal pensionRadix;
+
+ @Column(name = "`pension_personal_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "养老险个人缴纳比例")
+ private Double pensionPersonalProportion;
+
+ @Column(name = "`pension_company_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "养老险公司缴纳比例")
+ private Double pensionCompanyProportion;
+
+ @Column(name = "`medical_radix`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "医疗险基数")
+ private BigDecimal medicalRadix;
+
+ @Column(name = "`medical_personal_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "医疗险个人缴纳比例")
+ private Double medicalPersonalProportion;
+
+ @Column(name = "`medical_company_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "医疗险公司缴纳比例")
+ private Double medicalCompanyProportion;
+
+ @Column(name = "`unemployment_radix`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "失业险基数")
+ private BigDecimal unemploymentRadix;
+
+ @Column(name = "`unemployment_personal_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "失业险个人缴纳比例")
+ private Double unemploymentPersonalProportion;
+
+ @Column(name = "`unemployment_company_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "失业险公司缴纳比例")
+ private Double unemploymentCompanyProportion;
+
+ @Column(name = "`maternity_radix`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "生育险基数")
+ private BigDecimal maternityRadix;
+
+ @Column(name = "`maternity_personal_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "生育险个人缴纳比例")
+ private Double maternityPersonalProportion;
+
+ @Column(name = "`maternity_company_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "生育险公司缴纳比例")
+ private Double maternityCompanyProportion;
+
+ @Column(name = "`industrial_injury_radix`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "工伤险基数")
+ private BigDecimal industrialInjuryRadix;
+
+ @Column(name = "`industrial_injury_personal_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "工伤险个人缴纳比例")
+ private Double industrialInjuryPersonalProportion;
+
+ @Column(name = "`industrial_injury_company_proportion`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "工伤险公司缴纳比例")
+ private Double industrialInjuryCompanyProportion;
+
+ @Column(name = "`remarks`")
+ @ApiModelProperty(value = "备注")
+ private String remarks;
+
+ public void copy(SysUserLevelInsurance source){
+ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+ }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelInsuranceRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelInsuranceRepository.java
new file mode 100644
index 0000000..3e25b42
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelInsuranceRepository.java
@@ -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.system.repository;
+
+import me.zhengjie.modules.system.domain.SysUserLevelInsurance;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2022-12-26
+**/
+public interface SysUserLevelInsuranceRepository extends JpaRepository<SysUserLevelInsurance, Long>, JpaSpecificationExecutor<SysUserLevelInsurance> {
+
+ /**
+ * 根据用户ID查询最新记录
+ * @param userId /
+ * @return /
+ */
+ @Query(value = "SELECT * FROM sys_user_level_insurance WHERE user_id = ?1 ORDER BY start_date DESC, create_time DESC LIMIT 1", nativeQuery = true)
+ SysUserLevelInsurance findLastByUserId(Long userId);
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysUserLevelInsuranceController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysUserLevelInsuranceController.java
new file mode 100644
index 0000000..6da85e4
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysUserLevelInsuranceController.java
@@ -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.system.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.system.domain.SysUserLevelInsurance;
+import me.zhengjie.modules.system.service.SysUserLevelInsuranceService;
+import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceQueryCriteria;
+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 2022-12-26
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "用户级别保险管理")
+@RequestMapping("/api/sysUserLevelInsurance")
+public class SysUserLevelInsuranceController {
+
+ private final SysUserLevelInsuranceService sysUserLevelInsuranceService;
+
+ @Log("导出数据")
+ @ApiOperation("导出数据")
+ @GetMapping(value = "/download")
+ @PreAuthorize("@el.check('sysUserLevelInsurance:download')")
+ public void exportSysUserLevelInsurance(HttpServletResponse response, SysUserLevelInsuranceQueryCriteria criteria) throws IOException {
+ sysUserLevelInsuranceService.download(sysUserLevelInsuranceService.queryAll(criteria), response);
+ }
+
+ @GetMapping
+ @Log("查询用户级别保险")
+ @ApiOperation("查询用户级别保险")
+ @PreAuthorize("@el.check('sysUserLevelInsurance:list')")
+ public ResponseEntity<Object> querySysUserLevelInsurance(SysUserLevelInsuranceQueryCriteria criteria, Pageable pageable){
+ return new ResponseEntity<>(sysUserLevelInsuranceService.queryAll(criteria,pageable),HttpStatus.OK);
+ }
+
+ @GetMapping(value = "/all")
+ @Log("查询用户级别保险")
+ @ApiOperation("查询用户级别保险")
+ @PreAuthorize("@el.check('sysUserLevelInsurance:list')")
+ public ResponseEntity<Object> querySysUserLevelInsurance(SysUserLevelInsuranceQueryCriteria criteria){
+ return new ResponseEntity<>(sysUserLevelInsuranceService.queryAll(criteria),HttpStatus.OK);
+ }
+
+ @PostMapping
+ @Log("新增用户级别保险")
+ @ApiOperation("新增用户级别保险")
+ @PreAuthorize("@el.check('sysUserLevelInsurance:add')")
+ public ResponseEntity<Object> createSysUserLevelInsurance(@Validated @RequestBody SysUserLevelInsurance resources) throws Exception{
+ return new ResponseEntity<>(sysUserLevelInsuranceService.create(resources),HttpStatus.CREATED);
+ }
+
+ @PutMapping
+ @Log("修改用户级别保险")
+ @ApiOperation("修改用户级别保险")
+ @PreAuthorize("@el.check('sysUserLevelInsurance:edit')")
+ public ResponseEntity<Object> updateSysUserLevelInsurance(@Validated @RequestBody SysUserLevelInsurance resources) throws Exception{
+ sysUserLevelInsuranceService.update(resources);
+ return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+ }
+
+ @DeleteMapping
+ @Log("删除用户级别保险")
+ @ApiOperation("删除用户级别保险")
+ @PreAuthorize("@el.check('sysUserLevelInsurance:del')")
+ public ResponseEntity<Object> deleteSysUserLevelInsurance(@RequestBody Long[] ids) {
+ sysUserLevelInsuranceService.deleteAll(ids);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysUserLevelInsuranceService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysUserLevelInsuranceService.java
new file mode 100644
index 0000000..4bbbf8f
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysUserLevelInsuranceService.java
@@ -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.system.service;
+
+import me.zhengjie.modules.system.domain.SysUserLevelInsurance;
+import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceDto;
+import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceQueryCriteria;
+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 2022-12-26
+**/
+public interface SysUserLevelInsuranceService {
+
+ /**
+ * 查询数据分页
+ * @param criteria 条件
+ * @param pageable 分页参数
+ * @return Map<String,Object>
+ */
+ Map<String,Object> queryAll(SysUserLevelInsuranceQueryCriteria criteria, Pageable pageable);
+
+ /**
+ * 查询所有数据不分页
+ * @param criteria 条件参数
+ * @return List<SysUserLevelInsuranceDto>
+ */
+ List<SysUserLevelInsuranceDto> queryAll(SysUserLevelInsuranceQueryCriteria criteria);
+
+ /**
+ * 根据ID查询
+ * @param id ID
+ * @return SysUserLevelInsuranceDto
+ */
+ SysUserLevelInsuranceDto findById(Long id);
+
+ /**
+ * 创建
+ * @param resources /
+ * @return SysUserLevelInsuranceDto
+ */
+ SysUserLevelInsuranceDto create(SysUserLevelInsurance resources) throws Exception;
+
+ /**
+ * 编辑
+ * @param resources /
+ */
+ void update(SysUserLevelInsurance resources) throws Exception;
+
+ /**
+ * 多选删除
+ * @param ids /
+ */
+ void deleteAll(Long[] ids);
+
+ /**
+ * 导出数据
+ * @param all 待导出的数据
+ * @param response /
+ * @throws IOException /
+ */
+ void download(List<SysUserLevelInsuranceDto> all, HttpServletResponse response) throws IOException;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceDto.java
new file mode 100644
index 0000000..ed2731d
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceDto.java
@@ -0,0 +1,111 @@
+/*
+* 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.system.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 2022-12-26
+**/
+@Data
+public class SysUserLevelInsuranceDto extends BaseDTO implements Serializable {
+
+ /** ID */
+ private Long id;
+
+ /** 用户ID */
+ private Long userId;
+
+ /** 级别ID */
+ private Long levelId;
+
+ /** 开始日期 */
+ private Timestamp startDate;
+
+ /** 结束日期 */
+ private Timestamp endDate;
+
+ /** 公积金基数 */
+ private BigDecimal accumulationRadix;
+
+ /** 公积金个人缴纳比例 */
+ private Double accumulationPersonalProportion;
+
+ /** 公积金公司缴纳比例 */
+ private Double accumulationCompanyProportion;
+
+ /** 养老险基数 */
+ private BigDecimal pensionRadix;
+
+ /** 养老险个人缴纳比例 */
+ private Double pensionPersonalProportion;
+
+ /** 养老险公司缴纳比例 */
+ private Double pensionCompanyProportion;
+
+ /** 医疗险基数 */
+ private BigDecimal medicalRadix;
+
+ /** 医疗险个人缴纳比例 */
+ private Double medicalPersonalProportion;
+
+ /** 医疗险公司缴纳比例 */
+ private Double medicalCompanyProportion;
+
+ /** 失业险基数 */
+ private BigDecimal unemploymentRadix;
+
+ /** 失业险个人缴纳比例 */
+ private Double unemploymentPersonalProportion;
+
+ /** 失业险公司缴纳比例 */
+ private Double unemploymentCompanyProportion;
+
+ /** 生育险基数 */
+ private BigDecimal maternityRadix;
+
+ /** 生育险个人缴纳比例 */
+ private Double maternityPersonalProportion;
+
+ /** 生育险公司缴纳比例 */
+ private Double maternityCompanyProportion;
+
+ /** 工伤险基数 */
+ private BigDecimal industrialInjuryRadix;
+
+ /** 工伤险个人缴纳比例 */
+ private Double industrialInjuryPersonalProportion;
+
+ /** 工伤险公司缴纳比例 */
+ private Double industrialInjuryCompanyProportion;
+
+ /** 备注 */
+ private String remarks;
+
+ /** 用户昵称 */
+ private String userNickName;
+
+ /** 级别名称 */
+ private String levelName;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceQueryCriteria.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceQueryCriteria.java
new file mode 100644
index 0000000..c5f95a2
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysUserLevelInsuranceQueryCriteria.java
@@ -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.system.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2022-12-26
+**/
+@Data
+public class SysUserLevelInsuranceQueryCriteria{
+
+ /** 精确 */
+ @Query
+ private Long userId;
+
+ /** 精确 */
+ @Query
+ private Long levelId;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelInsuranceServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelInsuranceServiceImpl.java
new file mode 100644
index 0000000..adeca97
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelInsuranceServiceImpl.java
@@ -0,0 +1,239 @@
+/*
+* 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.system.service.impl;
+
+import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.modules.system.domain.SysLevel;
+import me.zhengjie.modules.system.domain.SysUserLevelInsurance;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.repository.SysLevelRepository;
+import me.zhengjie.modules.system.repository.UserRepository;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.system.repository.SysUserLevelInsuranceRepository;
+import me.zhengjie.modules.system.service.SysUserLevelInsuranceService;
+import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceDto;
+import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceQueryCriteria;
+import me.zhengjie.modules.system.service.mapstruct.SysUserLevelInsuranceMapper;
+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.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.function.Function;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author 赵士淞
+* @date 2022-12-26
+**/
+@Service
+@RequiredArgsConstructor
+public class SysUserLevelInsuranceServiceImpl implements SysUserLevelInsuranceService {
+
+ private final SysUserLevelInsuranceRepository sysUserLevelInsuranceRepository;
+ private final SysUserLevelInsuranceMapper sysUserLevelInsuranceMapper;
+ private final UserRepository userRepository;
+ private final SysLevelRepository sysLevelRepository;
+
+ @Override
+ public Map<String,Object> queryAll(SysUserLevelInsuranceQueryCriteria criteria, Pageable pageable){
+ Page<SysUserLevelInsurance> page = sysUserLevelInsuranceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+ // 将实体类转换为DTO(重写)
+ Function<SysUserLevelInsurance, SysUserLevelInsuranceDto> func = new Function<SysUserLevelInsurance, SysUserLevelInsuranceDto>(){
+ @Override
+ public SysUserLevelInsuranceDto apply(SysUserLevelInsurance t) {
+ // 将实体类转换成DTO
+ SysUserLevelInsuranceDto sysUserLevelInsuranceDto = sysUserLevelInsuranceMapper.toDto(t);
+ // 根据用户ID查询用户信息
+ User user = userRepository.findById(sysUserLevelInsuranceDto.getUserId()).orElseGet(User::new);
+ ValidationUtil.isNull(user.getId(),"User","id",sysUserLevelInsuranceDto.getUserId());
+ // 用户昵称
+ sysUserLevelInsuranceDto.setUserNickName(user.getNickName());
+ // 根据级别ID查询级别信息
+ SysLevel sysLevel = sysLevelRepository.findById(sysUserLevelInsuranceDto.getLevelId()).orElseGet(SysLevel::new);
+ ValidationUtil.isNull(sysLevel.getId(),"SysLevel","id",sysUserLevelInsuranceDto.getLevelId());
+ // 级别名称
+ sysUserLevelInsuranceDto.setLevelName(sysLevel.getName());
+ // 返回处理好的DTO
+ return sysUserLevelInsuranceDto;
+ }
+ };
+ return PageUtil.toPage(page.map(func));
+ }
+
+ @Override
+ public List<SysUserLevelInsuranceDto> queryAll(SysUserLevelInsuranceQueryCriteria criteria){
+ return sysUserLevelInsuranceMapper.toDto(sysUserLevelInsuranceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+ }
+
+ @Override
+ @Transactional
+ public SysUserLevelInsuranceDto findById(Long id) {
+ SysUserLevelInsurance sysUserLevelInsurance = sysUserLevelInsuranceRepository.findById(id).orElseGet(SysUserLevelInsurance::new);
+ ValidationUtil.isNull(sysUserLevelInsurance.getId(),"SysUserLevelInsurance","id",id);
+ return sysUserLevelInsuranceMapper.toDto(sysUserLevelInsurance);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public SysUserLevelInsuranceDto create(SysUserLevelInsurance resources) throws Exception {
+ // 查询旧用户级别保险
+ SysUserLevelInsurance oldSysUserLevelInsurance = selectOldUserLevelInsurance(resources.getUserId());
+ // 判断旧用户级别保险是否为空
+ if (oldSysUserLevelInsurance != null) {
+ // 旧日期字符串
+ String oldDateString = oldSysUserLevelInsurance.getStartDate().toString().substring(0,10);
+ // 新日期字符串
+ String newDateString = resources.getStartDate().toString().substring(0,10);
+ // 判断新、旧日期字符串
+ if (oldDateString.equals(newDateString)) {
+ throw new BadRequestException("每天只能调整一次用户级别保险,请更换日期再试!");
+ }
+ if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(newDateString).getTime()) {
+ throw new BadRequestException("日期必须大于最新用户级别保险日期,请更换日期再试!");
+ }
+ // 创建Calendar实例
+ Calendar previousCalendar = Calendar.getInstance();
+ // 设置新日期时间
+ previousCalendar.setTime(resources.getStartDate());
+ // 设置前一天时间
+ previousCalendar.add(Calendar.DATE, -1);
+ // 旧用户级别保险
+ oldSysUserLevelInsurance.setEndDate(new Timestamp(previousCalendar.getTime().getTime()));
+ // 保存
+ sysUserLevelInsuranceRepository.save(oldSysUserLevelInsurance);
+ }
+ // 保存
+ return sysUserLevelInsuranceMapper.toDto(sysUserLevelInsuranceRepository.save(resources));
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(SysUserLevelInsurance resources) throws Exception {
+ // 查询旧用户级别保险
+ SysUserLevelInsurance oldSysUserLevelInsurance = selectOldUserLevelInsurance(resources.getUserId());
+ // 判断旧用户级别保险是否为空
+ if (oldSysUserLevelInsurance != null) {
+ // 判断修改的是否是最新履历
+ if (oldSysUserLevelInsurance.getId() != resources.getId()) {
+ throw new BadRequestException("旧用户级别保险无法进行修改,请选择最新用户级别保险再试!");
+ }
+ // 旧日期字符串
+ String oldDateString = oldSysUserLevelInsurance.getStartDate().toString().substring(0,10);
+ // 获取当前日期
+ Date nowDate = new Date();
+ // 创建Calendar实例
+ Calendar nowCalendar = Calendar.getInstance();
+ // 设置当前时间
+ nowCalendar.setTime(nowDate);
+ // 新日期字符串
+ String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10);
+ // 判断新、旧日期字符串
+ if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(nowDateString).getTime()) {
+ // 复制
+ oldSysUserLevelInsurance.copy(resources);
+ // 保存
+ sysUserLevelInsuranceRepository.save(oldSysUserLevelInsurance);
+ } else {
+ // 新用户级别保险
+ resources.setId(null);
+ resources.setStartDate(new Timestamp(nowCalendar.getTime().getTime()));
+ // 保存
+ sysUserLevelInsuranceRepository.save(resources);
+ // 设置前一天时间
+ nowCalendar.add(Calendar.DATE, -1);
+ // 旧用户级别保险
+ oldSysUserLevelInsurance.setEndDate(new Timestamp(nowCalendar.getTime().getTime()));
+ // 保存
+ sysUserLevelInsuranceRepository.save(oldSysUserLevelInsurance);
+ }
+ } else {
+ throw new BadRequestException("未找到最新用户级别保险,请稍后再试!");
+ }
+ }
+
+ @Override
+ public void deleteAll(Long[] ids) {
+ for (Long id : ids) {
+ sysUserLevelInsuranceRepository.deleteById(id);
+ }
+ }
+
+ @Override
+ public void download(List<SysUserLevelInsuranceDto> all, HttpServletResponse response) throws IOException {
+ List<Map<String, Object>> list = new ArrayList<>();
+ for (SysUserLevelInsuranceDto sysUserLevelInsurance : all) {
+ String nickName = sysUserLevelInsurance.getUserId() != null ? userRepository.findById(sysUserLevelInsurance.getUserId()).orElseGet(User::new).getNickName() : "";
+ String levelName = sysUserLevelInsurance.getLevelId() != null ? sysLevelRepository.findById(sysUserLevelInsurance.getLevelId()).orElseGet(SysLevel::new).getName() : "";
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("用户昵称", nickName);
+ map.put("级别名称", levelName);
+ map.put("开始日期", sysUserLevelInsurance.getStartDate());
+ map.put("结束日期", sysUserLevelInsurance.getEndDate());
+ map.put("公积金基数", sysUserLevelInsurance.getAccumulationRadix());
+ map.put("公积金个人缴纳比例", sysUserLevelInsurance.getAccumulationPersonalProportion());
+ map.put("公积金公司缴纳比例", sysUserLevelInsurance.getAccumulationCompanyProportion());
+ map.put("养老险基数", sysUserLevelInsurance.getPensionRadix());
+ map.put("养老险个人缴纳比例", sysUserLevelInsurance.getPensionPersonalProportion());
+ map.put("养老险公司缴纳比例", sysUserLevelInsurance.getPensionCompanyProportion());
+ map.put("医疗险基数", sysUserLevelInsurance.getMedicalRadix());
+ map.put("医疗险个人缴纳比例", sysUserLevelInsurance.getMedicalPersonalProportion());
+ map.put("医疗险公司缴纳比例", sysUserLevelInsurance.getMedicalCompanyProportion());
+ map.put("失业险基数", sysUserLevelInsurance.getUnemploymentRadix());
+ map.put("失业险个人缴纳比例", sysUserLevelInsurance.getUnemploymentPersonalProportion());
+ map.put("失业险公司缴纳比例", sysUserLevelInsurance.getUnemploymentCompanyProportion());
+ map.put("生育险基数", sysUserLevelInsurance.getMaternityRadix());
+ map.put("生育险个人缴纳比例", sysUserLevelInsurance.getMaternityPersonalProportion());
+ map.put("生育险公司缴纳比例", sysUserLevelInsurance.getMaternityCompanyProportion());
+ map.put("工伤险基数", sysUserLevelInsurance.getIndustrialInjuryRadix());
+ map.put("工伤险个人缴纳比例", sysUserLevelInsurance.getIndustrialInjuryPersonalProportion());
+ map.put("工伤险公司缴纳比例", sysUserLevelInsurance.getIndustrialInjuryCompanyProportion());
+ map.put("备注", sysUserLevelInsurance.getRemarks());
+ map.put("创建者", sysUserLevelInsurance.getCreateBy());
+ map.put("创建时间", sysUserLevelInsurance.getCreateTime());
+ map.put("更新者", sysUserLevelInsurance.getUpdateBy());
+ map.put("更新时间", sysUserLevelInsurance.getUpdateTime());
+ list.add(map);
+ }
+ FileUtil.downloadExcel(list, response);
+ }
+
+ /**
+ * 查询旧用户级别保险
+ * @param userId
+ * @return
+ */
+ private SysUserLevelInsurance selectOldUserLevelInsurance(Long userId) {
+ // 旧用户级别保险
+ SysUserLevelInsurance oldSysUserLevelInsurance = sysUserLevelInsuranceRepository.findLastByUserId(userId);
+ // 判断旧用户级别保险是否为空
+ if (oldSysUserLevelInsurance != null && oldSysUserLevelInsurance.getId() != null) {
+ return oldSysUserLevelInsurance;
+ } else {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
index 222f801..0cbec2d 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -21,11 +21,13 @@
import me.zhengjie.modules.security.service.OnlineUserService;
import me.zhengjie.modules.security.service.UserCacheManager;
import me.zhengjie.modules.system.domain.SysLevel;
+import me.zhengjie.modules.system.domain.SysUserLevelInsurance;
import me.zhengjie.modules.system.domain.SysUserLevelWage;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.EntityExistException;
import me.zhengjie.exception.EntityNotFoundException;
import me.zhengjie.modules.system.repository.SysLevelRepository;
+import me.zhengjie.modules.system.repository.SysUserLevelInsuranceRepository;
import me.zhengjie.modules.system.repository.SysUserLevelWageRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.system.service.UserService;
@@ -67,6 +69,7 @@
private final UserLoginMapper userLoginMapper;
private final SysLevelRepository sysLevelRepository;
private final SysUserLevelWageRepository sysUserLevelWageRepository;
+ private final SysUserLevelInsuranceRepository sysUserLevelInsuranceRepository;
@Override
public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
@@ -314,6 +317,8 @@
if (oldLevelId == null) {
// 创建用户级别工资
createSysUserLevelWage(userId, newLevelId);
+ // 创建用户级别保险
+ createSysUserLevelInsurance(userId, newLevelId);
} else if (oldLevelId != newLevelId) {
// 旧用户级别工资
SysUserLevelWage oldSysUserLevelWage = sysUserLevelWageRepository.findLastByUserId(userId);
@@ -342,6 +347,33 @@
}
// 创建用户级别工资
createSysUserLevelWage(userId, newLevelId);
+ // 旧用户级别保险
+ SysUserLevelInsurance oldSysUserLevelInsurance = sysUserLevelInsuranceRepository.findLastByUserId(userId);
+ // 判断旧用户级别保险是否为空
+ if (oldSysUserLevelInsurance != null && oldSysUserLevelInsurance.getId() != null) {
+ // 旧日期字符串
+ String oldDateString = oldSysUserLevelInsurance.getStartDate().toString().substring(0,10);
+ // 获取当前日期
+ Date nowDate = new Date();
+ // 创建Calendar实例
+ Calendar nowCalendar = Calendar.getInstance();
+ // 设置当前时间
+ nowCalendar.setTime(nowDate);
+ // 新日期字符串
+ String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10);
+ // 判断新、旧日期字符串
+ if (oldDateString.equals(nowDateString)) {
+ throw new BadRequestException("每天只能调整一次级别,请明日再试!");
+ }
+ // 设置前一天时间
+ nowCalendar.add(Calendar.DATE, -1);
+ // 旧用户级别保险
+ oldSysUserLevelInsurance.setEndDate(new Timestamp(nowCalendar.getTime().getTime()));
+ // 保存
+ sysUserLevelInsuranceRepository.save(oldSysUserLevelInsurance);
+ }
+ // 创建用户级别保险
+ createSysUserLevelInsurance(userId, newLevelId);
} else {
}
@@ -368,4 +400,35 @@
// 保存
sysUserLevelWageRepository.save(sysUserLevelWage);
}
+
+ // 创建用户级别保险
+ private void createSysUserLevelInsurance(Long userId, Long levelId) {
+ // 级别
+ SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new);
+ // 用户级别工资
+ SysUserLevelInsurance sysUserLevelInsurance = new SysUserLevelInsurance();
+ sysUserLevelInsurance.setUserId(userId);
+ sysUserLevelInsurance.setLevelId(levelId);
+ sysUserLevelInsurance.setStartDate(new Timestamp(new Date().getTime()));
+ sysUserLevelInsurance.setAccumulationRadix(sysLevel.getAccumulationRadix());
+ sysUserLevelInsurance.setAccumulationPersonalProportion(sysLevel.getAccumulationPersonalProportion());
+ sysUserLevelInsurance.setAccumulationCompanyProportion(sysLevel.getAccumulationCompanyProportion());
+ sysUserLevelInsurance.setPensionRadix(sysLevel.getPensionRadix());
+ sysUserLevelInsurance.setPensionPersonalProportion(sysLevel.getPensionPersonalProportion());
+ sysUserLevelInsurance.setPensionCompanyProportion(sysLevel.getPensionCompanyProportion());
+ sysUserLevelInsurance.setMedicalRadix(sysLevel.getMedicalRadix());
+ sysUserLevelInsurance.setMedicalPersonalProportion(sysLevel.getMedicalPersonalProportion());
+ sysUserLevelInsurance.setMedicalCompanyProportion(sysLevel.getMedicalCompanyProportion());
+ sysUserLevelInsurance.setUnemploymentRadix(sysLevel.getUnemploymentRadix());
+ sysUserLevelInsurance.setUnemploymentPersonalProportion(sysLevel.getUnemploymentPersonalProportion());
+ sysUserLevelInsurance.setUnemploymentCompanyProportion(sysLevel.getUnemploymentCompanyProportion());
+ sysUserLevelInsurance.setMaternityRadix(sysLevel.getMaternityRadix());
+ sysUserLevelInsurance.setMaternityPersonalProportion(sysLevel.getMaternityPersonalProportion());
+ sysUserLevelInsurance.setMaternityCompanyProportion(sysLevel.getMaternityCompanyProportion());
+ sysUserLevelInsurance.setIndustrialInjuryRadix(sysLevel.getIndustrialInjuryRadix());
+ sysUserLevelInsurance.setIndustrialInjuryPersonalProportion(sysLevel.getIndustrialInjuryPersonalProportion());
+ sysUserLevelInsurance.setIndustrialInjuryCompanyProportion(sysLevel.getIndustrialInjuryCompanyProportion());
+ // 保存
+ sysUserLevelInsuranceRepository.save(sysUserLevelInsurance);
+ }
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysUserLevelInsuranceMapper.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysUserLevelInsuranceMapper.java
new file mode 100644
index 0000000..deba7c7
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysUserLevelInsuranceMapper.java
@@ -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.system.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.system.domain.SysUserLevelInsurance;
+import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2022-12-26
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface SysUserLevelInsuranceMapper extends BaseMapper<SysUserLevelInsuranceDto, SysUserLevelInsurance> {
+
+}
\ No newline at end of file
diff --git a/eladmin-web-master/src/api/system/userLevelInsurance.js b/eladmin-web-master/src/api/system/userLevelInsurance.js
new file mode 100644
index 0000000..f3e728f
--- /dev/null
+++ b/eladmin-web-master/src/api/system/userLevelInsurance.js
@@ -0,0 +1,35 @@
+import request from '@/utils/request'
+
+export function getAll(params) {
+ return request({
+ url: 'api/sysUserLevelInsurance/all',
+ method: 'get',
+ params
+ })
+}
+
+export function add(data) {
+ return request({
+ url: 'api/sysUserLevelInsurance',
+ method: 'post',
+ data
+ })
+}
+
+export function del(ids) {
+ return request({
+ url: 'api/sysUserLevelInsurance/',
+ method: 'delete',
+ data: ids
+ })
+}
+
+export function edit(data) {
+ return request({
+ url: 'api/sysUserLevelInsurance',
+ method: 'put',
+ data
+ })
+}
+
+export default { getAll, add, edit, del }
diff --git a/eladmin-web-master/src/views/system/user/index.vue b/eladmin-web-master/src/views/system/user/index.vue
index b0cadac..c29050b 100644
--- a/eladmin-web-master/src/views/system/user/index.vue
+++ b/eladmin-web-master/src/views/system/user/index.vue
@@ -68,6 +68,17 @@
>
用户级别工资
</el-button>
+ <el-button
+ slot="right"
+ class="filter-item"
+ size="mini"
+ type="info"
+ icon="el-icon-view"
+ style="margin-left: 4px !important;"
+ @click="toLevelInsurance"
+ >
+ 用户级别保险
+ </el-button>
</crudOperation>
</div>
<!--表单渲染-->
@@ -586,6 +597,11 @@
toLevelWage() {
// 跳转页面
this.$router.push({ path: '/system/sysUserLevelWage' })
+ },
+ // 去用户级别保险
+ toLevelInsurance() {
+ // 跳转页面
+ this.$router.push({ path: '/system/sysUserLevelInsurance' })
}
}
}
diff --git a/eladmin-web-master/src/views/system/userLevelInsurance/index.vue b/eladmin-web-master/src/views/system/userLevelInsurance/index.vue
new file mode 100644
index 0000000..8037f71
--- /dev/null
+++ b/eladmin-web-master/src/views/system/userLevelInsurance/index.vue
@@ -0,0 +1,515 @@
+<template>
+ <div class="app-container">
+ <!--工具栏-->
+ <div class="head-container">
+ <div v-if="crud.props.searchToggle">
+ <!-- 搜索 -->
+ <el-select v-model="query.userId" filterable clearable placeholder="所属用户" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+ <el-option
+ v-for="item in users"
+ :key="item.id"
+ :label="item.nickName"
+ :value="item.id"
+ />
+ </el-select>
+ <el-select v-model="query.levelId" filterable clearable placeholder="所属级别" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+ <el-option
+ v-for="item in levels"
+ :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="500px">
+ <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
+ <el-form-item label="所属用户" prop="userId">
+ <el-select v-model="form.userId" filterable clearable placeholder="所属用户" style="width: 340px;">
+ <el-option
+ v-for="item in users"
+ :key="item.id"
+ :label="item.nickName"
+ :value="item.id"
+ :disabled="!item.enabled"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="所属级别" prop="levelId">
+ <el-select v-model="form.levelId" filterable clearable placeholder="所属级别" style="width: 340px;" @change="levelChange">
+ <el-option
+ v-for="item in levels"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="开始日期" prop="startDate">
+ <el-date-picker v-model="form.startDate" type="date" :picker-options="startDatePickerOptions" :disabled="crud.status.edit == crudStatusPrepared" style="width: 340px;" />
+ </el-form-item>
+ <el-form-item label="结束日期">
+ <el-date-picker v-model="form.endDate" type="date" :picker-options="endDatePickerOptions" style="width: 340px;" />
+ </el-form-item>
+ <el-divider>公积金</el-divider>
+ <el-form-item label="基数" prop="accumulationRadix">
+ <money-input :key="random" v-model="form.accumulationRadix" :width="340" />
+ </el-form-item>
+ <el-form-item label="个人缴纳比例" prop="accumulationPersonalProportion">
+ <el-input v-model="form.accumulationPersonalProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="公司缴纳比例" prop="accumulationCompanyProportion">
+ <el-input v-model="form.accumulationCompanyProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-divider>养老险</el-divider>
+ <el-form-item label="基数" prop="pensionRadix">
+ <money-input :key="random" v-model="form.pensionRadix" :width="340" />
+ </el-form-item>
+ <el-form-item label="个人缴纳比例" prop="pensionPersonalProportion">
+ <el-input v-model="form.pensionPersonalProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="公司缴纳比例" prop="pensionCompanyProportion">
+ <el-input v-model="form.pensionCompanyProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-divider>医疗险</el-divider>
+ <el-form-item label="基数" prop="medicalRadix">
+ <money-input :key="random" v-model="form.medicalRadix" :width="340" />
+ </el-form-item>
+ <el-form-item label="个人缴纳比例" prop="medicalPersonalProportion">
+ <el-input v-model="form.medicalPersonalProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="公司缴纳比例" prop="medicalCompanyProportion">
+ <el-input v-model="form.medicalCompanyProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-divider>失业险</el-divider>
+ <el-form-item label="基数" prop="unemploymentRadix">
+ <money-input :key="random" v-model="form.unemploymentRadix" :width="340" />
+ </el-form-item>
+ <el-form-item label="个人缴纳比例" prop="unemploymentPersonalProportion">
+ <el-input v-model="form.unemploymentPersonalProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="公司缴纳比例" prop="unemploymentCompanyProportion">
+ <el-input v-model="form.unemploymentCompanyProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-divider>生育险</el-divider>
+ <el-form-item label="基数" prop="maternityRadix">
+ <money-input :key="random" v-model="form.maternityRadix" :width="340" />
+ </el-form-item>
+ <el-form-item label="个人缴纳比例" prop="maternityPersonalProportion">
+ <el-input v-model="form.maternityPersonalProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="公司缴纳比例" prop="maternityCompanyProportion">
+ <el-input v-model="form.maternityCompanyProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-divider>工伤险</el-divider>
+ <el-form-item label="基数" prop="industrialInjuryRadix">
+ <money-input :key="random" v-model="form.industrialInjuryRadix" :width="340" />
+ </el-form-item>
+ <el-form-item label="个人缴纳比例" prop="industrialInjuryPersonalProportion">
+ <el-input v-model="form.industrialInjuryPersonalProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </el-form-item>
+ <el-form-item label="公司缴纳比例" prop="industrialInjuryCompanyProportion">
+ <el-input v-model="form.industrialInjuryCompanyProportion" style="width: 340px;">
+ <template slot="append">%</template>
+ </el-input>
+ </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="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="userNickName" label="所属用户" fixed="left" width="100">
+ <template slot-scope="scope">
+ <el-tag>{{ scope.row.userNickName }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="levelName" label="所属级别" fixed="left" width="100">
+ <template slot-scope="scope">
+ <el-tag>{{ scope.row.levelName }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="startDate" label="开始日期" width="100">
+ <template slot-scope="scope">
+ {{ crud.toDate(scope.row.startDate) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="endDate" label="结束日期" width="100">
+ <template slot-scope="scope">
+ {{ crud.toDate(scope.row.endDate) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="公积金">
+ <el-table-column :show-overflow-tooltip="true" prop="accumulationRadix" label="基数" width="100">
+ <template slot-scope="scope">
+ {{ crud.toMoney(scope.row.accumulationRadix) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="accumulationPersonalProportion" label="个人缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.accumulationPersonalProportion }}%
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="accumulationCompanyProportion" label="公司缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.accumulationCompanyProportion }}%
+ </template>
+ </el-table-column>
+ </el-table-column>
+ <el-table-column label="养老险">
+ <el-table-column :show-overflow-tooltip="true" prop="pensionRadix" label="基数" width="100">
+ <template slot-scope="scope">
+ {{ crud.toMoney(scope.row.pensionRadix) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="pensionPersonalProportion" label="个人缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.pensionPersonalProportion }}%
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="pensionCompanyProportion" label="公司缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.pensionCompanyProportion }}%
+ </template>
+ </el-table-column>
+ </el-table-column>
+ <el-table-column label="医疗险">
+ <el-table-column :show-overflow-tooltip="true" prop="medicalRadix" label="基数" width="100">
+ <template slot-scope="scope">
+ {{ crud.toMoney(scope.row.medicalRadix) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="medicalPersonalProportion" label="个人缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.medicalPersonalProportion }}%
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="medicalCompanyProportion" label="公司缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.medicalCompanyProportion }}%
+ </template>
+ </el-table-column>
+ </el-table-column>
+ <el-table-column label="失业险">
+ <el-table-column :show-overflow-tooltip="true" prop="unemploymentRadix" label="基数" width="100">
+ <template slot-scope="scope">
+ {{ crud.toMoney(scope.row.unemploymentRadix) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="unemploymentPersonalProportion" label="个人缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.unemploymentPersonalProportion }}%
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="unemploymentCompanyProportion" label="公司缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.unemploymentCompanyProportion }}%
+ </template>
+ </el-table-column>
+ </el-table-column>
+ <el-table-column label="生育险">
+ <el-table-column :show-overflow-tooltip="true" prop="maternityRadix" label="基数" width="100">
+ <template slot-scope="scope">
+ {{ crud.toMoney(scope.row.maternityRadix) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="maternityPersonalProportion" label="个人缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.maternityPersonalProportion }}%
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="maternityCompanyProportion" label="公司缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.maternityCompanyProportion }}%
+ </template>
+ </el-table-column>
+ </el-table-column>
+ <el-table-column label="工伤险">
+ <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryRadix" label="基数" width="100">
+ <template slot-scope="scope">
+ {{ crud.toMoney(scope.row.industrialInjuryRadix) }}
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryPersonalProportion" label="个人缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.industrialInjuryPersonalProportion }}%
+ </template>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryCompanyProportion" label="公司缴纳比例" width="100">
+ <template slot-scope="scope">
+ {{ scope.row.industrialInjuryCompanyProportion }}%
+ </template>
+ </el-table-column>
+ </el-table-column>
+ <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" />
+ <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" />
+ <el-table-column v-if="checkPer(['admin','sysUserLevelInsurance:edit','sysUserLevelInsurance:del'])" label="操作" width="150px" align="center" fixed="right">
+ <template slot-scope="scope">
+ <udOperation
+ :data="scope.row"
+ :permission="permission"
+ />
+ </template>
+ </el-table-column>
+ </el-table>
+ <!--分页组件-->
+ <pagination />
+ </div>
+ </div>
+</template>
+
+<script>
+import crudSysUserLevelInsurance from '@/api/system/userLevelInsurance'
+import CRUD, { presenter, header, form, crud } from '@crud/crud'
+import rrOperation from '@crud/RR.operation'
+import crudOperation from '@crud/CRUD.operation'
+import udOperation from '@crud/UD.operation'
+import pagination from '@crud/Pagination'
+import moneyInput from '../../assembly/moneyInput/index.vue'
+import crudUser from '@/api/system/user'
+import crudLevel from '@/api/system/level'
+
+const defaultForm = { id: null, userId: null, levelId: null, startDate: null, endDate: null, accumulationRadix: null, accumulationPersonalProportion: null, accumulationCompanyProportion: null, pensionRadix: null, pensionPersonalProportion: null, pensionCompanyProportion: null, medicalRadix: null, medicalPersonalProportion: null, medicalCompanyProportion: null, unemploymentRadix: null, unemploymentPersonalProportion: null, unemploymentCompanyProportion: null, maternityRadix: null, maternityPersonalProportion: null, maternityCompanyProportion: null, industrialInjuryRadix: null, industrialInjuryPersonalProportion: null, industrialInjuryCompanyProportion: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+export default {
+ name: 'SysUserLevelInsurance',
+ components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
+ mixins: [presenter(), header(), form(defaultForm), crud()],
+ cruds() {
+ return CRUD({ title: '用户级别保险', url: 'api/sysUserLevelInsurance', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSysUserLevelInsurance }})
+ },
+ data() {
+ // 指针重指向
+ const _this = this
+ // 工资(千万内)验证
+ var wageValidate = (rule, value, callback) => {
+ if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 10000000)) {
+ callback(new Error('请输入 一千万 以内的正整数或两位小数'))
+ } else {
+ callback()
+ }
+ }
+ // 比例(百内)验证
+ var proportionValidate = (rule, value, callback) => {
+ const reg = /^([0-9]|[1-9]\d)(\.\d{1,2})?$|100$/
+ if (value != null && value !== '' && !reg.test(value)) {
+ callback(new Error('请输入 一百 以内的正整数或两位小数'))
+ } else {
+ callback()
+ }
+ }
+ return {
+ permission: {
+ add: ['admin', 'sysUserLevelInsurance:add'],
+ edit: ['admin', 'sysUserLevelInsurance:edit'],
+ del: ['admin', 'sysUserLevelInsurance:del'],
+ download: ['admin', 'sysUserLevelInsurance:download']
+ },
+ rules: {
+ userId: [
+ { required: true, message: '所属用户不能为空', trigger: 'change' }
+ ],
+ levelId: [
+ { required: true, message: '所属级别不能为空', trigger: 'change' }
+ ],
+ startDate: [
+ { required: true, message: '开始日期不能为空', trigger: 'change' }
+ ],
+ accumulationRadix: [
+ { required: true, message: '公积金基数不能为空', trigger: 'blur' },
+ { validator: wageValidate, trigger: 'blur' }
+ ],
+ accumulationPersonalProportion: [
+ { required: true, message: '公积金个人缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ accumulationCompanyProportion: [
+ { required: true, message: '公积金公司缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ pensionRadix: [
+ { required: true, message: '养老险基数不能为空', trigger: 'blur' },
+ { validator: wageValidate, trigger: 'blur' }
+ ],
+ pensionPersonalProportion: [
+ { required: true, message: '养老险个人缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ pensionCompanyProportion: [
+ { required: true, message: '养老险公司缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ medicalRadix: [
+ { required: true, message: '医疗险基数不能为空', trigger: 'blur' },
+ { validator: wageValidate, trigger: 'blur' }
+ ],
+ medicalPersonalProportion: [
+ { required: true, message: '医疗险个人缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ medicalCompanyProportion: [
+ { required: true, message: '医疗险公司缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ unemploymentRadix: [
+ { required: true, message: '失业险基数不能为空', trigger: 'blur' },
+ { validator: wageValidate, trigger: 'blur' }
+ ],
+ unemploymentPersonalProportion: [
+ { required: true, message: '失业险个人缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ unemploymentCompanyProportion: [
+ { required: true, message: '失业险公司缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ maternityRadix: [
+ { required: true, message: '生育险基数不能为空', trigger: 'blur' },
+ { validator: wageValidate, trigger: 'blur' }
+ ],
+ maternityPersonalProportion: [
+ { required: true, message: '生育险个人缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ maternityCompanyProportion: [
+ { required: true, message: '生育险公司缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ industrialInjuryRadix: [
+ { required: true, message: '工伤险基数不能为空', trigger: 'blur' },
+ { validator: wageValidate, trigger: 'blur' }
+ ],
+ industrialInjuryPersonalProportion: [
+ { required: true, message: '工伤险个人缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ],
+ industrialInjuryCompanyProportion: [
+ { required: true, message: '工伤险公司缴纳比例不能为空', trigger: 'blur' },
+ { validator: proportionValidate, trigger: 'blur' }
+ ]
+ },
+ queryTypeOptions: [
+ { key: 'userId', display_name: '所属用户' },
+ { key: 'levelId', display_name: '所属级别' }
+ ],
+ // 开始日期选项
+ startDatePickerOptions: {
+ // 禁用日期
+ disabledDate(time) {
+ return _this.form.endDate != null && _this.form.endDate !== '' ? time.getTime() > _this.form.endDate : false
+ }
+ },
+ // 结束日期选项
+ endDatePickerOptions: {
+ // 禁用日期
+ disabledDate(time) {
+ return _this.form.startDate != null && _this.form.startDate !== '' ? time.getTime() < _this.form.startDate : false
+ }
+ },
+ // CRUD状态
+ crudStatusPrepared: CRUD.STATUS.PREPARED,
+ // 用户列表
+ users: [],
+ // 级别列表
+ levels: [],
+ // 随机数
+ random: 0
+ }
+ },
+ methods: {
+ // 钩子:在获取表格数据之前执行,false 则代表不获取数据
+ [CRUD.HOOK.beforeRefresh]() {
+ // 获取用户
+ this.getUser()
+ // 获取级别
+ this.getLevel()
+ return true
+ },
+ // 获取用户
+ getUser() {
+ // 获取用户
+ crudUser.getAll().then(res => {
+ // 用户列表
+ this.users = res
+ })
+ },
+ // 获取级别
+ getLevel() {
+ // 获取级别
+ crudLevel.getAll().then(res => {
+ // 级别列表
+ this.levels = res
+ })
+ },
+ // 钩子: 开始 "新建/编辑" - 之前
+ [CRUD.HOOK.beforeToCU]() {
+ // 随机数
+ this.random = Math.random()
+ },
+ // 级别改变
+ levelChange() {
+ // 循环级别列表
+ for (const item in this.levels) {
+ // 判断级别
+ if (this.levels[item].id === this.form.levelId) {
+ // 表单赋值
+ this.form.accumulationRadix = this.levels[item].accumulationRadix
+ this.form.accumulationPersonalProportion = this.levels[item].accumulationPersonalProportion
+ this.form.accumulationCompanyProportion = this.levels[item].accumulationCompanyProportion
+ this.form.pensionRadix = this.levels[item].pensionRadix
+ this.form.pensionPersonalProportion = this.levels[item].pensionPersonalProportion
+ this.form.pensionCompanyProportion = this.levels[item].pensionCompanyProportion
+ this.form.medicalRadix = this.levels[item].medicalRadix
+ this.form.medicalPersonalProportion = this.levels[item].medicalPersonalProportion
+ this.form.medicalCompanyProportion = this.levels[item].medicalCompanyProportion
+ this.form.unemploymentRadix = this.levels[item].unemploymentRadix
+ this.form.unemploymentPersonalProportion = this.levels[item].unemploymentPersonalProportion
+ this.form.unemploymentCompanyProportion = this.levels[item].unemploymentCompanyProportion
+ this.form.maternityRadix = this.levels[item].maternityRadix
+ this.form.maternityPersonalProportion = this.levels[item].maternityPersonalProportion
+ this.form.maternityCompanyProportion = this.levels[item].maternityCompanyProportion
+ this.form.industrialInjuryRadix = this.levels[item].industrialInjuryRadix
+ this.form.industrialInjuryPersonalProportion = this.levels[item].industrialInjuryPersonalProportion
+ this.form.industrialInjuryCompanyProportion = this.levels[item].industrialInjuryCompanyProportion
+ // 随机数
+ this.random = Math.random()
+ }
+ }
+ }
+ }
+}
+</script>
+
+<style scoped>
+
+</style>
diff --git a/eladmin-web-master/src/views/system/userLevelWage/index.vue b/eladmin-web-master/src/views/system/userLevelWage/index.vue
index f62cd38..d89c0d6 100644
--- a/eladmin-web-master/src/views/system/userLevelWage/index.vue
+++ b/eladmin-web-master/src/views/system/userLevelWage/index.vue
@@ -202,13 +202,13 @@
},
rules: {
userId: [
- { required: true, message: '所属用户不能为空', trigger: 'blur' }
+ { required: true, message: '所属用户不能为空', trigger: 'change' }
],
levelId: [
- { required: true, message: '所属级别不能为空', trigger: 'blur' }
+ { required: true, message: '所属级别不能为空', trigger: 'change' }
],
startDate: [
- { required: true, message: '开始日期不能为空', trigger: 'blur' }
+ { required: true, message: '开始日期不能为空', trigger: 'change' }
],
levelWage: [
{ required: true, message: '级别工资不能为空', trigger: 'blur' },
--
Gitblit v1.9.3