Selaa lähdekoodia

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

TonyKang 5 vuotta sitten
vanhempi
commit
efcc5ad17d

+ 1 - 0
.gitignore

@@ -9,3 +9,4 @@ app/public/download/
 .DS_Store
 *.swp
 package-lock.json
+app/public/js/web

+ 34 - 23
app/public/js/gcl_gather.js

@@ -341,6 +341,39 @@ const gclGatherModel = (function () {
         }
     }
 
+    function compareCode(str1, str2, symbol = '-') {
+        if (!str1) {
+            return 1;
+        } else if (!str2) {
+            return -1;
+        }
+
+        function compareSubCode(code1, code2) {
+            if (numReg.test(code1)) {
+                if (numReg.test(code2)) {
+                    return parseInt(code1) - parseInt(code2);
+                } else {
+                    return -1
+                }
+            } else {
+                if (numReg.test(code2)) {
+                    return 1;
+                } else {
+                    return code1 === code2 ? 0 : (code1 < code2 ? -1 : 1); //code1.localeCompare(code2);
+                }
+            }
+        }
+        const numReg = /^[0-9]+$/;
+        const aCodes = str1.split(symbol), bCodes = str2.split(symbol);
+        for (let i = 0, iLength = Math.min(aCodes.length, bCodes.length); i < iLength; ++i) {
+            const iCompare = compareSubCode(aCodes[i], bCodes[i]);
+            if (iCompare !== 0) {
+                return iCompare;
+            }
+        }
+        return aCodes.length - bCodes.length;
+    }
+
     /**
      * 根据树结构 清单汇总
      */
