'字段错误提示文件格式由HTML变更为JS'

This commit is contained in:
ForeverSmiYng 2024-06-22 16:38:30 +08:00
parent 057d60a7c4
commit e2e984385b
2 changed files with 54 additions and 56 deletions

View File

@ -1,56 +0,0 @@
<script type="text/javascript">
function showPrompt(SP_fieldid, SP_content, SP_tabid, SP_rowIndex) {//添加提示,SP_rowIndex选填如要填SP_rowIndexSP_tabid必填可填null
if (SP_rowIndex === null || SP_rowIndex === undefined) {
$(`.myprom_${SP_fieldid}`).remove();
if ($(`.${SP_fieldid}_swapDiv`).length > 0) {
$(`.${SP_fieldid}_swapDiv`).after(`<div class="prompt-box myprom myprom_${SP_fieldid}" data_tab_id=${SP_tabid}><div class="prompt-arrow" style="top: -3px;"></div><div class="prompt-content"><i class="anticon anticon-exclamation-circle"></i><span class="prompt-content-label">${SP_content}</span><span class="prompt-content-info"></span></div></div>`);
}
} else {
$(`.myprom_${SP_fieldid}_${SP_rowIndex}`).remove();
if ($(`.${SP_fieldid}_${SP_rowIndex}_swapDiv`).length > 0) {
$(`.${SP_fieldid}_${SP_rowIndex}_swapDiv`).after(`<div class="prompt-box myprom myprom_${SP_fieldid}_${SP_rowIndex}" data_tab_id=${SP_tabid}><div class="prompt-arrow" style="top: -3px;"></div><div class="prompt-content"><i class="anticon anticon-exclamation-circle"></i><span class="prompt-content-label">${SP_content}</span><span class="prompt-content-info"></span></div></div>`);
}
}
}
function eraseFieldPrompt(EFP_fieldid, EFP_rowIndex) {//移除提示,SP_rowIndex选填
if (EFP_rowIndex === null || EFP_rowIndex === undefined) {
$(`.myprom_${EFP_fieldid}`).remove();
} else {
$(`.myprom_${EFP_fieldid}_${EFP_rowIndex}`).remove();
}
}
function checkPrompt() {//提交前判断先做一次if ($(".myprom").length > 0) {}判断true则触发该方法并禁断提交false不执行
WfForm.showMessage("请参考提示修正内容。", 1, 5);
let tab_id = $(".myprom")[0].getAttribute("data_tab_id");
if (tab_id === "null" || tab_id === "undefined") {
let scroll_to_windowTop = $(".wf-req-form-scroll")[0].getBoundingClientRect().top;//scroll框距离window顶部的距离
let dom_to_scrollTop = $(".myprom")[0].getBoundingClientRect().top - scroll_to_windowTop;//DOM节点距离scroll框顶部的距离
let scroll_display_height = window.innerHeight - scroll_to_windowTop;//scroll框最大显示高度
if (dom_to_scrollTop < scroll_display_height / 4 || dom_to_scrollTop > scroll_display_height / 4 * 3) {
$(".wf-req-form-scroll")[0].scrollTo({
top: dom_to_scrollTop + $(".wf-req-form-scroll")[0].scrollTop - scroll_display_height / 2,
behavior: "smooth"
});
}
} else {
$("#tab_" + tab_id)[0].click();
let myInterval2;
myInterval2 = setInterval(() => {
if ($("#tab_" + tab_id + "_content").css("display") == "block") {
clearInterval(myInterval2);
let scroll_to_windowTop = $(".wf-req-form-scroll")[0].getBoundingClientRect().top;//scroll框距离window顶部的距离
let dom_to_scrollTop = $(".myprom")[0].getBoundingClientRect().top - scroll_to_windowTop;//DOM节点距离scroll框顶部的距离
let scroll_display_height = window.innerHeight - scroll_to_windowTop;//scroll框最大显示高度
if (dom_to_scrollTop < scroll_display_height / 4 || dom_to_scrollTop > scroll_display_height / 4 * 3) {
$(".wf-req-form-scroll")[0].scrollTo({
top: dom_to_scrollTop + $(".wf-req-form-scroll")[0].scrollTop - scroll_display_height / 2,
behavior: "smooth"
});
}
}
}, 50);
}
}
</script>

