A self-consistent field theory of quantum electrodynamics