This commit is contained in:
ZaneYork 2024-09-12 18:00:26 +08:00
parent e5af152d14
commit aefcaf4311
2 changed files with 12 additions and 7 deletions

View File

@ -97,7 +97,7 @@ def dinner_update():
if not nickname: if not nickname:
return make_response(json.dumps(dict(code=-1, data="姓名必须填写"))) return make_response(json.dumps(dict(code=-1, data="姓名必须填写")))
if not is_valid_user(nickname): if not is_valid_user(nickname):
abort(403) return make_response(json.dumps(dict(code=-1, data="你不能投票(*^_^*)")))
if not user_menu: if not user_menu:
set_user_menu('', nickname) set_user_menu('', nickname)
return make_response(json.dumps(dict(code=0, data="OK"))) return make_response(json.dumps(dict(code=0, data="OK")))

View File

@ -8,16 +8,16 @@
<div class="container text-center pt-5"> <div class="container text-center pt-5">
<p>每天8:00-17:30间开放匿名投票更新17:30以后允许发起抽签抽签结果确定后不可更改</p> <p>每天8:00-17:30间开放匿名投票更新17:30以后允许发起抽签抽签结果确定后不可更改</p>
<p>第一名与第二名得票数相差不超过10%时随机抽签,按其得票数决定中签概率,否则选择第一名</p> <p>第一名与第二名得票数相差不超过10%时随机抽签,按其得票数决定中签概率,否则选择第一名</p>
<p>投票结果仅供参考,最终解释权归部门总经理、副总经理所有</p>
{% for last_result in last_results %} {% for last_result in last_results %}
<p>今日{{ last_result }}最终得票数降低{{ 2 + loop.index0 }}0%</p> <p>今日{{ last_result }}最终得票数降低{{ 2 + loop.index0 }}0%</p>
{% endfor %} {% endfor %}
<form id="inputForm" class="form-inline"> <form id="inputForm" class="form-inline">
<div class="form-group"> <div class="form-group">
<div class="input-group mb-3"> <div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">姓名</span> <label class="input-group-text" for="inputName" id="basic-addon1">姓名</label>
<input type="text" id="inputName" class="form-control" <input type="text" class="form-control"
name="nickname" id="inputName" name="nickname" value="{{ nickname }}">
value="{{ nickname }}">
</div> </div>
<div class="input-group mb-2"> <div class="input-group mb-2">
<span class="input-group-addon">我选择</span> <span class="input-group-addon">我选择</span>
@ -39,14 +39,14 @@
<button type="button" class="btn btn-primary" onclick="update()">更新</button> <button type="button" class="btn btn-primary" onclick="update()">更新</button>
<button type="button" class="btn btn-secondary" onclick="clearValue()">不吃</button> <button type="button" class="btn btn-secondary" onclick="clearValue()">不吃</button>
<button type="button" id="btnRoll" <button type="button" id="btnRoll"
class="btn btn-secondary" {{ "" if can_roll == True else 'disabled="disabled"' | safe }} class="btn btn-secondary{{ "" if can_roll == True else ' disabled="disabled"' | safe }}"
onclick="roll()">开始抽签 onclick="roll()">开始抽签
</button> </button>
<div class="pt-3"> <div class="pt-3">
<label>大家的选择 - 总票数:{{ '{:.2f}'.format(total_vote | round(2)) }}</label> <label>大家的选择 - 总票数:{{ '{:.2f}'.format(total_vote | round(2)) }}</label>
<ul class="list-group pt-2 mb-4"> <ul class="list-group pt-2 mb-4">
{% for key in summary_keys %} {% for key in summary_keys %}
<li class="list-group-item {{ "active" if result == key else "" }} {{ "list-group-item-primary" if predict_result == key else "" }}"> <li class="list-group-item{{ " active" if result == key else "" }} {{ " list-group-item-primary" if predict_result == key else "" }}">
<div class="row justify-content-between"> <div class="row justify-content-between">
<span class="col-5">{{ key }}</span> <span class="col-5">{{ key }}</span>
<span class="col-3">{{ '{:.2f}'.format(summary[key] | round(2)) }}票</span> <span class="col-3">{{ '{:.2f}'.format(summary[key] | round(2)) }}票</span>
@ -89,6 +89,11 @@
<!--suppress JSUnresolvedReference --> <!--suppress JSUnresolvedReference -->
<script> <script>
document.addEventListener('keydown', function (event) {
if (event.key === 'Enter' || event.keyCode === 13) {
update();
}
});
$("input[type=range]").change(function () { $("input[type=range]").change(function () {
const values = $("input[type=range]").map(function () { const values = $("input[type=range]").map(function () {
return $(this).val(); return $(this).val();