فهرست منبع

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 4 سال پیش
والد
کامیت
9df211a067

+ 9 - 4
app/const/material.js

@@ -28,23 +28,27 @@ const ex_type = [
     { text: '定值', value: 1 },
     { text: '变值', value: 2 },
 ];
-
+const ex_basic_text = {
+    bqht: '所选期合同计量金额',
+    bqbg: '所选期变更计量金额',
+    bqwc: '所选期完成计量金额',
+}
 const ex_calc = [
     {
         code: 'bqht',
-        text: '本期合同计量金额',
+        text: '所选期合同计量金额',
         value: '',
         select: false,
     },
     {
         code: 'bqbg',
-        text: '期变更计量金额',
+        text: '所选期变更计量金额',
         value: '',
         select: false,
     },
     {
         code: 'bqwc',
-        text: '期完成计量金额',
+        text: '所选期完成计量金额',
         value: '',
         select: true,
     },
@@ -61,4 +65,5 @@ module.exports = {
     ex_type,
     is_summary,
     ex_calc,
+    ex_basic_text,
 };

+ 5 - 4
app/controller/material_controller.js

@@ -400,12 +400,13 @@ module.exports = app => {
                             return bq.code === item.code;
                         });
                         bq.value = calc.value;
-                        if (calc.code === 'bqwc') {
-                            ctx.material.ex_expr = calc.value.toString() + '*[0-1]';
-                        }
+                        // if (calc.code === 'bqwc') {
+                        //     ctx.material.ex_expr = calc.value.toString() + '*[0-1]';
+                        //     ctx.material.ex_tp = this.ctx.helper.round(this.ctx.helper.mul(calc.value, -1), 2);
+                        // }
                     }
                     // 并更新至调差表中
-                    await ctx.service.material.update({ ex_calc: JSON.stringify(renderData.ex_calc), ex_expr: ctx.material.ex_expr }, { id: ctx.material.id });
+                    await ctx.service.material.update({ ex_calc: JSON.stringify(renderData.ex_calc) }, { id: ctx.material.id });
                 } else {
                     renderData.ex_calc = JSON.parse(ctx.material.ex_calc);
                 }

+ 17 - 7
app/public/js/material_exponent.js

@@ -50,7 +50,7 @@ $(document).ready(() => {
     const materialExponentBase = {
         isUsed: function (data) {
             if (data.type === 2) {
-                return data.mid === materialID || data.weight_num === null;
+                return data.mid === materialID || data.basic_price === null;
             } else {
                 return false;
             }
@@ -80,7 +80,8 @@ $(document).ready(() => {
                 return !(!readOnly && data.type === 2);
             },
             isConstant: function (data) {
-                return !(!readOnly && materialExponentBase.isConstant(data));
+                // return !(!readOnly && materialExponentBase.isConstant(data));
+                return readOnly;
             }
         },
     };
@@ -423,7 +424,7 @@ $(document).ready(() => {
         callback: function () {
             materialExponentSpread.refresh();
             const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
-            // setLocalCache('material_month_' + materialID, width);
+            setLocalCache('material_exponent_' + materialID, width);
         }
     });
 
@@ -439,16 +440,25 @@ $(document).ready(() => {
             showSideTools(tab.hasClass('active'));
             if (tab.attr('content') === '#base-tab') {
                 const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
-                // setLocalCache('material_month_' + materialID, width);
-                // materialMonthSpread.refresh();
+                setLocalCache('material_exponent_' + materialID, width);
             }
         } else {
-            // removeLocalCache('material_month_' + materialID);
+            removeLocalCache('material_exponent_' + materialID);
             tab.removeClass('active');
             tabPanel.removeClass('active');
             showSideTools(tab.hasClass('active'));
         }
-        // materialSpread.refresh();
         materialExponentSpread.refresh();
     });
+    // 根据浏览器记录展开收起
+    if (getLocalCache('material_exponent_' + materialID)) {
+        const tab = $('.right-nav a[content="#base-tab"]'), tabPanel = $(tab.attr('content'));
+        $('a', '.side-menu').removeClass('active');
+        $('.tab-content .tab-select-show').removeClass('active');
+        tab.addClass('active');
+        tabPanel.addClass('active');
+        $('#right-view').width(getLocalCache('material_exponent_' + materialID) + '%');
+        showSideTools(tab.hasClass('active'));
+        materialExponentSpread.refresh();
+    }
 });

+ 9 - 9
app/public/js/material_list.js

@@ -131,15 +131,15 @@ $(document).ready(() => {
     const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
     const ledgerSpreadSetting = {
         cols: [
-            {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 150, formatter: '@'},
-            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 250, formatter: '@'},
-            {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 120, formatter: '@'},
-            {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 120, type: 'Number'},
-            {title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 120, type: 'Number'},
-            {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 120, type: 'Number'},
-            {title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 120, type: 'Number'},
-            {title: '本期完成金额', colSpan: '1', rowSpan: '2', field: 'gather_tp', hAlign: 2, width: 150, type: 'Number'},
-            {title: '本期价差', colSpan: '1', rowSpan: '2', field: 'total_jiacha', hAlign:3, width: 150, type: 'Number'}
+            {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 90, formatter: '@'},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 220, formatter: '@'},
+            {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 80, formatter: '@'},
+            {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 110, type: 'Number'},
+            {title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 110, type: 'Number'},
+            {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 110, type: 'Number'},
+            {title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 110, type: 'Number'},
+            {title: '本期完成金额', colSpan: '1', rowSpan: '2', field: 'gather_tp', hAlign: 2, width: 110, type: 'Number'},
+            {title: '本期价差', colSpan: '1', rowSpan: '2', field: 'total_jiacha', hAlign:3, width: 110, type: 'Number'}
         ],
         emptyRows: 0,
         headRows: 2,

+ 2 - 1
app/service/material_exponent.js

@@ -212,7 +212,8 @@ module.exports = app => {
                 }
             }
             expr += '-1]';
