diff --git a/module/dept/model.php b/module/dept/model.php index 2898370902..00f6fcfd61 100644 --- a/module/dept/model.php +++ b/module/dept/model.php @@ -256,6 +256,7 @@ class deptModel extends model $parentPath = ','; } + $i = 1; foreach($childs as $deptID => $deptName) { if(empty($deptName)) continue; @@ -264,10 +265,12 @@ class deptModel extends model $dept->name = strip_tags($deptName); $dept->parent = $parentDeptID; $dept->grade = $grade; + $dept->order = $this->post->maxOrder + $i * 10; $this->dao->insert(TABLE_DEPT)->data($dept)->exec(); $deptID = $this->dao->lastInsertID(); $childPath = $parentPath . "$deptID,"; $this->dao->update(TABLE_DEPT)->set('path')->eq($childPath)->where('id')->eq($deptID)->exec(); + $i++; } else { diff --git a/module/dept/view/browse.html.php b/module/dept/view/browse.html.php index 908e456397..e93c27ebaa 100644 --- a/module/dept/view/browse.html.php +++ b/module/dept/view/browse.html.php @@ -48,7 +48,12 @@ id]", $sonDept->name) . '
'; + $maxOrder = 0; + foreach($sons as $sonDept) + { + if($sonDept->order > $maxOrder) $maxOrder = $sonDept->order; + echo html::input("depts[id$sonDept->id]", $sonDept->name) . '
'; + } for($i = 0; $i < DEPT::NEW_CHILD_COUNT ; $i ++) echo html::input("depts[]") . '
'; ?> @@ -56,7 +61,7 @@ - +