Selaa lähdekoodia

变更清单汇总功能

ellisran 1 vuosi sitten
vanhempi
commit
6a75b106e5

+ 2 - 2
app/controller/change_controller.js

@@ -796,7 +796,7 @@ module.exports = app => {
                         // 清单表页赋值
                         for (const [index, au] of auditList2.entries()) {
                             if (au.usite !== 0) {
-                                cl['audit_amount_' + au.uid] = audit_amount[index - 1] ? audit_amount[index - 1] : null;
+                                cl['audit_amount_' + au.uid] = audit_amount[index - 1] !== undefined ? audit_amount[index - 1] : null;
                             }
                         }
                         cl.changed_amount = ctx.helper._.indexOf([audit.flow.status.backnew, audit.flow.status.checking, audit.flow.status.checked], change.status) !== -1 ?
@@ -849,7 +849,7 @@ module.exports = app => {
                         // 清单表页赋值
                         for (const [index, au] of auditList2.entries()) {
                             if (au.usite !== 0) {
-                                cl['audit_amount_' + au.uid] = au.uid === ctx.session.sessionUser.accountId ? cl.spamount : (audit_amount[index - 1] ? audit_amount[index - 1] : null);
+                                cl['audit_amount_' + au.uid] = au.uid === ctx.session.sessionUser.accountId ? cl.spamount : (audit_amount[index - 1] !== undefined ? audit_amount[index - 1] : null);
                             }
                         }
                         cl.changed_amount = ctx.helper._.indexOf([audit.flow.status.backnew, audit.flow.status.checking, audit.flow.status.checked], change.status) !== -1 ?

+ 117 - 0
app/public/js/change_information.js

@@ -419,6 +419,123 @@ $(document).ready(() => {
         czSpreadObj.makeSjsFooter();
     });
 
+    // 清单汇总信息获取
+    let hzSpread = null;
+    const hzSpreadSetting = {
+        cols: [
+            {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120},
+            {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60},
+            {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price'},
+            {title: '申报变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount'},
+            {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp'},
+            {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount', visible: auditStatus !== 6},
+            {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.sa_tp', visible: auditStatus !== 6},
+            {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'spamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.spamount', visible: auditStatus === 6},
+            {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'spa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.spa_tp', visible: auditStatus === 6},
+        ],
+        emptyRows: 0,
+        headRows: 2,
+        headRowHeight: [25, 25],
+        defaultRowHeight: 21,
+        headerFont: '12px 微软雅黑',
+        font: '12px 微软雅黑',
+        readOnly: true,
+        localCache: {
+            key: 'changes-hz',
+            colWidth: true,
+        }
+    };
+    const hzCol = {
+        getValue: {
+            unit_price: function(data) {
+                return ZhCalc.round(data.unit_price, unitPriceUnit);
+            },
+            camount: function (data) {
+                return ZhCalc.round(data.camount, findDecimal(data.unit));
+            },
+            ca_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
+            },
+            samount: function (data) {
+                return ZhCalc.round(data.samount, findDecimal(data.unit));
+            },
+            sa_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit);
+            },
+            spamount: function (data) {
+                return ZhCalc.round(data.spamount, findDecimal(data.unit));
+            },
+            spa_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.spamount, findDecimal(data.unit))), totalPriceUnit);
+            },
+        }
+    };
+    const hzSpreadObj = {
+        makeBackColor: function () {
+            const rowCount = hzSpread.getActiveSheet().getRowCount();
+            for (let i = 0; i < rowCount; i++) {
+                if (auditStatus === 6 && hzSpread.getActiveSheet().zh_data[i].camount != hzSpread.getActiveSheet().zh_data[i].spamount) {
+                    hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
+                } else if (auditStatus !== 6 && hzSpread.getActiveSheet().zh_data[i].camount != hzSpread.getActiveSheet().zh_data[i].samount) {
+                    hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
+                }
+            }
+        },
+        makeSjsFooter: function () {
+            // 增加汇总行并设为锁定禁止编辑状态
+            hzSpread.getActiveSheet().addRows(hzSpread.getActiveSheet().getRowCount(), 1);
+            hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 0, '合计');
+            hzSpread.getActiveSheet().setStyle(hzSpread.getActiveSheet().getRowCount() - 1, -1, style1);
+            hzSpreadObj.countSum();
+        },
+        countSum: function () {
+            const rowCount = hzSpread.getActiveSheet().getRowCount();
+            let cSum = 0,
+                sSum = 0,
+                spSum = 0;
+            for (let i = 0; i < rowCount - 1; i++) {
+                cSum = ZhCalc.add(cSum, hzSpread.getActiveSheet().getValue(i, 5));
+                sSum = ZhCalc.add(sSum, hzSpread.getActiveSheet().getValue(i, 7));
+                spSum = ZhCalc.add(spSum, hzSpread.getActiveSheet().getValue(i, 9));
+            }
+            hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 5, cSum !== 0 ? cSum : null);
+            hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 7, sSum !== 0 ? sSum : null);
+            hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 9, spSum !== 0 ? spSum : null);
+        },
+    };
+
+    $('#qdgather').on('shown.bs.modal', function () {
+        if (!hzSpread) {
+            hzSpread = SpreadJsObj.createNewSpread($('#hz-spread')[0]);
+            SpreadJsObj.initSpreadSettingEvents(hzSpreadSetting, hzCol);
+            SpreadJsObj.initSheet(hzSpread.getActiveSheet(), hzSpreadSetting);
+        }
+        const hzList = [];
+        const newChangeList = _.cloneDeep(changeList);
+        for (const cl of newChangeList) {
+            const hzIndex = _.findIndex(hzList, { code: cl.code, name: cl.name, unit: cl.unit, unit_price: cl.unit_price});
+            if (hzIndex !== -1) {
+                hzList[hzIndex].camount = ZhCalc.add(hzList[hzIndex].camount, cl.camount);
+                hzList[hzIndex].spamount = ZhCalc.add(hzList[hzIndex].spamount, cl.spamount);
+                const samount = cl.samount ? parseFloat(cl.samount) : 0;
+                hzList[hzIndex].samount = hzList[hzIndex].samount ? parseFloat(hzList[hzIndex].samount) : 0;
+                hzList[hzIndex].samount = ZhCalc.add(hzList[hzIndex].samount, samount);
+            } else {
+                hzList.push(cl);
+            }
+        }
+        if (hzList.length > 0) {
+            // 按清单编号排序
+            hzList.sort(sortByCode);
+        }
+        console.log(hzList);
+        // // sjs设置
+        SpreadJsObj.loadSheetData(hzSpread.getActiveSheet(), SpreadJsObj.DataType.Data, hzList);
+        hzSpreadObj.makeBackColor();
+        hzSpreadObj.makeSjsFooter();
+    });
+
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',

+ 3 - 0
app/view/change/information.ejs

@@ -64,6 +64,9 @@
                 </div>
                 <% } %>
                 <div class="d-inline-block mr-2">
+                    <a class="btn btn-sm btn-primary" href="#qdgather" data-toggle="modal" data-target="#qdgather">清单汇总</a>
+                </div>
+                <div class="d-inline-block mr-2">
                     <div class="input-group input-group-sm">
                         <div class="input-group-prepend">
                             <span class="input-group-text" id="basic-addon1">表达式</span>

+ 16 - 0
app/view/change/information_modal.ejs

@@ -1181,6 +1181,22 @@
     </div>
 </div>
 <% } %>
+<!--多部位同条清单汇总-->
+<div class="modal fade" id="qdgather" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">清单汇总</h5>
+            </div>
+            <div class="modal-body">
+                <div class="modal-height-300" id="hz-spread"></div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>
 <script type="text/javascript">
     const csrf = '<%= ctx.csrf %>';
     const authMobile = '<%= authMobile %>';