From 34ae25bf4686c3cc974be2bb8710812128fbd05a Mon Sep 17 00:00:00 2001 From: zhuyu Date: Thu, 15 May 2025 16:29:41 +0800 Subject: [PATCH] feature: kpi item --- application/admin/controller/kpi/Item.php | 37 ++++++++++++++++++++++- application/admin/view/kpi/item/add.html | 10 ++---- application/admin/view/kpi/item/edit.html | 10 ++---- public/assets/js/backend/kpi/item.js | 1 - 4 files changed, 40 insertions(+), 18 deletions(-) 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 @@
- +
- - - + {:build_select('group', $groupdata, null, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
diff --git a/application/admin/view/kpi/item/edit.html b/application/admin/view/kpi/item/edit.html index ca6c954..4c5a6e8 100644 --- a/application/admin/view/kpi/item/edit.html +++ b/application/admin/view/kpi/item/edit.html @@ -1,15 +1,9 @@
- +
- - - + {:build_select('group', $groupdata, $groupid, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
diff --git a/public/assets/js/backend/kpi/item.js b/public/assets/js/backend/kpi/item.js index 5912864..4baa171 100644 --- a/public/assets/js/backend/kpi/item.js +++ b/public/assets/js/backend/kpi/item.js @@ -27,7 +27,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'admin_id', title: __('Admin_id')}, - {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal}, {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'target_value', title: __('Target_value')},