feature: kpi template
This commit is contained in:
parent
34ae25bf46
commit
24466054c7
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
namespace app\admin\controller\kpi;
|
namespace app\admin\controller\kpi;
|
||||||
|
|
||||||
|
use app\admin\model\AuthGroup;
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use fast\Tree;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
|
|
@ -27,6 +29,34 @@ class Template extends Backend
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->model = new \app\admin\model\kpi\Template;
|
$this->model = new \app\admin\model\kpi\Template;
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -90,7 +120,8 @@ class Template extends Backend
|
||||||
$this->model->validateFailException()->validate($validate);
|
$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['create_time'] = date('Y-m-d H:i:s');
|
||||||
$params['update_time'] = date('Y-m-d H:i:s');
|
$params['update_time'] = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
|
@ -153,6 +184,7 @@ class Template extends Backend
|
||||||
$assignKpiitem = json_encode($assignKpiitem);
|
$assignKpiitem = json_encode($assignKpiitem);
|
||||||
|
|
||||||
$this->view->assign('assignkpiitem', $assignKpiitem);
|
$this->view->assign('assignkpiitem', $assignKpiitem);
|
||||||
|
$this->view->assign("groupid", $row['group_id']);
|
||||||
$this->view->assign('row', $row);
|
$this->view->assign('row', $row);
|
||||||
return $this->view->fetch();
|
return $this->view->fetch();
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +203,8 @@ class Template extends Backend
|
||||||
$row->validateFailException()->validate($validate);
|
$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');
|
$params['update_time'] = date('Y-m-d H:i:s');
|
||||||
$result = $row->allowField(true)->save($params);
|
$result = $row->allowField(true)->save($params);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,6 @@
|
||||||
return [
|
return [
|
||||||
'Id' => 'ID',
|
'Id' => 'ID',
|
||||||
'Admin_id' => '创建人id',
|
'Admin_id' => '创建人id',
|
||||||
'Type' => '指标类型',
|
|
||||||
'Type 1' => '派单员',
|
|
||||||
'Type 2' => '运营',
|
|
||||||
'Type 3' => '售前',
|
|
||||||
'Name' => '名称',
|
'Name' => '名称',
|
||||||
'Desc' => '描述',
|
'Desc' => '描述',
|
||||||
'Target_value' => '目标值',
|
'Target_value' => '目标值',
|
||||||
|
|
|
||||||
|
|
@ -30,26 +30,12 @@ class Item extends Model
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getTypeList()
|
|
||||||
{
|
|
||||||
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUnitList()
|
public function getUnitList()
|
||||||
{
|
{
|
||||||
return ['1' => __('Unit 1'), '2' => __('Unit 2')];
|
return ['1' => __('Unit 1'), '2' => __('Unit 2')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getTypeTextAttr($value, $data)
|
|
||||||
{
|
|
||||||
$value = $value ?: ($data['type'] ?? '');
|
|
||||||
$list = $this->getTypeList();
|
|
||||||
return $list[$value] ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getUnitTextAttr($value, $data)
|
public function getUnitTextAttr($value, $data)
|
||||||
{
|
{
|
||||||
$value = $value ?: ($data['unit'] ?? '');
|
$value = $value ?: ($data['unit'] ?? '');
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
{:build_select('group', $groupdata, null, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
{:build_select('group', $groupdata, $groupid, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user