解决分公司类目从总公司选取的功能

This commit is contained in:
clunt 2022-05-10 11:11:50 +08:00
parent 7a2c3683bd
commit ad7357aea7
7 changed files with 49 additions and 155 deletions

View File

@ -152,7 +152,7 @@ public class GoodsCategoryController extends BaseController {
/**
* 商品类别表
*/
@RequiresPermissions("goods:goods:list")
// @RequiresPermissions("goods:goods:list")
@PostMapping("/list")
@ResponseBody
public List<GoodsCategory> list(GoodsCategory category) {

View File

@ -2,13 +2,12 @@ package com.ghy.web.controller.goods;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.Ztree;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.service.GoodsCategoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -32,11 +31,21 @@ public class GoodsDeptCategoryController extends BaseController {
@RequiresPermissions("goods:deptcategory:add")
@GetMapping("/add")
public String edit(ModelMap mmap) {
@GetMapping("/add/{id}")
public String edit(@PathVariable(name = "id") Long id, ModelMap mmap) {
return PREFIX + "/add";
}
/**
* 商品类别表
*/
@RequiresPermissions("goods:goods:list")
@PostMapping("/list")
@ResponseBody
public List<GoodsCategory> list(GoodsCategory category) {
return goodsCategoryService.selectGoodsCategoryList(category);
}
@GetMapping("/tree")
@ResponseBody
public List<Ztree> goodsDeptCategoryTree() {

View File

@ -1,141 +0,0 @@
<!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>

View File

@ -1,14 +1,13 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改角色')" />
<th:block th:include="include :: header('新增分公司类目')" />
<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-edit">
<form class="form-horizontal m" id="form-category-add">
<div class="form-group">
<label class="col-sm-3 control-label">菜单权限:</label>
<div class="col-sm-8">
<label class="check-box">
<input type="checkbox" value="1">展开/折叠</label>
@ -34,9 +33,33 @@
};
$.tree.init(options);
});
function edit() {
var menuIds = $.tree.getCheckedNodes();
$('input').on('ifChanged', function(obj){
var type = $(this).val();
var checked = obj.currentTarget.checked;
if (type == 1) {
if (checked) {
$._tree.expandAll(true);
} else {
$._tree.expandAll(false);
}
} else if (type == "2") {
if (checked) {
$._tree.checkAllNodes(true);
} else {
$._tree.checkAllNodes(false);
}
} else if (type == "3") {
if (checked) {
$._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" };
} else {
$._tree.setting.check.chkboxType = { "Y": "", "N": "" };
}
}
})
function add() {
var menuIds = $.tree.getCheckedNodes("goodsCategoryId");
$.ajax({
cache : true,
type : "POST",

View File

@ -32,7 +32,7 @@
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-primary" onclick="$.operate.edit(1)" shiro:hasPermission="goods:category:edit">
<a class="btn btn-primary" onclick="$.operate.add(1)" shiro:hasPermission="goods:category:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
@ -50,7 +50,7 @@
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/category"
var prefix = ctx + "goods/deptcategory"
$(function() {
var options = {
@ -58,6 +58,7 @@
parentCode: "parentCategoryId",
uniqueId: "goodsCategoryId",
url: prefix + "/list",
addUrl: prefix + "/add/{id}",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove/{id}",

View File

@ -278,6 +278,7 @@ public class ShiroConfig
//部分接口不需要登陆校验
filterChainDefinitionMap.put("/wx/**", "anon");
filterChainDefinitionMap.put("/pay/**", "anon");
filterChainDefinitionMap.put("/goods/**", "anon");
filterChainDefinitionMap.put("/adapay/**", "anon");
filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon");
// 对静态资源设置匿名访问

View File

@ -114,6 +114,7 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
ztree.setpId(goodsCategory.getParentCategoryId());
ztree.setName(goodsCategory.getGoodsCategoryName());
ztree.setTitle(goodsCategory.getGoodsCategoryName());
ztrees.add(ztree);
}
}