公司配件类目与服务类目分开两个页面

This commit is contained in:
HH 2022-07-27 19:42:08 +08:00
parent e4f894a52b
commit 290b988bee
11 changed files with 211 additions and 24 deletions

View File

@ -138,9 +138,9 @@ public class GoodsCategoryController extends BaseController {
@GetMapping("/tree")
@ResponseBody
public List<Ztree> tree() {
public List<Ztree> tree(Integer type) {
Long deptId = ShiroUtils.getSysUser().getDept().getParentId();
return goodsCategoryService.tree(deptId);
return goodsCategoryService.tree(deptId, type);
}
/**

View File

@ -11,12 +11,12 @@ import com.ghy.common.utils.ShiroUtils;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.web.pojo.vo.AppCategoryRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -33,17 +33,23 @@ public class GoodsDeptCategoryController extends BaseController {
@RequiresPermissions("goods:deptcategory:view")
@GetMapping()
public String DeptGoodsCategory() {
public String deptGoodsCategory() {
return PREFIX + "/deptcategory";
}
@RequiresPermissions("goods:deptcategory:add")
@GetMapping("/add/1")
public String add() {
@GetMapping("/add/{type}")
public String add(@PathVariable("type") Integer type, ModelMap mmap) {
mmap.put("type", type);
return PREFIX + "/add";
}
@RequiresPermissions("goods:deptservecategory:view")
@GetMapping("serve")
public String deptServeCategory() {
return PREFIX + "/deptservecategory";
}
@RequiresPermissions("goods:deptcategory:add")
@PostMapping("/add")
@ResponseBody
@ -68,7 +74,7 @@ public class GoodsDeptCategoryController extends BaseController {
@PostMapping("/app/listByStep")
@ResponseBody
public AjaxResult appListByStep(@RequestBody DeptGoodsCategory deptGoodsCategory) {
List<DeptGoodsCategory> resList = new ArrayList<DeptGoodsCategory>();
List<DeptGoodsCategory> resList = new ArrayList<>();
try {
if (deptGoodsCategory.getIsAllNode() == null || !deptGoodsCategory.getIsAllNode()) {
List<DeptGoodsCategory> list = deptGoodsCategoryService.listByStep(deptGoodsCategory);

View File

@ -25,8 +25,11 @@
<th:block th:include="include :: ztree-js"/>
<script type="text/javascript">
let type = '[[${type}]]';
$(function () {
var url = ctx + "goods/category/tree";
var url = ctx + "goods/category/tree?type=" + type;
var options = {
id: "menuTrees",
url: url,

View File

@ -32,7 +32,7 @@
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-primary" onclick="$.operate.add(1)" shiro:hasPermission="goods:category:add">
<a class="btn btn-primary" onclick="$.operate.add(2)" shiro:hasPermission="goods:category:add">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
@ -57,7 +57,7 @@
code: "goodsCategoryId",
parentCode: "parentCategoryId",
uniqueId: "goodsCategoryId",
url: prefix + "/list",
url: prefix + "/list?type=2",
addUrl: prefix + "/add/{id}",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",

View File

@ -0,0 +1,162 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('类目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="dept-form">
<div class="select-list">
<ul>
<li>
类目名称:<input type="text" name="goodsCategoryName"/>
</li>
<li>
类目状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-primary" onclick="$.operate.add(1)" shiro:hasPermission="goods:category:add">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
<i class="fa fa-exchange"></i> 展开/折叠
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var addFlag = [[${@permission.hasPermi('goods:category:add')}]];
var editFlag = [[${@permission.hasPermi('goods:category:edit')}]];
var removeFlag = [[${@permission.hasPermi('goods:category:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "goods/deptcategory"
$(function () {
var options = {
code: "goodsCategoryId",
parentCode: "parentCategoryId",
uniqueId: "goodsCategoryId",
url: prefix + "/list?type=1",
addUrl: prefix + "/add/{id}",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove/{id}",
modalName: "类目",
columns: [{
field: 'selectItem',
radio: true
},
{
field: 'goodsCategoryName',
title: '类目名称',
align: "left"
},
{
field: 'oneRate',
title: '一级分销扣点',
align: "left"
},
{
field: 'twoRate',
title: '二级分销扣点',
align: "left"
},
{
field: 'threeRate',
title: '三级分销扣点',
align: "left"
},
{
field: 'deptRate',
title: '平台扣点比例',
align: "left"
},
{
field: 'deptMoney',
title: '平台固定扣金额',
align: "left"
},
{
field: 'retainRate',
title: '截留扣点',
align: "left"
},
{
field: 'retainMoney',
title: '截留金额',
align: "left"
},
{
field: 'isHot',
title: '是否热门类目',
align: "left",
formatter: function (value) {
if (value === 1){
return "是";
}else {
return "否";
}
}
},
{
field: 'status',
title: '状态',
align: "left",
formatter: function (value, item, index) {
return $.table.selectDictLabel(datas, item.status);
}
},
{
field: 'createTime',
title: '创建时间',
align: "left"
},
{
field: 'remark',
title: '备注',
align: "left"
},
{
title: '操作',
align: 'left',
formatter: function (value, row, index) {
if (row.parentId !== 0) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.deptGoodsCategoryId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
// actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.deptGoodsCategoryId + '\')"><i class="fa fa-plus"></i>新增</a> ');
// actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="remove(\'' + row.deptGoodsCategoryId + '\')"><i class="fa fa-trash"></i>删除</a>');
return actions.join('');
} else {
return "";
}
}
}
]
};
$.treeTable.init(options);
});
</script>
</body>
</html>

View File

@ -48,6 +48,9 @@ public class DeptGoodsCategory extends GoodsCategory {
@Excel(name = "截留金额", cellType = Excel.ColumnType.STRING)
private BigDecimal retainMoney;
@Excel(name = "类别类型. 1.服务类 2.商品类", cellType = Excel.ColumnType.STRING)
private Integer type;
private Long parentCategoryId;
private List<DeptGoodsCategory> child;

View File

@ -1,12 +1,10 @@
package com.ghy.goods.service;
import com.ghy.common.core.domain.Ztree;
import com.ghy.common.core.domain.entity.SysDept;
import com.ghy.goods.domain.GoodsCategory;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* @author clunt
@ -81,6 +79,7 @@ public interface GoodsCategoryService {
* 获取所有的商品类目并标记出当前公司拥有的类目
*
* @param deptId 分公司ID
* @param type 类目类型
*/
List<Ztree> tree(Long deptId);
List<Ztree> tree(Long deptId, Integer type);
}

View File

@ -9,9 +9,11 @@ import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.mapper.DeptGoodsCategoryMapper;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.*;
@ -25,6 +27,8 @@ import java.util.stream.Collectors;
@Service
public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
@Resource
private GoodsCategoryService goodsCategoryService;
@Resource
private DeptGoodsCategoryMapper deptGoodsCategoryMapper;
@ -107,9 +111,11 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult batchAdd(Long parentId, Long[] checked) {
GoodsCategory goodsCategory = goodsCategoryService.selectById(checked[0]);
Assert.notNull(goodsCategory, "不存在该类目: " + checked[0]);
List<DeptGoodsCategory> oldList = deptGoodsCategoryMapper.selectByDeptId(parentId);
Map<Long, Long> oldMap = oldList.stream().collect(Collectors.toMap(GoodsCategory::getGoodsCategoryId,
DeptGoodsCategory::getDeptGoodsCategoryId));
Map<Long, Long> oldMap = oldList.stream().filter(x -> x.getType().equals(goodsCategory.getType()))
.collect(Collectors.toMap(GoodsCategory::getGoodsCategoryId, DeptGoodsCategory::getDeptGoodsCategoryId));
HashSet<Long> newSet = new HashSet<>(Arrays.asList(checked));
Set<Long> intersection = oldList.stream().map(DeptGoodsCategory::getGoodsCategoryId).collect(Collectors.toSet());
intersection.addAll(Arrays.asList(checked));

View File

@ -92,8 +92,10 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
}
@Override
public List<Ztree> tree(Long deptId) {
List<GoodsCategory> goodsCategoryList = goodsCategoryMapper.selectGoodsCategoryList(null);
public List<Ztree> tree(Long deptId, Integer type) {
GoodsCategory goodsCategory = new GoodsCategory();
goodsCategory.setType(type);
List<GoodsCategory> goodsCategoryList = goodsCategoryMapper.selectGoodsCategoryList(goodsCategory);
DeptGoodsCategory category = new DeptGoodsCategory();
category.setDeptId(deptId);
Set<Long> usedSet = deptGoodsCategoryService.list(category).stream()

View File

@ -140,6 +140,9 @@
<if test="isHot != null">
AND dgc.is_hot = #{isHot}
</if>
<if test="type != null">
AND gc.type = #{type}
</if>
</where>
</select>
@ -154,7 +157,7 @@
</select>
<select id="selectByDeptId" resultMap="DeptGoodsCategoryResult">
<include refid="selectDeptGoodsCategory"/>
WHERE dept_id = #{deptId}
<include refid="selectJoin"/>
WHERE dgc.dept_id = #{deptId}
</select>
</mapper>

View File

@ -39,6 +39,9 @@
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="type != null">
AND type = #{type}
</if>
</where>
</select>