feat(admin): 新增尾首概率分析弹窗

在history页面工具栏添加"尾首概率"按钮,弹窗显示:
- 下一期尾数与前一期尾数相同的概率
- 下一期首位与前一期首位相同的概率
支持切换统计期数(30/50/100/200期)
This commit is contained in:
2026-05-02 15:36:00 +08:00
parent 8b2590c5b5
commit 919fbbc148
4 changed files with 134 additions and 1 deletions
+66
View File
@@ -112,6 +112,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
$(document).off('click', '.btn-normal-relation').on('click', '.btn-normal-relation', function () {
Controller.api.showNormalRelationDialog();
});
// 尾首概率按钮事件
$(document).off('click', '.btn-tailheadprob').on('click', '.btn-tailheadprob', function () {
Controller.api.showTailHeadProbabilityDialog();
});
},
add: function () {
Controller.api.bindevent();
@@ -2163,6 +2168,67 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
$('#nr-result', layero).html(html);
},
/**
* 尾首概率弹窗
*/
showTailHeadProbabilityDialog: function () {
var content = '<div id="tailheadprob-content" style="padding:20px 30px;">';
content += '<div style="text-align:center;margin-bottom:20px;">';
content += '<label style="margin-right:10px;">统计期数:</label>';
content += '<select id="tailheadprob-periods" style="width:100px;padding:5px 10px;">';
content += '<option value="30">近30期</option>';
content += '<option value="50">近50期</option>';
content += '<option value="100" selected>近100期</option>';
content += '<option value="200">近200期</option>';
content += '</select>';
content += ' <button class="btn btn-primary btn-sm" id="btn-tailheadprob-query" style="margin-left:10px;"><i class="fa fa-search"></i> 查询</button>';
content += '</div>';
content += '<div id="tailheadprob-result"></div>';
content += '</div>';
layer.open({
type: 1,
title: '尾首概率分析',
area: ['500px', '380px'],
content: content,
success: function (layero) {
$('#btn-tailheadprob-query', layero).on('click', function () {
var periods = $('#tailheadprob-periods').val();
$.ajax({
url: 'history/tailHeadProb',
type: 'GET',
data: { periods: periods },
dataType: 'json',
success: function (ret) {
if (ret.code == 1) {
var d = ret.msg;
var html = '<div style="margin-top:15px;">';
html += '<div style="padding:15px;background:#f0f9ff;border-radius:8px;margin-bottom:12px;">';
html += '<div style="font-size:14px;font-weight:bold;color:#1565c0;margin-bottom:10px;"><i class="fa fa-bar-chart"></i> 概率统计</div>';
html += '<table class="table table-bordered" style="margin-bottom:0;">';
html += '<tr><th style="width:50%;">对比项</th><th>相同概率</th></tr>';
html += '<tr><td>下一期尾数与前一期尾数相同</td><td style="text-align:center;font-size:18px;font-weight:bold;color:#e65100;">' + d.tailProb + '%</td></tr>';
html += '<tr><td>下一期首位与前一期首位相同</td><td style="text-align:center;font-size:18px;font-weight:bold;color:#e65100;">' + d.headProb + '%</td></tr>';
html += '</table></div>';
html += '<div style="font-size:12px;color:#999;">共分析 ' + d.periodCount + ' 期数据,' + d.totalTransitions + ' 次转移</div>';
html += '</div>';
$('#tailheadprob-result').html(html);
} else {
Toastr.error(ret.msg);
}
},
error: function () {
Toastr.error('请求失败,请重试');
}
});
});
// 初始加载
$('#btn-tailheadprob-query', layero).trigger('click');
}
});
}
}
};