Explorar o código

成本报审相关bug

MaiXinRong hai 13 horas
pai
achega
26e799e0a0

+ 3 - 3
app/controller/cost_controller.js

@@ -216,13 +216,13 @@ module.exports = app => {
                 if (stage.id !== stages[0].id) throw '非最新一期,不可删除';
                 if (stage.id !== stages[0].id) throw '非最新一期,不可删除';
                 if (stage.stage_type === 'ledger') {
                 if (stage.stage_type === 'ledger') {
                     const bookStages = await ctx.service.costStage.getAllStages(ctx.tender.id, 'book', 'DESC');
                     const bookStages = await ctx.service.costStage.getAllStages(ctx.tender.id, 'book', 'DESC');
-                    if (bookStages.findIndex(x => { return x.rela_stage && x.rela_stage.sid === stage.id; })) throw '该期已关联财务账面,请勿删除';
+                    if (bookStages.findIndex(x => { return x.rela_stage && x.rela_stage.sid === stage.id; }) >= 0) throw '该期已关联财务账面,请勿删除';
                     const analysisStages = await ctx.service.costStage.getAllStages(ctx.tender.id, 'analysis', 'DESC');
                     const analysisStages = await ctx.service.costStage.getAllStages(ctx.tender.id, 'analysis', 'DESC');
-                    if (analysisStages.findIndex(x => { return x.rela_stage && x.rela_stage.sid === stage.id; })) throw '该期已关联成本分析,请勿删除';
+                    if (analysisStages.findIndex(x => { return x.rela_stage && x.rela_stage.sid === stage.id; }) >= 0) throw '该期已关联成本分析,请勿删除';
                 }
                 }
                 if (stage.stage_type === 'book') {
                 if (stage.stage_type === 'book') {
                     const analysisStages = await ctx.service.costStage.getAllStages(ctx.tender.id, 'analysis', 'DESC');
                     const analysisStages = await ctx.service.costStage.getAllStages(ctx.tender.id, 'analysis', 'DESC');
-                    if (analysisStages.findIndex(x => { return x.rela_stage && x.rela_stage.sid === stage.id; })) throw '该期已关联成本分析,请勿删除';
+                    if (analysisStages.findIndex(x => { return x.rela_stage && x.rela_stage.sid === stage.id; }) >= 0) throw '该期已关联成本分析,请勿删除';
                 }
                 }
 
 
                 await ctx.service.costStage.delete(stage_id);
                 await ctx.service.costStage.delete(stage_id);

+ 3 - 3
app/public/js/cost_stage_ledger.js

@@ -22,7 +22,7 @@ $(document).ready(function() {
                 isLeaf: 'tree_is_leaf',
                 isLeaf: 'tree_is_leaf',
                 fullPath: 'tree_full_path',
                 fullPath: 'tree_full_path',
                 rootId: -1,
                 rootId: -1,
-                calcFields: ['cur_tp', 'pre_tp', 'end_tp'],
+                calcFields: ['yf_tp', 'sf_tp', 'pay_tp', 'cut_tp'],
                 keys: ['id', 'stage_id', 'tree_id'],
                 keys: ['id', 'stage_id', 'tree_id'],
             };
             };
             this.tree = createNewPathTree('ledger', this.treeSetting);
             this.tree = createNewPathTree('ledger', this.treeSetting);
@@ -814,7 +814,7 @@ $(document).ready(function() {
             let level, filterRow = 0;
             let level, filterRow = 0;
             for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
             for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
                 const curRow = info.cellRange.row + iRow;
                 const curRow = info.cellRange.row + iRow;
-                const node = tree.nodes[curRow];
+                const node = info.sheet.zh_data[curRow];
                 if (!node) continue;
                 if (!node) continue;
 
 
                 let bPaste = false;
                 let bPaste = false;
@@ -1283,7 +1283,7 @@ $(document).ready(function() {
             billsObj.loadRelaData();
             billsObj.loadRelaData();
             if (cur.pid) {
             if (cur.pid) {
                 const pIndex = detailObj.sheet.zh_data.findIndex(x => { return x.id === cur.pid; });
                 const pIndex = detailObj.sheet.zh_data.findIndex(x => { return x.id === cur.pid; });
-                SpreadJsObj.locateRow(detailObj.sheet, pIndex);
+                if (pIndex >= 0) SpreadJsObj.locateRow(detailObj.sheet, pIndex);
             }
             }
         },
         },
     });
     });

+ 5 - 6
app/service/cost_stage_detail.js

@@ -281,7 +281,6 @@ module.exports = app => {
             const paySql = `SELECT cp.*, c.c_code, c.name, c.party_b FROM ${this.ctx.service.contractPay.tableName} cp LEFT JOIN ${this.ctx.service.contract.tableName} c ON cp.cid = c.id ` +
             const paySql = `SELECT cp.*, c.c_code, c.name, c.party_b FROM ${this.ctx.service.contractPay.tableName} cp LEFT JOIN ${this.ctx.service.contract.tableName} c ON cp.cid = c.id ` +
                            `    WHERE cp.cid IN(${ids.map(x => { return `'${x}'`}).join(', ')}) AND cp.pay_time >= ? AND cp.pay_time <= ?`;
                            `    WHERE cp.cid IN(${ids.map(x => { return `'${x}'`}).join(', ')}) AND cp.pay_time >= ? AND cp.pay_time <= ?`;
             const validPays = await this.db.query(paySql, [beginTime, endTime]);
             const validPays = await this.db.query(paySql, [beginTime, endTime]);
-            console.log(this.db.format(paySql, [beginTime, endTime]));
 
 
             const insertDetails = [];
             const insertDetails = [];
             for (const pay of validPays) {
             for (const pay of validPays) {
@@ -311,17 +310,17 @@ module.exports = app => {
             const conn = await this.db.beginTransaction();
             const conn = await this.db.beginTransaction();
             try {
             try {
                 await conn.delete(this.tableName, { stage_id: this.ctx.costStage.id, ledger_id: ledgerId });
                 await conn.delete(this.tableName, { stage_id: this.ctx.costStage.id, ledger_id: ledgerId });
-                await conn.insert(this.tableName, insertDetails);
+                if (insertDetails.length > 0) await conn.insert(this.tableName, insertDetails);
                 await conn.update(this.ctx.service.costStageLedger.tableName, billsUpdate);
                 await conn.update(this.ctx.service.costStageLedger.tableName, billsUpdate);
                 await conn.commit();
                 await conn.commit();
             } catch(err) {
             } catch(err) {
                 await conn.rollback();
                 await conn.rollback();
                 throw err;
                 throw err;
             }
             }
-            const addData = await this.getAllDataByCondition({
-                where: { id: this.ctx.helper._.map(insertDetails, 'id') }
-            });
-            const ledgerData = await this.ctx.service.costStageLedger.getDataById(addData[0].ledger_id);
+            const addData = insertDetails.length > 0
+                ? await this.getAllDataByCondition({ where: { id: this.ctx.helper._.map(insertDetails, 'id') }})
+                : [];
+            const ledgerData = await this.ctx.service.costStageLedger.getDataById(ledgerId);
             return { detail: { add: addData, del: detailDatas.map(x => { return x.id; }) }, ledger: ledgerData };
             return { detail: { add: addData, del: detailDatas.map(x => { return x.id; }) }, ledger: ledgerData };
         }
         }
         async _importContractByTypes(ledgerId, costId, types, months) {
         async _importContractByTypes(ledgerId, costId, types, months) {