get_type_title_list = MaintainConstant::get_type_title_list(); } /** * 列表 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function index() { $name = input('name'); $mobile = input('mobile'); $this->title = '维修人员列表'; $data = model::field('is_deleted', true) ->where('is_deleted', CommonConstant::IS_DELETED_0) ->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); } /** * 列表数据处理 * @param array $data * @throws \Exception */ protected function _index_page_filter(&$data) { if($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; } } } /** * 添加 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function add() { $this->title = '添加'; $this->_form($this->table, 'form'); } /** * 编辑 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '编辑'; $this->_form($this->table, 'form'); } /** * 表单处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _form_filter(&$data) { if ($this->request->isGet()) { } if ($this->request->isPost()) { } } /** * 删除 * @auth true * @throws \think\Exception * @throws \think\exception\PDOException */ public function remove() { $this->applyCsrfToken(); $this->_delete($this->table); } }