...
|
...
|
@@ -190,8 +190,7 @@ func departmentRelationUpdate(departmentUpdate models.Department, newparent mode |
|
|
//重建关系树
|
|
|
s := strings.TrimLeft(departmentSubset[i].Relation, oldRelation)
|
|
|
departmentSubset[i].Relation = fmt.Sprintf("%s%s", newRelation, s)
|
|
|
s1 := strings.Split(departmentSubset[i].Relation, ",")
|
|
|
departmentSubset[i].Level = len(s1) - 2
|
|
|
departmentSubset[i].Level = setDepartmentLevel(departmentSubset[i].Relation)
|
|
|
}
|
|
|
|
|
|
//修改部门及子级部门的relation
|
...
|
...
|
@@ -257,8 +256,8 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
|
departmentData.ParentId = topDepartment.Id
|
|
|
departmentData.SetRelation(topDepartment)
|
|
|
}
|
|
|
s := strings.Split(departmentData.Relation, ",")
|
|
|
departmentData.Level = len(s) - 2
|
|
|
|
|
|
departmentData.Level = setDepartmentLevel(departmentData.Relation)
|
|
|
_, err = models.AddDepartment(departmentData, o)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("存储部门数据失败,err:%s", err)
|
...
|
...
|
@@ -271,6 +270,11 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func setDepartmentLevel(relation string) int {
|
|
|
s := strings.Split(relation, ",")
|
|
|
return len(s) - 3
|
|
|
}
|
|
|
|
|
|
//DeleteDepartmentData ...
|
|
|
func DeleteDepartmentData(ids []int64) error {
|
|
|
o := orm.NewOrm()
|
...
|
...
|
|