系统类目新增半成品
This commit is contained in:
parent
6a376310cf
commit
097965d7a0
|
|
@ -4,6 +4,8 @@ import com.ghy.common.annotation.Log;
|
|||
import com.ghy.common.constant.UserConstants;
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.core.domain.Ztree;
|
||||
import com.ghy.common.core.domain.entity.SysDept;
|
||||
import com.ghy.common.core.page.TableDataInfo;
|
||||
import com.ghy.common.enums.BusinessType;
|
||||
import com.ghy.goods.domain.GoodsCategory;
|
||||
|
|
@ -35,6 +37,17 @@ public class GoodsCategoryController extends BaseController {
|
|||
return PREFIX + "/category";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@GetMapping("/add/{parentCategoryId}")
|
||||
public String add(@PathVariable("parentCategoryId") Long parentCategoryId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("goodsCategory", goodsCategoryService.selectById(parentCategoryId));
|
||||
return PREFIX + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品类别页面
|
||||
*/
|
||||
|
|
@ -102,6 +115,40 @@ public class GoodsCategoryController extends BaseController {
|
|||
return toAjax(goodsCategoryService.updateGoodsCategory(category));
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择部门树
|
||||
*
|
||||
* @param categoryId 类目ID
|
||||
* @param excludeId 排除ID
|
||||
*/
|
||||
@GetMapping(value = { "/selectGoodsCategoryTree/{categoryId}", "/selectGoodsCategoryTree/{categoryId}/{excludeId}" })
|
||||
public String selectDeptTree(@PathVariable("categoryId") Long categoryId,
|
||||
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("goodsCategory", goodsCategoryService.selectById(categoryId));
|
||||
mmap.put("excludeId", excludeId);
|
||||
return PREFIX + "/tree";
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载部门列表树
|
||||
*/
|
||||
@GetMapping("/treeData")
|
||||
@ResponseBody
|
||||
public List<Ztree> treeData()
|
||||
{
|
||||
return goodsCategoryService.selectCategoryTree(new GoodsCategory());
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载部门列表树(排除下级)
|
||||
*/
|
||||
@GetMapping("/treeData/{excludeId}")
|
||||
@ResponseBody
|
||||
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
|
||||
{
|
||||
return goodsCategoryService.selectCategoryTree(new GoodsCategory());
|
||||
}
|
||||
/**
|
||||
* 商品类别表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('新增类目')" />
|
||||
</head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-dept-add">
|
||||
<input id="treeId" name="parentCategoryId" type="hidden" th:value="${goodsCategory?.goodsCategoryId}" />
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">上级类目:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true" th:value="${goodsCategory?.goodsCategoryName}" required>
|
||||
<span class="input-group-addon"><i class="fa fa-search"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">类目名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="goodsCategoryName" id="goodsCategoryName" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">显示排序:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="categorySort" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">类目类别:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('goods_category_type')}">
|
||||
<input type="radio" th:id="${dict.dictCode}" name="type" th:value="${dict.dictValue}" th:checked="${dict.default}">
|
||||
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">类目状态:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
|
||||
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
|
||||
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script type="text/javascript">
|
||||
var prefix = ctx + "goods/category";
|
||||
|
||||
$("#form-dept-add").validate({
|
||||
onkeyup: false,
|
||||
rules:{
|
||||
deptName:{
|
||||
remote: {
|
||||
url: prefix + "/checkGoodsCategoryNameUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
"parentCategoryId": function() {
|
||||
return $("input[name='parentCategoryId']").val();
|
||||
},
|
||||
"goodsCategoryName" : function() {
|
||||
return $.common.trim($("#goodsCategoryName").val());
|
||||
}
|
||||
},
|
||||
dataFilter: function(data, type) {
|
||||
return $.validate.unique(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
categorySort:{
|
||||
digits:true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
"goodsCategoryName": {
|
||||
remote: "类目已经存在"
|
||||
}
|
||||
},
|
||||
focusCleanup: true
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-dept-add').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
/*部门管理-新增-选择父部门树*/
|
||||
function selectDeptTree() {
|
||||
var treeId = $("#treeId").val();
|
||||
if ($.common.isEmpty(treeId)) {
|
||||
$.modal.alertWarning("请先添加用户所属的类目!");
|
||||
return;
|
||||
}
|
||||
var options = {
|
||||
title: '类目选择',
|
||||
width: "380",
|
||||
url: prefix + "/selectGoodsCategoryTree/" + treeId,
|
||||
callBack: doSubmit
|
||||
};
|
||||
$.modal.openOptions(options);
|
||||
}
|
||||
|
||||
function doSubmit(index, layero){
|
||||
var body = $.modal.getChildFrame(index);
|
||||
$("#treeId").val(body.find('#treeId').val());
|
||||
$("#treeName").val(body.find('#treeName').val());
|
||||
$.modal.close(index);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="goods:category:add">
|
||||
<a class="btn btn-success" onclick="$.operate.add(1)" shiro:hasPermission="goods:category:add">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="goods:category:edit">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('修改部门')" />
|
||||
</head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
|
||||
<input name="deptId" type="hidden" th:field="*{deptId}" />
|
||||
<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">上级部门:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="treeName" onclick="selectDeptTree()" readonly="true" th:field="*{parentName}">
|
||||
<span class="input-group-addon"><i class="fa fa-search"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">部门名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="deptName" th:field="*{deptName}" id="deptName" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">显示排序:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="orderNum" th:field="*{orderNum}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">负责人:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="leader" th:field="*{leader}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">联系电话:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="phone" th:field="*{phone}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">邮箱:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="email" th:field="*{email}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门状态:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
|
||||
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
|
||||
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script type="text/javascript">
|
||||
var prefix = ctx + "system/dept";
|
||||
|
||||
$("#form-dept-edit").validate({
|
||||
onkeyup: false,
|
||||
rules:{
|
||||
deptName:{
|
||||
remote: {
|
||||
url: prefix + "/checkDeptNameUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
"deptId": function() {
|
||||
return $("#deptId").val();
|
||||
},
|
||||
"parentId": function() {
|
||||
return $("input[name='parentId']").val();
|
||||
},
|
||||
"deptName": function() {
|
||||
return $.common.trim($("#deptName").val());
|
||||
}
|
||||
},
|
||||
dataFilter: function(data, type) {
|
||||
return $.validate.unique(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
orderNum:{
|
||||
digits:true
|
||||
},
|
||||
email:{
|
||||
email:true,
|
||||
},
|
||||
phone:{
|
||||
isPhone:true,
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
"deptName": {
|
||||
remote: "部门已经存在"
|
||||
}
|
||||
},
|
||||
focusCleanup: true
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/edit", $('#form-dept-edit').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
/*部门管理-修改-选择部门树*/
|
||||
function selectDeptTree() {
|
||||
var deptId = $("#treeId").val();
|
||||
var excludeId = $("input[name='deptId']").val();
|
||||
if(deptId > 0) {
|
||||
var options = {
|
||||
title: '部门选择',
|
||||
width: "380",
|
||||
url: prefix + "/selectDeptTree/" + $("#treeId").val() + "/" + excludeId,
|
||||
callBack: doSubmit
|
||||
};
|
||||
$.modal.openOptions(options);
|
||||
} else {
|
||||
$.modal.alertError("父部门不能选择");
|
||||
}
|
||||
}
|
||||
|
||||
function doSubmit(index, layero){
|
||||
var tree = layero.find("iframe")[0].contentWindow.$._tree;
|
||||
if ($.tree.notAllowLastLevel(tree)) {
|
||||
var body = $.modal.getChildFrame(index);
|
||||
$("#treeId").val(body.find('#treeId').val());
|
||||
$("#treeName").val(body.find('#treeName').val());
|
||||
$.modal.close(index);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('类目树选择')" />
|
||||
<th:block th:include="include :: ztree-css" />
|
||||
</head>
|
||||
<style>
|
||||
body{height:auto;font-family: "Microsoft YaHei";}
|
||||
button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
|
||||
</style>
|
||||
<body class="hold-transition box box-main">
|
||||
<input id="treeId" name="treeId" type="hidden" th:value="${goodsCategory.goodsCategoryId}"/>
|
||||
<input id="treeName" name="treeName" type="hidden" th:value="${goodsCategory.goodsCategoryName}"/>
|
||||
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
|
||||
<label id="btnShow" title="显示搜索" style="display:none;">︾</label>
|
||||
<label id="btnHide" title="隐藏搜索">︽</label>
|
||||
</div>
|
||||
<div class="treeSearchInput" id="search">
|
||||
<label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
|
||||
<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
|
||||
</div>
|
||||
<div class="treeExpandCollapse">
|
||||
<a href="#" onclick="$.tree.expand()">展开</a> /
|
||||
<a href="#" onclick="$.tree.collapse()">折叠</a>
|
||||
</div>
|
||||
<div id="tree" class="ztree treeselect"></div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<th:block th:include="include :: ztree-js" />
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "goods/category"
|
||||
var deptId = [[${goodsCategoryId}]];
|
||||
var excludeId = [[${excludeId}]];
|
||||
$(function() {
|
||||
var url = $.common.isEmpty(excludeId) ? prefix + "/treeData": prefix + "/treeData/" + excludeId;
|
||||
var options = {
|
||||
url: url,
|
||||
expandLevel: 2,
|
||||
onClick : zOnClick
|
||||
};
|
||||
$.tree.init(options);
|
||||
});
|
||||
|
||||
function zOnClick(event, treeId, treeNode) {
|
||||
var treeId = treeNode.id;
|
||||
var treeName = treeNode.name;
|
||||
$("#treeId").val(treeId);
|
||||
$("#treeName").val(treeName);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -30,6 +30,12 @@ public class UserConstants
|
|||
/** 部门正常状态 */
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/** 类目正常状态 */
|
||||
public static final Integer CATEGORY_NORMAL = 0;
|
||||
|
||||
/** 类目停用状态 */
|
||||
public static final Integer CATEGORY_DISABLE = 1;
|
||||
|
||||
/** 部门停用状态 */
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
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.List;
|
||||
|
|
@ -30,6 +32,14 @@ public interface GoodsCategoryService {
|
|||
List<GoodsCategory> selectGoodsCategoryList(GoodsCategory goodsCategory);
|
||||
|
||||
|
||||
/**
|
||||
* 查询类目管理树
|
||||
*
|
||||
* @param goodsCategory 类目信息
|
||||
* @return 所有类目信息
|
||||
*/
|
||||
public List<Ztree> selectCategoryTree(GoodsCategory goodsCategory);
|
||||
|
||||
/**
|
||||
* @param goodsCategoryId 商品类别id
|
||||
* @return 商品类别
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package com.ghy.goods.service.impl;
|
||||
|
||||
import com.ghy.common.constant.UserConstants;
|
||||
import com.ghy.common.core.domain.Ztree;
|
||||
import com.ghy.common.core.domain.entity.SysDept;
|
||||
import com.ghy.common.core.text.Convert;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.goods.domain.Goods;
|
||||
import com.ghy.goods.domain.GoodsCategory;
|
||||
import com.ghy.goods.mapper.GoodsCategoryMapper;
|
||||
|
|
@ -10,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -39,6 +44,12 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
|
|||
return goodsCategoryMapper.selectGoodsCategoryList(goodsCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ztree> selectCategoryTree(GoodsCategory goodsCategory) {
|
||||
List<GoodsCategory> goodsCategoryList = goodsCategoryMapper.selectGoodsCategoryList(goodsCategory);
|
||||
return initZtree(goodsCategoryList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoodsCategory selectById(Long goodsCategoryId) {
|
||||
return goodsCategoryMapper.selectById(goodsCategoryId);
|
||||
|
|
@ -71,4 +82,43 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
|
|||
}
|
||||
return category.getGoodsCategoryId().equals(goodsCategory.getGoodsCategoryId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转类目树
|
||||
*
|
||||
* @param goodsCategoryList 类目列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList)
|
||||
{
|
||||
return initZtree(goodsCategoryList, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转部门树
|
||||
*
|
||||
* @param goodsCategoryList 类目列表
|
||||
* @param roleDeptList 该列表无需校验
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList, List<String> roleDeptList)
|
||||
{
|
||||
|
||||
List<Ztree> ztrees = new ArrayList<Ztree>();
|
||||
for (GoodsCategory goodsCategory : goodsCategoryList)
|
||||
{
|
||||
if (UserConstants.CATEGORY_NORMAL.equals(goodsCategory.getStatus()))
|
||||
{
|
||||
Ztree ztree = new Ztree();
|
||||
ztree.setId(goodsCategory.getGoodsCategoryId());
|
||||
ztree.setpId(goodsCategory.getParentCategoryId());
|
||||
ztree.setName(goodsCategory.getGoodsCategoryName());
|
||||
ztree.setTitle(goodsCategory.getGoodsCategoryName());
|
||||
ztrees.add(ztree);
|
||||
}
|
||||
}
|
||||
return ztrees;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<result property="parentCategoryId" column="parent_category_id" />
|
||||
<result property="level" column="level" />
|
||||
<result property="type" column="type" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
|
@ -18,7 +19,7 @@
|
|||
|
||||
<sql id="selectGoodsCategory">
|
||||
SELECT goods_category_id, goods_category_code, goods_category_name, parent_category_id,
|
||||
level, type, create_by, create_time, remark
|
||||
level, type, status, create_by, create_time, remark
|
||||
FROM goods_category
|
||||
</sql>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue