Pārlūkot izejas kodu

汇总对比,只统计审批完成

MaiXinRong 1 nedēļu atpakaļ
vecāks
revīzija
1b95bc3850

+ 22 - 20
app/controller/spss_controller.js

@@ -186,41 +186,43 @@ module.exports = app => {
         async _loadDealBillsData(tender) {
 
         }
-        async _getValidStages(tenderId, sort = 'desc') {
+        async _getValidStages(tenderId, sort = 'desc', checked = false) {
             const accountId = this.ctx.session.sessionUser.accountId;
-            const stages = await this.ctx.service.stage.getAllDataByCondition({ where: { tid: tenderId }, orders: [['order', sort]] });
+            const condition = { tid: tenderId };
+            if (checked) condition.status = status.checked;
+            const stages = await this.ctx.service.stage.getAllDataByCondition({ where: condition, orders: [['order', sort]] });
             return stages.filter(s => { return s.status !== status.uncheck || s.user_id === accountId; });
         }
-        async _filterOrder(tender, order) {
-            const stages = await this._getValidStages(tender.id);
+        async _filterOrder(tender, order, checked) {
+            const stages = await this._getValidStages(tender.id, 'desc', checked);
             const stage = this.ctx.helper._.find(stages, { order });
             if (stage) await this.ctx.service.stage.doCheckStage(stage);
             return { type: 'stage', stage, filter: `第${order}期` };
         }
-        async _filterMonth(tender, month) {
-            const stages = await this._getValidStages(tender.id);
+        async _filterMonth(tender, month, checked) {
+            const stages = await this._getValidStages(tender.id, 'desc', checked);
             const stage = this.ctx.helper._.find(stages, { s_time: month });
             if (stage) await this.ctx.service.stage.doCheckStage(stage);
             return { type: 'stage', stage, filter: month };
         }
-        async _filterFinal(tender) {
-            const stages = await this._getValidStages(tender.id);
+        async _filterFinal(tender, checked) {
+            const stages = await this._getValidStages(tender.id, 'desc', checked);
             const stage = stages[0];
             if (stage) await this.ctx.service.stage.doCheckStage(stage);
             return { type: 'stage', stage, filter: `第${stage.order}期` };
         }
-        async _filterCheckedFinal(tender) {
-            const stages = await this._getValidStages(tender.id);
+        async _filterCheckedFinal(tender, checked) {
+            const stages = await this._getValidStages(tender.id, 'desc', checked);
             const checkedStages = stages.filter(x => { return x.status === status.checked; });
             const stage = checkedStages[0];
             if (stage) await this.ctx.service.stage.doCheckStage(stage);
             return { type: 'stage', stage, filter: `第${stage.order}期` };
         }
-        async _filterOrderZone(tender, zone) {
+        async _filterOrderZone(tender, zone, checked) {
             let [iBegin, iEnd] = zone.split(':');
             iBegin = this.ctx.helper._.toInteger(iBegin) || 0;
             iEnd = this.ctx.helper._.toInteger(iEnd) || 0;
-            const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
+            const stages = await this._getValidStages(tender.id, 'asc', checked), validStages = [];
             let preStage, endStage;
             for (const stage of stages) {
                 if (stage.order < iBegin) {
@@ -233,13 +235,13 @@ module.exports = app => {
             }
             return { type: 'stages', stages: validStages, preStage, endStage, filter: `第${iBegin}期 ~ 第${iEnd}期` };
         }
-        async _filterTimeZone(tender, zone) {
+        async _filterTimeZone(tender, zone, checked) {
             const times = zone.split(' - ');
             if (times.length !== 2) throw '选择的汇总周期无效';
             const beginTime = moment(times[0], 'YYYY-MM');
             const endTime = moment(times[1], 'YYYY-MM');
 
-            const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
+            const stages = await this._getValidStages(tender.id, 'asc', checked), validStages = [];
             let preStage, endStage;
             for (const stage of stages) {
                 const sTime = moment(stage.s_time, 'YYYY-MM');
@@ -256,17 +258,17 @@ module.exports = app => {
         async _filterStages(tender, stageInfo) {
             switch (stageInfo.type) {
                 case 'stage':
-                    return await this._filterOrder(tender, stageInfo.stage);
+                    return await this._filterOrder(tender, stageInfo.stage, stageInfo.checked);
                 case 'month':
-                    return await this._filterMonth(tender, stageInfo.month);
+                    return await this._filterMonth(tender, stageInfo.month, stageInfo.checked);
                 case 'final':
-                    return await this._filterFinal(tender);
+                    return await this._filterFinal(tender, stageInfo.checked);
                 case 'checked-final':
-                    return await this._filterCheckedFinal(tender);
+                    return await this._filterCheckedFinal(tender, stageInfo.checked);
                 case 'zone':
-                    return await this._filterTimeZone(tender, stageInfo.zone);
+                    return await this._filterTimeZone(tender, stageInfo.zone, stageInfo.checked);
                 case 'stage-zone':
-                    return await this._filterOrderZone(tender, stageInfo.stage_zone);
+                    return await this._filterOrderZone(tender, stageInfo.stage_zone, stageInfo.checked);
                 default:
                     return;
             }

+ 4 - 3
app/public/js/shares/tender_select_multi.js

@@ -138,7 +138,8 @@ const TenderSelectMulti = function (setting) {
             });
         },
         getSelectData: function() {
-            const selectData =  tsObj.trArray;
+            const selectData = tsObj.trArray;
+            const checked = $('#tsm-filter-checked')[0].checked;
             if (selectData.length === 0) {
                 toastr.warning('请选择标段');
                 return;
@@ -154,13 +155,13 @@ const TenderSelectMulti = function (setting) {
                             toastr.warning('请选择标段进行对比的期');
                             return;
                         }
-                        s.stageInfo = { type: 'stage', stage: s.stage };
+                        s.stageInfo = { type: 'stage', stage: s.stage, checked };
                     }
                 }
             }
             if (this.setting.type === 'gather' && this.setting.dataType === 'stage') {
                 // todo 检查汇总选项
-                const stage = { type: $('[name=tsm-source]:checked').val() };
+                const stage = { type: $('[name=tsm-source]:checked').val(), checked };
                 if (stage.type === 'stage') {
                     stage.stage = _.toInteger($('#gather-stage').val()) || 0;
                     if (!stage.stage) {

+ 0 - 1
app/view/budget/compare_modal.ejs

@@ -30,7 +30,6 @@
                         <button type="button" class="btn btn-sm btn-primary ml-1" id="select-final-ok">确定</button>
                     </div>
                 </div>
-            </div>iv>
             </div>
         </div>
     </div>

+ 4 - 0
app/view/spss/spss_select_modal.ejs

@@ -87,6 +87,10 @@
                                 </div>
                             </div>
                         </div>
+                        <div class="form-check form-check-inline ml-2">
+                            <input class="form-check-input" type="checkbox" id="tsm-filter-checked">
+                            <label class="form-check-label" for="tsm-filter-checked">仅统计审批完成</label>
+                        </div>
                     </div>
                 </div>
                 <div class="d-flex">