Browse Source

新版变更查看 ok

laiguoran 4 năm trước cách đây
mục cha
commit
c1f5bac7f2

+ 6 - 38
app/controller/change_controller.js

@@ -571,11 +571,11 @@ module.exports = app => {
                     shenpiConst,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.change.information),
                     preUrl: '/tender/' + ctx.tender.id + '/change/' + ctx.change.cid + '/information',
+                    precision: ctx.tender.info.precision,
                 };
                 // 根据auditStatus状态获取的不同的数据
                 if (auditStatus === 1 || auditStatus === 2) {
                     renderData.changeUnits = changeConst.units;
-                    renderData.precision = ctx.tender.info.precision;
                     // renderData.accountGroup = accountGroup;
                     // 获取所有项目参与者
                     const accountList = await ctx.service.projectAccount.getAllDataByCondition({
@@ -610,17 +610,6 @@ module.exports = app => {
                         }
                         renderData.auditList3 = auditList3;
                     }
-
-                    // 根据清单获取提交数据和计算总金额
-                    let ototalCost = 0;
-                    let ctotalCost = 0;
-                    for (const cl of changeList) {
-                        ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, ctx.tender.info.decimal.tp);
-                        ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, ctx.tender.info.decimal.tp);
-                    }
-                    renderData.ototalCost = ototalCost;
-                    renderData.ctotalCost = ctotalCost;
-
                     // 获取公司列表
                     const companyList = await ctx.service.changeCompany.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                     renderData.companyList = companyList;
@@ -651,37 +640,16 @@ module.exports = app => {
                     renderData.auditList3 = auditList3;
 
                     changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
-                    renderData.changeList = changeList;
-                    let ototalCost = 0;
-                    let ctotalCost = 0;
-                    let stotalCost = 0;
-                    const auditTotalCost = [];
                     for (const cl of changeList) {
-                        // ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
-                        ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, renderData.tpUnit);
-                        // ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
-                        ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, renderData.tpUnit);
-                        // stotalCost += cl.samount !== '' && cl.unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), renderData.tpUnit)) : 0;
-                        stotalCost += cl.samount !== '' && cl.unit_price !== null ? ctx.helper.mul(cl.unit_price, cl.samount, renderData.tpUnit) : 0;
                         const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
-                        auditTotalCost.push(audit_amount);
-                    }
-                    renderData.ototalCost = ototalCost;
-                    renderData.ctotalCost = ctotalCost;
-                    renderData.stotalCost = stotalCost;
-
-                    // 清单表页赋值
-                    for (const [index, au] of auditList2.entries()) {
-                        if (au.usite !== 0) {
-                            au.list_amount = [];
-                            au.totalCost = 0;
-                            for (const [auindex, at] of auditTotalCost.entries()) {
-                                au.list_amount.push(at[index - 1]);
-                                // au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
-                                au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? ctx.helper.mul(changeList[auindex].unit_price, at[index - 1], renderData.tpUnit) : 0;
+                        // 清单表页赋值
+                        for (const [index, au] of auditList2.entries()) {
+                            if (au.usite !== 0) {
+                                cl['audit_amount_' + au.uid] = audit_amount[index] ? audit_amount[index] : null;
                             }
                         }
                     }
+                    renderData.changeList = changeList;
                     renderData.auditList2 = auditList2;
                 } else if (auditStatus === 6) {
                     // 展示页左侧审批流程列表和清单审批列表数据

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

@@ -176,3 +176,15 @@ $(document).ready(() => {
         }
     });
 });
+function findDecimal(unit) {
+    let value = precision.other.value;
+    const changeUnits = precision;
+    for (const d in changeUnits) {
+        if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
+            value = changeUnits[d].value;
+            break;
+        }
+    }
+    return value;
+}
+

+ 0 - 13
app/public/js/change_information_set.js

