Glamorgan chased down Kent's imposing total of 317 with just a couple of balls to spare in the Royal London one-day cup.