Legislation near final approval would affect drivers for ride-hailing services, food-delivery couriers, janitors and others now viewed as contractors.