Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
bd3d8bd2
Commit
bd3d8bd2
authored
Mar 14, 2019
by
qiankunpingtai
Browse files
添加商品类型和机构选择父级的时候只能从父级或者旁级选择的控制
parent
08d3490a
Changes
13
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/organization.html
View file @
bd3d8bd2
...
...
@@ -116,6 +116,7 @@
var
url
;
//初始化界面
$
(
function
()
{
var
id
=
$
(
"
#id
"
).
val
();
var
treeHeight
=
webH
-
35
;
//初始化系统基础信息
$
(
'
#tableData
'
).
datagrid
({
...
...
@@ -142,7 +143,7 @@
});
$
(
'
#tableData
'
).
prev
(
'
.datagrid-view2
'
).
find
(
"
.datagrid-body
"
).
append
(
"
<ul id='tt'><ul>
"
);
$
(
'
#tt
'
).
tree
({
url
:
'
/organization/getOrganizationTree
'
,
url
:
'
/organization/getOrganizationTree
?id=
'
+
id
,
animate
:
true
,
checkbox
:
true
,
onDblClick
:
function
(
node
){
...
...
erp_web/pages/manage/organization_forselect.html
View file @
bd3d8bd2
...
...
@@ -23,8 +23,9 @@
<script
type=
"text/javascript"
>
$
(
function
()
{
var
id
=
$
(
"
#id
"
).
val
();
$
(
'
#ttForSelect
'
).
tree
({
url
:
'
/organization/getOrganizationTree
'
,
url
:
'
/organization/getOrganizationTree
?id=
'
+
id
,
animate
:
true
,
onDblClick
:
function
(
node
)
{
//双击修改
...
...
erp_web/pages/materials/materialcategory.html
View file @
bd3d8bd2
...
...
@@ -82,6 +82,7 @@
//初始化界面
$
(
function
()
{
var
treeHeight
=
webH
-
35
;
var
id
=
$
(
"
#id
"
).
val
();
//初始化系统基础信息
$
(
'
#tableData
'
).
datagrid
({
height
:
treeHeight
,
...
...
@@ -107,7 +108,7 @@
});
$
(
'
#tableData
'
).
prev
(
'
.datagrid-view2
'
).
find
(
"
.datagrid-body
"
).
append
(
"
<ul id='tt'><ul>
"
);
$
(
'
#tt
'
).
tree
({
url
:
'
/materialCategory/getMaterialCategoryTree
'
,
url
:
'
/materialCategory/getMaterialCategoryTree
?id=
'
+
id
,
animate
:
true
,
checkbox
:
true
,
onDblClick
:
function
(
node
){
...
...
erp_web/pages/materials/materialcategory_forselect.html
View file @
bd3d8bd2
...
...
@@ -21,10 +21,19 @@
</div>
<script
type=
"text/javascript"
>
/**
* create by: qiankunpingtai
* create time: 2019/3/14 11:41
* description:
* 为了防止当前节点选择父级目录为其子代节点造成闭环无法获取的问题
* 决定对树结构可选父级目录做一个筛选,只能为其上级目录
*
*/
$
(
function
()
{
var
id
=
$
(
"
#id
"
).
val
();
console
.
log
(
id
);
$
(
'
#ttForSelect
'
).
tree
({
url
:
'
/materialCategory/getMaterialCategoryTree
'
,
url
:
'
/materialCategory/getMaterialCategoryTree
?id=
'
+
id
,
animate
:
true
,
onDblClick
:
function
(
node
)
{
//双击修改
...
...
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
bd3d8bd2
...
...
@@ -83,7 +83,14 @@ public class BusinessConstants {
/**
* 商品类别根目录id
* */
public
static
final
Long
MATERIAL_CATEGORY_ROOT_ID
=
1L
;
/**
* create by: qiankunpingtai
* create time: 2019/3/14 11:41
* description:
* 为了使用户可以自己建初始目录,设定根目录的父级目录id为-1
*
*/
public
static
final
Long
MATERIAL_CATEGORY_ROOT_PARENT_ID
=
-
1L
;
/**
* 商品类别状态
* 0系统默认,1启用,2删除
...
...
@@ -101,10 +108,10 @@ public class BusinessConstants {
public
static
final
String
ORGANIZATION_STCD_BUSINESS_TERMINATED
=
"4"
;
public
static
final
String
ORGANIZATION_STCD_REMOVED
=
"5"
;
/**
* 根机构编号
* 根机构编号默认为-1
* 根机构
父级
编号
* 根机
父级
构编号默认为-1
* */
public
static
final
String
ORGANIZATION_ROOT_NO
=
"-1"
;
public
static
final
String
ORGANIZATION_ROOT_
PARENT_
NO
=
"-1"
;
/**
* 新增用户默认密码
* */
...
...
src/main/java/com/jsh/erp/controller/MaterialCategoryController.java
View file @
bd3d8bd2
...
...
@@ -92,9 +92,9 @@ public class MaterialCategoryController {
* @return com.alibaba.fastjson.JSONArray
*/
@RequestMapping
(
value
=
"/getMaterialCategoryTree"
)
public
JSONArray
getMaterialCategoryTree
()
throws
Exception
{
public
JSONArray
getMaterialCategoryTree
(
@RequestParam
(
"id"
)
Long
id
)
throws
Exception
{
JSONArray
arr
=
new
JSONArray
();
List
<
TreeNode
>
materialCategoryTree
=
materialCategoryService
.
getMaterialCategoryTree
();
List
<
TreeNode
>
materialCategoryTree
=
materialCategoryService
.
getMaterialCategoryTree
(
id
);
if
(
materialCategoryTree
!=
null
&&
materialCategoryTree
.
size
()>
0
){
for
(
TreeNode
node:
materialCategoryTree
){
String
str
=
JSON
.
toJSONString
(
node
);
...
...
src/main/java/com/jsh/erp/controller/OrganizationController.java
View file @
bd3d8bd2
...
...
@@ -95,9 +95,9 @@ public class OrganizationController {
* @return com.alibaba.fastjson.JSONArray
*/
@RequestMapping
(
value
=
"/getOrganizationTree"
)
public
JSONArray
getOrganizationTree
()
throws
Exception
{
public
JSONArray
getOrganizationTree
(
@RequestParam
(
"id"
)
Long
id
)
throws
Exception
{
JSONArray
arr
=
new
JSONArray
();
List
<
TreeNode
>
organizationTree
=
organizationService
.
getOrganizationTree
();
List
<
TreeNode
>
organizationTree
=
organizationService
.
getOrganizationTree
(
id
);
if
(
organizationTree
!=
null
&&
organizationTree
.
size
()>
0
){
for
(
TreeNode
node:
organizationTree
){
String
str
=
JSON
.
toJSONString
(
node
);
...
...
src/main/java/com/jsh/erp/datasource/mappers/MaterialCategoryMapperEx.java
View file @
bd3d8bd2
...
...
@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* Description
...
...
@@ -24,8 +25,8 @@ public interface MaterialCategoryMapperEx {
@Param
(
"name"
)
String
name
,
@Param
(
"parentId"
)
Integer
parentId
);
List
<
TreeNode
>
getNodeTree
();
List
<
TreeNode
>
getNextNodeTree
(
@Param
(
"id"
)
Long
id
);
List
<
TreeNode
>
getNodeTree
(
@Param
(
"currentId"
)
Long
currentId
);
List
<
TreeNode
>
getNextNodeTree
(
Map
<
String
,
Object
>
parameterMap
);
int
addMaterialCategory
(
MaterialCategory
mc
);
...
...
src/main/java/com/jsh/erp/datasource/mappers/OrganizationMapperEx.java
View file @
bd3d8bd2
...
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* Description
...
...
@@ -17,8 +18,8 @@ import java.util.List;
public
interface
OrganizationMapperEx
{
List
<
TreeNode
>
getNodeTree
();
List
<
TreeNode
>
getNextNodeTree
(
@Param
(
"id"
)
Long
id
);
List
<
TreeNode
>
getNodeTree
(
@Param
(
"currentId"
)
Long
currentId
);
List
<
TreeNode
>
getNextNodeTree
(
Map
<
String
,
Object
>
parameterMap
);
int
addOrganization
(
Organization
org
);
...
...
src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java
View file @
bd3d8bd2
...
...
@@ -100,8 +100,8 @@ public class MaterialCategoryService {
* @Param:
* @return java.util.List<com.jsh.erp.datasource.vo.TreeNode>
*/
public
List
<
TreeNode
>
getMaterialCategoryTree
()
throws
Exception
{
return
materialCategoryMapperEx
.
getNodeTree
();
public
List
<
TreeNode
>
getMaterialCategoryTree
(
Long
id
)
throws
Exception
{
return
materialCategoryMapperEx
.
getNodeTree
(
id
);
}
/**
* create by: cjl
...
...
@@ -117,8 +117,8 @@ public class MaterialCategoryService {
return
0
;
}
if
(
mc
.
getParentid
()==
null
){
//没有给定父级目录的id,默认设置父级目录为根目录
mc
.
setParentid
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_ID
);
//没有给定父级目录的id,默认设置父级目录为根目录
的父目录
mc
.
setParentid
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_
PARENT_
ID
);
}
//检查商品类型编号是否已存在
checkMaterialCategorySerialNo
(
mc
);
...
...
@@ -148,40 +148,16 @@ public class MaterialCategoryService {
if
(
strArray
.
length
<
1
){
return
0
;
}
/**
* create by: qiankunpingtai
* create time: 2019/3/13 14:49
* description:
* 添加一个限制,根目录不允许删除
*/
String
rootIdStr
=
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_ID
.
toString
();
for
(
String
s:
strArray
){
if
(
rootIdStr
.
equals
(
s
)){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,id:[{}]"
,
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG
,
s
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG
);
}
}
return
materialCategoryMapperEx
.
batchDeleteMaterialCategoryByIds
(
updateDate
,
updater
,
strArray
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
editMaterialCategory
(
MaterialCategory
mc
)
{
/**
* create by: qiankunpingtai
* create time: 2019/3/13 14:49
* description:
* 添加一个限制根目录不允许修改
*/
if
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_ID
.
equals
(
mc
.
getId
())){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,id:[{}]"
,
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG
,
mc
.
getId
());
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG
);
if
(
mc
.
getParentid
()==
null
){
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
mc
.
setParentid
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_PARENT_ID
);
}
//检查商品类型编号是否已存在
checkMaterialCategorySerialNo
(
mc
);
//更新时间
...
...
src/main/java/com/jsh/erp/service/organization/OrganizationService.java
View file @
bd3d8bd2
...
...
@@ -82,7 +82,7 @@ public class OrganizationService {
* 未指定父级机构的时候默认为根机构
* */
if
(
StringUtil
.
isEmpty
(
org
.
getOrgParentNo
())){
org
.
setOrgParentNo
(
BusinessConstants
.
ORGANIZATION_ROOT_NO
);
org
.
setOrgParentNo
(
BusinessConstants
.
ORGANIZATION_ROOT_
PARENT_
NO
);
}
return
organizationMapperEx
.
addOrganization
(
org
);
}
...
...
@@ -103,13 +103,13 @@ public class OrganizationService {
* 未指定父级机构的时候默认为根机构
* */
if
(
StringUtil
.
isEmpty
(
org
.
getOrgParentNo
())){
org
.
setOrgParentNo
(
BusinessConstants
.
ORGANIZATION_ROOT_NO
);
org
.
setOrgParentNo
(
BusinessConstants
.
ORGANIZATION_ROOT_
PARENT_
NO
);
}
return
organizationMapperEx
.
editOrganization
(
org
);
}
public
List
<
TreeNode
>
getOrganizationTree
()
throws
Exception
{
return
organizationMapperEx
.
getNodeTree
();
public
List
<
TreeNode
>
getOrganizationTree
(
Long
id
)
throws
Exception
{
return
organizationMapperEx
.
getNodeTree
(
id
);
}
public
List
<
Organization
>
findById
(
Long
id
)
throws
Exception
{
...
...
src/main/resources/mapper_xml/MaterialCategoryMapperEx.xml
View file @
bd3d8bd2
...
...
@@ -33,14 +33,14 @@
<resultMap
id=
"BaseTreeResultMap"
type=
"com.jsh.erp.datasource.vo.TreeNode"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"name"
property=
"text"
/>
<collection
column=
"
id
"
property=
"children"
javaType=
"java.util.ArrayList"
<collection
column=
"
{currentId=currentId,id=id}
"
property=
"children"
javaType=
"java.util.ArrayList"
ofType=
"com.jsh.erp.datasource.vo.TreeNode"
select=
"getNextNodeTree"
/>
</resultMap>
<resultMap
id=
"NextTreeResultMap"
type=
"com.jsh.erp.datasource.vo.TreeNode"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"name"
property=
"text"
/>
<collection
column=
"
id
"
property=
"children"
javaType=
"java.util.ArrayList"
<collection
column=
"
{currentId=currentId,id=id}
"
property=
"children"
javaType=
"java.util.ArrayList"
ofType=
"com.jsh.erp.datasource.vo.TreeNode"
select=
"getNextNodeTree"
/>
</resultMap>
...
...
@@ -50,19 +50,25 @@
<select
id=
"getNextNodeTree"
resultMap=
"NextTreeResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
,#{currentId} as currentId
FROM jsh_materialcategory
WHERE ParentId = #{id}
<if
test=
"currentId != null"
>
and id !=#{currentId}
</if>
and status !='2'
order by sort asc
</select>
<select
id=
"getNodeTree"
resultMap=
"BaseTreeResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
,#{currentId} as currentId
FROM jsh_materialcategory
WHERE ParentId = -1
and status !='2'
<if
test=
"currentId != null"
>
and id !=#{currentId}
</if>
order by sort asc
</select>
<insert
id=
"addMaterialCategory"
parameterType=
"com.jsh.erp.datasource.entities.MaterialCategory"
...
...
src/main/resources/mapper_xml/OrganizationMapperEx.xml
View file @
bd3d8bd2
...
...
@@ -6,7 +6,7 @@
<result
column=
"id"
property=
"id"
/>
<result
column=
"org_abr"
property=
"text"
/>
<result
column=
"org_no"
property=
"attributes"
/>
<collection
column=
"
org_no
"
property=
"children"
javaType=
"java.util.ArrayList"
<collection
column=
"
{currentId=currentId,org_no=org_no}
"
property=
"children"
javaType=
"java.util.ArrayList"
ofType=
"com.jsh.erp.datasource.vo.TreeNode"
select=
"getNextNodeTree"
/>
</resultMap>
...
...
@@ -14,7 +14,7 @@
<result
column=
"id"
property=
"id"
/>
<result
column=
"org_abr"
property=
"text"
/>
<result
column=
"org_no"
property=
"attributes"
/>
<collection
column=
"
org_no
"
property=
"children"
javaType=
"java.util.ArrayList"
<collection
column=
"
{currentId=currentId,org_no=org_no}
"
property=
"children"
javaType=
"java.util.ArrayList"
ofType=
"com.jsh.erp.datasource.vo.TreeNode"
select=
"getNextNodeTree"
/>
</resultMap>
...
...
@@ -24,18 +24,24 @@
<select
id=
"getNextNodeTree"
resultMap=
"NextTreeResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
,#{currentId} as currentId
FROM jsh_organization
WHERE org_parent_no = #{org_no}
<if
test=
"currentId != null"
>
and id !=#{currentId}
</if>
and org_stcd !='5'
order by sort asc
</select>
<select
id=
"getNodeTree"
resultMap=
"BaseTreeResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
,#{currentId} as currentId
FROM jsh_organization
WHERE org_parent_no = -1
<if
test=
"currentId != null"
>
and id !=#{currentId}
</if>
and org_stcd !='5'
order by sort asc
</select>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment