sql行结果行转列现实,以及数值/百分比显示切换


<div class="ui blue segment">
<div class="right floated ui mini buttons">
<button class="ui mini button green show_data">#</button>
<button class="ui mini button show_rake">%</button>
</div>
<table class="ui selectable striped celled table">
<thead>
<tr>
<th class="center aligned" style="width: 10%;">Time</th>
<th class="center aligned" style="width: 10%;">Client Development</th>
<th class="center aligned" style="width: 15%;">Beginning of Month</th>
<th class="center aligned" style="width: 15%;">End of Month</th>
<th class="center aligned" style="width: 15%;">Trend</th>
</tr>
</thead>
<tbody>
<% (@reports_detail_size-1).times.each do |index| %>
<tr >
<td rowspan="5"><%= @reports_detail[index]['created_at'].strftime('%Y-%m-%d') %> - <%= @reports_detail[index+1]['created_at'].strftime('%Y-%m-%d') %></td>
<td>Total Client</td>
<td>
<span class='date'><%= a = @reports_detail[index]['buyer_count'] ; a %></span>
<span class="rake">--</span>
</td>
<td>
<span class='date'><%= b = @reports_detail[index+1]['buyer_count'] ; b %></span>
<span class="rake">--</span>
</td>
<td class="center aligned" >
<span class='date'><%= c = b - a ; c.abs %> <i class="long arrow <%= c.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
<span class="rake"><%= cc = (a - b ) * 100 / a ; cc.abs.round(2) %>% <i class="long arrow <%= cc.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
</td>
</tr>
<tr >
<td>No Contact</td>
<td>
<span class='date'><%= d = @reports_detail[index]['buyer_no_contact'] ; d %></span>
<span class="rake"><%= dd = d * 100 / a ; dd.round(2) %>%</span>
</td>
<td>
<span class='date'><%= e = @reports_detail[index+1]['buyer_no_contact'] ; e %></span>
<span class="rake"><%= ee = e * 100 / b ; ee.round(2) %>%</span>
</td>
<td class="center aligned" >
<span class='date'><%= f = e - d ; f.abs %> <i class="long arrow <%= f.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
<span class="rake"><%= ff = (ee - dd) * 100 / ee ; ff.abs.round(2) %>% <i class="long arrow <%= ff.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
</td>
</tr>
<tr >
<td>Contacting</td>
<td>
<span class='date'><%= g = @reports_detail[index]['buyer_contacting'] ; g %></span>
<span class="rake"><%= gg = g * 100 / a ; gg.round(2) %>%</span>
</td>
<td>
<span class='date'><%= h = @reports_detail[index+1]['buyer_contacting'] ; h %></span>
<span class="rake"><%= hh = h * 100 / b ; hh.round(2) %>%</span>
</td>
<td class="center aligned" >
<span class='date'><%= i = h-g ; i.abs %> <i class="long arrow <%= i.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
<span class="rake"><%= ii = (hh - gg) * 100 / hh ; ii.abs.round(2) %>% <i class="long arrow <%= ii.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
</td>
</tr>
<tr >
<td>Developed</td>
<td>
<span class='date'><%= j = @reports_detail[index]['buyer_developed'] ; j %></span>
<span class="rake"><%= jj = j * 100 / a ; jj.round(2) %>%</span>
</td>
<td>
<span class='date'><%= k = @reports_detail[index+1]['buyer_developed'] ; k %></span>
<span class="rake"><%= kk = k * 100 / b ; kk.round(2) %>%</span>
</td>
<td class="center aligned" >
<span class='date'><%= l = k-j ; l.abs %> <i class="long arrow <%= l.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
<span class="rake"><%= ll = (kk - jj) * 100 / kk ; ll.abs.round(2) %>% <i class="long arrow <%= ll.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
</td>
</tr>
<tr >
<td>Failed</td>
<td>
<span class='date'><%= m = @reports_detail[index]['buyer_failed'] ; m %></span>
<span class="rake"><%= mm = m * 100 / a ; mm.round(2) %>%</span>
</td>
<td>
<span class='date'><%= n = @reports_detail[index+1]['buyer_failed'] ; n %></span>
<span class="rake"><%= nn = n * 100 / b ; nn.round(2) %>%</span>
</td>
<td class="center aligned" >
<span class='date'><%= q = n-m ; q.abs %> <i class="long arrow <%= q.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
<span class="rake"><%= qq = nn == 0 ? 0 : (nn - mm) * 100 / nn ; qq.abs.round(2) %>% <i class="long arrow <%= qq.to_i > 0 ? 'up' : 'down'%> icon"></i> </span>
</td>
</tr>
<% end %>
</tbody>
</table>

</div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值