Просмотр исходного кода

台账修订中禁止进度任何操作

laiguoran 4 лет назад
Родитель
Сommit
fde1bce6da

+ 21 - 0
app/controller/schedule_controller.js

@@ -9,6 +9,7 @@
  */
 
 const moment = require('moment');
+const reviseStatus = require('../const/audit').revise.status;
 const measureType = require('../const/tender').measureType;
 const scheduleConst = require('../const/schedule');
 const billsPosConvert = require('../lib/bills_pos_convert');
@@ -27,6 +28,17 @@ module.exports = app => {
             return lastMonth && lastMonth[0] && lastMonth[0].yearmonth ? lastMonth[0].yearmonth : null;
         }
 
+        async _getLastReviseStatus(ctx) {
+            const lastRevise = await ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id);
+            return (lastRevise && lastRevise.status !== reviseStatus.checked) || false;
+        }
+
+        async _checkScheduleCanModify(ctx) {
+            if (await this._getLastReviseStatus(ctx)) {
+                throw '台账修订中,请勿修改提交进度数据';
+            }
+        }
+
         async index(ctx) {
             try {
                 const scheduleInfo = await ctx.service.schedule.getDataByCondition({ tid: ctx.tender.id });
@@ -39,6 +51,7 @@ module.exports = app => {
                     planMonth: await this._getLastPlanMonth(ctx),
                     scheduleLedgerList: await this._getSelectedLedgerList(ctx),
                     preUrl: '/tender/' + ctx.tender.id,
+                    revising: await this._getLastReviseStatus(ctx),
                 };
                 await this.layout('schedule/index.ejs', renderData, 'schedule/modal.ejs');
             } catch (err) {
@@ -70,6 +83,7 @@ module.exports = app => {
                 scheduleLedgerList,
                 hadDataLidList,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.ledger),
+                revising: await this._getLastReviseStatus(ctx),
             };
             await this.layout('schedule/ledger.ejs', renderData);
         }
@@ -88,6 +102,7 @@ module.exports = app => {
                 mode: scheduleConst.plan_mode,
                 scheduleLedgerList: await this._getSelectedLedgerList(ctx),
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.plan),
+                revising: await this._getLastReviseStatus(ctx),
             };
             await this.layout('schedule/plan.ejs', renderData, 'schedule/plan_modal.ejs');
         }
@@ -150,6 +165,7 @@ module.exports = app => {
                 yearSlmList,
                 curYearStageData,
                 scheduleLedgerList: await this._getSelectedLedgerList(ctx),
+                revising: await this._getLastReviseStatus(ctx),
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.stageTp),
             };
             await this.layout('schedule/stage_tp.ejs', renderData, 'schedule/stage_tp_modal.ejs');
@@ -170,6 +186,7 @@ module.exports = app => {
                 scheduleStage,
                 curScheduleStage,
                 scheduleLedgerList: await this._getSelectedLedgerList(ctx),
+                revising: await this._getLastReviseStatus(ctx),
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.stageGcl),
             };
             await this.layout('schedule/stage_gcl.ejs', renderData, 'schedule/stage_gcl_modal.ejs');
