weicd
2023-01-31 e33e5c68c1c6d51af8a1fb0dc262276e9058980f
新增用户选择公司,修正
6 files modified
73 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SystemSettingRepository.java 10 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/system/user/index.vue 37 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -218,4 +218,8 @@
    public static final String PUBLICITY_STATUS_NOT = "publicity_status_not";
    // 公示状态:已公示
    public static final String PUBLICITY_STATUS_YES = "publicity_status_yes";
    // key iv
    public static final String key = "1234567890123456";
    public static final String iv = "1234567890123456";
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java
@@ -77,6 +77,12 @@
    @ApiModelProperty(value = "生日")
    private Timestamp birthday;
    // 魏传栋 - 始
    @Column(name = "company")
    @ApiModelProperty(value = "所属公司")
    private String company;
    // 魏传栋 - 终
    @Email
    @NotBlank
    @ApiModelProperty(value = "邮箱")
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SystemSettingRepository.java
@@ -18,6 +18,9 @@
import me.zhengjie.modules.system.domain.SystemSetting;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.sql.Timestamp;
/**
* @website https://eladmin.vip
@@ -25,4 +28,11 @@
* @date 2023-01-30
**/
public interface SystemSettingRepository extends JpaRepository<SystemSetting, Long>, JpaSpecificationExecutor<SystemSetting> {
    /**
     * 根据标题查询公司(导出用)
     * @return
     */
    @Query
    SystemSetting findByLabel(String lable);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java
@@ -77,4 +77,8 @@
    private Boolean isAdmin = false;
    private Date pwdResetTime;
    // 魏传栋 - 始
    private String company;
    // 魏传栋 - 终
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -95,6 +95,7 @@
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final SystemSettingRepository systemSettingRepository;
    @Override
    public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
@@ -175,6 +176,7 @@
        user.setJobs(resources.getJobs());
        user.setPhone(resources.getPhone());
        user.setNickName(resources.getNickName());
        user.setCompany(resources.getCompany());
        user.setGender(resources.getGender());
        user.setBirthday(resources.getBirthday());
        user.setAddress(resources.getAddress());
@@ -351,8 +353,14 @@
        LocalDate startDate = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth());
        LocalDate endDate = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth());
        List<Attendance> attendanceRecordList = attendanceRepository.findAllByUserAndDate(userId, startDate.toString(), endDate.toString());
        int numDay = 0;
        for(Attendance attendance : attendanceRecordList){
            if(!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_REST) && !attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_REST)){
                numDay++;
            }
        }
        // 出勤天数
        returnData.put("onDutyDays", attendanceRecordList.size());
        returnData.put("onDutyDays", numDay);
        // 剩余年假
        Double yearTimes = attendanceLeaveService.getYearTimeLength(userId);
        returnData.put("annualLeave", yearTimes);
@@ -538,6 +546,7 @@
        for (UserDto userDTO : queryAll) {
            List<String> roles = userDTO.getRoles().stream().map(RoleSmallDto::getName).collect(Collectors.toList());
            String levelName = userDTO.getLevelId() != null ? sysLevelRepository.findById(userDTO.getLevelId()).orElseGet(SysLevel::new).getName() : "";
            SystemSetting systemSetting = systemSettingRepository.findByLabel(userDTO.getCompany());
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("用户名", userDTO.getUsername());
            map.put("角色", roles);
@@ -547,6 +556,7 @@
            map.put("钉钉号", userDTO.getDingding());
            map.put("排班", userDTO.getSysRostering().getName());
            map.put("级别", levelName);
            map.put("所属公司", systemSetting == null ? "" : systemSetting.getLabel());
            map.put("状态", userDTO.getEnabled() ? "启用" : "禁用");
            map.put("手机号码", userDTO.getPhone());
            map.put("修改密码的时间", userDTO.getPwdResetTime());
eladmin-web-master/src/views/system/user/index.vue
@@ -187,6 +187,11 @@
                >{{ item.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="公司" prop="company">
              <el-select v-model="form.company" style="width: 437px" clearable>
                <el-option v-for="item in companyList" :key="item.id" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
              <el-select
                v-model="roleDatas"
@@ -225,6 +230,15 @@
              <div>{{ scope.row.dept.name }}</div>
            </template>
          </el-table-column>
          <!-- 魏传栋 - 始 -->
          <el-table-column :show-overflow-tooltip="true" prop="company" label="公司" width="150">
            <template slot-scope="scope">
              <template v-for="item in companyList">
                <span v-if="scope.row.company == item.value" :key="item.id">{{ item.label }}</span>
              </template>
            </template>
          </el-table-column>
          <!-- 魏传栋 - 终 -->
          <el-table-column label="状态" align="center" prop="enabled">
            <template slot-scope="scope">
              <el-switch
@@ -278,6 +292,7 @@
import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import crudRostering from '@/api/system/rostering'
import crudLevel from '@/api/system/level'
import crudSystemSetting from '@/api/system/systemSetting'
let userRoles = []
let userJobs = []
const defaultForm = { id: null, username: null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }, levelId: null }
@@ -346,14 +361,23 @@
        ],
        address: [
          { min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
        ],
        // 魏传栋 - 始
        company: [
          { required: true, message: '请选择公司', trigger: 'blur' }
        ]
        // 魏传栋 - 终
      },
      // CRUD状态
      crudStatusPrepared: CRUD.STATUS.PREPARED,
      // 排班
      rosterings: [],
      // 级别
      levels: []
      levels: [],
      // 魏传栋-始
      // 公司
      companyList: []
      // 魏传栋-终
    }
  },
  computed: {
@@ -371,6 +395,17 @@
    }
  },
  methods: {
    // 魏传栋 - 始
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 查询配置参数
      crudSystemSetting.getAll().then(res => {
        // 公司列表
        this.companyList = res
      })
      return true
    },
    // 魏传栋 - 终
    // 禁止输入空格
    keydown(e) {
      if (e.keyCode === 32) {