-            const ex_tp = this.ctx.helper.round(this.ctx.helper.mul(basic_calc, this.ctx.helper.sub(this.ctx.helper.add(constant, sumByChange), 1)), 2);
+            expr = constant !== 0 ? expr : null;
+            const ex_tp = constant !== 0 ? this.ctx.helper.round(this.ctx.helper.mul(basic_calc, this.ctx.helper.sub(this.ctx.helper.add(constant, sumByChange), 1)), 2) : null;
             await transaction.update(this.ctx.service.material.tableName, {
                 id: mid ? mid : this.ctx.material.id,
                 ex_tp,

+ 2 - 0
app/service/tender.js

@@ -312,6 +312,8 @@ module.exports = app => {
                 await transaction.delete(this.ctx.service.materialBillsHistory.tableName, { tid: id });
                 await transaction.delete(this.ctx.service.materialList.tableName, { tid: id });
                 await transaction.delete(this.ctx.service.materialListNotjoin.tableName, { tid: id });
+                await transaction.delete(this.ctx.service.materialExponent.tableName, { tid: id });
+                await transaction.delete(this.ctx.service.materialExponentHistory.tableName, { tid: id });
 
 
                 await transaction.delete(this.ctx.service.materialFile.tableName, { tid: id });

+ 382 - 382
app/view/advance/detail.ejs

@@ -1,382 +1,382 @@
-<% include ../tender/tender_sub_menu.ejs %>
-<div class="panel-content">
-    <div class="panel-title">
-        <div class="title-main d-flex justify-content-between">
-            <div>
-                <div class="d-inline-block">
-                    第<%- advance.order %>期
-                </div>
-            </div>
-            <div id="au-btn">
-                <% include ./audit_btn.ejs %>
-            </div>
-        </div>
-    </div>
-    <div class="content-wrap">
-        <div class="c-body">
-            <div class="sjs-height-0">
-                <div class="col-xl-8 mx-auto">
-                    <h4 class="mt-3 text-center mb-3">第<%- advance.order %>期
-                        <%- advance.type === auditConst.type.start ? '开工' : '材料' %>预付款</h4>
-                    <table class="table table-bordered">
-                        <thead>
-                            <tr>
-                                <th colspan="4" class="text-center">
-                                    签约<%- advance.type === auditConst.type.start ? '开工' : '材料' %>预付款:<%- ctx.helper.formatMoney(advancePayTotal, ',', parseFloat(advancePayTotal.toFixed(decimal)).toString().split('.')[1] && parseFloat(advancePayTotal.toFixed(decimal)).toString().split('.')[1].length || 0) %>
-                                    元
-                                </th>
-                            </tr>
-                        </thead>
-                        <tbody id="pay-content">
-                            <tr>
-                                <th width="150" class="text-center">支付比例</th>
-                                <td class="text-right" width="405">
-                                    <div class="input-group input-group-sm">
-                                        <input type="number" class="pay-input form-control nospin text-right"
-                                            max="<%- max_pr %>" min="1" step="0.01" placeholder="请填写支付比例,将自动计算本期金额" data-type="0" <%- isEdited ? '' : 'disabled' %>
-                                            value="<%- advance.pay_ratio && ctx.helper.mul(ctx.helper.div(advance.cur_amount, advancePayTotal), 100, 2) || 0 %>">
-                                        <div class="input-group-append"><span class="input-group-text">%</span></div>
-                                    </div>
-                                </td>
-                                <th width="150" class="text-center">本期金额</th>
-                                <td class="text-right" width="405">
-                                    <div class="input-group input-group-sm">
-                                        <input type="number" class="pay-input form-control nospin text-right" min="1" <%- isEdited  ? '' : 'disabled' %>
-                                            placeholder="请填写本期金额,将自动计算支付比例" data-type="1"
-                                            value="<%- cur_amount %>">
-                                        <div class="input-group-append"><span class="input-group-text">元</span></div>
-                                    </div>
-                                </td>
-                            </tr>
-                            <tr>
-                                <th class="text-center">截止上期</th>
-                                <td class="text-right" id="p_total1" width="405">
-                                    <%- prev_amount %>元
-                                </td>
-                                <th class="text-center">截止本期金额</th>
-                                <td class="text-right" id="p_total2" width="405">
-                                    <%- prev_total_amount %>元
-                                </td>
-                            </tr>
-                            <tr>
-                                <th class="text-center" >备注</th>
-                                <td colspan="3">
-                                    <textarea id="ad-remark" class="form-control form-control-sm" rows="2"
-                                        <%- isEdited ? '' : 'disabled' %>></textarea>
-                                </td>
-                            </tr>
-                        </tbody>
-                    </table>
-                    <table class="table table-bordered mt-3">
-                        <thead>
-                            <tr>
-                                <th colspan="3" class="text-center">附件</th>
-                            </tr>
-                        </thead>
-                        <tbody id="file-content">
-                        </tbody>
-                    </table>
-                    <% if(isEdited) { %>
-                    <table class="table table-bordered mt-3">
-                        <thead>
-                            <tr>
-                                <th colspan="2" class="text-center">审批流程</th>
-                            </tr>
-                        </thead>
-                        <tbody>
-                            <tr>
-                                <td width="30%">
-                                    <div class="card">
-                                        <ul class="list-group list-group-flush" id="auditors2">
-                                            <% auditors.forEach((item, idx) => { %>
-                                            <% if (idx === 0) { %>
-                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
-                                                <i class="fa fa fa-play-circle fa-rotate-90"></i> <%- item.name %>
-                                                <small class="text-muted"><%- item.role %></small>
-                                            </li>
-                                            <% } else if(idx === auditors.length -1 && idx !== 0) { %>
-                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
-                                                <i class="fa fa fa-stop-circle"></i> <%- item.name %>
-                                                <small class="text-muted"><%- item.role %></small>
-                                            </li>
-                                            <% } else {%>
-                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
-                                                <i class="fa fa-chevron-circle-down"></i> <%- item.name %>
-                                                <small class="text-muted"><%- item.role %></small>
-                                            </li>
-                                            <% } %>
-                                            <% }) %>
-                                        </ul>
-                                    </div>
-                                </td>
-                                <td width="70%">
-                                    <div class="dropdown text-right">
-                                        <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button"
-                                            id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
-                                            aria-expanded="false">
-                                            添加审批流程
-                                        </button>
-                                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton"
-                                            style="width:220px">
-                                            <div class="mb-2 p-2"><input class="form-control form-control-sm"
-                                                    placeholder="姓名/手机 检索" id="gr-search" autocomplete="off"></div>
-                                            <dl class="list-unstyled book-list">
-                                                <% accountGroup.forEach((group, idx) => { %>
-                                                    <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>" data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
-                                                    <div class="dd-content" data-toggleid="<%- idx %>">
-                                                        <% group.groupList.forEach(item => { %>
-                                                            <% if (item.id !== ctx.session.sessionUser.accountId) { %>
-                                                                <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>" >
-                                                                    <p class="mb-0 d-flex">
-                                                                        <span class="text-primary"><%- item.name %></span>
-                                                                        <span class="ml-auto"><%- item.mobile %></span></p>
-                                                                    <span class="text-muted"><%- item.role %></span>
-                                                                </dd>
-                                                            <% } %>
-                                                        <% });%>
-                                                    </div>
-                                                <% }) %>
-                                            </dl>
-                                        </div>
-                                    </div>
-
-                                    <div class="card mt-3">
-                                        <div class="card-header">
-                                            审批流程
-                                        </div>
-                                        <ul class="list-group list-group-flush" id="auditors">
-                                            <% ctx.advance.auditors && ctx.advance.auditors.forEach((item, idx) => { %>
-                                            <li class="list-group-item" auditorId="<%- item.audit_id %>">
-                                                <a href="" class="text-danger pull-right">移除</a><%- idx+1 %>
-                                                <%- item.name %>
-                                                <small class="text-muted"><%- item.role %> </small>
-                                                <p class="m-0 ml-2">
-                                                    <small class="text-muted"><%- item.company %></small>
-                                                </p>
-                                            </li>
-                                            <% }) %>
-                                        </ul>
-                                    </div>
-                                </td>
-                            </tr>
-                        </tbody>
-                    </table>
-                    <% } else {%>
-                    <table class="table table-bordered mt-3">
-                        <thead>
-                            <tr>
-                                <th colspan="2" class="text-center">审批流程</th>
-                            </tr>
-                        </thead>
-                        <tbody>
-                            <tr>
-                                <td width="30%">
-                                    <div class="card">
-                                        <ul class="list-group list-group-flush">
-                                            <% auditors.forEach((item, idx) => { %>
-                                            <% if (idx === 0) { %>
-                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
-                                                <i class="fa fa fa-play-circle fa-rotate-90"></i> <%- item.name %>
-                                                <small class="text-muted"><%- item.role %></small>
-                                                <span class="pull-right">原报</span>
-                                            </li>
-                                            <% } else if(idx === auditors.length -1 && idx !== 0) { %>
-                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
-                                                <i class="fa fa fa-stop-circle"></i> <%- item.name %>
-                                                <small class="text-muted"><%- item.role %></small>
-                                                <span class="pull-right">终审</span>
-                                            </li>
-                                            <% } else {%>
-                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
-                                                <i class="fa fa-chevron-circle-down"></i> <%- item.name %>
-                                                <small class="text-muted"><%- item.role %></small>
-                                                <span
-                                                    class="pull-right"><%= ctx.helper.transFormToChinese(idx) %>审</span>
-                                            </li>
-                                            <% } %>
-                                            <% }) %>
-                                        </ul>
-                                    </div>
-                                </td>
-                                <td width="70%">
-
-                                    <% auditHistory.forEach((auditors, idx) => { %>
-                                        <!-- 展开/收起历史流程 -->
-                                        <% if(idx === auditHistory.length - 1 && auditHistory.length !== 1) { %>
-                                            <div class="text-right">
-                                                <a href="javascript: void(0);" id="fold-btn" data-target="show">展开历史审批流程</a>
-                                            </div>
-                                        <% } %>
-                                        <div class="<%- idx < auditHistory.length - 1 ? 'fold-card' : '' %>">
-                                            <div class="text-center text-muted" ><%- idx+1 %>#</div>
-                                            <ul class="timeline-list list-unstyled mt-2">
-                                                <% auditors.forEach((auditor, index) => { %>
-                                                <% if (index === 0) { %>
-                                                <li class="timeline-list-item pb-2">
-                                                    <div class="timeline-item-date">
-                                                        <%- ctx.helper.formatDate(auditor.create_time) %>
-                                                    </div>
-                                                    <div class="timeline-item-tail"></div>
-                                                    <div class="timeline-item-icon bg-success text-light">
-                                                        <i class="fa fa-caret-down"></i>
-                                                    </div>
-                                                    <div class="timeline-item-content">
-                                                        <div class="card">
-                                                            <div class="card-body p-3">
-                                                                <div class="card-text">
-                                                                    <p class="mb-1"><span
-                                                                            class="h5"><%- advance.user.name %></span><span
-                                                                            class="pull-right text-success"><%- idx !== 0 ? '重新' : '' %>上报审批</span>
-                                                                    </p>
-                                                                    <p class="text-muted mb-0"><%- advance.user.role %></p>
-                                                                </div>
-                                                            </div>
-                                                        </div>
-                                                    </div>
-                                                </li>
-                                                <li class="timeline-list-item pb-2">
-                                                    <div class="timeline-item-date">
-                                                        <%- ctx.helper.formatDate(auditor.end_time) %>
-                                                    </div>
-                                                    <% if(index < auditors.length - 1) { %>
-                                                    <div class="timeline-item-tail"></div>
-                                                    <% } %>
-                                                    <% if(auditor.status === auditConst.status.checked) { %>
-                                                    <div class="timeline-item-icon bg-success text-light">
-                                                        <i class="fa fa-check"></i>
-                                                    </div>
-                                                    <% } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {%>
-                                                    <div class="timeline-item-icon bg-warning text-light">
-                                                        <i class="fa fa-level-up"></i>
-                                                    </div>
-                                                    <% } else if(auditor.status === auditConst.status.checking) { %>
-                                                    <div class="timeline-item-icon bg-warning text-light">
-                                                        <i class="fa fa-ellipsis-h"></i>
-                                                    </div>
-                                                    <% } else {%>
-                                                    <div class="timeline-item-icon bg-secondary text-light">
-                                                    </div>
-                                                    <% } %>
-                                                    <div class="timeline-item-content">
-                                                        <div class="card">
-                                                            <div class="card-body p-3">
-                                                                <div class="card-text">
-                                                                    <p class="mb-1"><span
-                                                                            class="h5"><%- auditor.name %></span><span
-                                                                            class="pull-right <%- auditConst.statusClass[auditor.status] %>"><%- auditConst.statusString[auditor.status] %></span>
-                                                                    </p>
-                                                                    <p class="text-muted mb-0"><%- auditor.role %></p>
-                                                                </div>
-                                                            </div>
-                                                            <!--审批意见-->
-                                                            <% if (auditor.opinion) { %>
-                                                            <div class="card-body p-3 border-top">
-                                                                <p style="margin: 0;"><%- auditor.opinion %></p>
-                                                            </div>
-                                                            <% } %>
-                                                        </div>
-                                                    </div>
-                                                </li>
-                                                <% } else {%>
-                                                <li class="timeline-list-item pb-2">
-                                                    <div class="timeline-item-date">
-                                                        <%- ctx.helper.formatDate(auditor.end_time) %>
-                                                    </div>
-                                                    <% if(index < auditors.length - 1) { %>
-                                                    <div class="timeline-item-tail"></div>
-                                                    <% } %>
-                                                    <% if(auditor.status === auditConst.status.checked) { %>
-                                                    <div class="timeline-item-icon bg-success text-light">
-                                                        <i class="fa fa-check"></i>
-                                                    </div>
-                                                    <% } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {%>
-                                                    <div class="timeline-item-icon bg-warning text-light">
-                                                        <i class="fa fa-level-up"></i>
-                                                    </div>
-                                                    <% } else if(auditor.status === auditConst.status.checking) { %>
-                                                    <div class="timeline-item-icon bg-warning text-light">
-                                                        <i class="fa fa-ellipsis-h"></i>
-                                                    </div>
-                                                    <% } else { %>
-                                                    <div class="timeline-item-icon bg-secondary text-light">
-                                                    </div>
-                                                    <% } %>
-                                                    <div class="timeline-item-content">
-                                                        <div class="card">
-                                                            <div class="card-body p-3">
-                                                                <div class="card-text">
-                                                                    <p class="mb-1"><span
-                                                                            class="h5"><%- auditor.name %></span>
-                                                                        <span
-                                                                            class="pull-right
-                                                                                        <%- auditConst.statusClass[auditor.status] %>"><%- auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''%>
-                                                                            <%- auditor.status === auditConst.status.checkNo ? advance.user.name : '' %>
-                                                                            <%- auditor.status === auditConst.status.checkNoPre ? auditors[index-1].name : '' %>
-                                                                        </span>
-                                                                    </p>
-                                                                    <p class="text-muted mb-0"><%- auditor.role %></p>
-                                                                </div>
-                                                            </div>
-                                                            <!--审批意见-->
-                                                            <% if (auditor.opinion) { %>
-                                                            <div class="card-body p-3 border-top">
-                                                                <p style="margin: 0;"><%- auditor.opinion %></p>
-                                                            </div>
-                                                            <% } %>
-                                                        </div>
-                                                    </div>
-                                                </li>
-                                                <% } %>
-                                                <% }) %>
-                                            </ul>
-                                        </div>
-                                    <% }) %>
-                                </td>
-                            </tr>
-                        </tbody>
-                    </table>
-                    <% } %>
-                </div>
-            </div>
-        </div>
-    </div>
-</div>
-<script>
-    const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
-    const decimal = parseInt('<%- decimal %>');
-    const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
-    const advance = JSON.parse('<%- JSON.stringify(advance) %>');
-    const prevAdvance = JSON.parse('<%- JSON.stringify(prevAdvance) %>');
-    const isEdited = JSON.parse('<%- isEdited %>');
-    const advancePayTotal = parseFloat('<%- advancePayTotal %>');
-    const preUrl = '<%- preUrl %>';
-    const fileList = JSON.parse('<%- JSON.stringify(fileList) %>') || [];
-    const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
-    const curAuditor = JSON.parse('<%- JSON.stringify(ctx.advance.curAuditor) %>');
-
-    // 展开历史审核记录
-    $('td #fold-btn').click(function () {
-        const type = $(this).data('target')
-        const auditCard = $(this).parent().parent()
-        if (type === 'show') {
-            $(this).data('target', 'hide')
-            auditCard.find('.fold-card').slideDown('swing', () => {
-                auditCard.find('#fold-btn').text('收起历史审核记录')
-            })
-        } else {
-            $(this).data('target', 'show')
-            auditCard.find('.fold-card').slideUp('swing', () => {
-                auditCard.find('#fold-btn').text('展开历史审核记录')
-            })
-        }
-    });
-    // 处理换行
-    advance.remark && $('#ad-remark').html(advance.remark.replace(/<br\/>/g, '\n').replace(/' '/, '\s'));
-</script>
-<% if(isEdited && ctx.session.sessionUser.accountId === ctx.advance.uid) { %>
-<script>
-    const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
-    const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
-</script>
-<% } %>
-
+<% include ../tender/tender_sub_menu.ejs %>
+<div class="panel-content">
+    <div class="panel-title">
+        <div class="title-main d-flex justify-content-between">
+            <div>
+                <div class="d-inline-block">
+                    第<%- advance.order %>期
+                </div>
+            </div>
+            <div id="au-btn">
+                <% include ./audit_btn.ejs %>
+            </div>
+        </div>
+    </div>
+    <div class="content-wrap">
+        <div class="c-body">
+            <div class="sjs-height-0">
+                <div class="col-xl-8 mx-auto">
+                    <h4 class="mt-3 text-center mb-3">第<%- advance.order %>期
+                        <%- advance.type === auditConst.type.start ? '开工' : '材料' %>预付款</h4>
+                    <table class="table table-bordered">
+                        <thead>
+                            <tr>
+                                <th colspan="4" class="text-center">
+                                    签约<%- advance.type === auditConst.type.start ? '开工' : '材料' %>预付款:<%- ctx.helper.formatMoney(advancePayTotal, ',', parseFloat(advancePayTotal).toString().split('.')[1] && parseFloat(advancePayTotal).toString().split('.')[1].length || 0) %>
+                                    元
+                                </th>
+                            </tr>
+                        </thead>
+                        <tbody id="pay-content">
+                            <tr>
+                                <th width="150" class="text-center">支付比例</th>
+                                <td class="text-right" width="405">
+                                    <div class="input-group input-group-sm">
+                                        <input type="number" class="pay-input form-control nospin text-right"
+                                            max="<%- max_pr %>" min="1" step="0.01" placeholder="请填写支付比例,将自动计算本期金额" data-type="0" <%- isEdited ? '' : 'disabled' %>
+                                            value="<%- advance.pay_ratio && ctx.helper.mul(ctx.helper.div(advance.cur_amount, advancePayTotal), 100, 2) || 0 %>">
+                                        <div class="input-group-append"><span class="input-group-text">%</span></div>
+                                    </div>
+                                </td>
+                                <th width="150" class="text-center">本期金额</th>
+                                <td class="text-right" width="405">
+                                    <div class="input-group input-group-sm">
+                                        <input type="number" class="pay-input form-control nospin text-right" min="1" <%- isEdited  ? '' : 'disabled' %>
+                                            placeholder="请填写本期金额,将自动计算支付比例" data-type="1"
+                                            value="<%- cur_amount %>">
+                                        <div class="input-group-append"><span class="input-group-text">元</span></div>
+                                    </div>
+                                </td>
+                            </tr>
+                            <tr>
+                                <th class="text-center">截止上期</th>
+                                <td class="text-right" id="p_total1" width="405">
+                                    <%- prev_amount %>元
+                                </td>
+                                <th class="text-center">截止本期金额</th>
+                                <td class="text-right" id="p_total2" width="405">
+                                    <%- prev_total_amount %>元
+                                </td>
+                            </tr>
+                            <tr>
+                                <th class="text-center" >备注</th>
+                                <td colspan="3">
+                                    <textarea id="ad-remark" class="form-control form-control-sm" rows="2"
+                                        <%- isEdited ? '' : 'disabled' %>></textarea>
+                                </td>
+                            </tr>
+                        </tbody>
+                    </table>
+                    <table class="table table-bordered mt-3">
+                        <thead>
+                            <tr>
+                                <th colspan="3" class="text-center">附件</th>
+                            </tr>
+                        </thead>
+                        <tbody id="file-content">
+                        </tbody>
+                    </table>
+                    <% if(isEdited) { %>
+                    <table class="table table-bordered mt-3">
+                        <thead>
+                            <tr>
+                                <th colspan="2" class="text-center">审批流程</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <tr>
+                                <td width="30%">
+                                    <div class="card">
+                                        <ul class="list-group list-group-flush" id="auditors2">
+                                            <% auditors.forEach((item, idx) => { %>
+                                            <% if (idx === 0) { %>
+                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
+                                                <i class="fa fa fa-play-circle fa-rotate-90"></i> <%- item.name %>
+                                                <small class="text-muted"><%- item.role %></small>
+                                            </li>
+                                            <% } else if(idx === auditors.length -1 && idx !== 0) { %>
+                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
+                                                <i class="fa fa fa-stop-circle"></i> <%- item.name %>
+                                                <small class="text-muted"><%- item.role %></small>
+                                            </li>
+                                            <% } else {%>
+                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
+                                                <i class="fa fa-chevron-circle-down"></i> <%- item.name %>
+                                                <small class="text-muted"><%- item.role %></small>
+                                            </li>
+                                            <% } %>
+                                            <% }) %>
+                                        </ul>
+                                    </div>
+                                </td>
+                                <td width="70%">
+                                    <div class="dropdown text-right">
+                                        <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button"
+                                            id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
+                                            aria-expanded="false">
+                                            添加审批流程
+                                        </button>
+                                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton"
+                                            style="width:220px">
+                                            <div class="mb-2 p-2"><input class="form-control form-control-sm"
+                                                    placeholder="姓名/手机 检索" id="gr-search" autocomplete="off"></div>
+                                            <dl class="list-unstyled book-list">
+                                                <% accountGroup.forEach((group, idx) => { %>
+                                                    <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>" data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
+                                                    <div class="dd-content" data-toggleid="<%- idx %>">
+                                                        <% group.groupList.forEach(item => { %>
+                                                            <% if (item.id !== ctx.session.sessionUser.accountId) { %>
+                                                                <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>" >
+                                                                    <p class="mb-0 d-flex">
+                                                                        <span class="text-primary"><%- item.name %></span>
+                                                                        <span class="ml-auto"><%- item.mobile %></span></p>
+                                                                    <span class="text-muted"><%- item.role %></span>
+                                                                </dd>
+                                                            <% } %>
+                                                        <% });%>
+                                                    </div>
+                                                <% }) %>
+                                            </dl>
+                                        </div>
+                                    </div>
+
+                                    <div class="card mt-3">
+                                        <div class="card-header">
+                                            审批流程
+                                        </div>
+                                        <ul class="list-group list-group-flush" id="auditors">
+                                            <% ctx.advance.auditors && ctx.advance.auditors.forEach((item, idx) => { %>
+                                            <li class="list-group-item" auditorId="<%- item.audit_id %>">
+                                                <a href="" class="text-danger pull-right">移除</a><%- idx+1 %>
+                                                <%- item.name %>
+                                                <small class="text-muted"><%- item.role %> </small>
+                                                <p class="m-0 ml-2">
+                                                    <small class="text-muted"><%- item.company %></small>
+                                                </p>
+                                            </li>
+                                            <% }) %>
+                                        </ul>
+                                    </div>
+                                </td>
+                            </tr>
+                        </tbody>
+                    </table>
+                    <% } else {%>
+                    <table class="table table-bordered mt-3">
+                        <thead>
+                            <tr>
+                                <th colspan="2" class="text-center">审批流程</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <tr>
+                                <td width="30%">
+                                    <div class="card">
+                                        <ul class="list-group list-group-flush">
+                                            <% auditors.forEach((item, idx) => { %>
+                                            <% if (idx === 0) { %>
+                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
+                                                <i class="fa fa fa-play-circle fa-rotate-90"></i> <%- item.name %>
+                                                <small class="text-muted"><%- item.role %></small>
+                                                <span class="pull-right">原报</span>
+                                            </li>
+                                            <% } else if(idx === auditors.length -1 && idx !== 0) { %>
+                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
+                                                <i class="fa fa fa-stop-circle"></i> <%- item.name %>
+                                                <small class="text-muted"><%- item.role %></small>
+                                                <span class="pull-right">终审</span>
+                                            </li>
+                                            <% } else {%>
+                                            <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
+                                                <i class="fa fa-chevron-circle-down"></i> <%- item.name %>
+                                                <small class="text-muted"><%- item.role %></small>
+                                                <span
+                                                    class="pull-right"><%= ctx.helper.transFormToChinese(idx) %>审</span>
+                                            </li>
+                                            <% } %>
+                                            <% }) %>
+                                        </ul>
+                                    </div>
+                                </td>
+                                <td width="70%">
+
+                                    <% auditHistory.forEach((auditors, idx) => { %>
+                                        <!-- 展开/收起历史流程 -->
+                                        <% if(idx === auditHistory.length - 1 && auditHistory.length !== 1) { %>
+                                            <div class="text-right">
+                                                <a href="javascript: void(0);" id="fold-btn" data-target="show">展开历史审批流程</a>
+                                            </div>
+                                        <% } %>
+                                        <div class="<%- idx < auditHistory.length - 1 ? 'fold-card' : '' %>">
+                                            <div class="text-center text-muted" ><%- idx+1 %>#</div>
+                                            <ul class="timeline-list list-unstyled mt-2">
+                                                <% auditors.forEach((auditor, index) => { %>
+                                                <% if (index === 0) { %>
+                                                <li class="timeline-list-item pb-2">
+                                                    <div class="timeline-item-date">
+                                                        <%- ctx.helper.formatDate(auditor.create_time) %>
+                                                    </div>
+                                                    <div class="timeline-item-tail"></div>
+                                                    <div class="timeline-item-icon bg-success text-light">
+                                                        <i class="fa fa-caret-down"></i>
+                                                    </div>
+                                                    <div class="timeline-item-content">
+                                                        <div class="card">
+                                                            <div class="card-body p-3">
+                                                                <div class="card-text">
+                                                                    <p class="mb-1"><span
+                                                                            class="h5"><%- advance.user.name %></span><span
+                                                                            class="pull-right text-success"><%- idx !== 0 ? '重新' : '' %>上报审批</span>
+                                                                    </p>
+                                                                    <p class="text-muted mb-0"><%- advance.user.role %></p>
+                                                                </div>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                </li>
+                                                <li class="timeline-list-item pb-2">
+                                                    <div class="timeline-item-date">
+                                                        <%- ctx.helper.formatDate(auditor.end_time) %>
+                                                    </div>
+                                                    <% if(index < auditors.length - 1) { %>
+                                                    <div class="timeline-item-tail"></div>
+                                                    <% } %>
+                                                    <% if(auditor.status === auditConst.status.checked) { %>
+                                                    <div class="timeline-item-icon bg-success text-light">
+                                                        <i class="fa fa-check"></i>
+                                                    </div>
+                                                    <% } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {%>
+                                                    <div class="timeline-item-icon bg-warning text-light">
+                                                        <i class="fa fa-level-up"></i>
+                                                    </div>
+                                                    <% } else if(auditor.status === auditConst.status.checking) { %>
+                                                    <div class="timeline-item-icon bg-warning text-light">
+                                                        <i class="fa fa-ellipsis-h"></i>
+                                                    </div>
+                                                    <% } else {%>
+                                                    <div class="timeline-item-icon bg-secondary text-light">
+                                                    </div>
+                                                    <% } %>
+                                                    <div class="timeline-item-content">
+                                                        <div class="card">
+                                                            <div class="card-body p-3">
+                                                                <div class="card-text">
+                                                                    <p class="mb-1"><span
+                                                                            class="h5"><%- auditor.name %></span><span
+                                                                            class="pull-right <%- auditConst.statusClass[auditor.status] %>"><%- auditConst.statusString[auditor.status] %></span>
+                                                                    </p>
+                                                                    <p class="text-muted mb-0"><%- auditor.role %></p>
+                                                                </div>
+                                                            </div>
+                                                            <!--审批意见-->
+                                                            <% if (auditor.opinion) { %>
+                                                            <div class="card-body p-3 border-top">
+                                                                <p style="margin: 0;"><%- auditor.opinion %></p>
+                                                            </div>
+                                                            <% } %>
+                                                        </div>
+                                                    </div>
+                                                </li>
+                                                <% } else {%>
+                                                <li class="timeline-list-item pb-2">
+                                                    <div class="timeline-item-date">
+                                                        <%- ctx.helper.formatDate(auditor.end_time) %>
+                                                    </div>
+                                                    <% if(index < auditors.length - 1) { %>
+                                                    <div class="timeline-item-tail"></div>
+                                                    <% } %>
+                                                    <% if(auditor.status === auditConst.status.checked) { %>
+                                                    <div class="timeline-item-icon bg-success text-light">
+                                                        <i class="fa fa-check"></i>
+                                                    </div>
+                                                    <% } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {%>
+                                                    <div class="timeline-item-icon bg-warning text-light">
+                                                        <i class="fa fa-level-up"></i>
+                                                    </div>
+                                                    <% } else if(auditor.status === auditConst.status.checking) { %>
+                                                    <div class="timeline-item-icon bg-warning text-light">
+                                                        <i class="fa fa-ellipsis-h"></i>
+                                                    </div>
+                                                    <% } else { %>
+                                                    <div class="timeline-item-icon bg-secondary text-light">
+                                                    </div>
+                                                    <% } %>
+                                                    <div class="timeline-item-content">
+                                                        <div class="card">
+                                                            <div class="card-body p-3">
+                                                                <div class="card-text">
+                                                                    <p class="mb-1"><span
+                                                                            class="h5"><%- auditor.name %></span>
+                                                                        <span
+                                                                            class="pull-right
+                                                                                        <%- auditConst.statusClass[auditor.status] %>"><%- auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''%>
+                                                                            <%- auditor.status === auditConst.status.checkNo ? advance.user.name : '' %>
+                                                                            <%- auditor.status === auditConst.status.checkNoPre ? auditors[index-1].name : '' %>
+                                                                        </span>
+                                                                    </p>
+                                                                    <p class="text-muted mb-0"><%- auditor.role %></p>
+                                                                </div>
+                                                            </div>
+                                                            <!--审批意见-->
+                                                            <% if (auditor.opinion) { %>
+                                                            <div class="card-body p-3 border-top">
+                                                                <p style="margin: 0;"><%- auditor.opinion %></p>
+                                                            </div>
+                                                            <% } %>
+                                                        </div>
+                                                    </div>
+                                                </li>
+                                                <% } %>
+                                                <% }) %>
+                                            </ul>
+                                        </div>
+                                    <% }) %>
+                                </td>
+                            </tr>
+                        </tbody>
+                    </table>
+                    <% } %>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script>
+    const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
+    const decimal = parseInt('<%- decimal %>');
+    const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
+    const advance = JSON.parse('<%- JSON.stringify(advance) %>');
+    const prevAdvance = JSON.parse('<%- JSON.stringify(prevAdvance) %>');
+    const isEdited = JSON.parse('<%- isEdited %>');
+    const advancePayTotal = parseFloat('<%- advancePayTotal %>');
+    const preUrl = '<%- preUrl %>';
+    const fileList = JSON.parse('<%- JSON.stringify(fileList) %>') || [];
+    const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
+    const curAuditor = JSON.parse('<%- JSON.stringify(ctx.advance.curAuditor) %>');
+
+    // 展开历史审核记录
+    $('td #fold-btn').click(function () {
+        const type = $(this).data('target')
+        const auditCard = $(this).parent().parent()
+        if (type === 'show') {
+            $(this).data('target', 'hide')
+            auditCard.find('.fold-card').slideDown('swing', () => {
+                auditCard.find('#fold-btn').text('收起历史审核记录')
+            })
+        } else {
+            $(this).data('target', 'show')
+            auditCard.find('.fold-card').slideUp('swing', () => {
+                auditCard.find('#fold-btn').text('展开历史审核记录')
+            })
+        }
+    });
+    // 处理换行
+    advance.remark && $('#ad-remark').html(advance.remark.replace(/<br\/>/g, '\n').replace(/' '/, '\s'));
+</script>
+<% if(isEdited && ctx.session.sessionUser.accountId === ctx.advance.uid) { %>
+<script>
+    const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
+    const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
+</script>
+<% } %>
+

+ 100 - 100
app/view/advance/index.ejs

@@ -1,100 +1,100 @@
-<% include ../tender/tender_sub_menu.ejs %>
-<div class="panel-content">
-    <div class="panel-title">
-        <div class="title-main d-flex justify-content-between">
-            <div>
-                <div class="d-inline-block">
-                    <div class="btn-group group-tab">
-                        <a class="btn btn-sm btn-light <%- type === 0 ? 'active' : '' %>" href="/tender/<%- ctx.tender.id %>/advance">
-                            开工预付款<%- type === 0 && latestOrder ? `(第${latestOrder.order}期)` : '' %>
-                        </a>
-                        <a class="btn btn-sm btn-light <%- type === 1 ? 'active' : '' %>" href="/tender/<%- ctx.tender.id %>/advance/material">
-                            材料预付款<%- type === 1 && latestOrder ? `(第${latestOrder.order}期)` : '' %>
-                        </a>
-                    </div>
-                </div>
-                <div class="d-inline-block ml-2">
-                    签约<%- type === 0 ? '开工' : '材料' %>预付款
-                    <b><%- ctx.helper.formatMoney(advancePayTotal, ',', parseFloat(advancePayTotal.toFixed(decimal)).toString().split('.')[1] && parseFloat(advancePayTotal.toFixed(decimal)).toString().split('.')[1].length || 0) %></b> 元
-                </div>
-                <div class="d-inline-block ml-4" style="width:300px">
-                    <div class="progress">
-                        <div class="progress-bar bg-success" style="width: <%- progress.p_ratio%>%;" data-placement="bottom"
-                            data-toggle="tooltip" data-original-title="截止上期金额:¥<%- ctx.helper.formatMoney(progress.p_amount, ',', parseFloat(progress.p_amount.toFixed(decimal)).toString().split('.')[1] && parseFloat(progress.p_amount.toFixed(decimal)).toString().split('.')[1].length || 0) %>"><%- progress.p_ratio.toFixed() %>%</div>
-                        <div class="progress-bar bg-info" style="width:<%- progress.c_ratio%>%;" data-placement="bottom"
-                            data-toggle="tooltip" data-original-title="本期金额:¥<%- ctx.helper.formatMoney(progress.c_amount, ',', progress.c_amount && parseFloat(progress.c_amount.toFixed(decimal)).toString().split('.')[1] && parseFloat(progress.c_amount.toFixed(decimal)).toString().split('.')[1].length || 0) %>"><%- progress.c_ratio.toFixed() %>%</div>
-                        <div class="progress-bar bg-gray" style="width:<%- progress.s_ratio%>%;" data-placement="bottom"
-                            data-toggle="tooltip" data-original-title="未完成:¥<%- ctx.helper.formatMoney(progress.s_amount, ',', parseFloat(progress.s_amount.toFixed(decimal)).toString().split('.')[1] && parseFloat(progress.s_amount.toFixed(decimal)).toString().split('.')[1].length || 0) %>"><%- progress.s_ratio.toFixed() %>%</div>
-                    </div>
-                </div>
-            </div>
-            <div>
-                <% if(showAddBtn) { %>
-                    <form action="<%- preUrl %>" method="POST">
-                        <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
-                        <button type="submit" class="btn btn-primary btn-sm pull-right">开始新一期</button>
-                    </form>
-                    <!-- <a id="advance_add" href="" class="btn btn-primary btn-sm pull-right"></a> -->
-                <% } %>
-            </div>
-        </div>
-    </div>
-    <div class="content-wrap">
-        <div class="c-body">
-            <div class="sjs-height-0" >
-                <table class="table table-bordered">
-                    <thead>
-                        <tr>
-                            <th>期数</th>
-                            <th class="text-center" width="10%">支付比例</th>
-                            <th class="text-center" width="15%">本期金额</th>
-                            <th class="text-center" width="15%">截止上期</th>
-                            <th class="text-center" width="15%">截止本期金额</th>
-                            <th class="text-center">附件</th>
-                            <th class="text-center">进度</th>
-                            <th class="text-center" width="100">操作</th>
-                        </tr>
-                    </thead>
-                    <tbody id="advanceList">
-                        <% advanceList.forEach(item => { %>
-                            <tr>
-                                <td><a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" data-id="<%- item.id %>">第<%- item.order %>期</a></td>
-                                <td><%- item.pay_ratio %>%</td>
-                                <td class="text-right"><%- item.cur_amount %></td>
-                                <td class="text-right"><%- item.prev_amount %></td>
-                                <td class="text-right"><%- item.prev_total_amount %></td>
-                                <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file" data-id="<%- item.id %>"><i
-                                            class="fa fa-paperclip"></i> <%- item.fileList.length %></a></td>
-                                <td>
-                                    <% if (item.curAuditor) { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-vid="<%- item.id %>"><%- item.curAuditor.name %><%if (item.curAuditor.role !== '' && item.curAuditor.role !== null) { %>-<%- item.curAuditor.role %><% } %></a>
-                                    <% } %>
-                                    <span class="<%- auditConst.statusClass[item.status] %>">
-                                        <%- auditConst.statusString[item.status] %>
-                                    </span>
-                                </td>
-                                <td>
-                                    <% if((item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) && item.uid === ctx.session.sessionUser.accountId) { %>
-                                        <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-primary btn-sm">编辑</a>
-                                    <% } else if(item.status === auditConst.status.checking && item.curAuditor.audit_id === ctx.session.sessionUser.accountId) {%>
-                                        <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-success btn-sm">审批</a>
-                                    <% } else {%>
-                                        <span class="<%- auditConst.statusClass[item.status] %>"><%- auditConst.statusString[item.status] %></span>
-                                    <% } %>
-                                </td>
-                            </tr>
-                        <% }) %>
-                    </tbody>
-                </table>
-            </div>
-        </div>
-    </div>
-</div>
-</div>
-<script>
-    const type = parseInt('<%- type %>');
-    const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
-    const advanceList = JSON.parse('<%- JSON.stringify(advanceList) %>');
-    const decimal = parseInt('<%- decimal %>');
-    const advancePayTotal  = parseFloat('<%- advancePayTotal  %>');
-</script>
+<% include ../tender/tender_sub_menu.ejs %>
+<div class="panel-content">
+    <div class="panel-title">
+        <div class="title-main d-flex justify-content-between">
+            <div>
+                <div class="d-inline-block">
+                    <div class="btn-group group-tab">
+                        <a class="btn btn-sm btn-light <%- type === 0 ? 'active' : '' %>" href="/tender/<%- ctx.tender.id %>/advance">
+                            开工预付款<%- type === 0 && latestOrder ? `(第${latestOrder.order}期)` : '' %>
+                        </a>
+                        <a class="btn btn-sm btn-light <%- type === 1 ? 'active' : '' %>" href="/tender/<%- ctx.tender.id %>/advance/material">
+                            材料预付款<%- type === 1 && latestOrder ? `(第${latestOrder.order}期)` : '' %>
+                        </a>
+                    </div>
+                </div>
+                <div class="d-inline-block ml-2">
+                    签约<%- type === 0 ? '开工' : '材料' %>预付款
+                    <b><%- ctx.helper.formatMoney(advancePayTotal, ',', parseFloat(advancePayTotal).toString().split('.')[1] && parseFloat(advancePayTotal).toString().split('.')[1].length || 0) %></b> 元
+                </div>
+                <div class="d-inline-block ml-4" style="width:300px">
+                    <div class="progress">
+                        <div class="progress-bar bg-success" style="width: <%- progress.p_ratio%>%;" data-placement="bottom"
+                            data-toggle="tooltip" data-original-title="截止上期金额:¥<%- ctx.helper.formatMoney(progress.p_amount, ',', parseFloat(progress.p_amount).toString().split('.')[1] && parseFloat(progress.p_amount).toString().split('.')[1].length || 0) %>"><%- progress.p_ratio.toFixed() %>%</div>
+                        <div class="progress-bar bg-info" style="width:<%- progress.c_ratio%>%;" data-placement="bottom"
+                            data-toggle="tooltip" data-original-title="本期金额:¥<%- ctx.helper.formatMoney(progress.c_amount, ',', progress.c_amount && parseFloat(progress.c_amount).toString().split('.')[1] && parseFloat(progress.c_amount).toString().split('.')[1].length || 0) %>"><%- progress.c_ratio.toFixed() %>%</div>
+                        <div class="progress-bar bg-gray" style="width:<%- progress.s_ratio%>%;" data-placement="bottom"
+                            data-toggle="tooltip" data-original-title="未完成:¥<%- ctx.helper.formatMoney(progress.s_amount, ',', parseFloat(progress.s_amount).toString().split('.')[1] && parseFloat(progress.s_amount).toString().split('.')[1].length || 0) %>"><%- progress.s_ratio.toFixed() %>%</div>
+                    </div>
+                </div>
+            </div>
+            <div>
+                <% if(showAddBtn) { %>
+                    <form action="<%- preUrl %>" method="POST">
+                        <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
+                        <button type="submit" class="btn btn-primary btn-sm pull-right">开始新一期</button>
+                    </form>
+                    <!-- <a id="advance_add" href="" class="btn btn-primary btn-sm pull-right"></a> -->
+                <% } %>
+            </div>
+        </div>
+    </div>
+    <div class="content-wrap">
+        <div class="c-body">
+            <div class="sjs-height-0" >
+                <table class="table table-bordered">
+                    <thead>
+                        <tr>
+                            <th>期数</th>
+                            <th class="text-center" width="10%">支付比例</th>
+                            <th class="text-center" width="15%">本期金额</th>
+                            <th class="text-center" width="15%">截止上期</th>
+                            <th class="text-center" width="15%">截止本期金额</th>
+                            <th class="text-center">附件</th>
+                            <th class="text-center">进度</th>
+                            <th class="text-center" width="100">操作</th>
+                        </tr>
+                    </thead>
+                    <tbody id="advanceList">
+                        <% advanceList.forEach(item => { %>
+                            <tr>
+                                <td><a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" data-id="<%- item.id %>">第<%- item.order %>期</a></td>
+                                <td><%- item.pay_ratio %>%</td>
+                                <td class="text-right"><%- item.cur_amount %></td>
+                                <td class="text-right"><%- item.prev_amount %></td>
+                                <td class="text-right"><%- item.prev_total_amount %></td>
+                                <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file" data-id="<%- item.id %>"><i
+                                            class="fa fa-paperclip"></i> <%- item.fileList.length %></a></td>
+                                <td>
+                                    <% if (item.curAuditor) { %>
+                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" data-vid="<%- item.id %>"><%- item.curAuditor.name %><%if (item.curAuditor.role !== '' && item.curAuditor.role !== null) { %>-<%- item.curAuditor.role %><% } %></a>
+                                    <% } %>
+                                    <span class="<%- auditConst.statusClass[item.status] %>">
+                                        <%- auditConst.statusString[item.status] %>
+                                    </span>
+                                </td>
+                                <td>
+                                    <% if((item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) && item.uid === ctx.session.sessionUser.accountId) { %>
+                                        <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-primary btn-sm">编辑</a>
+                                    <% } else if(item.status === auditConst.status.checking && item.curAuditor.audit_id === ctx.session.sessionUser.accountId) {%>
+                                        <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-success btn-sm">审批</a>
+                                    <% } else {%>
+                                        <span class="<%- auditConst.statusClass[item.status] %>"><%- auditConst.statusString[item.status] %></span>
+                                    <% } %>
+                                </td>
+                            </tr>
+                        <% }) %>
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+<script>
+    const type = parseInt('<%- type %>');
+    const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
+    const advanceList = JSON.parse('<%- JSON.stringify(advanceList) %>');
+    const decimal = parseInt('<%- decimal %>');
+    const advancePayTotal  = parseFloat('<%- advancePayTotal  %>');
+</script>

+ 1 - 1
app/view/material/exponent.ejs

@@ -81,7 +81,7 @@
                                 <tbody id="calc_basic_select">
                                 <% for (const bq of ex_calc) { %>
                                     <tr>
-                                        <td><%- bq.text %></td><td><%- bq.value %></td>
+                                        <td><%- materialType.ex_basic_text[bq.code] %></td><td><%- bq.value %></td>
                                         <td><input type="checkbox" value="<%- bq.code %>" <% if (material.readOnly) { %>disabled<% } %> class="calc_select" <% if (bq.select) { %>checked<% } %>></td>
                                     </tr>
                                 <% } %>