feat(portal): 优化海威官网后台配置

- 新增 selectConfigTypeList 方法,用于查询门户网站配置类型列表
- 实现门户网站配置类型的树形结构查询和展示
- 优化产品信息明细配置的树形结构构建逻辑
- 修复产品信息明细配置的父节点判断逻辑
- 更新前端门户网站配置组件,支持配置类型树形结构选择
master
zch 4 days ago
parent 9bc96b7ecb
commit 9cd8e8b6ff

@ -66,11 +66,21 @@ public class HwPortalController extends BaseController
@GetMapping("/getPortalConfigTypeList")
public TableDataInfo getPortalConfigTypeList(HwPortalConfigType hwPortalConfigType)
{
startPage();
List<HwPortalConfigType> list = hwPortalConfigTypeService.selectHwPortalConfigTypeList(hwPortalConfigType);
return getDataTable(list);
}
/**
* config_type_classfication1homeConfigTypeNameconfigTypeName
*/
@GetMapping("/selectConfigTypeList")
public TableDataInfo selectConfigTypeList(HwPortalConfigType hwPortalConfigType)
{
List<HwPortalConfigType> list = hwPortalConfigTypeService.selectConfigTypeList(hwPortalConfigType);
return getDataTable(list);
}
/**
* tab title()
*/

@ -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;
/** 英文标题 */

@ -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<HwProductInfoDetail> hwProductInfoDetailList;
public void setProductInfoDetailId(Long productInfoDetailId)
{
this.productInfoDetailId = productInfoDetailId;
@ -106,6 +112,15 @@ public class HwProductInfoDetail extends TreeEntity
return productInfoDetailPic;
}
public List<HwProductInfoDetail> getHwProductInfoDetailList() {
return hwProductInfoDetailList;
}
public void setHwProductInfoDetailList(List<HwProductInfoDetail> hwProductInfoDetailList) {
this.hwProductInfoDetailList = hwProductInfoDetailList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -29,6 +29,15 @@ public interface IHwPortalConfigTypeService
*/
public List<HwPortalConfigType> selectHwPortalConfigTypeList(HwPortalConfigType hwPortalConfigType);
/**
*
*
* @param hwPortalConfigType
* @return
*/
public List<HwPortalConfigType> selectConfigTypeList(HwPortalConfigType hwPortalConfigType);
/**
*
*

@ -55,6 +55,54 @@ public class HwPortalConfigTypeServiceImpl implements IHwPortalConfigTypeService
return hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(hwPortalConfigType);
}
/**
*
*
* @param hwPortalConfigType
* @return
*/
@Override
public List<HwPortalConfigType> selectConfigTypeList(HwPortalConfigType hwPortalConfigType)
{
// 如果有 configTypeClassfication 条件,需要特殊处理以确保树形结构完整
if (StringUtils.isNotEmpty(hwPortalConfigType.getConfigTypeClassfication())) {
// 查询所有数据
List<HwPortalConfigType> allList = hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(new HwPortalConfigType());
// 找出指定分类的顶级节点
List<HwPortalConfigType> topLevelNodes = allList.stream()
.filter(item -> hwPortalConfigType.getConfigTypeClassfication().equals(item.getConfigTypeClassfication())
&& (item.getParentId() == null || item.getParentId() == 0L))
.collect(Collectors.toList());
// 构建包含所有子孙节点的完整列表
List<HwPortalConfigType> completeList = new ArrayList<>();
for (HwPortalConfigType topNode : topLevelNodes) {
completeList.add(topNode);
addAllDescendants(allList, topNode, completeList);
}
return buildPortalConfigTypeTree(completeList);
} else {
// 没有特定过滤条件时,直接查询并构建树形结构
List<HwPortalConfigType> list = hwPortalConfigTypeMapper.selectHwPortalConfigTypeList(hwPortalConfigType);
return buildPortalConfigTypeTree(list);
}
}
/**
*
*/
private void addAllDescendants(List<HwPortalConfigType> allList, HwPortalConfigType parentNode, List<HwPortalConfigType> resultList) {
for (HwPortalConfigType item : allList) {
if (item.getParentId() != null && item.getParentId().equals(parentNode.getConfigTypeId())) {
resultList.add(item);
addAllDescendants(allList, item, resultList); // 递归添加子节点的子节点
}
}
}
/**
*
*

@ -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());

@ -112,6 +112,18 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService
public List<HwProductInfo> selectHwProductInfoJoinDetailList(HwProductInfo hwProductInfo)
{
List<HwProductInfo> hwProductInfoJoinDetailList = hwProductInfoMapper.selectHwProductInfoJoinDetailList(hwProductInfo);
// 若配置模式configModal为13hwProductInfoDetailList应该变为树形结构
if ("13".equals(hwProductInfo.getConfigModal())) {
for (HwProductInfo productInfo : hwProductInfoJoinDetailList) {
if (productInfo.getHwProductInfoDetailList() != null && !productInfo.getHwProductInfoDetailList().isEmpty()) {
// 将每个产品信息的明细列表转换为树形结构
List<HwProductInfoDetail> treeStructureList = buildProductInfoDetailTree(productInfo.getHwProductInfoDetailList());
productInfo.setHwProductInfoDetailList(treeStructureList);
}
}
}
return hwProductInfoJoinDetailList;
}
@ -123,13 +135,12 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService
* @param productInfoDetails
* @return
*/
// @Override
public List<HwProductInfoDetail> buildProductInfoDetailTree(List<HwProductInfoDetail> productInfoDetails) {
List<HwProductInfoDetail> returnList = new ArrayList<>();
List<Long> 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<HwProductInfoDetail> list, HwProductInfoDetail t) {
// 得到子节点列表
List<HwProductInfoDetail> 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);

@ -21,7 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectHwPortalConfigTypeVo">
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
</sql>
<select id="selectHwPortalConfigTypeList" parameterType="HwPortalConfigType" resultMap="HwPortalConfigTypeResult">

@ -21,7 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectHwProductInfoDetailVo">
select product_info_detail_id, parent_id, product_info_id, config_modal, product_info_detail_title, product_info_detail_desc, product_info_detail_order, product_info_detail_pic, ancestors, create_time, create_by, update_time, update_by from hw_product_info_detail
select product_info_detail_id, parent_id, product_info_id, config_modal, product_info_detail_title, product_info_detail_desc, product_info_detail_order, product_info_detail_pic, ancestors, create_time, create_by, update_time, update_by
from hw_product_info_detail
</sql>
<select id="selectHwProductInfoDetailList" parameterType="HwProductInfoDetail" resultMap="HwProductInfoDetailResult">

@ -127,9 +127,10 @@
<el-input v-model="form.portalConfigTitle" placeholder="请输入标题" />
</el-form-item>
<!-- <el-form-item label="配置类型ID" prop="portalConfigTypeId">-->
<el-form-item label="配置类型ID" prop="portalConfigTypeId">
<!-- <el-input v-model="form.portalConfigTypeId" placeholder="请输入配置类型ID" />-->
<!-- </el-form-item>-->
<treeselect v-model="form.portalConfigTypeId" :options="PortalConfigTypeObtions" :normalizer="normalizer" placeholder="请选择" />
</el-form-item>
<el-form-item label="类型" prop="portalConfigType">
<el-select v-model="form.portalConfigType" placeholder="请选择类型">
@ -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
};
},
}
};
</script>

@ -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`,

Loading…
Cancel
Save