feat(biz): 完善业务模块功能并优化用户体验
This commit is contained in:
parent
75ce38875c
commit
a4fab917b0
@ -33,4 +33,7 @@ public class PageParam implements Serializable {
|
||||
@Max(value = 999, message = "每页条数最大值为 999")
|
||||
private Integer pageSize = PAGE_SIZE;
|
||||
|
||||
|
||||
private String keyWord;
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
|
||||
@ -8,6 +9,8 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo.MachineR
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo.MachineSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.machine.MachineDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.service.machine.MachineService;
|
||||
import com.ningxia.yunxi.chemmes.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.ningxia.yunxi.chemmes.module.system.service.user.AdminUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -17,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@ -29,6 +33,9 @@ public class MachineController {
|
||||
@Resource
|
||||
private MachineService machineService;
|
||||
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建机台主数据")
|
||||
@PreAuthorize("@ss.hasPermission('biz:machine:create')")
|
||||
@ -67,7 +74,25 @@ public class MachineController {
|
||||
@PreAuthorize("@ss.hasPermission('biz:machine:query')")
|
||||
public CommonResult<PageResult<MachineRespVO>> getMachinePage(@Valid MachinePageReqVO pageReqVO) {
|
||||
PageResult<MachineDO> pageResult = machineService.getMachinePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, MachineRespVO.class));
|
||||
PageResult<MachineRespVO> voPageResult = BeanUtils.toBean(pageResult, MachineRespVO.class);
|
||||
if (CollUtil.isNotEmpty(voPageResult.getList())) {
|
||||
voPageResult.getList().forEach(item -> {
|
||||
AdminUserDO userEntity = userService.getUser(Long.valueOf(item.getCreator()));
|
||||
if (userEntity != null) {
|
||||
item.setCreator(userEntity.getUsername());
|
||||
}
|
||||
});
|
||||
}
|
||||
return success(voPageResult);
|
||||
}
|
||||
|
||||
//机台下拉框
|
||||
@GetMapping("/dropdown")
|
||||
@Operation(summary = "获得机台下拉框")
|
||||
@PreAuthorize("@ss.hasPermission('biz:machine:query')")
|
||||
public CommonResult<List<MachineRespVO>> getMachineDropdown(@RequestParam(value = "keyWord", required = false, defaultValue = "") String keyWord) {
|
||||
List<MachineDO> dropdownList = machineService.getMachineDropdown(keyWord);
|
||||
return success(BeanUtils.toBean(dropdownList, MachineRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ningxia.yunxi.chemmes.framework.excel.core.annotations.DictFormat;
|
||||
import com.ningxia.yunxi.chemmes.framework.excel.core.convert.DictConvert;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 机台主数据 Response VO")
|
||||
@Data
|
||||
@ -48,4 +47,8 @@ public class MachineRespVO {
|
||||
@ExcelProperty("所属工序id")
|
||||
private Integer belgProcId;
|
||||
|
||||
@Schema(description = "创建者", example = "芋艿")
|
||||
@ExcelProperty("创建者")
|
||||
private String creator;
|
||||
|
||||
}
|
||||
@ -1,33 +1,31 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.operatelog.core.annotations.OperateLog;
|
||||
import static com.ningxia.yunxi.chemmes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.*;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineDetailRespVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachinePageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineRespVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDetailDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.service.usermachine.UserMachineDetailService;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.service.usermachine.UserMachineService;
|
||||
import com.ningxia.yunxi.chemmes.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.ningxia.yunxi.chemmes.module.system.service.user.AdminUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 人员所属机台、班组配置")
|
||||
@RestController
|
||||
@ -38,6 +36,12 @@ public class UserMachineController {
|
||||
@Resource
|
||||
private UserMachineService userMachineService;
|
||||
|
||||
@Resource
|
||||
private UserMachineDetailService userMachineDetailService;
|
||||
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建人员所属机台、班组配置")
|
||||
@PreAuthorize("@ss.hasPermission('biz:user-machine:create')")
|
||||
@ -68,7 +72,13 @@ public class UserMachineController {
|
||||
@PreAuthorize("@ss.hasPermission('biz:user-machine:query')")
|
||||
public CommonResult<UserMachineRespVO> getUserMachine(@RequestParam("id") Integer id) {
|
||||
UserMachineDO userMachine = userMachineService.getUserMachine(id);
|
||||
return success(BeanUtils.toBean(userMachine, UserMachineRespVO.class));
|
||||
AdminUserDO user = userService.getUser(Long.valueOf(userMachine.getCreator()));
|
||||
userMachine.setCreator(user.getUsername());
|
||||
List<UserMachineDetailDO> detailDOList = userMachineDetailService.getListByUserMachId(userMachine.getId());
|
||||
detailDOList.forEach(detail -> detail.setCreator(user.getUsername()));
|
||||
UserMachineRespVO userMachineRespVO = BeanUtils.toBean(userMachine, UserMachineRespVO.class);
|
||||
userMachineRespVO.setMachineList(BeanUtils.toBean(detailDOList, UserMachineDetailRespVO.class));
|
||||
return success(userMachineRespVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -76,20 +86,16 @@ public class UserMachineController {
|
||||
@PreAuthorize("@ss.hasPermission('biz:user-machine:query')")
|
||||
public CommonResult<PageResult<UserMachineRespVO>> getUserMachinePage(@Valid UserMachinePageReqVO pageReqVO) {
|
||||
PageResult<UserMachineDO> pageResult = userMachineService.getUserMachinePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, UserMachineRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出人员所属机台、班组配置 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('biz:user-machine:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportUserMachineExcel(@Valid UserMachinePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<UserMachineDO> list = userMachineService.getUserMachinePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "人员所属机台、班组配置.xls", "数据", UserMachineRespVO.class,
|
||||
BeanUtils.toBean(list, UserMachineRespVO.class));
|
||||
PageResult<UserMachineRespVO> voPageResult = BeanUtils.toBean(pageResult, UserMachineRespVO.class);
|
||||
if (CollUtil.isNotEmpty(voPageResult.getList())) {
|
||||
voPageResult.getList().forEach(item -> {
|
||||
AdminUserDO userEntity = userService.getUser(Long.valueOf(item.getCreator()));
|
||||
if (userEntity != null) {
|
||||
item.setCreator(userEntity.getUsername());
|
||||
}
|
||||
});
|
||||
}
|
||||
return success(voPageResult);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 人员所属机台、班组配置子分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class UserMachineDetailPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)", example = "1")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "主表id", example = "1157")
|
||||
private Integer userMachId;
|
||||
|
||||
@Schema(description = "机台编码")
|
||||
private String machineCd;
|
||||
|
||||
@Schema(description = "机台名称", example = "王五")
|
||||
private String machineName;
|
||||
|
||||
@Schema(description = "机台id", example = "9668")
|
||||
private Integer machineId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 人员所属机台、班组配置子 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class UserMachineDetailRespVO {
|
||||
|
||||
@Schema(description = "自增字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "27073")
|
||||
@ExcelProperty("自增字段")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// 创建者
|
||||
@Schema(description = "创建者", example = "1024")
|
||||
@ExcelProperty("创建者")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)", example = "1")
|
||||
@ExcelProperty("状态(1启用 2 未启用)")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "主表id", example = "1157")
|
||||
@ExcelProperty("主表id")
|
||||
private Integer userMachId;
|
||||
|
||||
@Schema(description = "机台编码")
|
||||
@ExcelProperty("机台编码")
|
||||
private String machineCd;
|
||||
|
||||
@Schema(description = "机台名称", example = "王五")
|
||||
@ExcelProperty("机台名称")
|
||||
private String machineName;
|
||||
|
||||
@Schema(description = "机台id", example = "9668")
|
||||
@ExcelProperty("机台id")
|
||||
private Integer machineId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 人员所属机台、班组配置子新增/修改 Request VO")
|
||||
@Data
|
||||
public class UserMachineDetailSaveReqVO {
|
||||
|
||||
@Schema(description = "自增字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "27073")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)", example = "1")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "主表id", example = "1157")
|
||||
private Integer userMachId;
|
||||
|
||||
@Schema(description = "机台编码")
|
||||
private String machineCd;
|
||||
|
||||
@Schema(description = "机台名称", example = "王五")
|
||||
private String machineName;
|
||||
|
||||
@Schema(description = "机台id", example = "9668")
|
||||
private Integer machineId;
|
||||
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ningxia.yunxi.chemmes.framework.excel.core.annotations.DictFormat;
|
||||
import com.ningxia.yunxi.chemmes.framework.excel.core.convert.DictConvert;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 人员所属机台、班组配置 Response VO")
|
||||
@Data
|
||||
@ -46,7 +46,13 @@ public class UserMachineRespVO {
|
||||
|
||||
@Schema(description = "班组(甲 乙 丙 丁)")
|
||||
@ExcelProperty(value = "班组(甲 乙 丙 丁)", converter = DictConvert.class)
|
||||
@DictFormat("team_or_group") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
@DictFormat("team_or_group")
|
||||
private String classGroup;
|
||||
|
||||
@Schema(description = "创建人", example = "1024")
|
||||
@ExcelProperty("创建人")
|
||||
private String creator;
|
||||
|
||||
private List<UserMachineDetailRespVO> machineList;
|
||||
|
||||
}
|
||||
@ -1,10 +1,9 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 人员所属机台、班组配置新增/修改 Request VO")
|
||||
@Data
|
||||
@ -31,4 +30,6 @@ public class UserMachineSaveReqVO {
|
||||
@Schema(description = "班组(甲 乙 丙 丁)")
|
||||
private String classGroup;
|
||||
|
||||
private List<UserMachineDetailSaveReqVO> machineList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 人员所属机台、班组配置子 DO
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@TableName("tba_user_machine_detail")
|
||||
@KeySequence("tba_user_machine_detail_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserMachineDetailDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 自增字段
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 状态(1启用 2 未启用)
|
||||
*/
|
||||
private Integer enabledStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 主表id
|
||||
*/
|
||||
private Integer userMachId;
|
||||
/**
|
||||
* 机台编码
|
||||
*/
|
||||
private String machineCd;
|
||||
/**
|
||||
* 机台名称
|
||||
*/
|
||||
private String machineName;
|
||||
/**
|
||||
* 机台id
|
||||
*/
|
||||
private Integer machineId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineDetailPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员所属机台、班组配置子 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMachineDetailMapper extends BaseMapperX<UserMachineDetailDO> {
|
||||
|
||||
|
||||
default PageResult<UserMachineDetailDO> selectPage(UserMachineDetailPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<UserMachineDetailDO>()
|
||||
.betweenIfPresent(UserMachineDetailDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(UserMachineDetailDO::getEnabledStatus, reqVO.getEnabledStatus())
|
||||
.eqIfPresent(UserMachineDetailDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(UserMachineDetailDO::getUserMachId, reqVO.getUserMachId())
|
||||
.eqIfPresent(UserMachineDetailDO::getMachineCd, reqVO.getMachineCd())
|
||||
.likeIfPresent(UserMachineDetailDO::getMachineName, reqVO.getMachineName())
|
||||
.eqIfPresent(UserMachineDetailDO::getMachineId, reqVO.getMachineId())
|
||||
.orderByDesc(UserMachineDetailDO::getId));
|
||||
}
|
||||
|
||||
default List<UserMachineDetailDO> selectListByUserMachId(Integer id){
|
||||
return selectList(new LambdaQueryWrapperX<UserMachineDetailDO>()
|
||||
.eq(UserMachineDetailDO::getUserMachId, id).eq(UserMachineDetailDO::getEnabledStatus, 0).orderByDesc(UserMachineDetailDO::getMachineId));
|
||||
}
|
||||
|
||||
default void deleteByUserMachId(Integer userMachId){
|
||||
delete(new LambdaQueryWrapperX<UserMachineDetailDO>().eq(UserMachineDetailDO::getUserMachId, userMachId));
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,8 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo.MachineP
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.machine.MachineDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机台主数据 Mapper
|
||||
*
|
||||
@ -18,6 +20,10 @@ public interface MachineMapper extends BaseMapperX<MachineDO> {
|
||||
default PageResult<MachineDO> selectPage(MachinePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MachineDO>()
|
||||
.eqIfPresent(MachineDO::getEnabledStatus, reqVO.getEnabledStatus())
|
||||
.and(reqVO.getKeyWord() != null, wrapper -> wrapper
|
||||
.like(MachineDO::getMachineName, reqVO.getKeyWord())
|
||||
.or()
|
||||
.like(MachineDO::getMachineCd, reqVO.getKeyWord()))
|
||||
.orderByDesc(MachineDO::getId));
|
||||
}
|
||||
|
||||
@ -26,4 +32,10 @@ public interface MachineMapper extends BaseMapperX<MachineDO> {
|
||||
.eqIfPresent(MachineDO::getMachineCd, code));
|
||||
}
|
||||
|
||||
default List<MachineDO> seleLectListByKeyWord(String keyWord) {
|
||||
return selectList(new LambdaQueryWrapperX<MachineDO>()
|
||||
.like(MachineDO::getMachineName, keyWord)
|
||||
.or()
|
||||
.like(MachineDO::getMachineCd, keyWord));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.service.machine;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo.*;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.machine.MachineDO;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo.MachinePageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo.MachineSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.machine.MachineDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机台主数据 Service 接口
|
||||
@ -52,4 +53,5 @@ public interface MachineService {
|
||||
*/
|
||||
PageResult<MachineDO> getMachinePage(MachinePageReqVO pageReqVO);
|
||||
|
||||
List<MachineDO> getMachineDropdown(String keyWord);
|
||||
}
|
||||
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@ -80,4 +81,8 @@ public class MachineServiceImpl implements MachineService {
|
||||
return machineMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MachineDO> getMachineDropdown(String keyWord) {
|
||||
return machineMapper.seleLectListByKeyWord(keyWord);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.service.usermachine;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineDetailSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDetailDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员所属机台、班组配置子 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface UserMachineDetailService {
|
||||
|
||||
void saveMachineDetails(Integer userMachId, List<UserMachineDetailSaveReqVO> machineList);
|
||||
|
||||
/**
|
||||
* 删除人员所属机台、班组配置子
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteUserMachineDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 获得人员所属机台、班组配置子
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 人员所属机台、班组配置子
|
||||
*/
|
||||
UserMachineDetailDO getUserMachineDetail(Integer id);
|
||||
|
||||
List<UserMachineDetailDO> getListByUserMachId(Integer id);
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.service.usermachine;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineDetailSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDetailDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDetailMapper;
|
||||
import com.ningxia.yunxi.chemmes.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.ningxia.yunxi.chemmes.module.system.service.user.AdminUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 人员所属机台、班组配置子 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class UserMachineDetailServiceImpl implements UserMachineDetailService {
|
||||
|
||||
@Resource
|
||||
private UserMachineDetailMapper userMachineDetailMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveMachineDetails(Integer userMachId, List<UserMachineDetailSaveReqVO> machineList) {
|
||||
if (ObjectUtil.isEmpty(machineList)) {
|
||||
return;
|
||||
}
|
||||
userMachineDetailMapper.deleteByUserMachId(userMachId);
|
||||
List<UserMachineDetailDO> detailEntities = machineList.stream()
|
||||
.map(form -> {
|
||||
UserMachineDetailDO detailEntity = new UserMachineDetailDO();
|
||||
detailEntity.setUserMachId(userMachId);
|
||||
detailEntity.setMachineCd(form.getMachineCd());
|
||||
detailEntity.setMachineId(form.getMachineId());
|
||||
detailEntity.setMachineName(form.getMachineName());
|
||||
detailEntity.setEnabledStatus(0);
|
||||
return detailEntity;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
userMachineDetailMapper.insertBatch(detailEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserMachineDetail(Integer id) {
|
||||
// 校验存在
|
||||
validateUserMachineDetailExists(id);
|
||||
// 删除
|
||||
userMachineDetailMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateUserMachineDetailExists(Integer id) {
|
||||
if (userMachineDetailMapper.selectById(id) == null) {
|
||||
throw exception("人员所属机台、班组配置子不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMachineDetailDO getUserMachineDetail(Integer id) {
|
||||
return userMachineDetailMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserMachineDetailDO> getListByUserMachId(Integer id) {
|
||||
List<UserMachineDetailDO> detailDOList = userMachineDetailMapper.selectListByUserMachId(id);
|
||||
if (CollUtil.isNotEmpty(detailDOList)) {
|
||||
detailDOList.forEach(item -> {
|
||||
AdminUserDO userEntity = userService.getUser(Long.valueOf(item.getCreator()));
|
||||
if (userEntity != null) {
|
||||
item.setCreator(userEntity.getUsername());
|
||||
}
|
||||
});
|
||||
}
|
||||
return detailDOList;
|
||||
}
|
||||
}
|
||||
@ -2,14 +2,18 @@ package com.ningxia.yunxi.chemmes.module.biz.service.usermachine;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineDetailSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachinePageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo.UserMachineSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.usermachine.UserMachineDetailDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.usermachine.UserMachineMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员所属机台、班组配置 Service 实现类
|
||||
@ -23,22 +27,35 @@ public class UserMachineServiceImpl implements UserMachineService {
|
||||
@Resource
|
||||
private UserMachineMapper userMachineMapper;
|
||||
|
||||
@Resource
|
||||
private UserMachineDetailService userMachineDetailService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer createUserMachine(UserMachineSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
UserMachineDO userMachine = BeanUtils.toBean(createReqVO, UserMachineDO.class);
|
||||
userMachineMapper.insert(userMachine);
|
||||
// 返回
|
||||
|
||||
List<UserMachineDetailSaveReqVO> machineList = createReqVO.getMachineList();
|
||||
userMachineDetailService.saveMachineDetails(userMachine.getId(), machineList);
|
||||
return userMachine.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateUserMachine(UserMachineSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateUserMachineExists(updateReqVO.getId());
|
||||
// 更新
|
||||
|
||||
UserMachineDO updateObj = BeanUtils.toBean(updateReqVO, UserMachineDO.class);
|
||||
userMachineMapper.updateById(updateObj);
|
||||
|
||||
List<UserMachineDetailDO> existingDetails = userMachineDetailService.getListByUserMachId(updateReqVO.getId());
|
||||
for (UserMachineDetailDO existingDetail : existingDetails) {
|
||||
userMachineDetailService.deleteUserMachineDetail(existingDetail.getId());
|
||||
}
|
||||
|
||||
List<UserMachineDetailSaveReqVO> machineList = updateReqVO.getMachineList();
|
||||
userMachineDetailService.saveMachineDetails(updateObj.getId(), machineList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -39,3 +39,8 @@ export const deleteMachine = async (id: number) => {
|
||||
export const exportMachine = async (params) => {
|
||||
return await request.download({ url: `/biz/machine/export-excel`, params })
|
||||
}
|
||||
|
||||
// 查询机台下拉列表
|
||||
export const getMachineDropdown = async (params) => {
|
||||
return await request.get({ url: `/biz/machine/dropdown`, params })
|
||||
}
|
||||
@ -236,6 +236,14 @@ const formRules = reactive({
|
||||
enabledStatus: [{ required: true, message: '请选择启用状态', trigger: 'change' }],
|
||||
})
|
||||
const formRef = ref()
|
||||
import { watch } from 'vue'
|
||||
|
||||
/** 弹窗关闭时通知父组件 */
|
||||
watch(dialogVisible, (val) => {
|
||||
if (!val) {
|
||||
emit('close')
|
||||
}
|
||||
})
|
||||
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
@ -253,7 +261,7 @@ const open = async (type: string, id?: number) => {
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
formLoading.value = true
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<CustomerForm ref="formRef" @success="getList" />
|
||||
<CustomerForm ref="formRef" @success="getList" @close="handleQuery" />
|
||||
<!-- 详情弹窗 -->
|
||||
<CustomerDetail ref="detailRef" />
|
||||
</template>
|
||||
@ -155,7 +155,7 @@ import * as CustomerApi from '@/api/biz/customer'
|
||||
import CustomerForm from './CustomerForm.vue'
|
||||
import CustomerDetail from './CustomerDetail.vue'
|
||||
|
||||
defineOptions({ name: 'customer' })
|
||||
defineOptions({ name: 'Customer' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px"
|
||||
>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="600px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
@ -9,7 +8,7 @@
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="机台编码" prop="machineCd">
|
||||
<el-input v-model="formData.machineCd" placeholder="请输入机台编码" />
|
||||
<el-input v-model="formData.machineCd" placeholder="请输入机台编码" :disabled="formType === 'update'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="机台名称" prop="machineName">
|
||||
<el-input v-model="formData.machineName" placeholder="请输入机台名称" />
|
||||
@ -56,6 +55,7 @@
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { watch } from 'vue'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import * as MachineApi from '@/api/biz/machine'
|
||||
import * as ProLineApi from '@/api/biz/proline'
|
||||
@ -133,7 +133,7 @@ const open = async (type: string, id?: number) => {
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const emit = defineEmits(['success', 'close']) // 定义 success 和 close 事件
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
@ -156,6 +156,13 @@ const submitForm = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 弹窗关闭时通知父组件 */
|
||||
watch(dialogVisible, (val) => {
|
||||
if (!val) {
|
||||
emit('close')
|
||||
}
|
||||
})
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<MachineForm ref="formRef" @success="getList" />
|
||||
<MachineForm ref="formRef" @success="getList" @close="handleQuery" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="600px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
@ -52,7 +52,13 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="安全库存" prop="safeStock">
|
||||
<el-input v-model="formData.safeStock" placeholder="请输入安全库存" />
|
||||
<el-input-number
|
||||
v-model="formData.safeStock"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
placeholder="请输入安全库存"
|
||||
class="!w-full"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark">
|
||||
@ -90,6 +96,21 @@ const formData = ref({
|
||||
safeStock: undefined,
|
||||
schemeId: undefined,
|
||||
})
|
||||
|
||||
const validateSafeStock = (rule: any, value: number, callback: any) => {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
const strValue = String(value)
|
||||
const regex = /^\d+(\.\d{1,2})?$/
|
||||
if (!regex.test(strValue)) {
|
||||
callback(new Error('安全库存最多两位小数'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const formRules = reactive({
|
||||
// 物料类型,物料编码,物料名称,单位,质检方案,状态
|
||||
matType: [{ required: true, message: '请选择物料类型', trigger: ['blur'] }],
|
||||
@ -98,6 +119,10 @@ const formRules = reactive({
|
||||
unit: [{ required: true, message: '请输入单位', trigger: ['blur'] }],
|
||||
schemeId: [{ required: true, message: '请输入质检方案', trigger: ['blur'] }],
|
||||
enabledStatus: [{ required: true, message: '请选择状态', trigger: ['blur'] }],
|
||||
safeStock: [
|
||||
{ type: 'number', min: 0, message: '安全库存不能为负数', trigger: ['blur', 'change'] },
|
||||
{ validator: validateSafeStock, trigger: ['blur', 'change'] }
|
||||
],
|
||||
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
@ -83,7 +83,12 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="单位" align="center" prop="unit" />
|
||||
<el-table-column label="单位" align="center" prop="unit" >
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.UNIT" :value="scope.row.unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="规格型号" align="center" prop="spec" />
|
||||
<el-table-column label="品牌" align="center" prop="brand" />
|
||||
<el-table-column label="状态" align="center" prop="enabledStatus">
|
||||
@ -136,7 +141,7 @@ import download from '@/utils/download'
|
||||
import * as MaterialApi from '@/api/biz/material'
|
||||
import MaterialForm from './MaterialForm.vue'
|
||||
|
||||
defineOptions({ name: 'material' })
|
||||
defineOptions({ name: 'Material' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { watch } from 'vue'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import * as ProcApi from '@/api/biz/proc'
|
||||
|
||||
@ -77,7 +78,7 @@ const open = async (type: string, id?: number) => {
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const emit = defineEmits(['success', 'close']) // 定义 success 和 close 事件
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
@ -100,6 +101,13 @@ const submitForm = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 弹窗关闭时通知父组件 */
|
||||
watch(dialogVisible, (val) => {
|
||||
if (!val) {
|
||||
emit('close')
|
||||
}
|
||||
})
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ProcForm ref="formRef" @success="getList" />
|
||||
<ProcForm ref="formRef" @success="getList" @close="handleQuery" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { watch } from 'vue'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import * as ProLineApi from '@/api/biz/proline'
|
||||
|
||||
@ -77,7 +78,7 @@ const open = async (type: string, id?: number) => {
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const emit = defineEmits(['success', 'close']) // 定义 success 和 close 事件
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
@ -100,6 +101,13 @@ const submitForm = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 弹窗关闭时通知父组件 */
|
||||
watch(dialogVisible, (val) => {
|
||||
if (!val) {
|
||||
emit('close')
|
||||
}
|
||||
})
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ProLineForm ref="formRef" @success="getList" />
|
||||
<ProLineForm ref="formRef" @success="getList" @close="handleQuery" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
@ -215,13 +215,13 @@ const open = async (type: string, id?: number) => {
|
||||
try {
|
||||
const data = await SupplierApi.getSupplier(id)
|
||||
if (data.enabledStatus !== undefined && data.enabledStatus !== null) {
|
||||
data.enabledStatus = String(data.enabledStatus)
|
||||
data.enabledStatus = Number(data.enabledStatus)
|
||||
}
|
||||
if (data.status !== undefined && data.status !== null) {
|
||||
data.status = String(data.status)
|
||||
data.status = Number(data.status)
|
||||
}
|
||||
if (data.isBlacklist !== undefined && data.isBlacklist !== null) {
|
||||
data.isBlacklist = String(data.isBlacklist)
|
||||
data.isBlacklist = Number(data.isBlacklist)
|
||||
}
|
||||
formData.value = data
|
||||
} finally {
|
||||
|
||||
@ -132,6 +132,7 @@
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@ -140,14 +141,22 @@
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openDetail(scope.row.id)"
|
||||
v-hasPermi="['biz:supplier:query']"
|
||||
>
|
||||
详情
|
||||
</el-button>
|
||||
<!-- <el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['biz:supplier:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -161,12 +170,16 @@
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<SupplierForm ref="formRef" @success="getList" />
|
||||
<SupplierForm ref="formRef" @success="getList" @close="handleQuery" />
|
||||
|
||||
<!-- 详情弹窗 -->
|
||||
<SupplierDetail ref="detailRef" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getStrDictOptions, getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import SupplierDetail from './SupplierDetail.vue'
|
||||
import download from '@/utils/download'
|
||||
import * as SupplierApi from '@/api/biz/supplier'
|
||||
import SupplierForm from './SupplierForm.vue'
|
||||
@ -192,6 +205,7 @@ const queryParams = reactive({
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const detailRef = ref() // 详情弹窗的 Ref
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
@ -219,10 +233,16 @@ const resetQuery = () => {
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
/** 打开表单弹窗 */
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 打开详情弹窗 */
|
||||
const openDetail = (id: number) => {
|
||||
detailRef.value.open(id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
|
||||
@ -1,96 +1,210 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
label-width="70px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="状态(1启用 2 未启用)" prop="enabledStatus">
|
||||
<el-radio-group v-model="formData.enabledStatus">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="人员" prop="userNo">
|
||||
<el-select v-model="formData.userNo" placeholder="请选择人员" :disabled="formType === 'update'">
|
||||
<el-option
|
||||
v-for="user in userOptions"
|
||||
:key="user.value"
|
||||
:label="user.label"
|
||||
:value="user.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="班组" prop="classGroup">
|
||||
<el-select v-model="formData.classGroup" placeholder="请选择班组">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.TEAM_OR_GROUP)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="人员id" prop="userId">
|
||||
<el-input v-model="formData.userId" placeholder="请输入人员id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="人员名称" prop="userName">
|
||||
<el-input v-model="formData.userName" placeholder="请输入人员名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="人员账号" prop="userNo">
|
||||
<el-input v-model="formData.userNo" placeholder="请输入人员账号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="班组(甲 乙 丙 丁)" prop="classGroup">
|
||||
<el-input v-model="formData.classGroup" placeholder="请输入班组(甲 乙 丙 丁)" />
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 机台信息 -->
|
||||
<div class="mt-20px">
|
||||
<div class="mb-15px flex items-center">
|
||||
<span class="font-weight-600">机台信息</span>
|
||||
<el-button type="primary" plain size="small" @click="addMachine" class="ml-10px">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table :data="machineList" :show-overflow-tooltip="true">
|
||||
<el-table-column label="序号" align="center" type="index" width="60px" />
|
||||
<el-table-column label="机台编码" align="center" prop="machineCd" />
|
||||
<el-table-column label="机台名称" align="center" prop="machineName" />
|
||||
<el-table-column label="创建人" align="center" prop="creator" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter2" />
|
||||
<el-table-column label="操作" align="center" width="80px">
|
||||
<template #default="scope">
|
||||
<el-button link type="danger" size="small" @click="removeMachine(scope.$index)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 机台选择弹窗 -->
|
||||
<MachineSelect ref="machineSelectRef" @confirm="confirmMachine" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { ref, reactive, watch } from 'vue'
|
||||
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { Icon } from '@/components/Icon'
|
||||
import * as UserMachineApi from '@/api/biz/usermachine'
|
||||
import * as SystemUserApi from '@/api/system/user'
|
||||
import MachineSelect from '@/views/biz/machine/MachineSelect.vue'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const formLoading = ref(false)
|
||||
const formType = ref('')
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
enabledStatus: undefined,
|
||||
enabledStatus: 0,
|
||||
remark: undefined,
|
||||
userId: undefined,
|
||||
userName: undefined,
|
||||
userNo: undefined,
|
||||
classGroup: undefined,
|
||||
classGroup: '',
|
||||
})
|
||||
const formRules = reactive({
|
||||
userNo: [{ required: true, message: '请选择人员', trigger: 'change' }],
|
||||
classGroup: [{ required: true, message: '请选择班组', trigger: 'change' }],
|
||||
enabledStatus: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const formRef = ref()
|
||||
|
||||
const userOptions = ref([])
|
||||
const userList = ref([])
|
||||
const machineList = ref([])
|
||||
const machineSelectRef = ref()
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
await loadUsers()
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await UserMachineApi.getUserMachine(id)
|
||||
const data = await UserMachineApi.getUserMachine(id)
|
||||
formData.value = data
|
||||
machineList.value = data.machineList || []
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
defineExpose({ open })
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const loadUsers = async () => {
|
||||
try {
|
||||
const data = await SystemUserApi.getSimpleUserList()
|
||||
userList.value = data
|
||||
userOptions.value = data.map((item: any) => ({
|
||||
value: item.username,
|
||||
label: item.nickname,
|
||||
}))
|
||||
} catch {}
|
||||
}
|
||||
|
||||
watch(() => formData.value.userNo, (userNo) => {
|
||||
if (userNo) {
|
||||
const user = userList.value.find((u: any) => u.username === userNo)
|
||||
if (user) {
|
||||
formData.value.userId = user.id
|
||||
formData.value.userName = user.nickname
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const addMachine = () => {
|
||||
const selectedIds = machineList.value.map(m => m.machineId)
|
||||
machineSelectRef.value.open(selectedIds)
|
||||
}
|
||||
|
||||
const confirmMachine = (machines: any[]) => {
|
||||
machines.forEach((item: any) => {
|
||||
const exists = machineList.value.some(m => m.machineId === item.id)
|
||||
if (!exists) {
|
||||
machineList.value.push({
|
||||
machineId: item.id,
|
||||
machineCd: item.machineCd,
|
||||
machineName: item.machineName,
|
||||
creator: item.creator,
|
||||
createTime: item.createTime,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const removeMachine = (index: number) => {
|
||||
machineList.value.splice(index, 1)
|
||||
}
|
||||
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
|
||||
/** 弹窗关闭时通知父组件 */
|
||||
watch(dialogVisible, (val) => {
|
||||
if (!val) {
|
||||
emit('close')
|
||||
}
|
||||
})
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (machineList.value.length === 0) {
|
||||
message.warning('请选择机台信息')
|
||||
return
|
||||
}
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as UserMachineApi.UserMachineVO
|
||||
const data = {
|
||||
...formData.value,
|
||||
machineList: machineList.value.map(m => ({
|
||||
machineId: m.machineId,
|
||||
machineCd: m.machineCd,
|
||||
machineName: m.machineName,
|
||||
})),
|
||||
} as unknown as UserMachineApi.UserMachineVO
|
||||
if (formType.value === 'create') {
|
||||
await UserMachineApi.createUserMachine(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
@ -99,24 +213,34 @@ const submitForm = async () => {
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
enabledStatus: undefined,
|
||||
enabledStatus: 0,
|
||||
remark: undefined,
|
||||
userId: undefined,
|
||||
userName: undefined,
|
||||
userNo: undefined,
|
||||
classGroup: undefined,
|
||||
classGroup: '',
|
||||
}
|
||||
machineList.value = []
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.mt-15px {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.mt-20px {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.mb-15px {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -6,12 +6,36 @@
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="状态(1启用 2 未启用)" prop="enabledStatus">
|
||||
|
||||
<el-form-item label="人员编码" prop="userNo">
|
||||
<el-input
|
||||
v-model="queryParams.userNo"
|
||||
placeholder="请输入人员编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="班组" prop="classGroup">
|
||||
<el-select
|
||||
v-model="queryParams.classGroup"
|
||||
placeholder="请选择班组"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.TEAM_OR_GROUP)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<el-select
|
||||
v-model="queryParams.enabledStatus"
|
||||
placeholder="请选择状态(1启用 2 未启用)"
|
||||
placeholder="请选择状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
@ -23,23 +47,6 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="人员账号" prop="userNo">
|
||||
<el-input
|
||||
v-model="queryParams.userNo"
|
||||
placeholder="请输入人员账号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="班组(甲 乙 丙 丁)" prop="classGroup">
|
||||
<el-input
|
||||
v-model="queryParams.classGroup"
|
||||
placeholder="请输入班组(甲 乙 丙 丁)"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
@ -52,44 +59,30 @@
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['biz:user-machine:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="自增字段" align="center" prop="id" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="状态(1启用 2 未启用)" align="center" prop="enabledStatus">
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" @row-click="handleRowClick" :row-class-name="({ row }) => row.id === selectedRowId ? 'table-row-active' : ''">
|
||||
<el-table-column label="序号" align="center" type="index" width="60px" />
|
||||
<el-table-column label="人员名称" align="center" prop="userName" />
|
||||
<el-table-column label="人员编码" align="center" prop="userNo" />
|
||||
<el-table-column label="所属班组" align="center" prop="classGroup">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.TEAM_OR_GROUP" :value="scope.row.classGroup" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="启用状态" align="center" prop="enabledStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_STATUS" :value="scope.row.enabledStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="人员id" align="center" prop="userId" />
|
||||
<el-table-column label="人员名称" align="center" prop="userName" />
|
||||
<el-table-column label="人员账号" align="center" prop="userNo" />
|
||||
<el-table-column label="班组(甲 乙 丙 丁)" align="center" prop="classGroup">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.TEAM_OR_GROUP" :value="scope.row.classGroup" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建人" align="center" prop="creator" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter2" width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
@ -100,14 +93,14 @@
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
<!-- <el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['biz:user-machine:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -120,14 +113,25 @@
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 机台信息列表 -->
|
||||
<ContentWrap>
|
||||
<div class="font-weight-600 mb-15px">机台信息</div>
|
||||
<el-table v-loading="machineLoading" :data="machineList" :show-overflow-tooltip="true" :stripe="true">
|
||||
<el-table-column label="序号" align="center" type="index" width="60px" />
|
||||
<el-table-column label="机台编码" align="center" prop="machineCd" />
|
||||
<el-table-column label="机台名称" align="center" prop="machineName" />
|
||||
<el-table-column label="创建人" align="center" prop="creator" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter2" />
|
||||
</el-table>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<UserMachineForm ref="formRef" @success="getList" />
|
||||
<UserMachineForm ref="formRef" @success="getList" @close="handleQuery" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
import * as UserMachineApi from '@/api/biz/usermachine'
|
||||
import UserMachineForm from './UserMachineForm.vue'
|
||||
|
||||
@ -149,6 +153,11 @@ const queryParams = reactive({
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
// 机台信息
|
||||
const machineLoading = ref(false)
|
||||
const machineList = ref([])
|
||||
const selectedRowId = ref(undefined)
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
@ -156,11 +165,36 @@ const getList = async () => {
|
||||
const data = await UserMachineApi.getUserMachinePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
// 默认选择第一条数据
|
||||
if (list.value.length > 0) {
|
||||
await getMachineList(list.value[0].id)
|
||||
} else {
|
||||
// 搜索结果为空时,清空机台列表
|
||||
machineList.value = []
|
||||
selectedRowId.value = undefined
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询机台列表 */
|
||||
const getMachineList = async (id: number) => {
|
||||
machineLoading.value = true
|
||||
try {
|
||||
const data = await UserMachineApi.getUserMachine(id)
|
||||
machineList.value = data.machineList || []
|
||||
selectedRowId.value = id
|
||||
} finally {
|
||||
machineLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 行点击事件 */
|
||||
const handleRowClick = (row: any) => {
|
||||
getMachineList(row.id)
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
@ -192,23 +226,14 @@ const handleDelete = async (id: number) => {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await UserMachineApi.exportUserMachine(queryParams)
|
||||
download.excel(data, '人员所属机台、班组配置.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.table-row-active {
|
||||
background-color: #e8f4ff !important;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user