They went to an animal doctor. The vet said, "This pet is almost blind." The wife said to her husband, "What are you going to do?"

---------------------------
What is the difference between them in meaning?
1. What are you going to do?
2. What will you do?

In the last sentence #1 is used? Can we substitute #2 for #1?

I'd write "The wife asked her husband..."

Everything else is fine.

Yes, 1 and 2 mean the same thing, and each can be substituted for the other.

If a person uses 'be going to,' does it mean that he decided what to do before?

1. What did you decided to do for that? What are you going to do?

If a person uses, will,' does it mean that he decides to do something right now?

2. What do you decide to do for that right now? What will you do?

(What about the explanation?)

Yes, "going to do" and "will" indicate that the person has already decided what he or she will do.

Correction in explanation 1: The verb should be "did you decide" -- do you see why?

The difference in meaning between the sentences "What are you going to do?" and "What will you do?" is subtle, but there is a slight difference in nuance.

1. "What are you going to do?" implies a sense of immediacy and suggests that the speaker is asking about the person's immediate plans or intentions in response to a particular situation.

2. "What will you do?" also asks about the person's plans or intentions, but it may not carry the same sense of urgency or immediacy. It could be seen as a more general inquiry about their future actions in a given situation.

In the given context, the wife is likely asking her husband about their plan of action after hearing that their pet is almost blind. Both sentences convey a similar meaning, and in this case, you can substitute #2 ("What will you do?") for #1 ("What are you going to do?").