feature: kpi template
This commit is contained in:
parent
627d7cd788
commit
a087a9d4c8
|
|
@ -37,6 +37,29 @@ class Template extends Backend
|
|||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
//如果发送的来源是 Selectpage,则转发到 Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->with('kpiitem')
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ class Template extends Model
|
|||
|
||||
|
||||
|
||||
public function kpiitem()
|
||||
{
|
||||
return $this->belongsToMany('app\admin\model\kpi\item', 'kpi_template_item', 'item_id', 'template_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{field: 'admin_id', title: __('Admin_id')},
|
||||
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
||||
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{
|
||||
field: 'kpiitem',
|
||||
title: '指标',
|
||||
operate: false,
|
||||
formatter: function (value) {
|
||||
// value 是一个标签数组
|
||||
return value.map(function ($item) {
|
||||
return '<div>' + $item.name + '---' + $item.pivot.rate + '%' + '</div><br>';
|
||||
}).join('');
|
||||
}
|
||||
},
|
||||
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user