样式优化

This commit is contained in:
ZaneYork 2024-09-20 14:27:16 +08:00
parent 2cab5ab34c
commit e3c9aacece
2 changed files with 45 additions and 33 deletions

View File

@ -17,7 +17,7 @@
</select> </select>
</div> </div>
<div class="col-4"> <div class="col-4">
<button type="button" class="btn btn-secondary" onclick="back()">返回</button> <button type="button" class="btn btn-outline-secondary" onclick="back()">返回</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,12 +4,18 @@
{{ super() }} {{ super() }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<p>每天8:00-17:30间开放匿名投票更新17:30以后允许发起抽签抽签结果确定后不可更改</p> <div class="border rounded p-2 mb-2 text-start" style="text-indent: 2em">
<p>第一名与第二名得票数相差不超过10%时随机抽签,按其得票数决定中签概率,否则选择第一名</p> <div class="m-1">每天8:00-17:30间开放匿名投票更新17:30以后允许发起抽签抽签结果确定后不可更改。</div>
<p>投票结果仅供参考,最终解释权归部门总经理、副总经理所有</p> <div class="m-1">第一名与第二名得票数相差不超过<strong>10%</strong>时随机抽签,按其得票数决定中签概率,否则选择第一名。
{% for last_result in last_results %} </div>
<p>今日{{ last_result.value }}最终得票数降低{{ 2 + loop.index0 }}0%</p> <div class="m-1">投票结果仅供参考,最终解释权归部门总经理、副总经理所有。</div>
{% endfor %} </div>
<div class="alert alert-light text-start" role="alert" style="text-indent: 2em">
{% for last_result in last_results %}
<div class="m-1">
今日<strong>{{ last_result.value }}</strong>最终得票数降低<strong>{{ 2 + loop.index0 }}0%</strong></div>
{% endfor %}
</div>
<form id="inputForm" class="form-inline" onsubmit="return false;"> <form id="inputForm" class="form-inline" onsubmit="return false;">
<div class="form-group"> <div class="form-group">
<div class="mb-3"> <div class="mb-3">
@ -20,39 +26,44 @@
id="inputName" name="nickname" value="{{ user_menu.nickname }}"> id="inputName" name="nickname" value="{{ user_menu.nickname }}">
</div> </div>
</div> </div>
<div class="mb-3"> <div class="mb-2">
<label class="input-group-addon">我选择</label> <label class="input-group-addon">我选择</label>
</div> </div>
{% for choice in all_choice %} <div class="mb-3 row p-2">
<div class="mb-3 row"> {% for choice in all_choice %}
<div class="col-9"> <div class="col-6 mb-1 p-1 border rounded {{ loop.cycle("rounded-end-0", "border-start-0 rounded-start-0") }}">
<div class="input-group"> <div class="row">
<label for="range{{ loop.index }}" class="form-label"> <label for="range{{ loop.index }}" class="col-12">
<span>{{ choice.label }} - </span> <span>{{ choice.label }} - </span>
<span class="percentage">{{ '{:.2f}'.format((user_menu.menu.get(choice.name) or 0) * 100) }}</span>% <span class="percentage">{{ '{:.2f}'.format((user_menu.menu.get(choice.name) or 0) * 100) }}</span>
<span>%</span>
</label> </label>
<input type="range" class="form-range" data-skip-falsy="true" </div>
id="range{{ loop.index }}" name="choice[{{ choice.name }}]:number" <div class="d-flex justify-content-between">
min="0" max="10" step="1" <div class="col-8">
value="{{ (user_menu.menu.get(choice.name) or 0) * 10 }}"> <input type="range" class="form-range" data-skip-falsy="true"
id="range{{ loop.index }}" name="choice[{{ choice.name }}]:number"
min="0" max="10" step="1"
value="{{ (user_menu.menu.get(choice.name) or 0) * 10 }}">
</div>
<div class="col-4">
<input class="form-check-input" type="checkbox" name="dislike[]"
id="checkDislike{{ loop.index }}" value="{{ choice.name }}"
{{ 'checked' if choice.name in user_menu.dislike else '' }}>
<label class="form-check-label" for="checkDislike{{ loop.index }}">
不吃
</label>
</div>
</div> </div>
</div> </div>
<div class="col-3"> {% endfor %}
<input class="form-check-input" type="checkbox" name="dislike[]" </div>
id="checkDislike{{ loop.index }}" value="{{ choice.name }}"
{{ 'checked' if choice.name in user_menu.dislike else '' }}>
<label class="form-check-label" for="checkDislike{{ loop.index }}">
不吃
</label>
</div>
</div>
{% endfor %}
</div> </div>
</form> </form>
<button type="button" class="btn btn-primary" onclick="update()">更新</button> <button type="button" class="btn btn-outline-primary" onclick="update()">更新</button>
<button type="button" class="btn btn-secondary" onclick="clearValue()">不吃</button> <button type="button" class="btn btn-outline-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-outline-secondary" {{ "" if can_roll == True else ' disabled="disabled"' | safe }}
onclick="roll()">开始抽签 onclick="roll()">开始抽签
</button> </button>
<div class="pt-3"> <div class="pt-3">
@ -91,7 +102,8 @@
<label class="mb-2">最近点餐结果</label> <label class="mb-2">最近点餐结果</label>
<ul class="list-group"> <ul class="list-group">
{% for recent_result in recent_results %} {% for recent_result in recent_results %}
<li onclick="viewChart('{{ recent_result.datestr }}')" class="list-group-item d-flex justify-content-between align-items-center"> <li onclick="viewChart('{{ recent_result.datestr }}')"
class="list-group-item d-flex justify-content-between align-items-center">
<span>{{ recent_result.value }}</span> <span>{{ recent_result.value }}</span>
<span>{{ recent_result.datestr }}</span> <span>{{ recent_result.datestr }}</span>
</li> </li>
@ -118,7 +130,7 @@
const summary = values.reduce((a, b) => parseInt(a) + parseInt(b)); const summary = values.reduce((a, b) => parseInt(a) + parseInt(b));
const spans = $(".percentage") const spans = $(".percentage")
for (let i = 0; i < values.length; i++) { for (let i = 0; i < values.length; i++) {
spans[i].innerHTML = summary > 0 ? (parseFloat(values[i]) * 100 / summary).toFixed(2) : 0; spans[i].innerHTML = summary > 0 ? (parseFloat(values[i]) * 100 / summary).toFixed(2) : '0.00';
if (values[i] > 0 && checkBoxs[i].checked) { if (values[i] > 0 && checkBoxs[i].checked) {
checkBoxs[i].checked = false; checkBoxs[i].checked = false;
} }