The European Parliament has narrowly approved the wide-reaching reform of the European Union's migration and asylum policy.