Please apply it.
frappe.ui.form.on('Purchase Invoice', {
refresh: function(frm) {
setTimeout(function() {
var targetDiv = $(".page-head.flex");
targetDiv.css({
zIndex: '1020',
});
}, 100);
}
});
Output: