Browse Source

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 5 years ago
parent
commit
5d35853c84

+ 6 - 2
app/controller/revise_controller.js

@@ -389,12 +389,16 @@ module.exports = app => {
                 const revise = await ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id);
                 if (!revise) throw '台账修订数据有误';
 
-                const billsFile = revise.bills_file ? this.ctx.app.config.filePath + revise.bills_file : undefined;
+                const billsFile = revise.status === audit.revise.status.checked && revise.bills_file
+                    ? this.ctx.app.config.filePath + revise.bills_file
+                    : undefined;
                 const reviseBills = billsFile && fs.existsSync(billsFile)
                     ? JSON.parse(await fs.readFileSync(billsFile, 'utf8'))
                     : await ctx.service.reviseBills.getData(ctx.tender.id);
 
-                const posFile = revise.pos_file ? this.ctx.app.config.filePath + revise.pos_file : undefined;
+                const posFile = revise.status === audit.revise.status.checked && revise.pos_file
+                    ? this.ctx.app.config.filePath + revise.pos_file
+                    : undefined;
                 const revisePos = posFile && fs.existsSync(posFile)
                     ? JSON.parse(await fs.readFileSync(posFile, 'utf8'))
                     : await ctx.service.revisePos.getData(ctx.tender.id);

+ 8 - 4
app/controller/wap_controller.js

