diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalController.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalController.java index c1224a8..cdf9982 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalController.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalController.java @@ -66,11 +66,21 @@ public class HwPortalController extends BaseController @GetMapping("/getPortalConfigTypeList") public TableDataInfo getPortalConfigTypeList(HwPortalConfigType hwPortalConfigType) { - startPage(); List list = hwPortalConfigTypeService.selectHwPortalConfigTypeList(hwPortalConfigType); return getDataTable(list); } + + /** + * 门户网站配置类型(首页产品中心,config_type_classfication为1,按homeConfigTypeName显示;产品中心页面上面的按configTypeName显示) + */ + @GetMapping("/selectConfigTypeList") + public TableDataInfo selectConfigTypeList(HwPortalConfigType hwPortalConfigType) + { + List list = hwPortalConfigTypeService.selectConfigTypeList(hwPortalConfigType); + return getDataTable(list); + } + /** * 获取首页案例tab title(例如物联网、制造中心和快递物流) */ diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfo.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfo.java index 7f81024..c647c04 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfo.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfo.java @@ -29,7 +29,7 @@ public class HwProductInfo extends BaseEntity private String tabFlag; /** 配置模式(1图标 +文字+内容横铺4个2左标题+内容,右图片;3左图标,右标题+内容,一行2个;4左大图右标题+内容,一行2个;5上标题+下图片,6上标题+内容,下图片;7图标标题内容,一行3个,8左图右图9上图下内容,一行4个) */ - @Excel(name = "配置模式(1图标 +文字+内容横铺4个2左标题+内容,右图片;3左图标,右标题+内容,一行2个;4左大图右标题+内容,一行2个;5上标题+下图片,6上标题+内容,下图片;7图标标题内容,一行3个,8左图右图9上图下内容,一行4个)") + @Excel(name = "配置模式(1图标 +文字+内容横铺4个2左标题+内容,右图片;3左图标,右标题+内容,一行2个;4左大图右标题+内容,一行2个;5上标题+下图片,6上标题+内容,下图片;7图标标题内容,一行3个,8左图右图9上图下内容,一行4个),13为hw官网配置模式") private String configModal; /** 英文标题 */ diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfoDetail.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfoDetail.java index b543000..52411d3 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfoDetail.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwProductInfoDetail.java @@ -5,6 +5,9 @@ import com.ruoyi.common.core.web.domain.TreeEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.List; + + /** * 产品信息明细配置对象 hw_product_info_detail * @@ -42,6 +45,9 @@ public class HwProductInfoDetail extends TreeEntity @Excel(name = "图片地址") private String productInfoDetailPic; + /** 产品信息明细配置信息 */ + private List hwProductInfoDetailList; + public void setProductInfoDetailId(Long productInfoDetailId) { this.productInfoDetailId = productInfoDetailId; @@ -106,6 +112,15 @@ public class HwProductInfoDetail extends TreeEntity return productInfoDetailPic; } + public List getHwProductInfoDetailList() { + return hwProductInfoDetailList; + } + + public void setHwProductInfoDetailList(List hwProductInfoDetailList) { + this.hwProductInfoDetailList = hwProductInfoDetailList; + } + + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java index c998607..b23661a 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java @@ -29,6 +29,15 @@ public interface IHwPortalConfigTypeService */ public List selectHwPortalConfigTypeList(HwPortalConfigType hwPortalConfigType); + + /** + * 查询门户网站配置类型列表 + * + * @param hwPortalConfigType 门户网站配置类型 + * @return 门户网站配置类型集合 + */ + public List selectConfigTypeList(HwPortalConfigType hwPortalConfigType); + /** * 新增门户网站配置类型 * diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java index e6587b0..7db03c8 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java @@ -43,6 +43,19 @@ public class HwPortalConfigTypeServiceImpl implements IHwPortalConfigTypeService return hwPortalConfigTypeMapper.selectHwPortalConfigTypeByConfigTypeId(configTypeId); } + /** + * 查询门户网站配置类型列表 + * + * @param hwPortalConfigType 门户网站配置类型 + * @return 门户网站配置类型 + */ + @Override + public List selectHwPortalConfigTypeList(HwPortalConfigType hwPortalConfigType) + { + return hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(hwPortalConfigType); + } + + /** * 查询门户网站配置类型列表 * @@ -50,9 +63,44 @@ public class HwPortalConfigTypeServiceImpl implements IHwPortalConfigTypeService * @return 门户网站配置类型 */ @Override - public List selectHwPortalConfigTypeList(HwPortalConfigType hwPortalConfigType) + public List selectConfigTypeList(HwPortalConfigType hwPortalConfigType) { - return hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(hwPortalConfigType); + // 如果有 configTypeClassfication 条件,需要特殊处理以确保树形结构完整 + if (StringUtils.isNotEmpty(hwPortalConfigType.getConfigTypeClassfication())) { + // 查询所有数据 + List allList = hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(new HwPortalConfigType()); + + // 找出指定分类的顶级节点 + List topLevelNodes = allList.stream() + .filter(item -> hwPortalConfigType.getConfigTypeClassfication().equals(item.getConfigTypeClassfication()) + && (item.getParentId() == null || item.getParentId() == 0L)) + .collect(Collectors.toList()); + + // 构建包含所有子孙节点的完整列表 + List completeList = new ArrayList<>(); + for (HwPortalConfigType topNode : topLevelNodes) { + completeList.add(topNode); + addAllDescendants(allList, topNode, completeList); + } + + return buildPortalConfigTypeTree(completeList); + } else { + // 没有特定过滤条件时,直接查询并构建树形结构 + List list = hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(hwPortalConfigType); + return buildPortalConfigTypeTree(list); + } + } + + /** + * 递归添加所有子孙节点 + */ + private void addAllDescendants(List allList, HwPortalConfigType parentNode, List resultList) { + for (HwPortalConfigType item : allList) { + if (item.getParentId() != null && item.getParentId().equals(parentNode.getConfigTypeId())) { + resultList.add(item); + addAllDescendants(allList, item, resultList); // 递归添加子节点的子节点 + } + } } /** diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoDetailServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoDetailServiceImpl.java index 8210496..7581288 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoDetailServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoDetailServiceImpl.java @@ -49,7 +49,7 @@ public class HwProductInfoDetailServiceImpl implements IHwProductInfoDetailServi /** * 新增产品信息明细配置 - * + * * @param hwProductInfoDetail 产品信息明细配置 * @return 结果 */ @@ -59,6 +59,9 @@ public class HwProductInfoDetailServiceImpl implements IHwProductInfoDetailServi if (hwProductInfoDetail.getParentId() == null) { hwProductInfoDetail.setParentId(0L); hwProductInfoDetail.setAncestors("0"); + }else if(hwProductInfoDetail.getParentId() == 0L) { + hwProductInfoDetail.setParentId(0L); + hwProductInfoDetail.setAncestors("0"); } else { HwProductInfoDetail info = hwProductInfoDetailMapper.selectHwProductInfoDetailByProductInfoDetailId(hwProductInfoDetail.getParentId()); diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoServiceImpl.java index d50c3ff..062c703 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwProductInfoServiceImpl.java @@ -112,6 +112,18 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService public List selectHwProductInfoJoinDetailList(HwProductInfo hwProductInfo) { List hwProductInfoJoinDetailList = hwProductInfoMapper.selectHwProductInfoJoinDetailList(hwProductInfo); + + // 若配置模式configModal为13,hwProductInfoDetailList应该变为树形结构 + if ("13".equals(hwProductInfo.getConfigModal())) { + for (HwProductInfo productInfo : hwProductInfoJoinDetailList) { + if (productInfo.getHwProductInfoDetailList() != null && !productInfo.getHwProductInfoDetailList().isEmpty()) { + // 将每个产品信息的明细列表转换为树形结构 + List treeStructureList = buildProductInfoDetailTree(productInfo.getHwProductInfoDetailList()); + productInfo.setHwProductInfoDetailList(treeStructureList); + } + } + } + return hwProductInfoJoinDetailList; } @@ -123,13 +135,12 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService * @param productInfoDetails 产品明细列表 * @return 树结构列表 */ -// @Override public List buildProductInfoDetailTree(List productInfoDetails) { List returnList = new ArrayList<>(); List tempList = productInfoDetails.stream().map(HwProductInfoDetail::getProductInfoDetailId).collect(Collectors.toList()); for (HwProductInfoDetail hwProductInfoDetail : productInfoDetails) { - // 如果是顶级节点, 遍历该父节点的所有子节点 - if (!tempList.contains(hwProductInfoDetail.getParentId())) { + // 如果是顶级节点(parentId为null、0或者不在当前列表中), 遍历该父节点的所有子节点 + if (hwProductInfoDetail.getParentId() == null || hwProductInfoDetail.getParentId() == 0L || !tempList.contains(hwProductInfoDetail.getParentId())) { recursionFn(productInfoDetails, hwProductInfoDetail); returnList.add(hwProductInfoDetail); } @@ -146,7 +157,11 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService private void recursionFn(List list, HwProductInfoDetail t) { // 得到子节点列表 List childList = getChildList(list, t); + // 设置TreeEntity的children字段 t.setChildren(childList); + // 设置HwProductInfoDetail的hwProductInfoDetailList字段 + t.setHwProductInfoDetailList(childList); + for (HwProductInfoDetail tChild : childList) { if (hasChild(list, tChild)) { recursionFn(list, tChild); diff --git a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigTypeMapper.xml b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigTypeMapper.xml index 76eb01c..653eb53 100644 --- a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigTypeMapper.xml +++ b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigTypeMapper.xml @@ -21,7 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select config_type_id, config_type_classfication, config_type_name, home_config_type_name, config_type_desc, config_type_icon, home_config_type_pic, parent_id, ancestors, create_time, create_by, update_time, update_by from hw_portal_config_type + select config_type_id, config_type_classfication, config_type_name, home_config_type_name, config_type_desc, config_type_icon, home_config_type_pic, parent_id, ancestors, create_time, create_by, update_time, update_by + from hw_portal_config_type diff --git a/ruoyi-ui/src/views/portal/portalConfig/index.vue b/ruoyi-ui/src/views/portal/portalConfig/index.vue index a83231b..627be4b 100644 --- a/ruoyi-ui/src/views/portal/portalConfig/index.vue +++ b/ruoyi-ui/src/views/portal/portalConfig/index.vue @@ -127,9 +127,10 @@ - + - + + @@ -228,6 +229,7 @@ import { listPortalConfig, getPortalConfig, delPortalConfig, addPortalConfig, up import {getToken} from "@/utils/auth"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; +import {listPortalConfigType} from "@/api/portal/portalConfigType"; export default { components: {Treeselect}, @@ -319,11 +321,13 @@ export default { PORTAL_CONFIG_TYPE:{ HOME:"1", //首页 PRODUCT_CENTER:"2",//产品中心 - } + }, + PortalConfigTypeObtions: [], }; }, created() { this.getList(); + this.getListPortalConfigType(); }, methods: { /** 查询门户网站配置列表 */ @@ -531,6 +535,27 @@ export default { this.dialogVisible = true; }, + /** 查询门户网站配置类型下拉树结构 */ + getListPortalConfigType() { + listPortalConfigType().then(response => { + this.PortalConfigTypeObtions = []; + const data = {configTypeId: 0, configTypeName: '顶级节点', children: []}; + data.children = this.handleTree(response.data, "configTypeId", "parentId"); + this.PortalConfigTypeObtions.push(data); + }); + }, + /** 转换门户网站配置类型数据结构 */ + normalizer(node) { + if (node.children && !node.children.length) { + delete node.children; + } + return { + id: node.configTypeId, + label: node.configTypeName, + children: node.children + }; + }, + } }; diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 5db7f86..f91882a 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -7,7 +7,7 @@ function resolve(dir) { const CompressionPlugin = require('compression-webpack-plugin') -const name = process.env.VUE_APP_TITLE || '智慧物联监控平台' // 网页标题 +const name = process.env.VUE_APP_TITLE || '海威物联官网' // 网页标题 const port = process.env.port || process.env.npm_config_port || 8018 // 端口 @@ -35,13 +35,13 @@ module.exports = { proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - // target: `http://127.0.0.1:9080`, + target: `http://127.0.0.1:9080`, // target: `http://10.11.40.120:9080`, // target: `http://10.11.43.111:8080`, // target: `http://10.11.41.54:9080`, // target: `http://175.27.215.92:9080`, // target: `http://124.223.15.102:9080`, - target: `http://47.122.6.3:9080`, + // target: `http://47.122.6.3:9080`, // target: `http://10.11.41.54:9080`, // target: `http://10.11.40.122:9080`, // target: `http://10.11.43.177:9080`,