如果过期/日期截止日期现在小于日期,我需要更改为背景红色,如果过期/日期截止日期现在超过日期,则需要更改为彩色背景绿色,如果过期/日期截止日期更改为更改为彩色背景橙色超过1天3天
<div t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value gt (new Date())" style="margin: 0px; background-color: #00FF00;">
<b>Stage Deadline:</b> <t t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" t-set="redo">oe_kanban_text_red</t>
<span t-attf-class="#{redo || ''}"><i><field name="eth_current_stage_deadline"/></i></span>
</div>
<div t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" style="margin: 0px; background-color: #FF0000;">
<b>Stage Deadline:</b> <t t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" t-set="redo">oe_kanban_text_red</t>
<span t-attf-class="#{redo || ''}"><i><field name="eth_current_stage_deadline"/></i></span>
</div>
<div t-if="(record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value - new Date()) == 3" style="margin: 0px; background-color: #FF8C00;">
<b>Stage Deadline:</b> <t t-if="record.eth_current_stage_deadline.raw_value and record.eth_current_stage_deadline.raw_value lt (new Date())" t-set="redo">oe_kanban_text_red</t>
<span t-attf-class="#{redo || ''}"><i><field name="eth_current_stage_deadline"/></i></span>
</div>
如果在不到1天的时间内过期,我还没有找到更改颜色背景橙色的方法,直到3天。
答案 0 :(得分:0)
橙色测试存在条件问题:
( ( record.eth_current_stage_deadline.raw_value gt new Date() ) and (record.eth_current_stage_deadline.raw_value - new Date() lt 3*86400000) )
请注意,有两个这样的比较:
(date_val > today) and (date_val - today < 3 days)
值86400000 = 24 * 60 * 60 * 1000,相当于一天(毫秒)。