scene('list')->validate(); // 查询条件 $map = []; $limit = request('limit', config('page_num', 10)); $start_time = request('start_time', ''); $end_time = request('end_time', ''); $module_menu_name = request('module_menu_name', ''); $general_description = request('general_description', ''); $notes_type = request('notes_type', ''); // 时间条件 if ($start_time) $map[] = ['admin_history.insert_time', '>=', strtotime($start_time)]; if ($end_time) $map[] = ['admin_history.insert_time', '<=', strtotime($end_time)]; // 其他条件 if ($module_menu_name) $map[] = ['admin_history.module_menu_name', 'like', "%$module_menu_name%"]; if ($general_description) $map[] = ['admin_history.general_description', 'like', "%$general_description%"]; if ($notes_type) $map[] = ['admin_history.notes_type', '=', $notes_type]; // 查询数据 $result = $AdminHistoryModel->join('admin', 'admin.uid', '=', 'admin_history.admin_uid') ->where($map) ->select(['admin_history.id','admin.username','admin_history.admin_uid','admin_history.module_menu_name','admin_history.notes_type','admin_history.general_description','admin_history.insert_time']) ->orderByDesc('admin_history.id') ->paginate($limit); // 分配数据 if (!$result) return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]); // 加载模板 return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]); } }