diff --git a/application/admin/controller/kpi/Item.php b/application/admin/controller/kpi/Item.php index 72bce84..2cff64e 100644 --- a/application/admin/controller/kpi/Item.php +++ b/application/admin/controller/kpi/Item.php @@ -2,8 +2,10 @@ namespace app\admin\controller\kpi; +use app\admin\model\AuthGroup; use app\common\controller\Backend; use Exception; +use fast\Tree; use think\Db; use think\exception\DbException; use think\exception\PDOException; @@ -29,6 +31,35 @@ class Item extends Backend $this->model = new \app\admin\model\kpi\Item; $this->view->assign("typeList", $this->model->getTypeList()); $this->view->assign("unitList", $this->model->getUnitList()); + + $this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin()); + $this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin()); + + $groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray(); + + Tree::instance()->init($groupList); + $groupdata = []; + if ($this->auth->isSuperAdmin()) { + $result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0)); + foreach ($result as $k => $v) { + $groupdata[$v['id']] = $v['name']; + } + } else { + $result = []; + $groups = $this->auth->getGroups(); + foreach ($groups as $m => $n) { + $childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id'])); + $temp = []; + foreach ($childlist as $k => $v) { + $temp[$v['id']] = $v['name']; + } + $result[__($n['name'])] = $temp; + } + $groupdata = $result; + } + + $this->view->assign('groupdata', $groupdata); + } /** @@ -78,6 +109,8 @@ class Item extends Backend $this->model->validateFailException()->validate($validate); } + $group = $this->request->post("group/a"); + $params['group_id'] = $group[0]; $params['create_time'] = date('Y-m-d H:i:s'); $params['update_time'] = date('Y-m-d H:i:s'); @@ -112,6 +145,7 @@ class Item extends Backend $this->error(__('You have no permission')); } if (false === $this->request->isPost()) { + $this->view->assign("groupid", $row['group_id']); $this->view->assign('row', $row); return $this->view->fetch(); } @@ -130,7 +164,8 @@ class Item extends Backend $row->validateFailException()->validate($validate); } - + $group = $this->request->post("group/a"); + $params['group_id'] = $group[0]; $params['update_time'] = date('Y-m-d H:i:s'); $result = $row->allowField(true)->save($params); diff --git a/application/admin/view/kpi/item/add.html b/application/admin/view/kpi/item/add.html index e6e575d..2ef10fa 100644 --- a/application/admin/view/kpi/item/add.html +++ b/application/admin/view/kpi/item/add.html @@ -1,15 +1,9 @@