From 12925bc1cd195ca5445864e480a9ddc7e547b2dc Mon Sep 17 00:00:00 2001 From: Catouse Date: Mon, 11 Apr 2016 19:22:51 +0800 Subject: [PATCH] * change UI of department manage view. --- module/dept/control.php | 1 + module/dept/css/browse.css | 9 +- module/dept/lang/en.php | 4 +- module/dept/lang/zh-cn.php | 2 + module/dept/model.php | 20 ++++ module/dept/view/browse.html.php | 182 +++++++++++++++++++++---------- 6 files changed, 157 insertions(+), 61 deletions(-) diff --git a/module/dept/control.php b/module/dept/control.php index c40e892f27..7ade562193 100644 --- a/module/dept/control.php +++ b/module/dept/control.php @@ -41,6 +41,7 @@ class dept extends control $this->view->depts = $this->dept->getTreeMenu($rootDeptID = 0, array('deptmodel', 'createManageLink')); $this->view->parentDepts = $parentDepts; $this->view->sons = $this->dept->getSons($deptID); + $this->view->tree = $this->dept->getFullTree(0); $this->display(); } diff --git a/module/dept/css/browse.css b/module/dept/css/browse.css index 8bd5357e69..454ff34df7 100644 --- a/module/dept/css/browse.css +++ b/module/dept/css/browse.css @@ -1,4 +1,11 @@ .table.table-form {width: auto;} .table-form > tbody > tr > td .form-control + .form-control {margin-top: 5px;} -.tree-lines li.has-list.open > ul:after {bottom: 20px;} +.tree li.has-list > .tree-actions > .tree-action[data-type="delete"] {display: none} +.tree .dept-name {font-weight: 500} +.tree-toggle {cursor: pointer;} +.tree li:hover > .tree-actions {opacity: 0} +.tree li.hover > .tree-actions {opacity: 1} + +#addChildModal form > .form-control {margin-bottom: 8px;} +#addChildModal .modal-dialog {max-width: 360px;} diff --git a/module/dept/lang/en.php b/module/dept/lang/en.php index da6d13cf95..c4cdee47d2 100644 --- a/module/dept/lang/en.php +++ b/module/dept/lang/en.php @@ -10,7 +10,7 @@ * @link http://www.zentao.net */ $lang->dept->common = 'Department'; -$lang->dept->manageChild = "Child deprtment"; +$lang->dept->manageChild = "Child department"; $lang->dept->edit = "Edit"; $lang->dept->delete = "Delete"; $lang->dept->parent = "Parent"; @@ -19,6 +19,8 @@ $lang->dept->name = "Name"; $lang->dept->browse = "Manage"; $lang->dept->manage = "Manage"; $lang->dept->updateOrder = "Update order"; +$lang->dept->add = "Add department"; +$lang->dept->dragAndSort = "Drag and sort"; $lang->dept->confirmDelete = "Are you sure to delete this department?"; $lang->dept->successSave = "Success save."; diff --git a/module/dept/lang/zh-cn.php b/module/dept/lang/zh-cn.php index abb3a9751d..baaf22f613 100644 --- a/module/dept/lang/zh-cn.php +++ b/module/dept/lang/zh-cn.php @@ -19,6 +19,8 @@ $lang->dept->name = "部门名称"; $lang->dept->browse = "部门维护"; $lang->dept->manage = "维护部门结构"; $lang->dept->updateOrder = "更新排序"; +$lang->dept->add = "添加部门"; +$lang->dept->dragAndSort = "拖动排序"; $lang->dept->confirmDelete = " 您确定删除该部门吗?"; $lang->dept->successSave = " 修改成功。"; diff --git a/module/dept/model.php b/module/dept/model.php index d746f82ba7..212fedbc27 100644 --- a/module/dept/model.php +++ b/module/dept/model.php @@ -445,4 +445,24 @@ class deptModel extends model $this->dao->update(TABLE_DEPT)->data($dept)->where('id')->eq($dept->id)->exec(); } } + + public function getFullTree($rootDeptID = 0) + { + $tree = array_values($this->getSons($rootDeptID)); + $users = $this->loadModel('user')->getPairs('nodeleted|noletter|noclosed'); + if(count($tree)) + { + foreach ($tree as $node) + { + $node->managerName = $users[$node->manager]; + $children = $this->getFullTree($node->id); + if(count($children)) + { + $node->children = $children; + $node->actions = array('delete' => false); + } + } + } + return $tree; + } } diff --git a/module/dept/view/browse.html.php b/module/dept/view/browse.html.php index fec2c75b9a..b2c3dee661 100644 --- a/module/dept/view/browse.html.php +++ b/module/dept/view/browse.html.php @@ -15,68 +15,132 @@
icons['dept']);?> dept->common;?>
-
-
-
-
- icons['dept']);?> -
-
-
'> -
-
dept->updateOrder);?>
-
-
-
+
+
+ icons['dept']);?>
-
-
-
- dept->manageChild;?> -
-
-
' class='form-condensed'> - - - - - - - - - - -
- - createLink('dept', 'browse'), $this->app->company->name); - echo $lang->arrow; - foreach($parentDepts as $dept) - { - echo html::a($this->createLink('dept', 'browse', "deptID=$dept->id"), $dept->name); - echo $lang->arrow; - } - ?> - - - order > $maxOrder) $maxOrder = $sonDept->order; - echo html::input("depts[id$sonDept->id]", $sonDept->name, "class='form-control'"); - } - for($i = 0; $i < DEPT::NEW_CHILD_COUNT ; $i ++) echo html::input("depts[]", '', "class='form-control'"); - ?> -
- - -
-
-
+
+
+
    -
    + +