I'm sure he's perfectly aware that Turkey isn't going to join the EU, which is why he feels like he has nothing to lose with these actions.
Turkish industry heavily utilizes EU financial and consulting services.
Turkey also benefits from various infrastructural and knowledge-sharing schemes supplied by the EU.
So, quite a lot to lose.
Erdogan has to somehow keep his deeply indebted country rolling and his population of 82 million employed. It seems foolish to start picking fights with his biggest trading partner but, who knows, perhaps this is the sort of distraction that will keep his population focused on nationalism.
Turkey needs NATO more than the other way around
(b) the nukes (İncirlik)
As to who needs whom more, I have no opinion.