I found this glitch on a multiplayer survival server when i went to enchant a tool, but after I enchanted it I noticed the number didn't go down the right amount.
What I did to create and recreate this glitch:
Step 1: make sure you have 33 1/2 levels like the picture below
Step 2: grab any old pickaxe and open the enchanting table(make sure the enchanting table can do a 30 level enchant)
Step 3: get the level 30 enchant and you will see that your xp level only goes down by 3 levels instead of 30
Enchanting does not remove 30 levels. It's a minimum number of levels to apply the enchantment. Your second screenshot shows the cost of enchanting, which states "3 levels".