@@ -266,6 +283,7 @@ module.exports = app => {
          */
         async saveLedger(ctx) {
             try {
+                await this._checkScheduleCanModify(ctx);
                 const data = JSON.parse(ctx.request.body.data);
                 const result = await ctx.service.scheduleLedger.saveLedger(data);
                 ctx.body = { err: 0, msg: '', data: result };
@@ -283,6 +301,7 @@ module.exports = app => {
          */
         async savePlan(ctx) {
             try {
+                await this._checkScheduleCanModify(ctx);
                 const data = JSON.parse(ctx.request.body.data);
                 const responseData = {
                     err: 0,
@@ -319,6 +338,7 @@ module.exports = app => {
          */
         async saveStageTp(ctx) {
             try {
+                await this._checkScheduleCanModify(ctx);
                 const data = JSON.parse(ctx.request.body.data);
                 const responseData = {
                     err: 0,
@@ -352,6 +372,7 @@ module.exports = app => {
          */
         async saveStageGcl(ctx) {
             try {
+                await this._checkScheduleCanModify(ctx);
                 const data = JSON.parse(ctx.request.body.data);
                 const responseData = {
                     err: 0,

+ 2 - 2
app/public/js/schedule_plan.js

@@ -79,14 +79,14 @@ $(function () {
                 if (data.is_leaf) {
                     flag = schedule && schedule.mode === mode.tp;
                 }
-                return !flag;
+                return !(flag && !revising);
             },
             gcl: function (data) {
                 let flag = data.is_leaf;
                 if (data.is_leaf) {
                     flag = schedule && schedule.mode === mode.gcl;
                 }
-                return !flag;
+                return !(flag && !revising);
             },
         },
     };

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

@@ -82,7 +82,7 @@ $(function () {
     const ledgerCol = {
         readOnly: {
             gcl: function (data) {
-                return !data.is_leaf;
+                return !(data.is_leaf && !revising);
             },
         },
     };

+ 1 - 1
app/view/schedule/ledger.ejs

@@ -29,7 +29,7 @@
                     </a>
                 </div>
             </div>
-            <% if (tender.user_id === ctx.session.sessionUser.accountId) { %>
+            <% if (tender.user_id === ctx.session.sessionUser.accountId && !revising) { %>
             <div class="ml-auto">
                 <button type="button" id="ledger_submit" class="btn btn-primary btn-sm pull-right">确认提交</button>
             </div>

+ 23 - 1
app/view/schedule/modal.ejs

@@ -1,3 +1,4 @@
+<% if (scheduleLedgerList.length === 0 && !revising) { %>
 <!--首次使用提示-->
 <div class="modal fade" id="first" data-backdrop="static">
     <div class="modal-dialog" role="document">
@@ -23,12 +24,33 @@
         </div>
     </div>
 </div>
+<% } %>
+<% if (scheduleLedgerList.length !== 0 && revising) { %>
+    <!--正在修订提示-->
+    <div class="modal fade" id="unedit" data-backdrop="static">
+        <div class="modal-dialog " role="document" >
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">提示</h5>
+                </div>
+                <div class="modal-body">
+                    <h5>台账正在进行修订,形象进度无法进行任何操作。</h5>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">好的</button>
+                </div>
+            </div>
+        </div>
+    </div>
+    <script type="text/javascript">$('#unedit').modal('show');</script>
+<% } %>
 <script>
     const selectedLedgerList = JSON.parse('<%- JSON.stringify(scheduleLedgerList) %>');
+    const revising = <%- revising %>;
 </script>
 <script type="text/javascript">
     $(function () {
-        if (selectedLedgerList.length === 0) {
+        if (selectedLedgerList.length === 0 && !revising) {
             $('#first').modal('show');
         }
     })

+ 2 - 0
app/view/schedule/plan.ejs

@@ -6,11 +6,13 @@
             <h2>
                 <% if (planMonth) { %>计划至 <%- planMonth.split('-')[0] %>年<%- parseInt(planMonth.split('-')[1]) %>月 <% } %>
             </h2>
+            <% if (!revising) { %>
             <div class="ml-auto">
                 <a href="#mode" data-toggle="modal" data-target="#mode" class="btn btn-sm btn-outline-primary">计算方式</a>
                 <a href="#edit-plan" data-toggle="modal" data-target="#edit-plan" class="btn btn-sm btn-outline-primary">管理计划</a>
                 <a href="#add-plan" data-toggle="modal" data-target="#add-plan" class="btn btn-sm btn-primary">新增计划</a>
             </div>
+            <% } %>
         </div>
     </div>
     <div class="content-wrap">

+ 2 - 0
app/view/schedule/stage_gcl.ejs

@@ -15,10 +15,12 @@
                     </div>
                 </div>
             </div>
+            <% if (!revising) { %>
             <div class="ml-auto">
                 <a href="#edit-stage" data-toggle="modal" data-target="#edit-stage" class="btn btn-sm btn-outline-primary">管理计量</a>
                 <a href="#add" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#add">创建实际计量</a>
             </div>
+            <% } %>
         </div>
     </div>
     <div class="content-wrap">

+ 4 - 0
app/view/schedule/stage_tp.ejs

@@ -29,17 +29,21 @@
                         </div>
                     </div>
                 </div>
+                <% if (!revising) { %>
                 <div class="d-inline-flex">
                     <a href="#delete" data-toggle="modal" data-target="#delete" class="btn btn-sm btn-outline-danger">删除本期进度</a>
                 </div>
                 <% } %>
+                <% } %>
             </div>
+            <% if (!revising) { %>
             <div class="ml-auto">
                 <a href="" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#add">创建新计量进度</a>
                 <% if (scheduleStage.length > 0) { %>
                 <a href="" class="btn btn-sm btn-warning" data-toggle="modal" data-target="#re-build">重新生成本月进度</a>
                 <% } %>
             </div>
+            <% } %>
         </div>
     </div>
     <div class="content-wrap">