A suicide bomber detonated an explosive vest in the middle of a Shia gathering in Baghdad, killing at least 31 people and wounding about 30 on Saturday, police and medics said.