Compare commits

..

No commits in common. "5627c3f9ba7dd2b6af93effcc05622452779ac45" and "3914fd068973dc3f57e25e72e7253e786a87d16c" have entirely different histories.

11 changed files with 29 additions and 80 deletions

View File

@ -63,66 +63,31 @@ class Employee extends Backend
//得到查询值
$value = $opertime['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'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','mobile','avatar']);
$row->getRelation('team')->visible(['name']);
}
foreach ($list as $row) {
$total = $list->total();
$list = $list->items();
$row->getRelation('user')->visible(['nickname','mobile','avatar']);
$row->getRelation('team')->visible(['name']);
}
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 : '';
$total = $list->total();
$list = $list->items();
foreach ($list as &$row) {
$row['score_count'] = 0;
$row['opertime'] = '';
if($start_time){
$row['opertime'] = $start_time.'至'.$end_time;
}
unset($row);
$row['score_count'] = \app\common\model\score\Employee::getPriceByCoachAndTime($row['id'],$start_time,$end_time);
}
$result = array("total" => $total, "rows" => $list);

View File

@ -23,14 +23,8 @@ class Event extends Backend
parent::_initialize();
$this->model = new \app\admin\model\score\Event;
$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("wayList", $this->model->getWayList());
}

View File

@ -44,7 +44,7 @@ class Event extends Model
public function getStatusList()
{
return config("site.type_point_program");
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')];
}
public function getFrequencyList()

View File

@ -17,7 +17,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-team_id" data-source="score/team/index" class="form-control selectpage" name="row[team_id]" type="text" value="">
<input id="c-team_id" data-rule="required" data-source="score/team/index" class="form-control selectpage" name="row[team_id]" type="text" value="">
</div>
</div>

View File

@ -17,7 +17,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Team_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
<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}">
</div>
</div>

View File

@ -44,6 +44,3 @@
</div>
</div>
</div>
<script>
var statusListJson = {$statusListJson};
</script>

View File

@ -17,7 +17,6 @@ class Score extends Api
*/
protected $model = null;
protected $noNeedRight = ['*'];
// protected $noNeedLogin = ['*'];
public function _initialize()
{
@ -128,7 +127,7 @@ class Score extends Api
// var_dump($this->model->getLastSql());
}catch (\Exception $e){
$this->error($e->getMessage().$e->getFile().$e->getLine());
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}

View File

@ -45,7 +45,7 @@ class Event extends BaseModel
public function getStatusList()
{
return config("site.type_point_program");
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')];
}
public function getFrequencyList()

View File

@ -258,16 +258,16 @@ class Log extends BaseModel
//判断是否是员工
if(!$employee)$employee = Employee::where("user_id",$user_id)->find();
if(!$employee) throw new \Exception(__('用户不是员工'));
// if(!$employee["team_id"])throw new \Exception(__('用户未加入队伍!'));
// $team = Team::where("id",$employee["team_id"])->find();
// if(!$team)throw new \Exception(__('用户未加入队伍!'));
if(!$employee["team_id"])throw new \Exception(__('用户未加入队伍!'));
$team = Team::where("id",$employee["team_id"])->find();
if(!$team)throw new \Exception(__('用户未加入队伍!'));
if(!$params["images"] || !$params["name"] || !$params["score"])throw new \Exception(__('缺少关键申请参数!'));
$params["score_employee_id"] = $employee["id"];
$params["score_event_id"] = $score_event_id;
$params["score_team_id"] = $team["id"] ?? 0;
$params["score_team_id"] = $team["id"];
$params["status"] = $params["status"] ?? 0;
$params["authtime"] = $params["status"] != 0 ? time() : NULL;
@ -431,9 +431,6 @@ class Log extends BaseModel
$my_team_score = null;
$my_team_id = null;
// var_dump($user_id);
foreach ($employees as $employee){
//统计当前员工积分
$score = self::where("score_employee_id",$employee['id'])
@ -449,13 +446,12 @@ class Log extends BaseModel
];
$employee_score[$employee['id']] = $employeedata;
if($user_id && $user_id == $employee['user_id']){
$my_employee_score = $employeedata;
$my_team_id = $employee['team_id'];
}
if($employee['team_id'] && $employee['team']){
if(!isset($team_score[$employee['team_id']])){
$team_data = [
'id'=>$employee['team_id'],
@ -468,11 +464,10 @@ class Log extends BaseModel
//累加积分
$team_score[$employee['team_id']]['score'] += $score;
}
}
}
//自己团队的积分
if($my_team_id){
$my_team_score = $team_score[$my_team_id] ?? 0;
$my_team_score = $team_score[$my_team_id];
}

View File

@ -22,7 +22,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
pageSize: 30,
fixedColumns: true,
fixedRightNumber: 1,
columns: [
@ -37,7 +36,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'opertime', title: __('统计时间查询'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter:function (value, row, index) {
return row.opertime ? row.opertime : '未查询';
}},
{field: 'score_count', title: __('积分统计(根据具体统计时间筛选)'), sortable: true, formatter:function (value, row, index) {
{field: 'score_count', title: __('积分统计(根据具体统计时间筛选)'),formatter:function (value, row, index) {
// if( !row.opertime){
// return "<span style='color: #0d6aad'>#请在点开【搜索栏】后选择【统计时间查询】提交查询#</span>";
// }

View File

@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'status', title: __('Status'), searchList: statusListJson, formatter: Table.api.formatter.status},
{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: '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: 'score', title: __('Score'), operate: false},