表html jsreport中两个值数据的乘法

问题描述 投票:0回答:3

我需要在表html jsreport中将两个值数据相乘

数量*勇气->在表中逐行计算没关系,只需要计算

<div class="items">
  <!-- DIV DA TABELA DE ITEMS -->
  <div></div>
  <table class="table-items">
    <thead>
      <tr class="tr-items">
        {{props items}} {{if key
        <=0 }} {{props prop}} <th class="th-items">{{>key}}</th>
          {{/props}} {{/if}} {{/props}}
          <th class="th-items">Total</th>
      </tr>
    </thead>
    <tbody>
      {{for items}}
      <tr class="tr-items">
        <td class="td-items">
          {{>date}}
        </td>
        <td class="td-items">
          {{>qty}}
        </td>
        <td class="td-items">
          {{>item}}
        </td>
        <td class="td-items">
          {{>valor}}
        </td>
        <!-- <td> {{total items}}{{/total}}</td> -->
        <td class="td-items">
          {{>qty}} * {{>valor}} €
        </td>
      </tr>
      {{/for}}
    </tbody>
  </table>
</div>
javascript html jsrender jsreport
3个回答
1
投票

要在jsrender中执行计算,请在计算中加上括号:

<td class="td-items">
  {{>(qty * valor)}} €
</td>

最新新闻] >>

事实证明,“ valor”属性是形式为“ 50.00 EUR”的字符串,因此需要提取字符串的数字部分。修改后的表格将达到​​目的:

{{>(qty * valor.split(' ')[0])}}

事实证明,括号是可选的,因此这也可以使用:

{{> qty * valor.split(' ')[0]}}

0
投票

我将[valor]作为字符串,但是在表内放了[EUR,]并放置了此代码:


0
投票

有可能在数据{{total}}中保存“ {{>(qty * + unit_price).toFixed(2)}}”,因为我需要在另一张表中搜索{{total}}值

© www.soinside.com 2019 - 2024. All rights reserved.