Преглед изворни кода

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang пре 22 часа
родитељ
комит
bb22b798c3

+ 1 - 1
app/public/js/cost_stage_analysis.js

@@ -747,7 +747,7 @@ $(document).ready(function() {
             const node = SpreadJsObj.getSelectObject(info.sheet);
             if (!node.children || node.children.length === 0) {
                 const selected = tree.nodes.find(x => { return x.selected; });
-                if (selected && selected.detail_type !== node.detail_type) {
+                if (selected && selected.detail_type !== node.detail_type && !node.selected) {
                     toastr.warning('勾选节点类型不一致,不允许勾选');
                     return;
                 }

+ 83 - 0
app/service/cost_stage_analysis.js

@@ -196,6 +196,89 @@ module.exports = app => {
 
             await transaction.insert(this.tableName, insertData);
         }
+        // 以下为新增时,根据上一期导入的数据,自动导入明细等数据
+        // todo 暂未进行任何测试 -- 未考虑利润与利润率计算问题(待核实)
+        // async initByPre(stage, preStage, transaction) {
+        //     if (!stage || !preStage || !transaction) throw '成本分析数据错误';
+        //     const insertData = [], insertDetailData = [];
+        //     if (!stage.calcTemplate) stage.calcTemplate = await this.service.calcTmpl.getTemplate(stage.calc_template);
+        //
+        //     const costStageLedger = await this.getCostStageData(stage.relaStage);
+        //
+        //     const preBills = await this.getReadData(preStage);
+        //     const preLedger = new Ledger.baseTree(this.ctx, {
+        //         id: 'tree_id', pid: 'tree_pid', order: 'tree_order',
+        //         level: 'tree_level', isLeaf: 'tree_is_leaf', fullPath: 'tree_full_path',
+        //         rootId: -1, calcField: [],
+        //     });
+        //     preLedger.loadDatas(preBills);
+        //     const preDetails = await this.ctx.service.costStageAnalysisDetail.getReadData(preStage);
+        //     for (const pl of preLedger.nodes) {
+        //         if (pl.tree_is_leaf) pl.detail = preDetails.filter(x => { return x.ledger_id === pl.id; });
+        //         const idata = {};
+        //         this._getDefaultData(idata, stage);
+        //         idata.cost_id = pl.cost_id;
+        //         idata.node_type = pl.node_type;
+        //         idata.calc_type = pl.calc_type;
+        //         idata.has_detail = pl.has_detail && pl.detail.length > 0;
+        //         idata.import_cost_id = pl.import_cost_id;
+        //         if (!idata.has_detail) {
+        //             for (const prop of costFields.preCopyFields) {
+        //                 idata[prop] = pl[prop];
+        //             }
+        //         }
+        //         insertData.push(idata);
+        //         if (idata.import_cost_id) {
+        //             const cost_id = idata.import_cost_id.split(',');
+        //             const nodes = costStageLedger.nodes.filter(x => { return cost_id.indexOf(x.cost_id) >= 0; });
+        //             if (nodes.length > 0) {
+        //                 if (nodes[0].detail.length > 0) {
+        //                     const insertDetails = [];
+        //                     const preDetail = await this.ctx.service.costStageAnalysisDetail.getAllDataByCondition({ where: { stage_id: preStage.id, cost_id: select.cost_id } });
+        //                     for (const node of nodes) {
+        //                         for (const d of node.detail) {
+        //                             let id = insertDetails.find(x => { return x.source_id === d.source_cid && x.is_deal === d.is_deal; });
+        //                             if (!id) {
+        //                                 id = {
+        //                                     id: this.uuid.v4(), tender_id: stage.tid, stage_id: stage.id,
+        //                                     add_user_id: userId, update_user_id: userId,
+        //                                     ledger_id: select.id, cost_id: select.cost_id, source_id: d.source_cid, is_deal: d.is_deal,
+        //                                     d_order: insertDetails.length + 1,
+        //                                     code: d.code, name: d.name, party_b: d.party_b || '', tax: d.tax || 0,
+        //                                 };
+        //                                 insertDetails.push(id);
+        //                             }
+        //                             id.yf_excl_tax_tp = this.ctx.helper.add(id.yf_excl_tax_tp, d.yf_excl_tax_tp || 0);
+        //                             id.sf_excl_tax_tp = this.ctx.helper.add(id.sf_excl_tax_tp, d.sf_excl_tax_tp || 0);
+        //                             id.in_excl_tax_tp = this.ctx.helper.add(id.in_excl_tax_tp, d.in_excl_tax_tp || 0);
+        //                         }
+        //                     }
+        //                     for (const id of insertDetails) {
+        //                         const sourceDetail = preDetail.find(x => { return x.source_id === id.source_id && x.is_deal === id.is_deal; });
+        //                         for (const prop of costFields.selfCalcFields) {
+        //                             id[prop] = sourceDetail ? sourceDetail[prop] || 0 : 0;
+        //                         }
+        //                         this.ctx.service.calcTmpl.calcByTemplate(id, id, id, stage.calcTemplate.calc_expr);
+        //                         for (const prop of costFields.sumFields) {
+        //                             idata[prop] = this.ctx.helper.add(idata[prop], id[prop]);
+        //                         }
+        //                     }
+        //                     insertDetailData.push(...insertDetails);
+        //                 } else {
+        //                     for (const node of nodes) {
+        //                         idata.yf_excl_tax_tp = this.ctx.helper.add(idata.yf_excl_tax_tp, node.end_yf_excl_tax_tp || 0);
+        //                         idata.sf_excl_tax_tp = this.ctx.helper.add(idata.sf_excl_tax_tp, node.end_sf_excl_tax_tp || 0);
+        //                         idata.in_excl_tax_tp = this.ctx.helper.add(idata.in_excl_tax_tp, node.end_in_excl_tax_tp || 0);
+        //                     }
+        //                 }
+        //             }
+        //             this.ctx.service.calcTmpl.calcByTemplate(idata, idata, select, stage.calcTemplate.calc_expr);
+        //         }
+        //     }
+        //
+        //     await transaction.insert(this.tableName, insertData);
+        //     if (insertDetailData.length > 0) await transaction.insert(this.tableName, insertDetailData);
+        // }
         async initStageData(transaction, stage, preStage) {
             try {
                 if (preStage) {

+ 1 - 1
app/view/datacollect/index_tz.ejs

@@ -939,7 +939,7 @@
                     // chart_data.end_profit_tp.push(tendera.end_gather_tp || 0);
                     const tendera = tenders[t] ? tenders[t].a : null;
                     if (tendera) {
-                        calculateTender(tenderb);
+                        calculateTender(tendera);
                         const profit = ZhCalc.div(ZhCalc.sub(tendera.end_gather_tp, tenderb.end_gather_tp), 10000);
                         chart_data.end_profit_tp.push(ZhCalc.round(profit, 0) || 0);
                     } else {

+ 1 - 1
app/view/setting/show.ejs

@@ -11,7 +11,7 @@
                 <div class="row m-0 mt-3">
                     <div class="col-5">
                         <div class="form-group">
-                            <h6>项目列表默认显示</h6>
+                            <h6>计量管理默认显示</h6>
                             <div class="card w-50">
                                 <ul class="list-group list-group-flush" id="tenderList">
                                     <% showList.forEach(function(item, idx) { %>