Compare commits
4 Commits
3914fd0689
...
5627c3f9ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5627c3f9ba | ||
|
|
9e67c8f3d7 | ||
|
|
850f0e1f98 | ||
|
|
b70b948cdd |
@ -63,8 +63,47 @@ class Employee extends Backend
|
|||||||
//得到查询值
|
//得到查询值
|
||||||
$value = $opertime['value'];
|
$value = $opertime['value'];
|
||||||
list($start_time,$end_time) = explode(" - ",$value);
|
list($start_time,$end_time) = explode(" - ",$value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// var_dump($sort);
|
||||||
|
// 判断是否按 score_count 排序,该字段为PHP计算值无法直接数据库排序
|
||||||
|
$sortByScoreCount = ($sort === 'employee.score_count');
|
||||||
|
// var_dump($sortByScoreCount);
|
||||||
|
if ($sortByScoreCount) {
|
||||||
|
|
||||||
|
// 按积分统计排序:需取全量数据后在PHP层排序再手动分页
|
||||||
|
$list = $this->model
|
||||||
|
->with(['user','team'])
|
||||||
|
->where($where)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
foreach ($list as $row) {
|
||||||
|
$row->getRelation('user')->visible(['nickname','mobile','avatar']);
|
||||||
|
$row->getRelation('team')->visible(['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$list = collection($list)->toArray();
|
||||||
|
|
||||||
|
// 为每条记录计算 score_count
|
||||||
|
foreach ($list as &$row) {
|
||||||
|
$row['score_count'] = \app\common\model\score\Employee::getPriceByCoachAndTime($row['id'], $start_time, $end_time);
|
||||||
|
$row['opertime'] = $start_time ? $start_time.'至'.$end_time : '';
|
||||||
|
}
|
||||||
|
unset($row);
|
||||||
|
|
||||||
|
// PHP层按 score_count 排序
|
||||||
|
usort($list, function($a, $b) use ($order) {
|
||||||
|
if (strtolower($order) === 'desc') {
|
||||||
|
return $b['score_count'] <=> $a['score_count'];
|
||||||
|
}
|
||||||
|
return $a['score_count'] <=> $b['score_count'];
|
||||||
|
});
|
||||||
|
|
||||||
|
$total = count($list);
|
||||||
|
// 手动分页
|
||||||
|
$list = array_slice($list, $offset, $limit);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 常规排序:直接数据库分页
|
||||||
$list = $this->model
|
$list = $this->model
|
||||||
->with(['user','team'])
|
->with(['user','team'])
|
||||||
->where($where)
|
->where($where)
|
||||||
@ -72,7 +111,6 @@ class Employee extends Backend
|
|||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
|
|
||||||
foreach ($list as $row) {
|
foreach ($list as $row) {
|
||||||
|
|
||||||
$row->getRelation('user')->visible(['nickname','mobile','avatar']);
|
$row->getRelation('user')->visible(['nickname','mobile','avatar']);
|
||||||
$row->getRelation('team')->visible(['name']);
|
$row->getRelation('team')->visible(['name']);
|
||||||
}
|
}
|
||||||
@ -81,13 +119,10 @@ class Employee extends Backend
|
|||||||
$list = $list->items();
|
$list = $list->items();
|
||||||
|
|
||||||
foreach ($list as &$row) {
|
foreach ($list as &$row) {
|
||||||
$row['score_count'] = 0;
|
$row['score_count'] = \app\common\model\score\Employee::getPriceByCoachAndTime($row['id'], $start_time, $end_time);
|
||||||
$row['opertime'] = '';
|
$row['opertime'] = $start_time ? $start_time.'至'.$end_time : '';
|
||||||
if($start_time){
|
|
||||||
$row['opertime'] = $start_time.'至'.$end_time;
|
|
||||||
}
|
}
|
||||||
$row['score_count'] = \app\common\model\score\Employee::getPriceByCoachAndTime($row['id'],$start_time,$end_time);
|
unset($row);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array("total" => $total, "rows" => $list);
|
$result = array("total" => $total, "rows" => $list);
|
||||||
|
|||||||
@ -23,8 +23,14 @@ class Event extends Backend
|
|||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->model = new \app\admin\model\score\Event;
|
$this->model = new \app\admin\model\score\Event;
|
||||||
$this->view->assign("statusList", $this->model->getStatusList());
|
$this->view->assign("statusList", $this->model->getStatusList());
|
||||||
|
|
||||||
|
$this->view->assign("statusListJson", json_encode($this->model->getStatusList(), JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
$this->view->assign("frequencyList", $this->model->getFrequencyList());
|
$this->view->assign("frequencyList", $this->model->getFrequencyList());
|
||||||
$this->view->assign("wayList", $this->model->getWayList());
|
$this->view->assign("wayList", $this->model->getWayList());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class Event extends Model
|
|||||||
|
|
||||||
public function getStatusList()
|
public function getStatusList()
|
||||||
{
|
{
|
||||||
return ['attendance' => __('Status attendance'), 'morning_meeting_hosting' => __('Status morning_meeting_hosting'), 'safety_environment' => __('Status safety_environment'), 'appearance_demeanor' => __('Status appearance_demeanor'), 'thorough_summarization' => __('Status thorough_summarization'), 'good_people_deeds' => __('Status good_people_deeds'), 'customer_service' => __('Status customer_service'), 'corporate_culture' => __('Status corporate_culture')];
|
return config("site.type_point_program");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrequencyList()
|
public function getFrequencyList()
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<input id="c-team_id" data-rule="required" data-source="score/team/index" class="form-control selectpage" name="row[team_id]" type="text" value="">
|
<input id="c-team_id" data-source="score/team/index" class="form-control selectpage" name="row[team_id]" type="text" value="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<input id="c-team_id" data-rule="required" data-source="score/team/index" class="form-control selectpage" name="row[team_id]" type="text" value="{$row.team_id|htmlentities}">
|
<input id="c-team_id" data-source="score/team/index" class="form-control selectpage" name="row[team_id]" type="text" value="{$row.team_id|htmlentities}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -44,3 +44,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
var statusListJson = {$statusListJson};
|
||||||
|
</script>
|
||||||
@ -17,6 +17,7 @@ class Score extends Api
|
|||||||
*/
|
*/
|
||||||
protected $model = null;
|
protected $model = null;
|
||||||
protected $noNeedRight = ['*'];
|
protected $noNeedRight = ['*'];
|
||||||
|
// protected $noNeedLogin = ['*'];
|
||||||
|
|
||||||
public function _initialize()
|
public function _initialize()
|
||||||
{
|
{
|
||||||
@ -127,7 +128,7 @@ class Score extends Api
|
|||||||
// var_dump($this->model->getLastSql());
|
// var_dump($this->model->getLastSql());
|
||||||
}catch (\Exception $e){
|
}catch (\Exception $e){
|
||||||
|
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage().$e->getFile().$e->getLine());
|
||||||
}
|
}
|
||||||
$this->success('查询成功', $res);
|
$this->success('查询成功', $res);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class Event extends BaseModel
|
|||||||
|
|
||||||
public function getStatusList()
|
public function getStatusList()
|
||||||
{
|
{
|
||||||
return ['attendance' => __('Status attendance'), 'morning_meeting_hosting' => __('Status morning_meeting_hosting'), 'safety_environment' => __('Status safety_environment'), 'appearance_demeanor' => __('Status appearance_demeanor'), 'thorough_summarization' => __('Status thorough_summarization'), 'good_people_deeds' => __('Status good_people_deeds'), 'customer_service' => __('Status customer_service'), 'corporate_culture' => __('Status corporate_culture')];
|
return config("site.type_point_program");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrequencyList()
|
public function getFrequencyList()
|
||||||
|
|||||||
@ -258,16 +258,16 @@ class Log extends BaseModel
|
|||||||
//判断是否是员工
|
//判断是否是员工
|
||||||
if(!$employee)$employee = Employee::where("user_id",$user_id)->find();
|
if(!$employee)$employee = Employee::where("user_id",$user_id)->find();
|
||||||
if(!$employee) throw new \Exception(__('用户不是员工'));
|
if(!$employee) throw new \Exception(__('用户不是员工'));
|
||||||
if(!$employee["team_id"])throw new \Exception(__('用户未加入队伍!'));
|
// if(!$employee["team_id"])throw new \Exception(__('用户未加入队伍!'));
|
||||||
$team = Team::where("id",$employee["team_id"])->find();
|
// $team = Team::where("id",$employee["team_id"])->find();
|
||||||
if(!$team)throw new \Exception(__('用户未加入队伍!'));
|
// if(!$team)throw new \Exception(__('用户未加入队伍!'));
|
||||||
|
|
||||||
if(!$params["images"] || !$params["name"] || !$params["score"])throw new \Exception(__('缺少关键申请参数!'));
|
if(!$params["images"] || !$params["name"] || !$params["score"])throw new \Exception(__('缺少关键申请参数!'));
|
||||||
|
|
||||||
|
|
||||||
$params["score_employee_id"] = $employee["id"];
|
$params["score_employee_id"] = $employee["id"];
|
||||||
$params["score_event_id"] = $score_event_id;
|
$params["score_event_id"] = $score_event_id;
|
||||||
$params["score_team_id"] = $team["id"];
|
$params["score_team_id"] = $team["id"] ?? 0;
|
||||||
|
|
||||||
$params["status"] = $params["status"] ?? 0;
|
$params["status"] = $params["status"] ?? 0;
|
||||||
$params["authtime"] = $params["status"] != 0 ? time() : NULL;
|
$params["authtime"] = $params["status"] != 0 ? time() : NULL;
|
||||||
@ -431,6 +431,9 @@ class Log extends BaseModel
|
|||||||
$my_team_score = null;
|
$my_team_score = null;
|
||||||
$my_team_id = null;
|
$my_team_id = null;
|
||||||
|
|
||||||
|
|
||||||
|
// var_dump($user_id);
|
||||||
|
|
||||||
foreach ($employees as $employee){
|
foreach ($employees as $employee){
|
||||||
//统计当前员工积分
|
//统计当前员工积分
|
||||||
$score = self::where("score_employee_id",$employee['id'])
|
$score = self::where("score_employee_id",$employee['id'])
|
||||||
@ -446,12 +449,13 @@ class Log extends BaseModel
|
|||||||
];
|
];
|
||||||
$employee_score[$employee['id']] = $employeedata;
|
$employee_score[$employee['id']] = $employeedata;
|
||||||
if($user_id && $user_id == $employee['user_id']){
|
if($user_id && $user_id == $employee['user_id']){
|
||||||
|
|
||||||
$my_employee_score = $employeedata;
|
$my_employee_score = $employeedata;
|
||||||
$my_team_id = $employee['team_id'];
|
$my_team_id = $employee['team_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($employee['team_id'] && $employee['team']){
|
||||||
if(!isset($team_score[$employee['team_id']])){
|
if(!isset($team_score[$employee['team_id']])){
|
||||||
$team_data = [
|
$team_data = [
|
||||||
'id'=>$employee['team_id'],
|
'id'=>$employee['team_id'],
|
||||||
@ -465,9 +469,10 @@ class Log extends BaseModel
|
|||||||
$team_score[$employee['team_id']]['score'] += $score;
|
$team_score[$employee['team_id']]['score'] += $score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//自己团队的积分
|
//自己团队的积分
|
||||||
if($my_team_id){
|
if($my_team_id){
|
||||||
$my_team_score = $team_score[$my_team_id];
|
$my_team_score = $team_score[$my_team_id] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||||
pk: 'id',
|
pk: 'id',
|
||||||
sortName: 'id',
|
sortName: 'id',
|
||||||
|
pageSize: 30,
|
||||||
fixedColumns: true,
|
fixedColumns: true,
|
||||||
fixedRightNumber: 1,
|
fixedRightNumber: 1,
|
||||||
columns: [
|
columns: [
|
||||||
@ -36,7 +37,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{field: 'opertime', title: __('统计时间查询'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter:function (value, row, index) {
|
{field: 'opertime', title: __('统计时间查询'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter:function (value, row, index) {
|
||||||
return row.opertime ? row.opertime : '未查询';
|
return row.opertime ? row.opertime : '未查询';
|
||||||
}},
|
}},
|
||||||
{field: 'score_count', title: __('积分统计(根据具体统计时间筛选)'),formatter:function (value, row, index) {
|
{field: 'score_count', title: __('积分统计(根据具体统计时间筛选)'), sortable: true, formatter:function (value, row, index) {
|
||||||
// if( !row.opertime){
|
// if( !row.opertime){
|
||||||
// return "<span style='color: #0d6aad'>#请在点开【搜索栏】后选择【统计时间查询】提交查询#</span>";
|
// return "<span style='color: #0d6aad'>#请在点开【搜索栏】后选择【统计时间查询】提交查询#</span>";
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{checkbox: true},
|
{checkbox: true},
|
||||||
{field: 'id', title: __('Id')},
|
{field: 'id', title: __('Id')},
|
||||||
|
|
||||||
{field: 'status', title: __('Status'), searchList: {"attendance":__('Status attendance'),"morning_meeting_hosting":__('Status morning_meeting_hosting'),"safety_environment":__('Status safety_environment'),"appearance_demeanor":__('Status appearance_demeanor'),"thorough_summarization":__('Status thorough_summarization'),"good_people_deeds":__('Status good_people_deeds'),"customer_service":__('Status customer_service'),"corporate_culture":__('Status corporate_culture')}, formatter: Table.api.formatter.status},
|
{field: 'status', title: __('Status'), searchList: statusListJson, formatter: Table.api.formatter.status},
|
||||||
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||||
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||||
{field: 'score', title: __('Score'), operate: false},
|
{field: 'score', title: __('Score'), operate: false},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user