|
@@ -17,6 +17,7 @@ namespace app\approve\controller;
|
|
|
|
|
|
use app\common\constant\CommonConstant;
|
|
|
use app\common\constant\MaintainConstant;
|
|
|
+use app\common\model\ApproveMaintainUser as model;
|
|
|
use library\Controller;
|
|
|
|
|
|
/**
|
|
@@ -49,12 +50,24 @@ class ApproveMaintainUser extends Controller
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
+ $name = input('name');
|
|
|
+ $mobile = input('mobile');
|
|
|
+
|
|
|
$this->title = '维修人员列表';
|
|
|
- $query = $this->_query($this->table)
|
|
|
- ->field('is_deleted', true)
|
|
|
+ $data = model::field('is_deleted', true)
|
|
|
->where('is_deleted', CommonConstant::IS_DELETED_0)
|
|
|
- ->like('name,mobile');
|
|
|
- $query->page();
|
|
|
+ ->when($name, function ($query) use ($name) {
|
|
|
+ $query->where('name', 'like', '%' . $name . '%');
|
|
|
+ })
|
|
|
+ ->when($mobile, function ($query) use ($mobile) {
|
|
|
+ $query->where('mobile', 'like', '%' . $mobile . '%');
|
|
|
+ })
|
|
|
+ ->with([
|
|
|
+ 'log' => function ($query) {
|
|
|
+ $query->field('comment,create_at', true);
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+ self::_init($data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -65,7 +78,17 @@ class ApproveMaintainUser extends Controller
|
|
|
protected function _index_page_filter(&$data)
|
|
|
{
|
|
|
foreach ($data as &$value) {
|
|
|
-
|
|
|
+ $comment_count = !empty($value['log']) ? count($value['log']) : 0;
|
|
|
+ $comment_score = 0;
|
|
|
+ if (!empty($value['log'])) {
|
|
|
+ foreach ($value['log'] as $k => $v) {
|
|
|
+ $comment_score = bcadd($comment_score, $v['comment_score']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $log_score = $comment_score > 0 ? bcdiv($comment_score, $comment_count, 1) : 0;
|
|
|
+ $value['comment_count'] = $comment_count;
|
|
|
+ $value['comment_score'] = $comment_score;
|
|
|
+ $value['log_score'] = $log_score;
|
|
|
}
|
|
|
}
|
|
|
|