54
字段错误提示.js Normal file
View File

@ -0,0 +1,54 @@
function showPrompt(SP_fieldid, SP_content, SP_tabid, SP_rowIndex) {//添加提示,SP_rowIndex选填如要填SP_rowIndexSP_tabid必填可填null
if (SP_rowIndex === null || SP_rowIndex === undefined) {
$(`.myprom_${SP_fieldid}`).remove();
if ($(`.${SP_fieldid}_swapDiv`).length > 0) {
$(`.${SP_fieldid}_swapDiv`).after(`<div class="prompt-box myprom myprom_${SP_fieldid}" data_tab_id=${SP_tabid}><div class="prompt-arrow" style="top: -3px;"></div><div class="prompt-content"><i class="anticon anticon-exclamation-circle"></i><span class="prompt-content-label">${SP_content}</span><span class="prompt-content-info"></span></div></div>`);
}
} else {
$(`.myprom_${SP_fieldid}_${SP_rowIndex}`).remove();
if ($(`.${SP_fieldid}_${SP_rowIndex}_swapDiv`).length > 0) {
$(`.${SP_fieldid}_${SP_rowIndex}_swapDiv`).after(`<div class="prompt-box myprom myprom_${SP_fieldid}_${SP_rowIndex}" data_tab_id=${SP_tabid}><div class="prompt-arrow" style="top: -3px;"></div><div class="prompt-content"><i class="anticon anticon-exclamation-circle"></i><span class="prompt-content-label">${SP_content}</span><span class="prompt-content-info"></span></div></div>`);
}
}
}
function eraseFieldPrompt(EFP_fieldid, EFP_rowIndex) {//移除提示,SP_rowIndex选填
if (EFP_rowIndex === null || EFP_rowIndex === undefined) {
$(`.myprom_${EFP_fieldid}`).remove();
} else {
$(`.myprom_${EFP_fieldid}_${EFP_rowIndex}`).remove();
}
}
function checkPrompt() {//提交前判断先做一次if ($(".myprom").length > 0) {}判断true则触发该方法并禁断提交false不执行
WfForm.showMessage("请参考提示修正内容。", 1, 5);
let tab_id = $(".myprom")[0].getAttribute("data_tab_id");
if (tab_id === "null" || tab_id === "undefined") {
let scroll_to_windowTop = $(".wf-req-form-scroll")[0].getBoundingClientRect().top;//scroll框距离window顶部的距离
let dom_to_scrollTop = $(".myprom")[0].getBoundingClientRect().top - scroll_to_windowTop;//DOM节点距离scroll框顶部的距离
let scroll_display_height = window.innerHeight - scroll_to_windowTop;//scroll框最大显示高度
if (dom_to_scrollTop < scroll_display_height / 4 || dom_to_scrollTop > scroll_display_height / 4 * 3) {
$(".wf-req-form-scroll")[0].scrollTo({
top: dom_to_scrollTop + $(".wf-req-form-scroll")[0].scrollTop - scroll_display_height / 2,
behavior: "smooth"
});
}
} else {
$("#tab_" + tab_id)[0].click();
let myInterval2;
myInterval2 = setInterval(() => {
if ($("#tab_" + tab_id + "_content").css("display") == "block") {
clearInterval(myInterval2);
let scroll_to_windowTop = $(".wf-req-form-scroll")[0].getBoundingClientRect().top;//scroll框距离window顶部的距离
let dom_to_scrollTop = $(".myprom")[0].getBoundingClientRect().top - scroll_to_windowTop;//DOM节点距离scroll框顶部的距离
let scroll_display_height = window.innerHeight - scroll_to_windowTop;//scroll框最大显示高度
if (dom_to_scrollTop < scroll_display_height / 4 || dom_to_scrollTop > scroll_display_height / 4 * 3) {
$(".wf-req-form-scroll")[0].scrollTo({
top: dom_to_scrollTop + $(".wf-req-form-scroll")[0].scrollTop - scroll_display_height / 2,
behavior: "smooth"
});
}
}
}, 50);
}
}