@@ -353,29 +386,7 @@ const gclGatherModel = (function () {
         calculateGatherData();
         gatherDealBillsData();
         gclList.sort(function (a, b) {
-            function compareCode(code1, code2) {
-                if (numReg.test(code1)) {
-                    if (numReg.test(code2)) {
-                        return _.toNumber(code1) - _.toNumber(code2);
-                    } else {
-                        return -1
-                    }
-                } else {
-                    if (numReg.test(code2)) {
-                        return 1;
-                    } else {
-                        return code1 === code2 ? 0 : (code1 < code2 ? -1 : 1);
-                    }
-                }
-            }
-            const numReg = /^[0-9]+$/;
-            const aCodes = a.b_code.split('-'), bCodes = b.b_code.split('-');
-            for (let i = 0, iLength = Math.min(aCodes.length, bCodes.length); i < iLength; ++i) {
-                const iCompare = compareCode(aCodes[i], bCodes[i]);
-                if (iCompare !== 0) {
-                    return iCompare;
-                }
-            }
+            return compareCode(a.b_code, b.b_code);
         });
 
         return gclList;

+ 19 - 0
app/public/js/ledger_gather.js

@@ -68,6 +68,21 @@ $(document).ready(() => {
             SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, []);
         }
     }
+    // 标红显示 签约-台账≠0
+    function checkCompareData() {
+        const sheet = gclSheet;
+        const bCompare = $('#compare-tag')[0].checked;
+        SpreadJsObj.beginMassOperation(gclSheet);
+        for (let iRow = 0, iLength = gclSheet.getRowCount(); iRow < iLength; iRow++) {
+            const node = gclSheet.zh_data[iRow];
+            if (node) {
+                const bDiffer = node.compare_qty ? !checkZero(Math.abs(node.compare_qty)) : !checkZero(Math.abs(node.compare_tp));
+                const color = bCompare && bDiffer ? '#f8d7da' : '';
+                sheet.getRange(iRow, -1, 1, -1).backColor(color);
+            }
+        }
+        SpreadJsObj.endMassOperation(gclSheet);
+    }    
     // 切换清单行,读取所属项目节数据
     gclSpread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
         const iNewRow = info.newSelections[0].row;
@@ -110,8 +125,10 @@ $(document).ready(() => {
         for (const gcl of gclGatherData) {
             gcl.compare_qty = ZhCalc.sub(gcl.deal_bills_qty, gcl.quantity);
             gcl.compare_tp = ZhCalc.sub(gcl.deal_bills_tp, gcl.total_price);
+            gcl.compare_differ = checkZero(gcl.compare_qty) && checkZero(gcl.compare_tp);
         }
         SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData);
+        checkCompareData();
         loadLeafXmjData(0);
 
         const chapterData = gclGatherModel.gatherChapterData(chapter, ['total_price']);
@@ -121,6 +138,8 @@ $(document).ready(() => {
         generateChapterHtml(chapterData);
     }, null, true);
 
+    $('#compare-tag').click(checkCompareData);
+
     // 展开收起附件
     $('a', '.right-nav').bind('click', function () {
         const tab = $(this), tabPanel = $(tab.attr('content'));

+ 35 - 28
app/service/deal_bills.js

@@ -55,21 +55,25 @@ module.exports = app => {
                             iUp = -1;
                             iQty = -1;
                         }
-                    } else if (this.ctx.helper.validBillsCode(row[iCode])) {
-                        const data = {
-                            deal_id: bills.length + 1,
-                            tender_id: tenderId,
-                            code: row[iCode],
-                            name: row[iName],
-                            unit: row[iUnit],
-                            unit_price: row[iUp],
-                            quantity: row[iQty],
-                        };
-                        if ((data.unit_price && !this._.isNumber(data.unit_price)) || (data.quantity && !this._.isNumber(data.quantity))) {
-                            throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                    } else {
+                        const code = this.ctx.helper._.trimEnd(row[iCode]);
+                        console.log(code);
+                        if (this.ctx.helper.validBillsCode(code)) {
+                            const data = {
+                                deal_id: bills.length + 1,
+                                tender_id: tenderId,
+                                code: code,
+                                name: row[iName],
+                                unit: row[iUnit],
+                                unit_price: row[iUp],
+                                quantity: row[iQty],
+                            };
+                            if ((data.unit_price && !this._.isNumber(data.unit_price)) || (data.quantity && !this._.isNumber(data.quantity))) {
+                                throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                            }
+                            bills.push(data);
                         }
-                        bills.push(data);
-                    }
+                    } 
                 }
                 if (!bCheckCol) {
                     throw '导入的Excel表头定义有误,请下载示例检查';
@@ -144,21 +148,24 @@ module.exports = app => {
                         iQty = -1;
                         iTp = -1;
                     }
-                } else if (this.ctx.helper.validBillsCode(row[iCode])) {
-                    const data = {
-                        deal_id: bills.length + 1,
-                        tender_id: tenderId,
-                        code: this.ctx.helper.replaceReturn(row[iCode]),
-                        name: this.ctx.helper.replaceReturn(row[iName]),
-                        unit: this.ctx.helper.replaceReturn(row[iUnit]),
-                        unit_price: (row[iUp] === undefined || row[iUp] === null) ? 0 : this._.toNumber(row[iUp]),
-                        quantity: (row[iQty] === undefined || row[iQty] === null) ? 0 : this._.toNumber(row[iQty]),
-                        total_price: (row[iTp] === undefined || row[iTp] === null) ? 0 : this._.toNumber(row[iTp]),
-                    };
-                    if (this._.isNaN(data.unit_price) || this._.isNaN(data.quantity) || this._.isNaN(data.total_price)) {
-                        throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                } else {
+                    const code = this.ctx.helper.replaceReturn(this.ctx.helper._.trimEnd(row[iCode]));
+                    if (this.ctx.helper.validBillsCode(code)) {
+                        const data = {
+                            deal_id: bills.length + 1,
+                            tender_id: tenderId,
+                            code: code,
+                            name: this.ctx.helper.replaceReturn(row[iName]),
+                            unit: this.ctx.helper.replaceReturn(row[iUnit]),
+                            unit_price: (row[iUp] === undefined || row[iUp] === null) ? 0 : this._.toNumber(row[iUp]),
+                            quantity: (row[iQty] === undefined || row[iQty] === null) ? 0 : this._.toNumber(row[iQty]),
+                            total_price: (row[iTp] === undefined || row[iTp] === null) ? 0 : this._.toNumber(row[iTp]),
+                        };
+                        if (this._.isNaN(data.unit_price) || this._.isNaN(data.quantity) || this._.isNaN(data.total_price)) {
+                            throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                        }
+                        bills.push(data);
                     }
-                    bills.push(data);
                 }
             }
             if (!bCheckCol) {

+ 22 - 23
app/service/pos.js

@@ -355,7 +355,6 @@ module.exports = app => {
 
             const transaction = await this.db.beginTransaction();
             const result = { ledger: {}, pos: null };
-            const orgPos = await this.getPosData({tid: tid, id: this._.map(data, 'id')});
 
             const bills = await this.ctx.service.ledger.getDataById(data[0].lid);
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
@@ -374,29 +373,29 @@ module.exports = app => {
 
             try {
                 for (const d of data) {
-                    const op = d.id ? this._.find(orgPos, {id: d.id}) : null;
-                    if (d.sgfh_qty || d.sjcl_qty || d.qtcl_qty) {
-                        if (d.sgfh_qty !== undefined) {
-                            d.sgfh_qty = this.round(d.sgfh_qty, precision.value);
-                        } else if (op) {
-                            d.sgfh_qty = op.sgfh_qty;
-                        }
-                        updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, d.sgfh_qty);
-                        if (d.sjcl_qty !== undefined) {
-                            d.sjcl_qty = this.round(d.sjcl_qty, precision.value);
-                        } else if (op) {
-                            d.sjcl_qty = op.sjcl_qty;
-                        }
-                        updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, d.sjcl_qty);
-                        if (d.qtcl_qty) {
-                            d.qtcl_qty = this.round(d.qtcl_qty, precision.value);
-                        } else if (op) {
-                            d.qtcl_qty = op.qtcl_qty;
-                        }
-                        updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, d.qtcl_qty);
-                        d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
-                        updateBills.quantity = this.ctx.helper.add(updateBills.quantity, d.quantity);
+                    const op = d.id ? this._.find(billsPos, {id: d.id}) : null;
+                    
+                    if (d.sgfh_qty !== undefined) {
+                        d.sgfh_qty = this.round(d.sgfh_qty, precision.value);
+                    } else if (op) {
+                        d.sgfh_qty = op.sgfh_qty;
+                    }
+                    updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, d.sgfh_qty);
+                    if (d.sjcl_qty !== undefined) {
+                        d.sjcl_qty = this.round(d.sjcl_qty, precision.value);
+                    } else if (op) {
+                        d.sjcl_qty = op.sjcl_qty;
                     }
+                    updateBills.sjcl_qty = this.ctx.helper.add(updateBills.sjcl_qty, d.sjcl_qty);
+                    if (d.qtcl_qty) {
+                        d.qtcl_qty = this.round(d.qtcl_qty, precision.value);
+                    } else if (op) {
+                        d.qtcl_qty = op.qtcl_qty;
+                    }
+                    updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, d.qtcl_qty);
+                    d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
+                    updateBills.quantity = this.ctx.helper.add(updateBills.quantity, d.quantity);
+
                     if (d.id) {
                         await transaction.update(this.tableName, d);
                     } else {

+ 8 - 4
app/service/revise_bills.js

@@ -126,18 +126,20 @@ module.exports = app => {
                 }
                 // 数据库创建新增节点数据
                 await this.transaction.insert(this.tableName, bills);
-                await this.transaction.insert(this.ctx.service.revisePos.tableName, pos);
+                if (pos.length > 0) {
+                    await this.transaction.insert(this.ctx.service.revisePos.tableName, pos);
+                }
                 this._cacheMaxLid(tid, maxId + data.length);
                 await this.transaction.commit();
             } catch (err) {
-                await this.transaction.rollback();
+                await this.transaction.rollback();console.log(lastChild);
                 throw err;
             }
 
             // 查询应返回的结果
             result.ledger.create = await this.getDataById(newIds);
             if (!lastChild) {
-                result.ledger.update = await this.getDataByKid(select.id);
+                result.ledger.update = await this.getDataById(select.id);
             }
             result.pos = await this.ctx.service.revisePos.getDataByLid(tid, newIds);
             return result;
@@ -215,7 +217,9 @@ module.exports = app => {
                 await this._updateChildrenOrder(tid, select.ledger_pid, select.order+1);
                 // 数据库创建新增节点数据
                 await this.transaction.insert(this.tableName, bills);
-                await this.transaction.insert(this.ctx.service.revisePos.tableName, pos);
+                if (pos.length > 0) {
+                    await this.transaction.insert(this.ctx.service.revisePos.tableName, pos);
+                }
                 this._cacheMaxLid(tid, maxId + data.length);
                 await this.transaction.commit();
             } catch (err) {

+ 6 - 3
app/view/ledger/gather.ejs

@@ -4,9 +4,12 @@
         <div class="title-main d-flex">
             <% include ../tender/tender_sub_mini_menu.ejs %>
             <div>
-                <div class="d-inline-block">
-                    清单对比
-                </div>
+                <a class="btn btn-sm btn-light">
+                    <div class="custom-control custom-checkbox">
+                        <input type="checkbox" class="custom-control-input" id="compare-tag">
+                        <label class="custom-control-label text-primary" for="compare-tag">签约-台账≠0</label>
+                    </div>
+                </a>
             </div>
             <div class="ml-auto">
             </div>

+ 2 - 2
app/view/tender/detail_modal.ejs

@@ -1016,9 +1016,9 @@
     })();
     $('#bd-set-4').on('show.bs.modal', function () {
         dealObj.loadDealProperty();
-        if (firstStageChecked) {
+        <% if (lastStage !== undefined && lastStage !== null && (lastStage.user_id !== ctx.session.sessionUser.accountId || lastStage.order > 1 || (lastStage.order === 1 && (lastStage.status !== audit.stage.status.uncheck && lastStage.status !== audit.stage.status.checkNo)))) { %>
             dealObj.setReadOnly(true);
-        }
+        <% } %>
     });
     function post4 () {
         if (firstStageChecked) return;

+ 90 - 0
config/config.remoteqa.js

@@ -0,0 +1,90 @@
+'use strict';
+/**
+ * 开发环境相关配置
+ *
+ * @author CaiAoLin
+ * @date 2017/8/29
+ * @version
+ */
+
+module.exports = appInfo => {
+    const config = {};
+    // 数据库配置
+    config.mysql = {
+        client: {
+            // host
+            host: 'smartcost.in.8866.org',
+            // 端口号
+            port: '26905',
+            // 用户名
+            user: 'zh_dev',
+            // 密码
+            password: 'zongheng2019',
+            // 数据库名
+            database: 'calculation',
+            // database: 'calc_copy_pro',
+        },
+        // 是否加载到 app 上,默认开启
+        app: true,
+        // 是否加载到 agent 上,默认关闭
+        agent: false,
+    };
+    // 表名前缀
+    config.tablePrefix = 'zh_';
+
+    // redis设置
+    config.redis = {
+        client: {
+            host: 'smartcost.in.8866.org',
+            port: '26906',
+            password: 'zongheng2019',
+            db: '0',
+        },
+        agent: true,
+    };
+
+    // geetest验证码key
+    config.geetest = {
+        id: '23c50f6711966f744c93a70167c8e0a4',
+        key: '9b67989994f9def437ea68bb495f0162',
+    };
+
+    // 前端验证
+    config.jsValidator = {
+        client: {},
+        app: true,
+    };
+
+    // 上传设置
+    config.multipart = {
+        whitelist: ['.json', '.txt',
+            '.xls', '.xlsx',
+            '.doc', '.docx',
+            '.pdf',
+            '.png', '.jpg', '.jpeg', '.gif', '.bmp',
+            '.zip', '.rar', '.7z'],
+        fileSize: '30mb',
+    };
+
+    // session配置
+    config.session = {
+        key: 'ZHC_SESS',
+        maxAge: 7 * 24 * 3600 * 1000, // 7天
+        httpOnly: true,
+        encrypt: true,
+        //renew: true, // session临近过期更新过期时间
+        rolling: true, // 每次都更新session有效期
+    };
+
+    // 是否压缩替换前端js
+    config.min = false;
+
+    config.logger = {
+        consoleLevel: 'WARN',
+        disableConsoleAfterReady: false,
+    };
+
+    config.is_debug = true;
+
+    return config;
+};

+ 10 - 0
config/config.temp.js

@@ -53,5 +53,15 @@ module.exports = appInfo => {
         rolling: true, // 每次都更新session有效期
     };
 
+    // 是否压缩替换前端js
+    config.min = false;
+
+    config.logger = {
+        consoleLevel: 'WARN',
+        disableConsoleAfterReady: false,
+    };
+
+    config.is_debug = true;
+
     return config;
 };

+ 1 - 0
package.json

@@ -61,6 +61,7 @@
     "start-qa": "set EGG_SERVER_ENV=qa&&egg-scripts start --daemon --port 7002",
     "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-temp": "set EGG_SERVER_ENV=temp&&egg-bin dev --port 7002",
     "dev-qa": "set EGG_SERVER_ENV=qa&&egg-bin dev --port 7002",
     "dev-test": "set EGG_SERVER_ENV=test&&egg-bin dev --port 7002",