Here's how it works:
1) Attack with Targeting Battery. You don't have a lock yet, so you can't use Fire-Control System.
2) Targeting Battery says "After you attack...", so once the attack finishes, follow its rules and acquire a target lock (if the target is in lock range).
3) Attack again, either in the same turn (huge ships can have multiple attacks per turn) or next round. Now you have a lock on a ship, so if you attack that ship, you can use Fire-Control System to reroll a die. Or if you want, you could instead spend the lock to simply reroll as many dice as needed.