Jayden Stockley scored as Aberdeen beat Dundee 3-1 at Dens Park to move up to fourth in the Scottish Premiership.