diff --git a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/BusProjectTeamMember.java b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/BusProjectTeamMember.java index 4053a772..ffd07e19 100644 --- a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/BusProjectTeamMember.java +++ b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/BusProjectTeamMember.java @@ -3,10 +3,9 @@ package org.dromara.project.domain; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import lombok.EqualsAndHashCode; -import org.dromara.common.mybatis.core.domain.BaseEntity; import java.io.Serial; +import java.io.Serializable; import java.util.Date; /** @@ -16,9 +15,8 @@ import java.util.Date; * @date 2025-03-07 */ @Data -@EqualsAndHashCode(callSuper = true) @TableName("bus_project_team_member") -public class BusProjectTeamMember extends BaseEntity { +public class BusProjectTeamMember implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -59,5 +57,14 @@ public class BusProjectTeamMember extends BaseEntity { */ private Date deletedAt; + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; } diff --git a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/req/constructionuser/ConstructionUserQueryReq.java b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/req/constructionuser/ConstructionUserQueryReq.java index 619510df..428cdd67 100644 --- a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/req/constructionuser/ConstructionUserQueryReq.java +++ b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/req/constructionuser/ConstructionUserQueryReq.java @@ -53,6 +53,11 @@ public class ConstructionUserQueryReq extends PageRequest implements Serializabl */ private Long teamId; + /** + * 不在班组id + */ + private Long notTeamId; + /** * 状态(0在职 1离职) */ diff --git a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/BusProjectTeamMemberVo.java b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/BusProjectTeamMemberVo.java index f1f2e0e9..340f1f25 100644 --- a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/BusProjectTeamMemberVo.java +++ b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/BusProjectTeamMemberVo.java @@ -51,10 +51,10 @@ public class BusProjectTeamMemberVo implements Serializable { private Long memberId; /** - * 施工人员信息 + * 施工人员名称 */ - @ExcelProperty(value = "施工人员信息") - private BusConstructionUserVo constructionUserVo; + @ExcelProperty(value = "施工人员名称") + private String memberName; /** * 岗位(默认为0普通员工,1组长) diff --git a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusConstructionUserServiceImpl.java b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusConstructionUserServiceImpl.java index 61d591fc..84db9d0d 100644 --- a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusConstructionUserServiceImpl.java +++ b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusConstructionUserServiceImpl.java @@ -216,6 +216,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl wrapper + .ne("team_id", notTeamId) + .or().isNull("team_id")); + } // 排序规则 queryWrapper.orderBy(SqlUtil.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), diff --git a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java index e92b503a..49ef364d 100644 --- a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java +++ b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/service/impl/BusProjectTeamMemberServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jakarta.annotation.Resource; @@ -18,13 +19,12 @@ import org.dromara.project.domain.BusProjectTeamMember; import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberCreateReq; import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberQueryReq; import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberUpdateReq; -import org.dromara.project.domain.vo.BusConstructionUserVo; import org.dromara.project.domain.vo.BusProjectTeamMemberVo; import org.dromara.project.mapper.BusProjectTeamMemberMapper; import org.dromara.project.service.IBusConstructionUserService; +import org.dromara.project.service.IBusProjectService; import org.dromara.project.service.IBusProjectTeamMemberService; import org.dromara.project.service.IBusProjectTeamService; -import org.dromara.project.service.IBusProjectService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -104,6 +104,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl() - .eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId()) - .eq(BusProjectTeamMember::getTeamId, projectTeamMember.getTeamId())) != null) { - throw new ServiceException("用户和项目班组关联已存在", HttpStatus.CONFLICT); + BusProjectTeamMember teamMember = this.getOne(new LambdaQueryWrapper() + .eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId())); + if (teamMember != null) { + throw new ServiceException("当前用户以关联编号为:" + teamMember.getTeamId() + "的班组", HttpStatus.CONFLICT); } // 操作数据库 boolean save = this.save(projectTeamMember); if (!save) { throw new ServiceException("新增项目班组下的成员失败,数据库异常", HttpStatus.ERROR); } + // 同步修改用户表的team_id字段 + BusConstructionUser constructionUser = new BusConstructionUser(); + constructionUser.setId(projectTeamMember.getMemberId()); + constructionUser.setTeamId(projectTeamMember.getTeamId()); + constructionUserService.updateById(constructionUser); return projectTeamMember.getId(); } @@ -131,6 +137,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl projectTeamMemberList = this.listByIds(ids); + if (projectTeamMemberList.size() != ids.size()) { + throw new ServiceException("删除项目班组下的成员失败,数据缺失", HttpStatus.NOT_FOUND); + } + List memberIds = projectTeamMemberList.stream().map(BusProjectTeamMember::getMemberId).toList(); + LambdaUpdateWrapper queryWrapper = new LambdaUpdateWrapper<>(); + queryWrapper.in(BusConstructionUser::getId, memberIds); + queryWrapper.set(BusConstructionUser::getTeamId, null); + constructionUserService.update(null, queryWrapper); return this.removeBatchByIds(ids); } @@ -209,7 +230,8 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl - + + + - + + + - + + + 搜索 @@ -59,12 +65,12 @@ - + + - @@ -90,23 +96,19 @@ - + @@ -123,17 +125,10 @@ - - - - - - - - - - - + + + + @@ -145,16 +140,16 @@ - + - + - + @@ -168,20 +163,15 @@ - - + + + + - - - - - - - - - - - + + + + @@ -206,8 +196,11 @@ import { updateConstructionUser } from '@/api/project/constructionUser'; import { ConstructionUserForm, ConstructionUserQuery, ConstructionUserVO } from '@/api/project/constructionUser/types'; - import { useUserStoreHook } from '@/store/modules/user'; +import { listContractor } from '@/api/project/contractor'; +import { listProjectTeam } from '@/api/project/projectTeam'; +import { ContractorVO } from '@/api/project/contractor/types'; +import { ProjectTeamVO } from '@/api/project/projectTeam/types'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { type_of_work, user_sex_type, user_clock_type } = toRefs(proxy?.useDict('type_of_work', 'user_sex_type', 'user_clock_type')); @@ -266,8 +259,10 @@ const initFormData: ConstructionUserForm = { const data = reactive>({ form: { ...initFormData }, queryParams: { - pageNum: 1, + current: 1, pageSize: 10, + sortField: 'createTime', + sortOrder: 'descend', openid: undefined, nickName: undefined, pacePhoto: undefined, @@ -298,8 +293,7 @@ const data = reactive>({ }, rules: { id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }], - sex: [{ required: true, message: '0:保密 1:男 2女不能为空', trigger: 'change' }], - clock: [{ required: true, message: '打卡(0启用打卡 1禁止打卡)不能为空', trigger: 'blur' }] + clock: [{ required: true, message: '打卡不能为空', trigger: 'blur' }] } }); @@ -309,11 +303,53 @@ const { queryParams, form, rules } = toRefs(data); const getList = async () => { loading.value = true; const res = await listConstructionUser(queryParams.value); - constructionUserList.value = res.rows; - total.value = res.total; + constructionUserList.value = res.data.records; + total.value = res.data.total; loading.value = false; }; +const contractorOpt = ref(); + +/** 查询当前项目下的分包公司列表 */ +const getContractorList = async () => { + loading.value = true; + const res = await listContractor({ + current: 1, + pageSize: 20, + sortField: 'createTime', + sortOrder: 'descend' + }); + contractorOpt.value = res.data.records.map((contractor: ContractorVO) => ({ + value: contractor.id, + label: contractor.name + })); + loading.value = false; +}; + +const projectTeamOpt = ref(); + +/** 查询当前项目下的班组列表 */ +const getProjectTeamList = async () => { + loading.value = true; + const res = await listProjectTeam({ + current: 1, + pageSize: 20, + sortField: 'createTime', + sortOrder: 'descend', + projectId: currentProject.value.id + }); + projectTeamOpt.value = res.data.records.map((projectTeam: ProjectTeamVO) => ({ + value: projectTeam.id, + label: projectTeam.teamName + })); + loading.value = false; +}; + +const getTeamName = (teamId: string | number) => { + const team = projectTeamOpt.value.find((item: any) => item.value === teamId); + return team ? team.label : teamId; +}; + /** 取消按钮 */ const cancel = () => { reset(); @@ -328,7 +364,7 @@ const reset = () => { /** 搜索按钮操作 */ const handleQuery = () => { - queryParams.value.pageNum = 1; + queryParams.value.current = 1; getList(); }; @@ -401,5 +437,7 @@ const handleExport = () => { onMounted(() => { getList(); + getContractorList(); + getProjectTeamList(); }); diff --git a/plus-ui/src/views/project/contractor/index.vue b/plus-ui/src/views/project/contractor/index.vue index 69be2cb3..8d4ca56c 100644 --- a/plus-ui/src/views/project/contractor/index.vue +++ b/plus-ui/src/views/project/contractor/index.vue @@ -62,17 +62,17 @@ - + @@ -141,7 +141,7 @@ const initFormData: ContractorForm = { const data = reactive>({ form: { ...initFormData }, queryParams: { - pageNum: 1, + current: 1, pageSize: 10, name: undefined, principal: undefined, @@ -162,7 +162,7 @@ const getList = async () => { loading.value = true; const res = await listContractor(queryParams.value); contractorList.value = res.data.records; - total.value = res.total; + total.value = res.data.total; loading.value = false; }; @@ -180,7 +180,7 @@ const reset = () => { /** 搜索按钮操作 */ const handleQuery = () => { - queryParams.value.pageNum = 1; + queryParams.value.current = 1; getList(); }; diff --git a/plus-ui/src/views/project/project/index.vue b/plus-ui/src/views/project/project/index.vue index 526dea70..3d0866c4 100644 --- a/plus-ui/src/views/project/project/index.vue +++ b/plus-ui/src/views/project/project/index.vue @@ -53,7 +53,6 @@ - diff --git a/plus-ui/src/views/project/projectTeam/index.vue b/plus-ui/src/views/project/projectTeam/index.vue index 5f530638..cc052003 100644 --- a/plus-ui/src/views/project/projectTeam/index.vue +++ b/plus-ui/src/views/project/projectTeam/index.vue @@ -23,13 +23,13 @@ 新增 - 修改 + + 修改 - 删除 + + 删除 @@ -43,23 +43,25 @@ - + + + - + @@ -81,7 +83,7 @@ - + @@ -92,7 +94,7 @@ import { useUserStoreHook } from '@/store/modules/user'; import UserListDialog from '@/views/project/projectTeam/component/UserListDialog.vue'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; - +const { team_clock_type } = toRefs(proxy?.useDict('team_clock_type')); // 获取用户 store const userStore = useUserStoreHook(); // 从 store 中获取项目列表和当前选中的项目 @@ -106,7 +108,13 @@ const single = ref(true); const multiple = ref(true); const total = ref(0); const userListVisible = ref(); -const currentRow = ref(); +const currentRow = ref({ + id: undefined, + projectId: undefined, + teamName: undefined, + isClockIn: undefined, + remark: undefined +}); const queryFormRef = ref(); const projectTeamFormRef = ref(); @@ -126,8 +134,10 @@ const initFormData: ProjectTeamForm = { const data = reactive>({ form: { ...initFormData }, queryParams: { - pageNum: 1, + current: 1, pageSize: 10, + sortField: 'createTime', + sortOrder: 'descend', projectId: currentProject.value.id, teamName: undefined, isClockIn: undefined, @@ -164,7 +174,7 @@ const reset = () => { /** 搜索按钮操作 */ const handleQuery = () => { - queryParams.value.pageNum = 1; + queryParams.value.current = 1; getList(); }; diff --git a/plus-ui/src/views/project/projectTeamMember/index.vue b/plus-ui/src/views/project/projectTeamMember/index.vue deleted file mode 100644 index 78503c99..00000000 --- a/plus-ui/src/views/project/projectTeamMember/index.vue +++ /dev/null @@ -1,272 +0,0 @@ - - -