laiguoran пре 4 година
родитељ
комит
4ad97449e3

+ 1 - 1
app/controller/schedule_controller.js

@@ -231,7 +231,7 @@ module.exports = app => {
                 // const convert = new billsPosConvert(ctx);
                 // convert.loadData(ledgerData, posData, []);
                 // const result = await convert.convert();
-                const scheduleLedgerMonthData = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ tid: ctx.tender.id });
+                const scheduleLedgerMonthData = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                 ctx.body = { err: 0, msg: '', data: { bills: ledgerData, slm: scheduleLedgerMonthData } };
             } catch (err) {
                 this.log(err);

+ 6 - 5
app/public/js/schedule_plan.js

@@ -34,7 +34,7 @@ $(function () {
         {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
         {title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
         {title: '总设计|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
     ];
 
     const ledgerSpreadSetting = {
@@ -54,10 +54,10 @@ $(function () {
     const calcCols = ['total_price'];
     if(scheduleMonth.length > 0) {
         for (const sm of scheduleMonth) {
-            const readOnly = sm.stage_used !== 0;
+            const readOnly = sm.stage_gcl_used !== 0 || sm.stage_tp_used !== 0;
             const yearmonth = sm.yearmonth.split('-')[0] + '年' + parseInt(sm.yearmonth.split('-')[1]) + '月';
             const cols = {title: yearmonth + '|计划工程量', colSpan: '2|1', rowSpan: '1|1', field: sm.yearmonth+'_gcl', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.gcl'};
-            const cols2 = {title: '|计划金额(元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_tp', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.tp'};
+            const cols2 = {title: '|计划金额(元)', colSpan: '|1', rowSpan: '|1', field: sm.yearmonth+'_tp', hAlign: 2, width: 90, type: 'Number', readOnly: readOnly ? readOnly : 'readOnly.tp'};
             monthsCols.push(cols);
             monthsCols.push(cols2);
             // calcCols.push(sm.yearmonth+'_gcl');
@@ -112,6 +112,7 @@ $(function () {
             // calcList.push(m + '_tp');
             // calcList.push(m + '_gcl');
         }
+        console.log(showList);
         const baseLedgerTree = createNewPathTree('base', {
             id: 'ledger_id',
             pid: 'ledger_pid',
@@ -138,10 +139,10 @@ $(function () {
                 }
             }
         }
-        console.log(ledgerTree);
+        // console.log(ledgerTree);
         ledgerTree.sortTreeNode(true);
         treeCalc.calculateAll(ledgerTree);
-        // console.log(ledgerTree);
+        console.log(ledgerTree);
         SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
     }, null, true);
 

+ 12 - 0
app/service/schedule_ledger.js

@@ -29,6 +29,8 @@ module.exports = app => {
                 if (oldLids.length > 0) {
                     for (const ol of oldLids) {
                         await transaction.delete(this.tableName, { tid: this.ctx.tender.id, ledger_id: ol });
+                        // 更新已选标段值
+                        await transaction.delete(this.ctx.service.scheduleLedgerMonth.tableName, { tid: this.ctx.tender.id, lid: ol });
                     }
                 }
                 if (insertDatas.length > 0) await transaction.insert(this.tableName, insertDatas);
@@ -62,6 +64,16 @@ module.exports = app => {
                 } else {
                     await transaction.update(this.ctx.service.schedule.tableName, { id: scheduleInfo.id, total_tp });
                 }
+                // 判断是否已存在计划月,并更新计划月统计数据,再更新总的统计数据
+                const smList = await this.ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
+                if (smList.length > 0) {
+                    for (const sm of smList) {
+                        await this.ctx.service.scheduleLedgerMonth.calcMonthPlan(transaction, this.ctx.tender.id, sm.yearmonth);
+                        await this.ctx.service.scheduleLedgerMonth.calcMonthSj(transaction, this.ctx.tender.id, sm.yearmonth);
+                    }
+                    await this.ctx.service.scheduleMonth.calcPlan(transaction, this.ctx.tender.id);
+                    await this.ctx.service.scheduleMonth.calcSj(transaction, this.ctx.tender.id);
+                }
                 await transaction.commit();
                 return true;
             } catch (err) {

+ 7 - 7
app/view/schedule/index.ejs

@@ -19,11 +19,11 @@
                     <div class="col-12 mb-4">
                         <ul class="nav nav-tabs justify-content-center">
                             <li class="nav-item">
-                                <a class="nav-link px-5 py-2 active" href="#tp" id="tp-tab" data-toggle="tab" role="tab" aria-controls="tp" aria-selected="true">金额模式</a>
+                                <a class="nav-link px-5 py-2" href="#tp" id="tp-tab" data-toggle="tab" role="tab" aria-controls="tp" aria-selected="false">金额模式</a>
+                            </li>
+                            <li class="nav-item">
+                                <a class="nav-link px-5 py-2 active" href="#gcl" id="gcl-tab" data-toggle="tab" role="tab" aria-controls="gcl" aria-selected="true">工程量模式</a>
                             </li>
-                            <!--<li class="nav-item">-->
-                                <!--<a class="nav-link px-5 py-2" href="#gcl" id="gcl-tab" data-toggle="tab" role="tab" aria-controls="gcl" aria-selected="false">工程量模式</a>-->
-                            <!--</li>-->
                         </ul>
                     </div>
                     <!--金额概况-->
@@ -31,7 +31,7 @@
                         <div class="col-auto p-0">
                             <div class="card text-center">
                                 <div class="card-body">
-                                    <h5 class="card-title"><%- scheduleInfo ? ctx.helper.formatNum(scheduleInfo.plan_tp, '#,##0.######') : '' %> <small class="text-danger"  data-toggle="tooltip" data-placement="bottom" title="" data-original-title="占设计比例"><%- scheduleInfo && scheduleInfo.total_tp !== 0 ? ctx.helper.round(ctx.helper.div(scheduleInfo.plan_tp, scheduleInfo.total_tp)*100, 0) + '%' : '' %></small></h5>
+                                    <h5 class="card-title"><%- scheduleInfo ? ctx.helper.formatNum(scheduleInfo.plan_tp, '#,##0.######') : '' %> <small class="text-danger"  data-toggle="tooltip" data-placement="bottom" title="" data-original-title="占设计比例"><%- scheduleInfo && scheduleInfo.total_tp !== 0 && scheduleInfo.plan_tp ? ctx.helper.round(ctx.helper.div(scheduleInfo.plan_tp, scheduleInfo.total_tp)*100, 0) + '%' : '0%' %></small></h5>
                                     <p class="card-text text-muted">计划完成金额</p>
                                 </div>
                             </div>
@@ -47,14 +47,14 @@
                         <div class="col-auto pr-0">
                             <div class="card text-center">
                                 <div class="card-body">
-                                    <h5 class="card-title"><%- scheduleInfo ? ctx.helper.formatNum(scheduleInfo.sj_tp, '#,##0.######') : '' %> <small class="text-danger"  data-toggle="tooltip" data-placement="bottom" title="" data-original-title="占设计比例"><%- scheduleInfo && scheduleInfo.total_tp !== 0 ? ctx.helper.round(ctx.helper.div(scheduleInfo.sj_tp, scheduleInfo.total_tp)*100, 0) + '%' : '' %></small></h5>
+                                    <h5 class="card-title"><%- scheduleInfo ? ctx.helper.formatNum(scheduleInfo.sj_tp, '#,##0.######') : '' %> <small class="text-danger"  data-toggle="tooltip" data-placement="bottom" title="" data-original-title="占设计比例"><%- scheduleInfo && scheduleInfo.total_tp !== 0 && scheduleInfo.sj_tp ? ctx.helper.round(ctx.helper.div(scheduleInfo.sj_tp, scheduleInfo.total_tp)*100, 0) + '%' : '0%' %></small></h5>
                                     <p class="card-text text-muted">实际完成金额</p>
                                 </div>
                             </div>
                         </div>
                     </div>
                     <div class="tab-content">
-                        <div id="tp" class="tab-pane fade show active" role="tabpanel" aria-labelledby="tp-tab">
+                        <div id="gcl" class="tab-pane fade show active" role="tabpanel" aria-labelledby="gcl-tab">
                             <!--进度条-->
                             <div class="mb-3">
                                 <% if (scheduleInfo && scheduleInfo.total_tp !== 0) { %>