Pārlūkot izejas kodu

修复计算精度bug

laiguoran 3 gadi atpakaļ
vecāks
revīzija
477115eeaa

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 0
app/public/js/CalcEval.js


+ 2 - 1
app/public/js/material_list.js

@@ -849,7 +849,8 @@ $(document).ready(() => {
                         const [valid, msg] = this._checkExprValid(expr);
                         if (!valid) return [valid, msg];
                         data.expr = expr;
-                        data.quantity = eval(expr);
+                        const ce = new CalcEval();
+                        data.quantity = ce.eval(expr);
                     }
                 } else {
                     data.quantity = 0;

+ 2 - 1
app/view/material/audit_modal.ejs

@@ -215,11 +215,12 @@
                                             <div class="card-body p-3">
                                                 <div class="card-text">
                                                     <p class="mb-1"><span class="h5"><%- auditor.name %></span>
+                                                        <% console.log(auditor.status) %>
                                                         <span
                                                             class="pull-right
                                                                             <%- auditConst.statusClass[auditor.status] %>"><%- auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''%>
                                                             <%- auditor.status === auditConst.status.checkNo ? ctx.material.user.name : '' %>
-                                                            <%- auditor.status === auditConst.status.checkNoPre ? ctx.material.auditors2.find(item => item.order === auditor.sort-1).name : '' %>
+                                                            <%- auditor.status === auditConst.status.checkNoPre ? (ctx.material.auditors2.find(item => item.order === auditor.sort-1) ? ctx.material.auditors2.find(item => item.order === auditor.sort-1).name : '') : '' %>
                                                         </span>
                                                     </p>
                                                     <p class="text-muted mb-0"><%- auditor.role %></p>

+ 1 - 0
config/web.js

@@ -560,6 +560,7 @@ const JsFiles = {
                     '/public/js/zh_calc.js',
                     '/public/js/path_tree.js',
                     '/public/js/gcl_gather.js',
+                    '/public/js/CalcEval.js', // 计算表达式使用
                     '/public/js/material_list.js',
                     '/public/js/shares/cs_tools.js',
                     '/public/js/material_audit.js',