The abundance of ultra-diffuse galaxies from groups to clusters. UDGs are relatively more common in more massive haloes