fix: 偏移设置新增校验和二次确认
This commit is contained in:
@@ -11,6 +11,17 @@
|
||||
.offset-form-group .form-control { width: 120px; }
|
||||
.help-block { margin-top: 5px; color: #999; }
|
||||
.form-footer { text-align: center; }
|
||||
.popover {
|
||||
min-width: 200px;
|
||||
}
|
||||
.popover-body {
|
||||
padding: 15px;
|
||||
}
|
||||
.popover-body .btn {
|
||||
margin: 0 5px;
|
||||
padding: 0.25rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
@@ -18,10 +29,67 @@
|
||||
@section JS{
|
||||
<script>
|
||||
$(function() {
|
||||
// 保存按钮点击事件
|
||||
$("#btnSave").click(function() {
|
||||
var bid = $("#bid").val();
|
||||
var ofr = $("#ofr").val();
|
||||
var $bid = $("#bid");
|
||||
var $ofr = $("#ofr");
|
||||
var $popover;
|
||||
|
||||
// 初始化popover
|
||||
$('[data-toggle="popover"]').popover({
|
||||
trigger: 'manual',
|
||||
container: 'body',
|
||||
sanitize: false, // 禁用HTML净化
|
||||
html: true // 允许HTML内容
|
||||
}).on('click', function(e) {
|
||||
// 阻止默认行为
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// 如果已经有popover显示,则不再重复显示
|
||||
if ($(this).attr('aria-describedby')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示popover
|
||||
$popover = $(this).popover('show');
|
||||
|
||||
// 点击确认按钮
|
||||
$(document).one('click', '#confirmSave', function(e) {
|
||||
e.stopPropagation();
|
||||
// 这里执行保存逻辑
|
||||
saveSettings();
|
||||
// 隐藏popover
|
||||
$popover.popover('hide');
|
||||
});
|
||||
|
||||
// 点击取消按钮
|
||||
$(document).one('click', '#cancelSave', function(e) {
|
||||
e.stopPropagation();
|
||||
$popover.popover('hide');
|
||||
});
|
||||
});
|
||||
|
||||
// 阻止popover内部的点击事件冒泡
|
||||
$(document).on('click', '.popover', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// 点击页面其他区域关闭popover
|
||||
$(document).on('click', function(e) {
|
||||
!$(e.target).closest('.popover').length && $popover?.popover('hide');
|
||||
});
|
||||
|
||||
// 关闭按钮点击事件
|
||||
$("#btnClose").click(function() {
|
||||
layer.closeMe();
|
||||
});
|
||||
|
||||
// 保存设置
|
||||
function saveSettings() {
|
||||
var bid = $bid.val();
|
||||
var ofr = $ofr.val();
|
||||
|
||||
if (!validInput($bid, bid)) return;
|
||||
if (!validInput($ofr, ofr)) return;
|
||||
|
||||
// 保存到后台
|
||||
$.ajax({
|
||||
@@ -38,14 +106,18 @@
|
||||
layer.closeMe();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 关闭按钮点击事件
|
||||
$("#btnClose").click(function() {
|
||||
layer.closeMe();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function validInput($input, value) {
|
||||
var $formGroup = $input.closest('.form-group');
|
||||
$formGroup.find('.text-danger').remove();
|
||||
if (!!`${value}`.trim() && !/^-?\d+$/.test(`${Number(value)}`)) {
|
||||
$formGroup.append('<div class="text-danger">只允许输入整数</div>');
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -76,12 +148,25 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-top: 20px;">
|
||||
<div class="help-block" style="color: #666;">保存后10分钟后生效</div>
|
||||
<div class="help-block text-danger">保存后10分钟后生效</div>
|
||||
</div>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<div class="form-footer">
|
||||
<button id="btnSave" type="button" class="btn btn-primary" style="margin-right: 10px;">保存</button>
|
||||
<button
|
||||
id="btnSave"
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
style="margin-right: 10px;"
|
||||
data-toggle="popover"
|
||||
data-html="true"
|
||||
data-placement="top"
|
||||
data-content='<div class="text-center">
|
||||
<p>请注意,此偏移数值即将于10分钟后生效,要继续吗?</p>
|
||||
<button id="confirmSave" class="btn btn-sm btn-primary">继续</button>
|
||||
<button id="cancelSave" class="btn btn-sm btn-default">取消</button>
|
||||
</div>'
|
||||
>保存</button>
|
||||
<button id="btnClose" type="button" class="btn btn-default">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -317,6 +317,6 @@ function batchTradeAdjustView() {
|
||||
// 偏移设置
|
||||
function spreadSetting() {
|
||||
main.open("偏移设置", "/ExchangeTrade/SpreadSetting", {
|
||||
area: ["450px", "310px"],
|
||||
area: ["450px", "360px"],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user