@@ -67,8 +67,6 @@ $.event.special.valuechange = {
     }
 };
 $(document).ready(() => {
-    const style1 = new GC.Spread.Sheets.Style();
-    style1.locked = true;
     const changeCol = {
         getValue: {
             unit_price: function(data) {
@@ -664,17 +662,6 @@ function checkAuditorFrom () {
     }
     return true;
 }
-function findDecimal(unit) {
-    let value = precision.other.value;
-    const changeUnits = precision;
-    for (const d in changeUnits) {
-        if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
-            value = changeUnits[d].value;
-            break;
-        }
-    }
-    return value;
-}
 
 function tableDataRemake(changeListData) {
     $('#table-list-select tr').removeClass('table-warning');

+ 132 - 0
app/public/js/change_information_show.js

@@ -0,0 +1,132 @@
+'use strict';
+
+/**
+ * 变更令详细页js
+ *
+ * @author EllisRan.
+ * @date 2018/11/22
+ * @version
+ */
+$(document).ready(() => {
+    const changeSpreadSetting = {
+        cols: [
+            {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@'},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@'},
+            {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@'},
+            {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@'},
+            {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
+            {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: 'oamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.oamount'},
+            {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.oa_tp'},
+            {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, formatter: '@', type: 'Number', getValue: 'getValue.ca_tp'},
+            {title: '审批后变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount'},
+            {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.sa_tp'},
+        ],
+        emptyRows: 0,
+        headRows: 2,
+        headRowHeight: [25, 25],
+        defaultRowHeight: 21,
+        headerFont: '12px 微软雅黑',
+        font: '12px 微软雅黑',
+        readOnly: true,
+    };
+    for (const aid of aidList) {
+        const userinfo = _.find(auditList2, { 'uid': aid });
+        const newColcount = {
+            title: userinfo.name + ' 审批|数量',
+            colSpan: '2|1', rowSpan: '1|1',
+            field: 'audit_amount_' + aid,
+            hAlign: 2, width: 60, type: 'Number',
+            getValue: 'getValue.samount'
+        };
+        const newColTp = {
+            title: '|金额',
+            colSpan: '|1', rowSpan: '|1',
+            field: 'sa_tp',
+            hAlign: 2, width: 80, formatter: '@', type: 'Number',
+            getValue: 'getValue.sa_tp'};
+        changeSpreadSetting.cols.push(newColcount);
+        changeSpreadSetting.cols.push(newColTp);
+    }
+
+    const changeCol = {
+        getValue: {
+            unit_price: function(data) {
+                return ZhCalc.round(data.unit_price, unitPriceUnit);
+            },
+            oa_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(data.unit_price, data.oamount), totalPriceUnit);
+            },
+            ca_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(data.unit_price, data.camount), totalPriceUnit);
+            },
+            oamount: function (data) {
+                return ZhCalc.round(data.oamount, findDecimal(data.unit));
+            },
+            camount: function (data) {
+                return ZhCalc.round(data.camount, findDecimal(data.unit));
+            },
+            samount: function (data) {
+                return ZhCalc.round(data.samount, findDecimal(data.unit));
+            },
+            sa_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(data.unit_price, data.samount), totalPriceUnit);
+            },
+        },
+    };
+
+    const changeSpreadObj = {
+        makeSjsFooter: function () {
+            // 增加汇总行并设为锁定禁止编辑状态
+            changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
+            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
+            changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
+            changeSpreadObj.countSum();
+        },
+        countSum: function() {
+            const rowCount = changeSpreadSheet.getRowCount();
+            let oSum = 0,
+                cSum = 0,
+                sSum = 0;
+            for(let i = 0; i < rowCount - 1; i++){
+                oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
+                cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
+                sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 11));
+            }
+            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
+            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
+            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, sSum !== 0 ? sSum : null);
+            // 用户的数据合计
+            for (const j in aidList) {
+                let audit_sum = 0;
+                for(let i = 0; i < rowCount - 1; i++){
+                    audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 13 + j*2));
+                }
+                changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13 + j*2, audit_sum !== 0 ? audit_sum : null);
+            }
+        },
+        showHideAudit: function (show = false) {
+            const count = changeSpreadSetting.cols.length;
+            for (let i = 12; i < count; i++) {
+                changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
+            }
+            changeSpreadSheet.setColumnVisible(10, !show, GC.Spread.Sheets.SheetArea.viewport);
+            changeSpreadSheet.setColumnVisible(11, !show, GC.Spread.Sheets.SheetArea.viewport);
+        }
+    };
+
+    SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
+    SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
+    SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
+    changeSpreadObj.makeSjsFooter();
+    changeSpreadObj.showHideAudit();
+
+    // 审批流程展示与隐藏
+    $('#show-table-detail').on('click', function (e) {
+        if($(e.target).is('label')){
+            return;
+        }
+        changeSpreadObj.showHideAudit($(this).is(':checked'));
+    });
+});

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

@@ -364,6 +364,7 @@
     const ledgerConsts = JSON.parse('<%- JSON.stringify(ledgerConsts) %>');
     const auditStatus = '<%- auditStatus %>'
     const auditList = JSON.parse('<%- JSON.stringify(auditList) %>');
+    const precision = JSON.parse('<%- JSON.stringify(precision) %>');
     autoFlashHeight();
     $('a[href="#sub-ap"').click(function() {
         if (parseInt(ledgeStatus) === ledgerConsts.uncheck) {
@@ -374,6 +375,10 @@
     const readOnly = <%- change.readOnly %>;
     const changeSpread = SpreadJsObj.createNewSpread($('#change-spread')[0]);
     const changeSpreadSheet = changeSpread.getActiveSheet();
+    let changeList = JSON.parse('<%- JSON.stringify(changeList) %>');
+    console.log(changeList);
+    const style1 = new GC.Spread.Sheets.Style();
+    style1.locked = true;
 </script>
 <script>
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
@@ -381,7 +386,6 @@
 <% if (auditStatus === 1 || auditStatus === 2) { %>
 <script>
     let changeUnits = JSON.parse('<%- JSON.stringify(changeUnits) %>');
-    const precision = JSON.parse('<%- JSON.stringify(precision) %>');
     changeUnits = _.map(changeUnits, 'unit');
     changeUnits.push('');
     const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
@@ -409,7 +413,6 @@
         charge: '<%- change.charge %>',
     };
     let changeInfo = Object.assign({}, back_changeInfo);
-    let changeList = JSON.parse('<%- JSON.stringify(changeList) %>');
 
     const changeSpreadSetting = {
         cols: [
@@ -437,7 +440,12 @@
 <script src="/public/js/change_information_set.js"></script>
 <script src="/public/js/change_audit.js"></script>
 <% } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
-<!--<script src="/public/js/change_show.js"></script>-->
+<script>
+    const auditList2 = JSON.parse('<%- JSON.stringify(auditList2) %>');
+    const aidList = _.map(auditList2, 'uid');
+    aidList.splice(0, 1);
+</script>
+<script src="/public/js/change_information_show.js"></script>
 <% } else if (auditStatus === 6) { %>
 <!--<script src="/public/js/change_approval.js"></script>-->
 <% } %>