Commit 8e5dc3fd authored by liaoxingda's avatar liaoxingda

Merge branch 'master' of http://192.168.60.201/root/sup-server

parents 29bc4b39 da2c79fb
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"test": "vue-cli-service serve --development", "test": "vue-cli-service serve --host 192.168.60.48 --development",
"serve": "vue-cli-service serve --production", "serve": "vue-cli-service serve --production",
"build": "vue-cli-service build --production" "build": "vue-cli-service build --production"
}, },
......
...@@ -7,6 +7,12 @@ export const getAuthenticationDetailApi = () => network({ ...@@ -7,6 +7,12 @@ export const getAuthenticationDetailApi = () => network({
// 获取供应商类型 // 获取供应商类型
export const getSupplierTypeApi = () => network({ export const getSupplierTypeApi = () => network({
url : "/category/list/tree", url: "/category/list/tree",
method : "post" method: "post",
}) headers : {
\ No newline at end of file isToken : false
},
data: {
name: ""
}
});
\ No newline at end of file
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</el-form-item> </el-form-item>
<el-form-item label="供应商类型选择:" prop="catId"> <el-form-item label="供应商类型选择:" prop="catId">
<el-cascader v-model="form.catId" :options="options" disabled placeholder=""></el-cascader> <el-cascader v-model="form.catId" :options="options" disabled placeholder="" :props="props"></el-cascader>
</el-form-item> </el-form-item>
</div> </div>
...@@ -141,9 +141,8 @@ export default { ...@@ -141,9 +141,8 @@ export default {
}, },
options: [], options: [],
props: { props: {
emitPath: false, value: "catId",
value : "catId", label: "name"
label : "name"
} }
}; };
}, },
...@@ -222,6 +221,10 @@ export default { ...@@ -222,6 +221,10 @@ export default {
flex: 1; flex: 1;
margin: 0px !important; margin: 0px !important;
.el-cascader {
width: 100%;
}
img { img {
width: 100%; width: 100%;
max-height: 200px; max-height: 200px;
......
...@@ -86,13 +86,13 @@ module.exports = defineConfig({ ...@@ -86,13 +86,13 @@ module.exports = defineConfig({
}, },
// 本地代理服务器 // 本地代理服务器
devServer: { devServer: {
host: 'localhost', host: '0.0.0.0',
port: "8866", port: "8866",
open: true, open: true,
proxy: { proxy: {
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://139.9.157.49:8088`, // target: `http://139.9.157.49:8088`,
// target: `http://192.168.60.172:8188`, target: `http://192.168.60.172:8188`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''
......
package com.supServer.project.controller; package com.supServer.project.controller;
import com.supServer.framework.web.domain.AjaxResult; import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.BizCategory;
import com.supServer.project.entity.vo.BizCategoryVo; import com.supServer.project.entity.vo.BizCategoryVo;
import com.supServer.project.service.BizCategoryService; import com.supServer.project.service.BizCategoryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -10,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* <p> * <p>
...@@ -30,9 +28,8 @@ public class BizCategoryController { ...@@ -30,9 +28,8 @@ public class BizCategoryController {
* 供应商类型查询 * 供应商类型查询
*/ */
@PostMapping("/list/tree") @PostMapping("/list/tree")
public AjaxResult list (BizCategoryVo vo) { public AjaxResult list (@RequestBody BizCategoryVo vo) {
AjaxResult ajaxResult = bizCategoryService.listTree(vo); return bizCategoryService.listTree(vo);
return AjaxResult.success(ajaxResult);
} }
} }
...@@ -5,6 +5,7 @@ import com.supServer.project.entity.vo.BizCategoryVo; ...@@ -5,6 +5,7 @@ import com.supServer.project.entity.vo.BizCategoryVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigInteger;
import java.util.List; import java.util.List;
@Mapper @Mapper
...@@ -12,4 +13,8 @@ public interface BizCategoryMapper { ...@@ -12,4 +13,8 @@ public interface BizCategoryMapper {
List<BizCategory> listTree(@Param("vo") BizCategoryVo vo); List<BizCategory> listTree(@Param("vo") BizCategoryVo vo);
List<BizCategory> oneLevels(@Param("vo") BizCategoryVo vo);
List<BizCategory> twoLevels(@Param("vo") List<BigInteger> vo);
} }
package com.supServer.project.service.impl; package com.supServer.project.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.supServer.framework.web.domain.AjaxResult; import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.BizCategory; import com.supServer.project.entity.BizCategory;
import com.supServer.project.entity.vo.BizCategoryVo; import com.supServer.project.entity.vo.BizCategoryVo;
import com.supServer.project.mapper.BizCategoryMapper; import com.supServer.project.mapper.BizCategoryMapper;
import com.supServer.project.service.BizCategoryService; import com.supServer.project.service.BizCategoryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -22,18 +29,72 @@ public class BizCategoryServiceImpl implements BizCategoryService { ...@@ -22,18 +29,72 @@ public class BizCategoryServiceImpl implements BizCategoryService {
@Override @Override
public AjaxResult listTree(BizCategoryVo vo) { public AjaxResult listTree(BizCategoryVo vo) {
List<BizCategory> list=bizCategoryMapper.listTree(vo); List<BizCategory> res;
if (CollectionUtil.isEmpty(list)) { List<BizCategory> list = CollUtil.newArrayList();
return AjaxResult.success(list); if (ObjectUtil.isNull(vo) || StringUtils.isBlank(vo.getName())){
List<BizCategory> bizCategories = bizCategoryMapper.listTree(vo);
list.addAll(bizCategories);
}else {
//一级目录
List<BizCategory> oneLevels = bizCategoryMapper.oneLevels(vo);
if(CollUtil.isNotEmpty(oneLevels)){
list.addAll(oneLevels);
//一级目录id集合
List<BigInteger> oneCodes = oneLevels.stream().map(BizCategory::getCode).distinct().collect(Collectors.toList());
//根据一级目录id集合 查找二级目录
List<BizCategory> twoLevels = bizCategoryMapper.twoLevels(oneCodes);
if (CollUtil.isNotEmpty(twoLevels)){
list.addAll(twoLevels);
//二级目录id集合
List<BigInteger> twoCodes = twoLevels.stream().map(BizCategory::getCode).distinct().collect(Collectors.toList());
//三级目录
List<BizCategory> threeLevels = bizCategoryMapper.twoLevels(twoCodes);
if (CollUtil.isNotEmpty(threeLevels)) list.addAll(threeLevels);
} }
// 2 组装成父子的树形结构
List<BizCategory> level1Menus = list.stream().filter(bizCategory -> }
bizCategory.getParentCode().equals(BigInteger.ZERO) }
).map((menu) -> { //配置
menu.setChildren(getChildrens(menu, list)); TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
return menu; // 自定义属性名 都要默认值的
}).collect(Collectors.toList()); treeNodeConfig.setIdKey("code");
return AjaxResult.success(level1Menus); treeNodeConfig.setParentIdKey("parentCode");
treeNodeConfig.setWeightKey("level");
treeNodeConfig.setNameKey("name");
treeNodeConfig.setChildrenKey("children");
//转换器
List<Tree<String>> treeNodes = TreeUtil.build(list, "0", treeNodeConfig,
(treeNode, tree) -> {
tree.setId(treeNode.getCode().toString());
tree.setParentId(treeNode.getParentCode().toString());
tree.setWeight(treeNode.getLevel());
tree.setName(treeNode.getName());
tree.putExtra("showStatus",treeNode.getShowStatus());
tree.putExtra("catId",treeNode.getCatId());
tree.putExtra("sort",treeNode.getSort());
tree.putExtra("mark",treeNode.getMark());
tree.putExtra("userId",treeNode.getUserId());
tree.putExtra("createTime",treeNode.getCreateTime());
tree.putExtra("updateTime",treeNode.getUpdateTime());
tree.putExtra("userName",treeNode.getUserName());
});
String jsonStr = JSONUtil.toJsonStr(treeNodes);
JSONArray jsonArray = JSONUtil.parseArray(jsonStr);
res = JSONUtil.toList(jsonArray, BizCategory.class);
return AjaxResult.success(res);
// List<BizCategory> list=bizCategoryMapper.listTree(vo);
// if (CollectionUtil.isEmpty(list)) {
// return AjaxResult.success(list);
// }
// // 2 组装成父子的树形结构
// List<BizCategory> level1Menus = list.stream().filter(bizCategory ->
// bizCategory.getParentCode().equals(BigInteger.ZERO)
// ).map((menu) -> {
// menu.setChildren(getChildrens(menu, list));
// return menu;
// }).collect(Collectors.toList());
// return AjaxResult.success(level1Menus);
} }
......
...@@ -31,4 +31,27 @@ ...@@ -31,4 +31,27 @@
</select> </select>
<select id="oneLevels" parameterType="com.supServer.project.entity.vo.BizCategoryVo" resultMap="BizCategoryResult">
select bc.*
from biz_category bc
<where>
<if test="vo.name != null and vo.name != ''">
and bc.name like concat('%', #{vo.name}, '%')
</if>
and bc.show_status='1'
and bc.parent_code=0
</where>
</select>
<select id="twoLevels" parameterType="java.util.List" resultMap="BizCategoryResult">
select bc.*
from biz_category bc
where bc.parent_code in
<foreach collection="vo" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment