I am going to call this a bug and it is a huge problem.
If an enemy is anywhere visible, all civilians become paralyzed with fight and will do NOTHING but be interrupted and eventually die.
My last example of this was a beak dog which fell into a river (and didn't drown). He should have been invisible since he was only able to be seen by going one z level down. Basically no one should have known he was there, yet my entire civilian population became idle because the river was near a common path and couldn't do anything include eat or drink. After getting some archers to kill the thing suddenly all the civilians unlocked and started operating normally.
I think there is a simple fix for this that isn't CPU intensive. Nobody should be 'interrupted' unless they creature is right next to them on the same Z level OR is attacked by a creature who uses a ranged attack.
A more complex fix which I wouldn't suggest because it might cause a huge amount of lag is line of sight checks (which are obviously not happening right). An efficient way to handle this might be to just do a line of sight check from the enemy's point of view and if it can see a dwarf then the dwarf can see it. This way you may cut the number of line of sight checks down considerably.
Finally, even if an enemy is visible, the AI shouldn't lock up a dwarf. What seems to be happening is that a dwarf's task is removed, then the next frame causes it to re-assign a task (usually the same one), which in turn is interrupted ending in an endless cycle.
I would suggest that certain task be considered uninterpretable, such as moving, health care, medicine, eating and drinking, and such. I would also suggest that an interrupted task is changed to a 'move' to a safe location task immediately instead of simply unassigning it and allowing the dwarf to pick a new task.
Finally, if a task is in a threatened area, like a corpse or item or whatever, those tasks will be flagged as threatened and will NEVER be assigned until they are not threatened. Similarly some tasks can have a 'safe' flag on them, meaning it is know that the area is 'safe' even though a monster might be 10 feet away. A pike-man one tile below or on the other side of a 1 tile wide stream isn't a threat.