烘胶房及烘胶分类新增
This commit is contained in:
@@ -1180,3 +1180,42 @@ jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/components/CollectModal.vue
|
||||
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/mcsSyncConfig.api.ts
|
||||
jeecgboot-vue3/src/views/xslmesMcs/mcsSyncConfig/mcsSyncConfig.data.ts
|
||||
-- author:GHT---date:20260617--for: 【MES上辅机】采集模式:全量/时间/增量 + 批量增量写入(应对大表) ---
|
||||
|
||||
-- author:jiangxh---date:20260702--for: 【MES】烘胶房管理(MES基础资料,无导入导出) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDryingRoom.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslDryingRoomMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslDryingRoomService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslDryingRoomServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDryingRoomController.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_159__mes_xsl_drying_room.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoom/MesXslDryingRoomList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoom/MesXslDryingRoom.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoom/MesXslDryingRoom.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoom/components/MesXslDryingRoomModal.vue
|
||||
-- author:jiangxh---date:20260702--for: 【MES】烘胶房管理(MES基础资料,无导入导出) ---
|
||||
|
||||
-- author:jiangxh---date:20260702--for: 【MES】烘胶分类管理(主子表+选择物料弹窗,无导入导出) ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDryingCategory.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDryingCategoryMaterial.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslDryingCategoryMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslDryingCategoryMaterialMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslDryingCategoryService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslDryingCategoryServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDryingCategoryController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/vo/MesXslDryingCategoryPage.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_160__mes_xsl_drying_category.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/MesXslDryingCategoryList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/MesXslDryingCategory.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/MesXslDryingCategory.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/components/MesXslDryingCategoryModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/components/MesXslDryingCategoryMixerMaterialSelectModal.vue
|
||||
-- author:jiangxh---date:20260702--for: 【MES】烘胶分类管理(主子表+选择物料弹窗,无导入导出) ---
|
||||
|
||||
-- author:jiangxh---date:20260702--for: 【MES】烘胶分类管理补充导出功能 ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDryingCategory.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDryingCategoryController.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_160__mes_xsl_drying_category.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_161__mes_xsl_drying_category_export.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/MesXslDryingCategoryList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingCategory/MesXslDryingCategory.api.ts
|
||||
-- author:jiangxh---date:20260702--for: 【MES】烘胶分类管理补充导出功能 ---
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
|
||||
import org.jeecg.modules.mes.material.service.IMesMixerMaterialService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategoryMaterial;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDryingCategoryService;
|
||||
import org.jeecg.modules.xslmes.vo.MesXslDryingCategoryPage;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* MES 烘胶分类管理(主子表)
|
||||
*/
|
||||
@Tag(name = "MES烘胶分类管理")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslDryingCategory")
|
||||
@Slf4j
|
||||
public class MesXslDryingCategoryController
|
||||
extends JeecgController<MesXslDryingCategory, IMesXslDryingCategoryService> {
|
||||
|
||||
/** 母炼胶、终炼胶、塑炼胶(塑料胶)大类 id,见 V3.9.2_35__mes_xsl_material_category_tree.sql */
|
||||
private static final Set<String> ALLOWED_MAJOR_CATEGORY_IDS =
|
||||
Set.of("1993000000000000104", "1993000000000000105", "1993000000000000103");
|
||||
|
||||
@Autowired
|
||||
private IMesXslDryingCategoryService mesXslDryingCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesMixerMaterialService mesMixerMaterialService;
|
||||
|
||||
@Operation(summary = "MES烘胶分类管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslDryingCategory>> queryPageList(
|
||||
MesXslDryingCategory model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslDryingCategory> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
Page<MesXslDryingCategory> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslDryingCategory> pageList = mesXslDryingCategoryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶分类管理-添加")
|
||||
@Operation(summary = "MES烘胶分类管理-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_category:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslDryingCategoryPage page) {
|
||||
MesXslDryingCategory main = new MesXslDryingCategory();
|
||||
BeanUtils.copyProperties(page, main);
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶分类保存校验:名称唯一、明细物料大类限制-----------
|
||||
String err = validateForSave(main, page.getMaterialList(), null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶分类保存校验:名称唯一、明细物料大类限制-----------
|
||||
mesXslDryingCategoryService.saveMain(main, page.getMaterialList());
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶分类管理-编辑")
|
||||
@Operation(summary = "MES烘胶分类管理-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_category:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslDryingCategoryPage page) {
|
||||
MesXslDryingCategory main = new MesXslDryingCategory();
|
||||
BeanUtils.copyProperties(page, main);
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶分类保存校验:名称唯一、明细物料大类限制-----------
|
||||
String err = validateForSave(main, page.getMaterialList(), main.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶分类保存校验:名称唯一、明细物料大类限制-----------
|
||||
mesXslDryingCategoryService.updateMain(main, page.getMaterialList());
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶分类管理-删除")
|
||||
@Operation(summary = "MES烘胶分类管理-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_category:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslDryingCategoryService.delMain(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶分类管理-批量删除")
|
||||
@Operation(summary = "MES烘胶分类管理-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_category:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslDryingCategoryService.delBatchMain(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES烘胶分类管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslDryingCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslDryingCategory entity = mesXslDryingCategoryService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "MES烘胶分类管理-查询物料明细")
|
||||
@GetMapping(value = "/queryMaterialListByCategoryId")
|
||||
public Result<List<MesXslDryingCategoryMaterial>> queryMaterialListByCategoryId(
|
||||
@RequestParam(name = "id", required = true) String id) {
|
||||
return Result.OK(mesXslDryingCategoryService.selectMaterialsByCategoryId(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "校验分类名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkCategoryName")
|
||||
public Result<String> checkCategoryName(
|
||||
@RequestParam(name = "categoryName", required = true) String categoryName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(categoryName) || categoryName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslDryingCategory ctx = new MesXslDryingCategory();
|
||||
if (mesXslDryingCategoryService.isCategoryNameDuplicated(categoryName.trim(), dataId, ctx)) {
|
||||
return Result.error("分类名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_drying_category:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslDryingCategory model) {
|
||||
return super.exportXls(request, model, MesXslDryingCategory.class, "烘胶分类管理");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES烘胶分类-可选密炼物料分页(大类:母炼胶/终炼胶/塑炼胶)")
|
||||
@GetMapping(value = "/listSelectableMixerMaterials")
|
||||
public Result<IPage<MesMixerMaterial>> listSelectableMixerMaterials(
|
||||
MesMixerMaterial model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesMixerMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.in("major_category_id", ALLOWED_MAJOR_CATEGORY_IDS);
|
||||
queryWrapper.and(
|
||||
q -> q.eq("del_flag", CommonConstant.DEL_FLAG_0).or().isNull("del_flag"));
|
||||
queryWrapper.orderByAsc("material_code");
|
||||
Page<MesMixerMaterial> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesMixerMaterial> pageList = mesMixerMaterialService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶分类保存前校验:名称唯一、明细物料不重复且大类受限-----------
|
||||
private String validateForSave(
|
||||
MesXslDryingCategory main, List<MesXslDryingCategoryMaterial> materialList, String excludeId) {
|
||||
if (main == null) {
|
||||
return "参数不能为空";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(main.getCategoryName()) || main.getCategoryName().trim().isEmpty()) {
|
||||
return "分类名称不能为空";
|
||||
}
|
||||
String categoryName = main.getCategoryName().trim();
|
||||
main.setCategoryName(categoryName);
|
||||
if (mesXslDryingCategoryService.isCategoryNameDuplicated(categoryName, excludeId, main)) {
|
||||
return "分类名称不能重复";
|
||||
}
|
||||
if (materialList == null || materialList.isEmpty()) {
|
||||
return "请通过「选择物料」至少添加一条明细";
|
||||
}
|
||||
Set<String> materialIds = new HashSet<>();
|
||||
int sort = 0;
|
||||
for (int i = 0; i < materialList.size(); i++) {
|
||||
MesXslDryingCategoryMaterial line = materialList.get(i);
|
||||
if (line == null) {
|
||||
continue;
|
||||
}
|
||||
int rowNo = i + 1;
|
||||
if (oConvertUtils.isEmpty(line.getMixerMaterialId())) {
|
||||
return "第 " + rowNo + " 行未选择物料";
|
||||
}
|
||||
String materialId = line.getMixerMaterialId().trim();
|
||||
if (!materialIds.add(materialId)) {
|
||||
return "第 " + rowNo + " 行物料与前面行重复,同一分类中物料不能重复";
|
||||
}
|
||||
MesMixerMaterial material = mesMixerMaterialService.getById(materialId);
|
||||
if (material == null || isDeleted(material.getDelFlag())) {
|
||||
return "第 " + rowNo + " 行物料不存在或已删除";
|
||||
}
|
||||
String majorId = material.getMajorCategoryId();
|
||||
if (oConvertUtils.isEmpty(majorId) || !ALLOWED_MAJOR_CATEGORY_IDS.contains(majorId.trim())) {
|
||||
return "第 " + rowNo + " 行物料大类不在允许范围(母炼胶/终炼胶/塑炼胶)";
|
||||
}
|
||||
line.setMixerMaterialId(materialId);
|
||||
line.setMaterialCode(material.getMaterialCode());
|
||||
line.setMaterialName(material.getMaterialName());
|
||||
line.setMaterialDesc(material.getMaterialDesc());
|
||||
line.setSortNo(sort++);
|
||||
}
|
||||
if (materialIds.isEmpty()) {
|
||||
return "请通过「选择物料」至少添加一条明细";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isDeleted(Integer delFlag) {
|
||||
return delFlag != null && delFlag.equals(CommonConstant.DEL_FLAG_1);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶分类保存前校验:名称唯一、明细物料不重复且大类受限-----------
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingRoom;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDryingRoomService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* MES 烘胶房管理
|
||||
*/
|
||||
@Tag(name = "MES烘胶房管理")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslDryingRoom")
|
||||
@Slf4j
|
||||
public class MesXslDryingRoomController extends JeecgController<MesXslDryingRoom, IMesXslDryingRoomService> {
|
||||
|
||||
private static final Pattern MONTH_DAY_PATTERN = Pattern.compile("^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$");
|
||||
|
||||
@Autowired
|
||||
private IMesXslDryingRoomService mesXslDryingRoomService;
|
||||
|
||||
@Operation(summary = "MES烘胶房管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslDryingRoom>> queryPageList(
|
||||
MesXslDryingRoom model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslDryingRoom> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslDryingRoom> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslDryingRoom> pageList = mesXslDryingRoomService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶房管理-添加")
|
||||
@Operation(summary = "MES烘胶房管理-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_room:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslDryingRoom model) {
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶房保存前校验:编码/名称唯一、月日格式-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶房保存前校验:编码/名称唯一、月日格式-----------
|
||||
mesXslDryingRoomService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶房管理-编辑")
|
||||
@Operation(summary = "MES烘胶房管理-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_room:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslDryingRoom model) {
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶房保存前校验:编码/名称唯一、月日格式-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶房保存前校验:编码/名称唯一、月日格式-----------
|
||||
mesXslDryingRoomService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶房管理-删除")
|
||||
@Operation(summary = "MES烘胶房管理-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_room:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslDryingRoomService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES烘胶房管理-批量删除")
|
||||
@Operation(summary = "MES烘胶房管理-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_drying_room:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslDryingRoomService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES烘胶房管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslDryingRoom> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslDryingRoom entity = mesXslDryingRoomService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验烘胶房编码是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkRoomCode")
|
||||
public Result<String> checkRoomCode(
|
||||
@RequestParam(name = "roomCode", required = true) String roomCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(roomCode) || roomCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslDryingRoom ctx = new MesXslDryingRoom();
|
||||
if (mesXslDryingRoomService.isRoomCodeDuplicated(roomCode.trim(), dataId, ctx)) {
|
||||
return Result.error("烘胶房编码不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@Operation(summary = "校验烘胶房名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkRoomName")
|
||||
public Result<String> checkRoomName(
|
||||
@RequestParam(name = "roomName", required = true) String roomName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(roomName) || roomName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslDryingRoom ctx = new MesXslDryingRoom();
|
||||
if (mesXslDryingRoomService.isRoomNameDuplicated(roomName.trim(), dataId, ctx)) {
|
||||
return Result.error("烘胶房名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶房保存前校验-----------
|
||||
private String validateForSave(MesXslDryingRoom model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getRoomCode()) || model.getRoomCode().trim().isEmpty()) {
|
||||
return "烘胶房编码不能为空";
|
||||
}
|
||||
String roomCode = model.getRoomCode().trim();
|
||||
model.setRoomCode(roomCode);
|
||||
if (mesXslDryingRoomService.isRoomCodeDuplicated(roomCode, excludeId, model)) {
|
||||
return "烘胶房编码不能重复";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getRoomName()) || model.getRoomName().trim().isEmpty()) {
|
||||
return "烘胶房名称不能为空";
|
||||
}
|
||||
String roomName = model.getRoomName().trim();
|
||||
model.setRoomName(roomName);
|
||||
if (mesXslDryingRoomService.isRoomNameDuplicated(roomName, excludeId, model)) {
|
||||
return "烘胶房名称不能重复";
|
||||
}
|
||||
String startMd = normalizeMonthDay(model.getDryingStartMd(), "烘胶开始日期");
|
||||
if (startMd == null) {
|
||||
return "烘胶开始日期格式无效,须为 MM-DD";
|
||||
}
|
||||
model.setDryingStartMd(startMd);
|
||||
String endMd = normalizeMonthDay(model.getDryingEndMd(), "烘胶结束日期");
|
||||
if (endMd == null) {
|
||||
return "烘胶结束日期格式无效,须为 MM-DD";
|
||||
}
|
||||
model.setDryingEndMd(endMd);
|
||||
return null;
|
||||
}
|
||||
|
||||
private String normalizeMonthDay(String value, String fieldLabel) {
|
||||
if (oConvertUtils.isEmpty(value) || value.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String md = value.trim();
|
||||
if (md.length() >= 10 && md.charAt(4) == '-') {
|
||||
md = md.substring(5, 10);
|
||||
}
|
||||
if (!MONTH_DAY_PATTERN.matcher(md).matches()) {
|
||||
log.warn("{}格式无效: {}", fieldLabel, value);
|
||||
return null;
|
||||
}
|
||||
return md;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶房保存前校验-----------
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 烘胶分类管理主表(表 mes_xsl_drying_category)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_drying_category")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES烘胶分类管理")
|
||||
public class MesXslDryingCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "分类名称", width = 24)
|
||||
@Schema(description = "分类名称(同租户未删除数据中唯一)")
|
||||
private String categoryName;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
@Excel(name = "创建人", width = 15)
|
||||
private String createBy;
|
||||
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "物料明细")
|
||||
private List<MesXslDryingCategoryMaterial> materialList;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 烘胶分类物料明细(表 mes_xsl_drying_category_material)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_drying_category_material")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES烘胶分类物料明细")
|
||||
public class MesXslDryingCategoryMaterial implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "主表主键 mes_xsl_drying_category.id")
|
||||
private String dryingCategoryId;
|
||||
|
||||
@Schema(description = "密炼物料主键 mes_mixer_material.id")
|
||||
private String mixerMaterialId;
|
||||
|
||||
@Schema(description = "物料编码冗余")
|
||||
private String materialCode;
|
||||
|
||||
@Schema(description = "物料名称冗余")
|
||||
private String materialName;
|
||||
|
||||
@Schema(description = "物料描述冗余")
|
||||
private String materialDesc;
|
||||
|
||||
private Integer sortNo;
|
||||
private String createBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 烘胶房管理(表 mes_xsl_drying_room)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_drying_room")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES烘胶房管理")
|
||||
public class MesXslDryingRoom implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "烘胶房编码(同租户未删除数据中唯一)")
|
||||
private String roomCode;
|
||||
|
||||
@Schema(description = "烘胶房名称(同租户未删除数据中唯一)")
|
||||
private String roomName;
|
||||
|
||||
@Schema(description = "烘胶开始日期(月日,格式 MM-DD,不含年份)")
|
||||
private String dryingStartMd;
|
||||
|
||||
@Schema(description = "烘胶结束日期(月日,格式 MM-DD,不含年份)")
|
||||
private String dryingEndMd;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategory;
|
||||
|
||||
/**
|
||||
* MES 烘胶分类管理
|
||||
*/
|
||||
public interface MesXslDryingCategoryMapper extends BaseMapper<MesXslDryingCategory> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategoryMaterial;
|
||||
|
||||
/**
|
||||
* MES 烘胶分类物料明细
|
||||
*/
|
||||
public interface MesXslDryingCategoryMaterialMapper extends BaseMapper<MesXslDryingCategoryMaterial> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingRoom;
|
||||
|
||||
/**
|
||||
* MES 烘胶房管理
|
||||
*/
|
||||
public interface MesXslDryingRoomMapper extends BaseMapper<MesXslDryingRoom> {}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategoryMaterial;
|
||||
|
||||
public interface IMesXslDryingCategoryService extends IService<MesXslDryingCategory> {
|
||||
|
||||
void saveMain(MesXslDryingCategory main, List<MesXslDryingCategoryMaterial> materialList);
|
||||
|
||||
void updateMain(MesXslDryingCategory main, List<MesXslDryingCategoryMaterial> materialList);
|
||||
|
||||
void delMain(String id);
|
||||
|
||||
void delBatchMain(Collection<? extends Serializable> idList);
|
||||
|
||||
List<MesXslDryingCategoryMaterial> selectMaterialsByCategoryId(String categoryId);
|
||||
|
||||
boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslDryingCategory context);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingRoom;
|
||||
|
||||
public interface IMesXslDryingRoomService extends IService<MesXslDryingRoom> {
|
||||
|
||||
/**
|
||||
* 烘胶房编码是否已被占用(仅统计未删除:del_flag 为 0 或 null)。
|
||||
*/
|
||||
boolean isRoomCodeDuplicated(String roomCode, String excludeId, MesXslDryingRoom context);
|
||||
|
||||
/**
|
||||
* 烘胶房名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。
|
||||
*/
|
||||
boolean isRoomNameDuplicated(String roomName, String excludeId, MesXslDryingRoom context);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.common.MesXslTenantUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategoryMaterial;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslDryingCategoryMapper;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslDryingCategoryMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDryingCategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Service
|
||||
public class MesXslDryingCategoryServiceImpl extends ServiceImpl<MesXslDryingCategoryMapper, MesXslDryingCategory>
|
||||
implements IMesXslDryingCategoryService {
|
||||
|
||||
@Autowired
|
||||
private MesXslDryingCategoryMaterialMapper mesXslDryingCategoryMaterialMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveMain(MesXslDryingCategory main, List<MesXslDryingCategoryMaterial> materialList) {
|
||||
this.save(main);
|
||||
insertMaterials(main.getId(), materialList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateMain(MesXslDryingCategory main, List<MesXslDryingCategoryMaterial> materialList) {
|
||||
this.updateById(main);
|
||||
mesXslDryingCategoryMaterialMapper.delete(
|
||||
new LambdaQueryWrapper<MesXslDryingCategoryMaterial>()
|
||||
.eq(MesXslDryingCategoryMaterial::getDryingCategoryId, main.getId()));
|
||||
insertMaterials(main.getId(), materialList);
|
||||
}
|
||||
|
||||
private void insertMaterials(String categoryId, List<MesXslDryingCategoryMaterial> materialList) {
|
||||
if (CollectionUtils.isEmpty(materialList)) {
|
||||
return;
|
||||
}
|
||||
int sort = 0;
|
||||
for (MesXslDryingCategoryMaterial line : materialList) {
|
||||
line.setId(null);
|
||||
line.setDryingCategoryId(categoryId);
|
||||
line.setSortNo(sort++);
|
||||
mesXslDryingCategoryMaterialMapper.insert(line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delMain(String id) {
|
||||
mesXslDryingCategoryMaterialMapper.delete(
|
||||
new LambdaQueryWrapper<MesXslDryingCategoryMaterial>()
|
||||
.eq(MesXslDryingCategoryMaterial::getDryingCategoryId, id));
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delBatchMain(Collection<? extends Serializable> idList) {
|
||||
for (Serializable id : idList) {
|
||||
delMain(id.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesXslDryingCategoryMaterial> selectMaterialsByCategoryId(String categoryId) {
|
||||
return mesXslDryingCategoryMaterialMapper.selectList(
|
||||
new LambdaQueryWrapper<MesXslDryingCategoryMaterial>()
|
||||
.eq(MesXslDryingCategoryMaterial::getDryingCategoryId, categoryId)
|
||||
.orderByAsc(MesXslDryingCategoryMaterial::getSortNo));
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶分类名称同租户不可重复;仅统计未删除-----------
|
||||
@Override
|
||||
public boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslDryingCategory context) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = MesXslTenantUtils.resolveTenantId(context != null ? context.getTenantId() : null);
|
||||
LambdaQueryWrapper<MesXslDryingCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslDryingCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslDryingCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslDryingCategory::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslDryingCategory::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslDryingCategory::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶分类名称同租户不可重复;仅统计未删除-----------
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.common.MesXslTenantUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingRoom;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslDryingRoomMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDryingRoomService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslDryingRoomServiceImpl extends ServiceImpl<MesXslDryingRoomMapper, MesXslDryingRoom>
|
||||
implements IMesXslDryingRoomService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260702 for:【MES】烘胶房编码/名称同租户不可重复;仅统计未删除-----------
|
||||
@Override
|
||||
public boolean isRoomCodeDuplicated(String roomCode, String excludeId, MesXslDryingRoom context) {
|
||||
return isFieldDuplicated(MesXslDryingRoom::getRoomCode, roomCode, excludeId, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRoomNameDuplicated(String roomName, String excludeId, MesXslDryingRoom context) {
|
||||
return isFieldDuplicated(MesXslDryingRoom::getRoomName, roomName, excludeId, context);
|
||||
}
|
||||
|
||||
private boolean isFieldDuplicated(
|
||||
com.baomidou.mybatisplus.core.toolkit.support.SFunction<MesXslDryingRoom, String> fieldGetter,
|
||||
String fieldValue,
|
||||
String excludeId,
|
||||
MesXslDryingRoom context) {
|
||||
if (oConvertUtils.isEmpty(fieldValue)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = MesXslTenantUtils.resolveTenantId(context != null ? context.getTenantId() : null);
|
||||
LambdaQueryWrapper<MesXslDryingRoom> w = new LambdaQueryWrapper<>();
|
||||
w.eq(fieldGetter, fieldValue.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslDryingRoom::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslDryingRoom::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslDryingRoom::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslDryingRoom::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260702 for:【MES】烘胶房编码/名称同租户不可重复;仅统计未删除-----------
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDryingCategory;
|
||||
|
||||
/**
|
||||
* 烘胶分类主子保存页 VO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MesXslDryingCategoryPage extends MesXslDryingCategory {}
|
||||
@@ -0,0 +1,63 @@
|
||||
-- MES 烘胶房管理:建表 + 菜单 + 按钮 + 租户 admin 授权(无导入导出)
|
||||
-- 权限前缀:mes:mes_xsl_drying_room:*;父菜单 MES基础资料 / MES资料
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_drying_room` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`room_code` varchar(50) NOT NULL COMMENT '烘胶房编码(同租户未删除数据中唯一)',
|
||||
`room_name` varchar(100) NOT NULL COMMENT '烘胶房名称(同租户未删除数据中唯一)',
|
||||
`drying_start_md` varchar(5) NOT NULL COMMENT '烘胶开始日期(月日,格式 MM-DD,不含年份)',
|
||||
`drying_end_md` varchar(5) NOT NULL COMMENT '烘胶结束日期(月日,格式 MM-DD,不含年份)',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_mxdr_tenant_code` (`tenant_id`, `room_code`),
|
||||
KEY `idx_mxdr_tenant_name` (`tenant_id`, `room_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES烘胶房管理';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_base_pid = (
|
||||
SELECT MIN(`id`) FROM `sys_permission`
|
||||
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
|
||||
);
|
||||
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
|
||||
VALUES ('1860000000000000230', @mes_base_pid, '烘胶房管理', '/xslmes/mesXslDryingRoom', 'xslmes/mesXslDryingRoom/MesXslDryingRoomList', 'MesXslDryingRoomList', 1, NULL, '1', 18, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
|
||||
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
|
||||
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
|
||||
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
|
||||
|
||||
UPDATE `sys_permission` SET `icon` = 'ant-design:home-outlined' WHERE `id` = '1860000000000000230' AND `del_flag` = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000231', '1860000000000000230', '新增', 2, 'mes:mes_xsl_drying_room:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000232', '1860000000000000230', '编辑', 2, 'mes:mes_xsl_drying_room:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000233', '1860000000000000230', '删除', 2, 'mes:mes_xsl_drying_room:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000234', '1860000000000000230', '批量删除', 2, 'mes:mes_xsl_drying_room:deleteBatch', '1', '1', 0, 'admin', NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
|
||||
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
|
||||
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
|
||||
FROM `sys_role` r
|
||||
CROSS JOIN `sys_permission` p
|
||||
WHERE r.`tenant_id` = @mes_tenant_id
|
||||
AND r.`role_code` = 'admin'
|
||||
AND p.`id` IN (
|
||||
'1860000000000000230',
|
||||
'1860000000000000231', '1860000000000000232', '1860000000000000233', '1860000000000000234'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,78 @@
|
||||
-- MES 烘胶分类管理:建表 + 菜单 + 按钮 + 租户 admin 授权(含导出,无导入)
|
||||
-- 权限前缀:mes:mes_xsl_drying_category:*;父菜单 MES基础资料 / MES资料
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_drying_category` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`category_name` varchar(100) NOT NULL COMMENT '分类名称(同租户未删除数据中唯一)',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_mxdc_tenant_name` (`tenant_id`, `category_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES烘胶分类管理';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_drying_category_material` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`drying_category_id` varchar(32) NOT NULL COMMENT '主表主键 mes_xsl_drying_category.id',
|
||||
`mixer_material_id` varchar(32) NOT NULL COMMENT '密炼物料主键 mes_mixer_material.id',
|
||||
`material_code` varchar(64) DEFAULT NULL COMMENT '物料编码冗余',
|
||||
`material_name` varchar(128) DEFAULT NULL COMMENT '物料名称冗余',
|
||||
`material_desc` varchar(512) DEFAULT NULL COMMENT '物料描述冗余',
|
||||
`sort_no` int DEFAULT NULL COMMENT '排序号',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_mxdcm_category` (`drying_category_id`),
|
||||
KEY `idx_mxdcm_material` (`mixer_material_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES烘胶分类物料明细';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_base_pid = (
|
||||
SELECT MIN(`id`) FROM `sys_permission`
|
||||
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
|
||||
);
|
||||
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
|
||||
VALUES ('1860000000000000240', @mes_base_pid, '烘胶分类管理', '/xslmes/mesXslDryingCategory', 'xslmes/mesXslDryingCategory/MesXslDryingCategoryList', 'MesXslDryingCategoryList', 1, NULL, '1', 19, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
|
||||
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
|
||||
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
|
||||
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
|
||||
|
||||
UPDATE `sys_permission` SET `icon` = 'ant-design:appstore-outlined' WHERE `id` = '1860000000000000240' AND `del_flag` = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000241', '1860000000000000240', '新增', 2, 'mes:mes_xsl_drying_category:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000242', '1860000000000000240', '编辑', 2, 'mes:mes_xsl_drying_category:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000243', '1860000000000000240', '删除', 2, 'mes:mes_xsl_drying_category:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000244', '1860000000000000240', '批量删除', 2, 'mes:mes_xsl_drying_category:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000245', '1860000000000000240', '导出', 2, 'mes:mes_xsl_drying_category:exportXls', '1', '1', 0, 'admin', NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
|
||||
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
|
||||
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
|
||||
FROM `sys_role` r
|
||||
CROSS JOIN `sys_permission` p
|
||||
WHERE r.`tenant_id` = @mes_tenant_id
|
||||
AND r.`role_code` = 'admin'
|
||||
AND p.`id` IN (
|
||||
'1860000000000000240',
|
||||
'1860000000000000241', '1860000000000000242', '1860000000000000243', '1860000000000000244',
|
||||
'1860000000000000245'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,22 @@
|
||||
-- MES 烘胶分类管理:补充导出按钮权限 + 租户 admin 授权
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000245', '1860000000000000240', '导出', 2, 'mes:mes_xsl_drying_category:exportXls', '1', '1', 0, 'admin', NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
|
||||
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
|
||||
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
|
||||
FROM `sys_role` r
|
||||
CROSS JOIN `sys_permission` p
|
||||
WHERE r.`tenant_id` = @mes_tenant_id
|
||||
AND r.`role_code` = 'admin'
|
||||
AND p.`id` = '1860000000000000245'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,64 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslDryingCategory/list',
|
||||
checkCategoryName = '/xslmes/mesXslDryingCategory/checkCategoryName',
|
||||
save = '/xslmes/mesXslDryingCategory/add',
|
||||
edit = '/xslmes/mesXslDryingCategory/edit',
|
||||
deleteOne = '/xslmes/mesXslDryingCategory/delete',
|
||||
deleteBatch = '/xslmes/mesXslDryingCategory/deleteBatch',
|
||||
queryById = '/xslmes/mesXslDryingCategory/queryById',
|
||||
queryMaterialList = '/xslmes/mesXslDryingCategory/queryMaterialListByCategoryId',
|
||||
listSelectableMixerMaterials = '/xslmes/mesXslDryingCategory/listSelectableMixerMaterials',
|
||||
exportXls = '/xslmes/mesXslDryingCategory/exportXls',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
|
||||
|
||||
export const queryMaterialListByCategoryId = (params: { id: string }) =>
|
||||
defHttp.get({ url: Api.queryMaterialList, params });
|
||||
|
||||
export const listSelectableMixerMaterials = (params) =>
|
||||
defHttp.get({ url: Api.listSelectableMixerMaterials, params });
|
||||
|
||||
export const checkCategoryName = (params: { categoryName: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkCategoryName, params },
|
||||
{
|
||||
successMessageMode: 'none',
|
||||
errorMessageMode: 'none',
|
||||
},
|
||||
);
|
||||
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
};
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
const url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url, params });
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
||||
import { checkCategoryName } from './MesXslDryingCategory.api';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '分类名称', align: 'center', dataIndex: 'categoryName', width: 200 },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '分类名称', field: 'categoryName', component: 'JInput', colProps: { span: 6 } },
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '分类名称',
|
||||
field: 'categoryName',
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入分类名称' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
try {
|
||||
await checkCategoryName({ categoryName: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.message || e?.message || '分类名称不能重复';
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const materialJVxeColumns: JVxeColumn[] = [
|
||||
{ title: '', key: 'mixerMaterialId', type: JVxeTypes.hidden },
|
||||
{ title: '物料编码', key: 'materialCode', type: JVxeTypes.normal, width: 140, disabled: true },
|
||||
{ title: '物料名称', key: 'materialName', type: JVxeTypes.normal, width: 180, disabled: true },
|
||||
{ title: '物料描述', key: 'materialDesc', type: JVxeTypes.normal, width: 260, disabled: true },
|
||||
];
|
||||
|
||||
/** 物料明细操作列(编辑/新增时展示) */
|
||||
export const materialActionColumn: JVxeColumn = {
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
type: JVxeTypes.slot,
|
||||
fixed: 'right',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
slotName: 'materialActionSlot',
|
||||
};
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_drying_category:add'"
|
||||
@click="handleAdd"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
>
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_drying_category:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button v-auth="'mes:mes_xsl_drying_category:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_drying_category:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslDryingCategoryModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslDryingCategory" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslDryingCategoryModal from './components/MesXslDryingCategoryModal.vue';
|
||||
import { reactive } from 'vue';
|
||||
import { columns, searchFormSchema } from './MesXslDryingCategory.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl } from './MesXslDryingCategory.api';
|
||||
|
||||
const queryParam = reactive<any>({});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '烘胶分类管理',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 100,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { customRender: 'action' },
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '烘胶分类管理',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||
}
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
selectedRowKeys.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_xsl_drying_category:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" :title="modalTitle" :width="1000" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { listSelectableMixerMaterials } from '../MesXslDryingCategory.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const multipleMode = ref(true);
|
||||
const selectedRows = ref<Recordable[]>([]);
|
||||
|
||||
const modalTitle = computed(() =>
|
||||
multipleMode.value ? '选择物料(母炼胶/终炼胶/塑炼胶,可多选)' : '选择物料(母炼胶/终炼胶/塑炼胶)',
|
||||
);
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRows.value = rows || [];
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
|
||||
api: listSelectableMixerMaterials,
|
||||
columns: [
|
||||
{ title: '物料编码', dataIndex: 'materialCode', width: 130 },
|
||||
{ title: '物料名称', dataIndex: 'materialName', width: 160 },
|
||||
{ title: '物料大类', dataIndex: 'majorCategoryId_dictText', width: 100 },
|
||||
{ title: '物料小类', dataIndex: 'minorCategoryId_dictText', width: 100 },
|
||||
{ title: '物料描述', dataIndex: 'materialDesc', width: 220, ellipsis: true },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '物料编码', field: 'materialCode', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '物料名称', field: 'materialName', component: 'Input', colProps: { span: 8 } },
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
columnWidth: 48,
|
||||
onChange: handleSelectionChange,
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
multipleMode.value = data?.multiple !== false;
|
||||
selectedRows.value = [];
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
let rows = selectedRows.value?.length ? [...selectedRows.value] : ((getSelectRows?.() || []) as Recordable[]);
|
||||
const valid = rows.filter((r) => r?.id && (r.materialCode != null || r.materialName != null));
|
||||
if (!valid.length) {
|
||||
createMessage.warning('请至少选择一条物料');
|
||||
return;
|
||||
}
|
||||
if (multipleMode.value) {
|
||||
emit('select', valid);
|
||||
} else {
|
||||
emit('select', valid[0]);
|
||||
}
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
width="960px"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm" />
|
||||
<a-divider orientation="left">物料明细</a-divider>
|
||||
<JVxeTable
|
||||
v-if="tableReady"
|
||||
ref="materialTableRef"
|
||||
toolbar
|
||||
row-number
|
||||
keep-source
|
||||
:insert-row="false"
|
||||
:max-height="380"
|
||||
:loading="materialLoading"
|
||||
:columns="materialColumns"
|
||||
:dataSource="materialDataSource"
|
||||
:disabled="!showFooterFlag"
|
||||
:toolbar-config="{ slots: ['suffix'] }"
|
||||
:add-btn-cfg="{ enabled: false }"
|
||||
>
|
||||
<template #toolbarSuffix>
|
||||
<a-button
|
||||
v-if="showFooterFlag"
|
||||
type="primary"
|
||||
preIcon="ant-design:select-outlined"
|
||||
@click="openMaterialSelect"
|
||||
>
|
||||
选择物料
|
||||
</a-button>
|
||||
</template>
|
||||
<template #materialActionSlot="slotProps">
|
||||
<Popconfirm v-if="showFooterFlag" title="确定删除该明细吗?" @confirm="handleRemoveRow(slotProps)">
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</template>
|
||||
</JVxeTable>
|
||||
<MesXslDryingCategoryMixerMaterialSelectModal @register="registerMaterialModal" @select="onMaterialsSelect" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { Popconfirm } from 'ant-design-vue';
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import type { JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { formSchema, materialJVxeColumns, materialActionColumn } from '../MesXslDryingCategory.data';
|
||||
import { saveOrUpdate, queryById, queryMaterialListByCategoryId } from '../MesXslDryingCategory.api';
|
||||
import MesXslDryingCategoryMixerMaterialSelectModal from './MesXslDryingCategoryMixerMaterialSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const isUpdate = ref(false);
|
||||
const isDetail = ref(false);
|
||||
const showFooterFlag = ref(true);
|
||||
const tableReady = ref(false);
|
||||
const materialLoading = ref(false);
|
||||
const materialDataSource = ref<Recordable[]>([]);
|
||||
const materialTableRef = ref<JVxeTableInstance>();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
const [registerMaterialModal, { openModal: openMaterialModal }] = useModal();
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
tableReady.value = false;
|
||||
materialDataSource.value = [];
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
showFooterFlag.value = !!data?.showFooter;
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
if (unref(isUpdate) && data?.record?.id) {
|
||||
materialLoading.value = true;
|
||||
try {
|
||||
const mainRaw = await queryById({ id: data.record.id });
|
||||
const m = (mainRaw as any)?.id != null ? mainRaw : (mainRaw as any)?.result ?? mainRaw;
|
||||
const linesRaw = await queryMaterialListByCategoryId({ id: data.record.id });
|
||||
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
|
||||
await setFieldsValue({ ...m });
|
||||
materialDataSource.value = [...(list || [])];
|
||||
} finally {
|
||||
materialLoading.value = false;
|
||||
}
|
||||
}
|
||||
tableReady.value = true;
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增烘胶分类' : unref(isDetail) ? '烘胶分类详情' : '编辑烘胶分类',
|
||||
);
|
||||
|
||||
const materialColumns = computed(() =>
|
||||
unref(showFooterFlag) ? [...materialJVxeColumns, materialActionColumn] : materialJVxeColumns,
|
||||
);
|
||||
|
||||
function materialToLineRow(item: Recordable) {
|
||||
return {
|
||||
mixerMaterialId: item.id,
|
||||
materialCode: item.materialCode || '',
|
||||
materialName: item.materialName || '',
|
||||
materialDesc: item.materialDesc || '',
|
||||
};
|
||||
}
|
||||
|
||||
function getExistingMaterialIds(): Set<string> {
|
||||
const tableRef = materialTableRef.value as any;
|
||||
const tableData = (tableRef?.getTableData?.() || materialDataSource.value || []) as Recordable[];
|
||||
const ids = new Set<string>();
|
||||
for (const r of tableData) {
|
||||
if (r?.mixerMaterialId) {
|
||||
ids.add(String(r.mixerMaterialId));
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
function openMaterialSelect() {
|
||||
openMaterialModal(true, { multiple: true });
|
||||
}
|
||||
|
||||
async function handleRemoveRow(slotProps: Recordable) {
|
||||
const tableRef = materialTableRef.value as any;
|
||||
if (!tableRef?.removeRows || !slotProps?.row) {
|
||||
return;
|
||||
}
|
||||
await tableRef.removeRows(slotProps.row);
|
||||
}
|
||||
|
||||
function onMaterialsSelect(payload: Recordable | Recordable[]) {
|
||||
const items = Array.isArray(payload) ? payload : payload ? [payload] : [];
|
||||
if (!items.length) {
|
||||
return;
|
||||
}
|
||||
const existing = getExistingMaterialIds();
|
||||
const toAdd: Recordable[] = [];
|
||||
const skipped: string[] = [];
|
||||
for (const item of items) {
|
||||
if (!item?.id) {
|
||||
continue;
|
||||
}
|
||||
const id = String(item.id);
|
||||
if (existing.has(id)) {
|
||||
skipped.push(item.materialName || item.materialCode || id);
|
||||
continue;
|
||||
}
|
||||
existing.add(id);
|
||||
toAdd.push(materialToLineRow(item));
|
||||
}
|
||||
if (!toAdd.length) {
|
||||
if (skipped.length) {
|
||||
createMessage.warning('所选物料均已在明细中,未添加新行');
|
||||
}
|
||||
return;
|
||||
}
|
||||
const tableRef = materialTableRef.value as any;
|
||||
if (tableRef?.pushRows) {
|
||||
tableRef.pushRows(toAdd);
|
||||
} else {
|
||||
materialDataSource.value = [...materialDataSource.value, ...toAdd];
|
||||
}
|
||||
if (skipped.length) {
|
||||
createMessage.warning(`已添加 ${toAdd.length} 项,跳过 ${skipped.length} 项重复物料`);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
const tableRef = materialTableRef.value as any;
|
||||
const tableData = (tableRef?.getTableData?.() || []) as Recordable[];
|
||||
const materialList = tableData
|
||||
.filter((r) => r && r.mixerMaterialId)
|
||||
.map((r) => ({
|
||||
mixerMaterialId: r.mixerMaterialId,
|
||||
materialCode: r.materialCode,
|
||||
materialName: r.materialName,
|
||||
materialDesc: r.materialDesc,
|
||||
}));
|
||||
if (!materialList.length) {
|
||||
createMessage.warning('请通过「选择物料」至少添加一条明细');
|
||||
return;
|
||||
}
|
||||
const ids = new Set<string>();
|
||||
for (const line of materialList) {
|
||||
if (ids.has(line.mixerMaterialId)) {
|
||||
createMessage.warning('明细中物料不能重复');
|
||||
return;
|
||||
}
|
||||
ids.add(line.mixerMaterialId);
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate({ ...values, materialList }, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,63 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslDryingRoom/list',
|
||||
checkRoomCode = '/xslmes/mesXslDryingRoom/checkRoomCode',
|
||||
checkRoomName = '/xslmes/mesXslDryingRoom/checkRoomName',
|
||||
save = '/xslmes/mesXslDryingRoom/add',
|
||||
edit = '/xslmes/mesXslDryingRoom/edit',
|
||||
deleteOne = '/xslmes/mesXslDryingRoom/delete',
|
||||
deleteBatch = '/xslmes/mesXslDryingRoom/deleteBatch',
|
||||
queryById = '/xslmes/mesXslDryingRoom/queryById',
|
||||
}
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
|
||||
|
||||
export const checkRoomCode = (params: { roomCode: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkRoomCode, params },
|
||||
{
|
||||
successMessageMode: 'none',
|
||||
errorMessageMode: 'none',
|
||||
},
|
||||
);
|
||||
|
||||
export const checkRoomName = (params: { roomName: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkRoomName, params },
|
||||
{
|
||||
successMessageMode: 'none',
|
||||
errorMessageMode: 'none',
|
||||
},
|
||||
);
|
||||
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
};
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
const url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url, params });
|
||||
};
|
||||
@@ -0,0 +1,126 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { checkRoomCode, checkRoomName } from './MesXslDryingRoom.api';
|
||||
|
||||
const monthDayPickerProps = {
|
||||
format: 'MM-DD',
|
||||
valueFormat: 'MM-DD',
|
||||
placeholder: '请选择月日',
|
||||
style: { width: '100%' },
|
||||
getPopupContainer: () => document.body,
|
||||
};
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '烘胶房编码', align: 'center', dataIndex: 'roomCode', width: 140 },
|
||||
{ title: '烘胶房名称', align: 'center', dataIndex: 'roomName', width: 180 },
|
||||
{ title: '烘胶开始日期', align: 'center', dataIndex: 'dryingStartMd', width: 120 },
|
||||
{ title: '烘胶结束日期', align: 'center', dataIndex: 'dryingEndMd', width: 120 },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '烘胶房编码', field: 'roomCode', component: 'JInput', colProps: { span: 6 } },
|
||||
{ label: '烘胶房名称', field: 'roomName', component: 'JInput', colProps: { span: 6 } },
|
||||
{
|
||||
label: '烘胶开始日期',
|
||||
field: 'dryingStartMd',
|
||||
component: 'DatePicker',
|
||||
componentProps: monthDayPickerProps,
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '烘胶结束日期',
|
||||
field: 'dryingEndMd',
|
||||
component: 'DatePicker',
|
||||
componentProps: monthDayPickerProps,
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '烘胶房编码',
|
||||
field: 'roomCode',
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入烘胶房编码' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
try {
|
||||
await checkRoomCode({ roomCode: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.message || e?.message || '烘胶房编码不能重复';
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '烘胶房名称',
|
||||
field: 'roomName',
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入烘胶房名称' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
try {
|
||||
await checkRoomName({ roomName: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.message || e?.message || '烘胶房名称不能重复';
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '烘胶开始日期',
|
||||
field: 'dryingStartMd',
|
||||
component: 'DatePicker',
|
||||
componentProps: monthDayPickerProps,
|
||||
dynamicRules: () => [
|
||||
{ required: true, message: '请选择烘胶开始日期' },
|
||||
{ pattern: /^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/, message: '日期格式须为 MM-DD' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '烘胶结束日期',
|
||||
field: 'dryingEndMd',
|
||||
component: 'DatePicker',
|
||||
componentProps: monthDayPickerProps,
|
||||
dynamicRules: () => [
|
||||
{ required: true, message: '请选择烘胶结束日期' },
|
||||
{ pattern: /^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/, message: '日期格式须为 MM-DD' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const superQuerySchema = {
|
||||
roomCode: { title: '烘胶房编码', order: 0, view: 'text' },
|
||||
roomName: { title: '烘胶房名称', order: 1, view: 'text' },
|
||||
dryingStartMd: { title: '烘胶开始日期', order: 2, view: 'text' },
|
||||
dryingEndMd: { title: '烘胶结束日期', order: 3, view: 'text' },
|
||||
};
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_xsl_drying_room:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button v-auth="'mes:mes_xsl_drying_room:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_drying_room:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslDryingRoomModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslDryingRoom" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslDryingRoomModal from './components/MesXslDryingRoomModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './MesXslDryingRoom.data';
|
||||
import { list, deleteOne, batchDelete } from './MesXslDryingRoom.api';
|
||||
|
||||
const queryParam = reactive<any>({});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext } = useListPage({
|
||||
tableProps: {
|
||||
title: '烘胶房管理',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 110,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { customRender: 'action' },
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).forEach((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||
}
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
selectedRowKeys.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_xsl_drying_room:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-picker) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :title="title" width="640" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../MesXslDryingRoom.data';
|
||||
import { saveOrUpdate } from '../MesXslDryingRoom.api';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) {
|
||||
await setFieldsValue({ ...data.record });
|
||||
}
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增烘胶房' : unref(isDetail) ? '烘胶房详情' : '编辑烘胶房',
|
||||
);
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user