@@ -142,11 +142,10 @@ module.exports = app => {
         async list(ctx) {
             try {
                 // 获取用户新建标段权利
-                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
 
                 const tenderList = await this.ctx.service.tender.getList('', userPermission);
-
                 for (const t of tenderList) {
                     if (t.user_id === this.ctx.session.sessionUser.accountId && (
                         t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
@@ -156,9 +155,14 @@ module.exports = app => {
                     }
                     if (t.ledger_status === auditConst.ledger.status.checked) {
                         t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
-                        if (t.lastStage) {
-                            await this.ctx.service.stage.checkStageGatherData(t.lastStage);
+
+                        if (!t.lastStage) continue;
+                        if (t.lastStage.status === auditConst.stage.status.uncheck && t.lastStage.user_id !== this.ctx.session.sessionUser.accountId) {
+                            t.lastStage = await this.ctx.service.stage.getLastestStage(t.id);
                         }
+
+                        if (!t.lastStage) continue;
+                        await this.ctx.service.stage.checkStageGatherData(t.lastStage);
                     }
                 }
                 const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);

+ 65 - 19
app/public/js/ledger.js

@@ -127,18 +127,28 @@ $(document).ready(function() {
                         $('#bills-expr').val(data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field])
                             .attr('field', col.field).attr('org', data[col.field]);
                     } else {
-                        $('#bills-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field]);
+                        $('#bills-expr').val(data[col.field])
+                            .attr('field', col.field).attr('org', data[col.field]);
                     }
                     if (col.field.indexOf('dgn') >= 0) {
                         $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (_.isString(data.b_code) && data.b_code !== ''));
                     } else {
-                        $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
+                        const nodePos = pos.getLedgerPos(data.id);
+                        if (nodePos && nodePos.length > 0) {
+                            $('#bills-expr').val('').attr('readOnly', true);
+                            $('#bills-expr').removeAttr('data-row');
+                        } else {
+                            $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
+                        }
                     }
+                    $('#bills-expr').attr('data-row', sel.row);
                 } else {
                     $('#bills-expr').val('').attr('readOnly', true);
+                    $('#bills-expr').removeAttr('data-row');
                 }
             } else {
                 $('#bills-expr').val('').attr('readOnly', true);
+                $('#bills-expr').removeAttr('data-row');
             }
         },
         getSelectNode: function (sheet) {
@@ -482,6 +492,7 @@ $(document).ready(function() {
                 }
                 // 获取更新数据
                 if (col.type === 'Number') {
+                    const exprInfo = getExprInfo(col.field);
                     if (newValue) {
                         const num = _.toNumber(newValue);
                         if (_.isFinite(num)) {
@@ -489,7 +500,6 @@ $(document).ready(function() {
                         } else {
                             try {
                                 data[col.field] = math.evaluate(transExpr(newValue));
-                                const exprInfo = getExprInfo(col.field);
                                 if (exprInfo) {
                                     data[exprInfo.expr] = newValue;
                                 }
@@ -501,6 +511,9 @@ $(document).ready(function() {
                         }
                     } else {
                         data[col.field] = null;
+                        if (exprInfo) {
+                            data[exprInfo.expr] = '';
+                        }
                     }
                 } else {
                     data[col.field] = newValue;
@@ -866,6 +879,12 @@ $(document).ready(function() {
                 info.cancel = true;
                 return;
             }
+            const exprInfo = getExprInfo(col.field);
+            if (exprInfo) {
+                if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
+                    info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
+                }
+            }
             switch (col.field) {
                 case 'code':
                     const posRange = pos.getLedgerPos(node.id);
@@ -933,13 +952,10 @@ $(document).ready(function() {
             treeOperationObj.refreshOperationValid(info.sheet, info.newSelections);
         });
         ledgerSpread.bind(GC.Spread.Sheets.Events.EditEnded, treeOperationObj.editEnded);
-        //ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasted, treeOperationObj.clipboardPasted);
         SpreadJsObj.addDeleteBind(ledgerSpread, treeOperationObj.deletePress);
         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardChanging, function (e, info) {
             const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
-            //console.log(info.copyData);
             SpreadJsObj.Clipboard.setCopyData(copyText);
-            //copyToClipboard(copyText);
         });
         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasting, treeOperationObj.clipboardPasting);
         ledgerSpread.bind(spreadNS.Events.EditStarting, treeOperationObj.editStarting);
@@ -983,15 +999,31 @@ $(document).ready(function() {
             });
         });
 
-        $('#bills-expr').bind('change mouseleave', function () {
-            if (document.activeElement.id !== "bills-expr") return;
-
+        $('#bills-expr').bind('change onblur', function () {
             const expr = $(this);
-            const sheet = ledgerSpread.getActiveSheet();
-            const select = SpreadJsObj.getSelectObject(sheet);
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = ledgerTree.getItemsByIndex(row);
+            if (!select) return;
+
             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
+            // 台账模式,检查计量单元相关
+            if (checkTzMeasureType()) {
+                if (field === 'sgfh_qty' || field === 'sgfh_tp' ||
+                    field === 'sjcl_qty' || field === 'sjcl_tp' ||
+                    field === 'qtcl_qty' || field === 'qtcl_tp') {
+                    if (!select.children || select.children.length === 0) {
+                        const lPos = pos.getLedgerPos(select.id);
+                        if (lPos && lPos.length > 0) {
+                            toastr.error('清单含有计量单元,请在计量单元输入数量');
+                            expr.val('');
+                            return;
+                        }
+                    }
+                }
+            }
+
             const data = {
                 id: select.id,
                 tender_id: select.tender_id,
@@ -1026,7 +1058,7 @@ $(document).ready(function() {
             // 更新至服务器
             postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
                 const refreshNode = ledgerTree.loadPostData(result);
-                treeOperationObj.refreshTree(sheet, refreshNode);
+                treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
             });
         });
     }
@@ -1451,6 +1483,16 @@ $(document).ready(function() {
         },
         editStarting: function (e, info) {
             posOperationObj.ledgerTreeNode = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
+            const sel = info.sheet.getSelections();
+            if (!sel || !sel[0]) return;
+            const col = info.sheet.zh_setting.cols[sel[0].col];
+            const node = SpreadJsObj.getSelectObject(info.sheet);
+            const exprInfo = getExprInfo(col.field);
+            if (exprInfo) {
+                if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
+                    info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
+                }
+            }
         },
         loadExprToInput: function () {
             const sheet = posSpread.getActiveSheet();
@@ -1466,12 +1508,14 @@ $(document).ready(function() {
                         ? (data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field])
                         : data[col.field];
                     $('#pos-expr').val(value).attr('field', col.field).attr('org', data[col.field])
-                        .attr('row', sel.row).attr('readOnly', readOnly || cell.locked());
+                        .attr('readOnly', readOnly || cell.locked()).attr('data-row', sel.row);
                 } else {
                     $('#pos-expr').val('').attr('readOnly', true);
+                    $('#pos-expr').removeAttr('data-row');
                 }
             } else {
                 $('#pos-expr').val('').attr('readOnly', true);
+                $('#pos-expr').removeAttr('data-row');
             }
         },
         /**
@@ -1606,13 +1650,16 @@ $(document).ready(function() {
                     data.updateData = {id: posData.id};
 
                     if (col.type === 'Number') {
+                        const exprInfo = getExprInfo(col.field);
                         const num = _.toNumber(newText);
                         if (_.isFinite(num)) {
                             data.updateData[col.field] = num;
+                            if (exprInfo) {
+                                data.updateData[exprInfo.expr] = '';
+                            }
                         } else {
                             try {
                                 data.updateData[col.field] = math.evaluate(transExpr(newText));
-                                const exprInfo = getExprInfo(col.field);
                                 if (exprInfo) {
                                     data.updateData[exprInfo.expr] = newText;
                                 }
@@ -1836,15 +1883,14 @@ $(document).ready(function() {
         $('a[name="pos-opr"]').click(function () {
             posOperationObj.baseOpr(posSpread.getActiveSheet(), this.getAttribute('type'));
         });
-        $('#pos-expr').bind('change mouseleave', function () {
-            if (document.activeElement.id !== "pos-expr") return;
-
+        $('#pos-expr').bind('change onblur', function () {
             const expr = $(this);
             const posSheet = posSpread.getActiveSheet();
-            const select = SpreadJsObj.getSelectObject(posSheet);
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = posSheet.zh_data ? posSheet.zh_data[row] : null;
             if (!select) return;
 
-            const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val(), row = trimInvalidChar(expr.attr('row'));
+            const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val();
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
             const data = {id: select.id};

+ 48 - 10
app/public/js/revise.js

@@ -97,13 +97,22 @@ $(document).ready(() => {
                     } else if (col.field === 'unit_price') {
                         $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0) || (_.isBoolean(data.used) && data.used === true));
                     } else {
-                        $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
+                        const nodePos = pos.getLedgerPos(data.id);
+                        if (nodePos && nodePos.length > 0) {
+                            $('#bills-expr').val('').attr('readOnly', true);
+                            $('#bills-expr').removeAttr('data-row');
+                        } else {
+                            $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
+                        }
                     }
+                    $('#bills-expr').attr('data-row', sel.row);
                 } else {
                     $('#bills-expr').val('').attr('readOnly', true);
+                    $('#bills-expr').removeAttr('data-row');
                 }
             } else {
                 $('#bills-expr').val('').attr('readOnly', true);
+                $('#bills-expr').removeAttr('data-row');
             }
         },
         getDefaultSelectInfo: function (sheet) {
@@ -395,6 +404,7 @@ $(document).ready(() => {
                     }
                 }
                 // 获取更新数据
+                const exprInfo = getExprInfo(col.field);
                 if (info.editingText) {
                     const text = newValue;
                     if (node.used && (col.field === 'code' || col.field ==='b_code') && orgValue !== '' && text === '') {
@@ -406,10 +416,12 @@ $(document).ready(() => {
                         const num = _.toNumber(text);
                         if (_.isFinite(num)) {
                             data[col.field] = num;
+                            if (exprInfo) {
+                                data[exprInfo.expr] = '';
+                            }
                         } else {
                             try {
                                 data[col.field] = math.evaluate(transExpr(text));
-                                const exprInfo = getExprInfo(col.field);
                                 if (exprInfo) {
                                     data[exprInfo.expr] = newValue;
                                 }
@@ -429,6 +441,9 @@ $(document).ready(() => {
                         return;
                     }
                     data[col.field] = null;
+                    if (exprInfo) {
+                        data[exprInfo.expr] = '';
+                    }
                 }
                 // 更新至服务器
                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
@@ -715,6 +730,12 @@ $(document).ready(() => {
                 info.cancel = true;
                 return;
             }
+            const exprInfo = getExprInfo(col.field);
+            if (exprInfo) {
+                if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
+                    info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
+                }
+            }
             switch (col.field) {
                 case 'code':
                     const posRange = pos.getLedgerPos(node.id);
@@ -834,11 +855,14 @@ $(document).ready(() => {
             });
         });
 
-        $('#bills-expr').bind('change mouseleave', function () {
+        $('#bills-expr').bind('change onblur', function () {
             if (this.readOnly) return;
 
             const expr = $(this);
-            const select = SpreadJsObj.getSelectObject(billsSheet);
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = billsTree.getItemsByIndex(row);
+            if (!select) return;
+
             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
@@ -1124,12 +1148,14 @@ $(document).ready(() => {
                         ? (data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field])
                         : data[col.field];
                     $('#pos-expr').val(value).attr('field', col.field).attr('org', data[col.field])
-                        .attr('row', sel.row).attr('readOnly', readOnly || cell.locked());
+                        .attr('readOnly', readOnly || cell.locked()).attr('data-row', sel.row);
                 } else {
                     $('#pos-expr').val('').attr('readOnly', true);
+                    $('#pos-expr').removeAttr('data-row');
                 }
             } else {
                 $('#pos-expr').val('').attr('readOnly', true);
+                $('#pos-expr').removeAttr('data-row');
             }            
         },
         /**
@@ -1212,6 +1238,16 @@ $(document).ready(() => {
         },
         editStarting: function (e, info) {
             posSpreadObj.billsNode = SpreadJsObj.getSelectObject(billsSheet);
+            const sel = info.sheet.getSelections();
+            if (!sel || !sel[0]) return;
+            const col = info.sheet.zh_setting.cols[sel[0].col];
+            const node = SpreadJsObj.getSelectObject(info.sheet);
+            const exprInfo = getExprInfo(col.field);
+            if (exprInfo) {
+                if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
+                    info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
+                }
+            }
         },
         /**
          * 编辑单元格响应事件
@@ -1272,13 +1308,16 @@ $(document).ready(() => {
                 data.posPostType = 'update';
                 data.postData = {id: posData.id};
                 if (col.type === 'Number') {
+                    const exprInfo = getExprInfo(col.field);
                     const num = _.toNumber(newText);
                     if (_.isFinite(num)) {
                         data.postData[col.field] = num;
+                        if (exprInfo) {
+                            data.postData[exprInfo.expr] = '';
+                        }
                     } else {
                         try {
                             data.postData[col.field] = math.evaluate(transExpr(newText));
-                            const exprInfo = getExprInfo(col.field);
                             if (exprInfo) {
                                 data.postData[exprInfo.expr] = newText;
                             }
@@ -1518,15 +1557,14 @@ $(document).ready(() => {
         $('a[name="pos-opr"]').click(function () {
             posSpreadObj.baseOpr(posSheet, this.getAttribute('type'));
         });
-        $('#pos-expr').bind('change mouseleave', function () {
+        $('#pos-expr').bind('change onblur', function () {
             if (this.readOnly) return;
-            if (document.activeElement.id !== 'pos-expr') return;
 
             const expr = $(this);
-            const select = SpreadJsObj.getSelectObject(posSheet);
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = posSheet.zh_data ? posSheet.zh_data[row] : null;
             if (!select) return;
 
-            const row = posSheet.getSelections()[0].row;
             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
             if (orgValue === newValue || (!orgValue && newValue == '')) return;
 

+ 40 - 11
app/public/js/stage.js

@@ -539,6 +539,7 @@ $(document).ready(() => {
                 const data = SpreadJsObj.getSelectObject(sheet);
                 if (!data) {
                     $('#bills-expr').val('').attr('readOnly', true);
+                    $('#bills-expr').removeAttr('data-row');
                     return;
                 }
                 const nodePos = stagePos.getLedgerPos(data.id);
@@ -554,8 +555,10 @@ $(document).ready(() => {
                         $('#bills-expr').attr('readOnly', readOnly || cell.locked() || data.is_tp === 1)
                     }
                 }
+                $('#bills-expr').attr('data-row', sel.row);
             } else {
                 $('#bills-expr').val('').attr('readOnly', true);
+                $('#bills-expr').removeAttr('data-row');
             }
         },
         refreshTreeNodes: function (sheet, nodes) {
@@ -631,7 +634,7 @@ $(document).ready(() => {
                     updateData.stage[col.field] = newValue;
                     const exprInfo = getExprInfo(col.field);
                     if (exprInfo) {
-                        updateData.stage[exprInfo.expr] = trimInvalidChar(info.editingText);
+                        updateData.stage[exprInfo.expr] = info.editingText !== newValue+ '' ? trimInvalidChar(info.editingText) : '';
                     }
                 }
 
@@ -908,6 +911,12 @@ $(document).ready(() => {
             if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
             const col = info.sheet.zh_setting.cols[info.col];
             const node = info.sheet.zh_tree.nodes[info.row];
+            const exprInfo = getExprInfo(col.field);
+            if (exprInfo) {
+                if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
+                    info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
+                }
+            }
             switch (col.field) {
                 case 'contract_qty':
                 case 'qc_qty':
@@ -983,17 +992,19 @@ $(document).ready(() => {
     slSpread.bind(spreadNS.Events.ButtonClicked, stageTreeSpreadObj.buttonClicked);
     SpreadJsObj.addDeleteBind(slSpread, stageTreeSpreadObj.deletePress);
     if (!readOnly) {
-        $('#bills-expr').bind('change mouseleave', function () {
+        $('#bills-expr').bind('change onblur', function () {
             if (this.readOnly) return;
 
             const expr = $(this);
-            const sheet = slSpread.getActiveSheet();
-            const select = SpreadJsObj.getSelectObject(sheet);
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = stageTree.getItemsByIndex(row);
+            if (!select) return;
+
             const field = expr.attr('field'), orgValue = expr.attr('org'), updateData = {};
             let newValue = expr.val();
 
             const num = _.toNumber(newValue);
-            if (num) {
+            if (_.isFinite(num)) {
                 newValue = num;
             } else {
                 try {
@@ -1042,12 +1053,15 @@ $(document).ready(() => {
                     const exprInfo = getExprInfo(col.field);
                     const value = exprInfo && data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field];
                     $('#pos-expr').val(value).attr('field', col.field).attr('org', data[col.field])
-                        .attr('row', sel.row).attr('readOnly', readOnly || cell.locked());
+                        .attr('readOnly', readOnly || cell.locked());
+                    $('#pos-expr').attr('data-row', sel.row);
                 } else {
                     $('#pos-expr').val('').attr('readOnly', true);
+                    $('#pos-expr').removeAttr('data-row');
                 }
             } else {
                 $('#pos-expr').val('').attr('readOnly', true);
+                $('#pos-expr').removeAttr('data-row');
             }
         },
         /**
@@ -1132,13 +1146,16 @@ $(document).ready(() => {
                     data.updateType = 'update';
                     data.updateData = {pid: posData.id, lid: posData.lid};
                     if (col.type === 'Number') {
+                        const exprInfo = getExprInfo(col.field);
                         const num = _.toNumber(newText);
                         if (_.isFinite(num)) {
                             data.updateData[col.field] = num;
+                            if (exprInfo) {
+                                data.updateData[exprInfo.expr] = '';
+                            }
                         } else {
                             try {
                                 data.updateData[col.field] = math.evaluate(transExpr(newText));
-                                const exprInfo = getExprInfo(col.field);
                                 if (exprInfo) {
                                     data.updateData[exprInfo.expr] = newText;
                                 }
@@ -1173,6 +1190,16 @@ $(document).ready(() => {
         },
         editStarting: function (e, info) {
             stagePosSpreadObj.stageTreeNode = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+            const sel = info.sheet.getSelections();
+            if (!sel || !sel[0]) return;
+            const col = info.sheet.zh_setting.cols[sel[0].col];
+            const node = SpreadJsObj.getSelectObject(info.sheet);
+            const exprInfo = getExprInfo(col.field);
+            if (exprInfo) {
+                if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
+                    info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
+                }
+            }
         },
         clipboardPasting: function (e, info) {
             if (info.sheet.zh_setting) {
@@ -1452,14 +1479,16 @@ $(document).ready(() => {
     spSpread.bind(spreadNS.Events.SelectionChanged, stagePosSpreadObj.selectionChanged);
     SpreadJsObj.addDeleteBind(spSpread, stagePosSpreadObj.deletePress);
     if (!readOnly) {
-        $('#pos-expr').bind('change mouseleave', function () {
+        $('#pos-expr').bind('change onblur', function () {
             if (this.readOnly) return;
-            if (document.activeElement.id !== "pos-expr") return;
 
             const expr = $(this);
             const posSheet = spSpread.getActiveSheet();
-            const select = SpreadJsObj.getSelectObject(posSheet);
-            const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val(), row = expr.attr('row');
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = posSheet.zh_data ? posSheet.zh_data[row] : null;
+            if (!select) return;
+
+            const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val();
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
             const data = {pid: select.id, lid: select.lid};

+ 18 - 14
app/public/js/stage_pay.js

@@ -487,17 +487,23 @@ $(document).ready(() => {
             const sel = sheet.getSelections()[0];
             const col = sheet.zh_setting.cols[sel.col];
             const data = SpreadJsObj.getSelectObject(sheet);
-            if (col.field === 'tp') {
-                $('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
-                    .attr('readOnly', readOnly|| payBase.isSpecial(data));
-            } else if (col.field === 'sprice') {
-                $('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
-                    .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
-            } else if (col.field === 'rprice') {
-                $('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
-                    .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
+            if (data) {
+                if (col.field === 'tp') {
+                    $('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
+                        .attr('readOnly', readOnly|| payBase.isSpecial(data));
+                } else if (col.field === 'sprice') {
+                    $('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
+                        .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
+                } else if (col.field === 'rprice') {
+                    $('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
+                        .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
+                } else {
+                    $('#expr').val('').attr('readOnly', true);
+                }
+                $('#expr').attr('data-row', sel.row);
             } else {
                 $('#expr').val('').attr('readOnly', true);
+                $('#expr').removeAttr('data-row');
             }
         },
         add: function () {
@@ -848,11 +854,12 @@ $(document).ready(() => {
         $('#del').click(paySpreadObj.del);
         $('#up-move').click(paySpreadObj.upMove);
         $('#down-move').click(paySpreadObj.downMove);
-        $('#expr').bind('change mouseleave', function () {
+        $('#expr').bind('change onblur', function () {
             if (this.readOnly) return;
 
             const expr = $(this);
-            const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
+            const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
+            const select = paySpread.getActiveSheet().zh_data[row];
             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val();
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
@@ -894,9 +901,6 @@ $(document).ready(() => {
                 SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
             });
         });
-        // $('#expr').bind('onpaste', function (e) {
-        //     console.log(e);
-        // });
     }
 
     const deadlineObj = {

+ 9 - 1
app/service/report_memory.js

@@ -30,13 +30,14 @@ const billsFields = (function () {
     const pre = ['pre_contract_qty', 'pre_contract_tp', 'pre_qc_qty', 'pre_qc_tp', 'pre_gather_qty', 'pre_gather_tp'];
     const end = ['end_contract_qty', 'end_contract_tp', 'end_qc_qty', 'end_qc_tp', 'end_gather_qty', 'end_gather_tp'];
     const final = ['final_tp', 'final_ratio'];
+    const stageDgn = ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'];
 
     const stage = cur.concat(pre, end, final);
     const stageEnd = pre.concat(end, final);
     const bgl = ['qc_bgl_code'];
     const leafXmj = ['leaf_xmj_id'];
 
-    return {cur, pre, end, final, stage, stageEnd, bgl, leafXmj};
+    return {cur, pre, end, final, stageDgn, stage, stageEnd, bgl, leafXmj};
 })();
 const posFields = (function () {
     const cur = ['contract_qty', 'qc_qty', 'gather_qty', 'postil'];
@@ -348,6 +349,13 @@ module.exports = app => {
             }
 
             const billsData = await this.ctx.service.ledger.getData(this.ctx.tender.id);
+            if (this._checkFieldsExist(fields, billsFields.stageDgn)) {
+                const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(this.ctx.tender.id);
+                for (const d of dgnData) {
+                    const l = this.ctx.helper._.find(billsData, {id: d.id});
+                    this.ctx.helper._.assignIn(l, d);
+                }
+            }
             if (this._checkFieldsExist(fields, billsFields.stage)) {
                 if (this.ctx.stage.readOnly) {
                     const curStage = await this.ctx.service.stageBills.getAuditorStageData(this.ctx.tender.id,

+ 32 - 0
app/service/rpt_gather_memory.js

@@ -35,6 +35,9 @@ const gatherUtils = {
         gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
         gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
 
+        gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
+        gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
+
         gatherNode[prefix + "contract_qty"] = helper.add(gatherNode[prefix + "contract_qty"], sourceNode.contract_qty);
         gatherNode[prefix + "contract_tp"] = helper.add(gatherNode[prefix + "contract_tp"], sourceNode.contract_tp);
         gatherNode[prefix + "qc_qty"] = helper.add(gatherNode[prefix + "qc_qty"], sourceNode.qc_qty);
@@ -56,6 +59,11 @@ const gatherUtils = {
         gatherNode[prefix + "end_gather_qty"] = helper.add(gatherNode[prefix + "end_gather_qty"], sourceNode.end_gather_qty);
         gatherNode[prefix + "end_gather_tp"] = helper.add(gatherNode[prefix + "end_gather_tp"], sourceNode.end_gather_tp);
 
+        gatherNode[prefix + "deal_dgn_qty1"] = helper.add(gatherNode[prefix + "deal_dgn_qty1"], sourceNode.deal_dgn_qty1);
+        gatherNode[prefix + "deal_dgn_qty2"] = helper.add(gatherNode[prefix + "deal_dgn_qty2"], sourceNode.deal_dgn_qty2);
+        gatherNode[prefix + "c_dgn_qty1"] = helper.add(gatherNode[prefix + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
+        gatherNode[prefix + "c_dgn_qty2"] = helper.add(gatherNode[prefix + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
+
         gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
         gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
 
@@ -87,6 +95,9 @@ const gatherUtils = {
         gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
         gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
 
+        gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
+        gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
+
         gatherNode[prefix + "contract_qty"] = helper.add(gatherNode[prefix + "contract_qty"], sourceNode.contract_qty);
         gatherNode[prefix + "contract_tp"] = helper.add(gatherNode[prefix + "contract_tp"], sourceNode.contract_tp);
         gatherNode[prefix + "qc_qty"] = helper.add(gatherNode[prefix + "qc_qty"], sourceNode.qc_qty);
@@ -94,6 +105,11 @@ const gatherUtils = {
         gatherNode[prefix + "gather_qty"] = helper.add(gatherNode[prefix + "gather_qty"], sourceNode.gather_qty);
         gatherNode[prefix + "gather_tp"] = helper.add(gatherNode[prefix + "gather_tp"], sourceNode.gather_tp);
 
+        gatherNode[prefix + "deal_dgn_qty1"] = helper.add(gatherNode[prefix + "deal_dgn_qty1"], sourceNode.deal_dgn_qty1);
+        gatherNode[prefix + "deal_dgn_qty2"] = helper.add(gatherNode[prefix + "deal_dgn_qty2"], sourceNode.deal_dgn_qty2);
+        gatherNode[prefix + "c_dgn_qty1"] = helper.add(gatherNode[prefix + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
+        gatherNode[prefix + "c_dgn_qty2"] = helper.add(gatherNode[prefix + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
+
         gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
         gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
 
@@ -111,6 +127,9 @@ const gatherUtils = {
         gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
         gatherNode[prefix + "tp"] = helper.add(gatherNode[prefix + "tp"], sourceNode.total_price);
 
+        gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
+        gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
+
         gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
         gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
     },
@@ -215,6 +234,13 @@ module.exports = app => {
                 }
             });
             const billsData = await this.ctx.service.ledger.getData(tender.id);
+
+            const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(tender.id);
+            for (const d of dgnData) {
+                const l = this.ctx.helper._.find(billsData, {id: d.id});
+                this.ctx.helper._.assignIn(l, d);
+            }
+
             if (stage) {
                 await this.ctx.service.stage.doCheckStage(stage);
                 if (stage.readOnly) {
@@ -298,6 +324,12 @@ module.exports = app => {
             completeData.name = tender.name;
             const billsData = await this.ctx.service.ledger.getData(tender.id);
 
+            const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(tender.id);
+            for (const d of dgnData) {
+                const l = this.ctx.helper._.find(billsData, {id: d.id});
+                this.ctx.helper._.assignIn(l, d);
+            }
+
             let billsIndexData = {};
             for (const bd of billsData) {
                 billsIndexData[indexPre + bd.id] = bd;

+ 1 - 1
app/service/stage.js

@@ -225,7 +225,7 @@ module.exports = app => {
                     }, {id: stage.id});
                 } else if (stage.tp_history) {
                     const his = this.ctx.helper._.find(stage.tp_history, {times: stage.curTimes, order: stage.curOrder});
-                    console.log(his);
+                    // console.log(his);
                     if (his) {
                         stage.contract_tp = his.contract_tp;
                         stage.qc_tp = his.qc_tp;

+ 1 - 1
app/view/layout/menu.ejs

@@ -34,7 +34,7 @@
                 <a href="/profile/info" class="dropdown-item">账号资料</a>
                 <a href="/profile/safe" class="dropdown-item">账号安全</a>
                 <div class="dropdown-divider"></div>
-                <!--<a href="#" class="dropdown-item">帮助中心</a>-->
+                <a href="http://doc.zhzdwd.com/docs/measure" target="_blank" class="dropdown-item">用户手册</a>
                 <a href="/logout" class="dropdown-item">退出登录</a>
             </div>
         </div>

+ 1 - 1
app/view/wap/shenpi_change.ejs

@@ -217,7 +217,7 @@
 <!--审批通过弹窗-->
 <div class="modal" tabindex="-1" role="dialog" id="sp-done">
     <div class="modal-dialog" role="document">
-        <form class="modal-content" action="/wap/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="success-approval">
+        <form class="modal-content" action="/wap/tender/<%- tender.id %>/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="success-approval">
             <div class="modal-header">
                 <h5 class="modal-title">审批通过</h5>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">

+ 12 - 0
builder_report_index_define.js

@@ -271,6 +271,11 @@ const stage_bills = {
         { name: '设计错漏-公式', field: 'sjcl_expr', type: dataType.currency },
         { name: '其他错漏-公式', field: 'qtcl_expr', type: dataType.currency },
         { name: '本期-合同-公式', field: 'contract_expr', type: dataType.currency },
+
+        { name: '合同-设计数量1', field: 'deal_dgn_qty1', type: dataType.currency },
+        { name: '合同-设计数量2', field: 'deal_dgn_qty2', type: dataType.currency },
+        { name: '变更-设计数量1', field: 'c_dgn_qty1', type: dataType.currency },
+        { name: '变更-设计数量2', field: 'c_dgn_qty2', type: dataType.currency },
     ],
 };
 const stage_bills_compare = {
@@ -794,6 +799,13 @@ const gather_stage_bills = {
 
         { name: '(特殊3-需替换key3)台账-设计数量1', field: 'ts_key3_dgn_qty1', type: dataType.currency },
         { name: '(特殊3-需替换key3)台账-设计数量2', field: 'ts_key3_dgn_qty2', type: dataType.currency },
+
+        { name: '(标段)台账-设计数量1', field: 't_dgn_qty1', type: dataType.currency },
+        { name: '(标段)台账-设计数量2', field: 't_dgn_qty2', type: dataType.currency },
+        { name: '(标段)合同-设计数量1', field: 't_deal_dgn_qty1', type: dataType.currency },
+        { name: '(标段)合同-设计数量2', field: 't_deal_dgn_qty2', type: dataType.currency },
+        { name: '(标段)变更-设计数量1', field: 't_c_dgn_qty1', type: dataType.currency },
+        { name: '(标段)变更-设计数量2', field: 't_c_dgn_qty2', type: dataType.currency },
     ],
 };
 const gather_tender_info = {

+ 58 - 0
config/config.remoteuat.js

@@ -0,0 +1,58 @@
+'use strict';
+/**
+ * 开发环境相关配置
+ *
+ * @author CaiAoLin
+ * @date 2017/8/29
+ * @version
+ */
+
+module.exports = appInfo => {
+    const config = {};
+    // 数据库配置
+    config.mysql = {
+        client: {
+            // host
+            host: '47.106.95.114',
+            // 端口号
+            port: '3306',
+            // 用户名
+            user: 'smartcost',
+            // 密码
+            password: 'zongheng_@)!(_jlzf',
+            // 数据库名
+            database: 'calculation',
+            multipleStatements: true,
+        },
+        // 是否加载到 app 上,默认开启
+        app: true,
+        // 是否加载到 agent 上,默认关闭
+        agent: false,
+    };
+    // 表名前缀
+    config.tablePrefix = 'zh_';
+
+    // redis设置
+    config.redis = {
+        client: {
+            host: '47.106.95.114',
+            port: '6379',
+            password: 'zongheng_@)!(_jlzf',
+            db: '0',
+        },
+        agent: true,
+        version: '1.0.0',
+    };
+
+    // session配置
+    config.session = {
+        key: 'ZHC_SESS',
+        maxAge: 7 * 24 * 3600 * 1000, // 7天
+        httpOnly: true,
+        encrypt: true,
+        //renew: true, // session临近过期更新过期时间
+        rolling: true, // 每次都更新session有效期
+    };
+
+    return config;
+};

+ 1 - 0
package.json

@@ -63,6 +63,7 @@
     "dev": "egg-bin dev --port 7002",
     "dev-local": "set EGG_SERVER_ENV=local&&egg-bin dev --port 7002",
     "dev-remoteqa": "set EGG_SERVER_ENV=remoteqa&&egg-bin dev --port 7002",
+    "dev-remoteuat": "set EGG_SERVER_ENV=remoteuat&&egg-bin dev --port 7002",
     "dev-localpro": "set EGG_SERVER_ENV=localpro&&egg-bin dev --port 7002",
     "dev-temp": "set EGG_SERVER_ENV=temp&&egg-bin dev --port 7002",
     "dev-qa": "set EGG_SERVER_ENV=qa&&egg-bin dev --port 7002",

+ 9 - 1
sql/update.sql

@@ -2,7 +2,7 @@ UPDATE `zh_stage_pay` sp
   LEFT JOIN `zh_stage` s ON sp.sid = s.id
   LEFT JOIN `zh_pay` p ON sp.pid = p.id
   SET sp.`pre_used` = 1
-  WHERE (sp.`start_stage_order` < s.`order` OR ((not IsNULL(sp.pre_tp)) AND sp.pre_tp) AND sp.`pre_used` = 0 AND p.`ptype` = 1;
+  WHERE (sp.`start_stage_order` < s.`order` OR ((not IsNULL(sp.pre_tp)) AND sp.pre_tp <> 0)) AND sp.`pre_used` = 0 AND p.`ptype` = 1;
 
 ALTER TABLE `zh_stage_detail`
 ADD COLUMN `pos_name`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '计量单元名称' AFTER `position`;
@@ -72,3 +72,11 @@ INSERT INTO `zh_permission`(`id`, `name`, `controller`, `action`, `pid`, `icon_c
 
 ALTER TABLE `zh_stage`
 ADD COLUMN `tp_history`  text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '金额类的历史记录' AFTER `cache_time_l`;
+
+ALTER TABLE `zh_stage`
+ADD COLUMN `sf_tp`  decimal(24,8) NULL DEFAULT NULL COMMENT '本期实付' AFTER `pre_yf_tp`,
+ADD COLUMN `pre_sf_tp`  decimal(24,8) NULL DEFAULT NULL COMMENT '截止上期实付' AFTER `sf_tp`;
+
+-- ----------------------------
+-- 以上于2020-6-15 16:40 因测试需求更新至uat,尚未更新prod,如需增加sql,请一定在其后添加
+-- ----------------------------