Selaa lähdekoodia

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

laiguoran 4 vuotta sitten
vanhempi
commit
6078846ac4

+ 1 - 0
.gitignore

@@ -11,6 +11,7 @@ app/public/upload/
 *.swp
 package-lock.json
 app/public/js/web
+app/public/archive
 .vscode/
 /report_temp
 /file

+ 35 - 0
app/controller/advance_controller.js

@@ -227,6 +227,41 @@ module.exports = app => {
         }
 
         /**
+         * 删除期
+         * @param {*} ctx 全局上下文
+         */
+        async delete(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                const id = data && this.app._.toInteger(data.id);
+                if (isNaN(id) || id <= 0) {
+                    throw '参数错误';
+                }
+                const advance = await ctx.service.advance.getDataById(id);
+                if (!advance) {
+                    throw '参数错误';
+                }
+                // 检查权限等
+                if (advance.uid !== ctx.session.sessionUser.accountId) {
+                    throw '您无权删除';
+                }
+                if (advance.status !== auditConst.status.uncheck && advance.status !== auditConst.status.checkNo) {
+                    console.log(advance.status !== auditConst.status.uncheck);
+                    console.log(advance.status !== auditConst.status.checkNo);
+                    throw '当前不允许删除';
+                }
+                const isDeleted = await ctx.service.advance.deleteAdvance(id);
+                if (!isDeleted) {
+                    throw '删除失败,请重试';
+                }
+                ctx.body = { err: 0, msg: '' };
+            } catch (error) {
+                this.log(error);
+                ctx.body = { err: 1, msg: error.toString(), data: null };
+            }
+        }
+
+        /**
          * 添加审批人
          * @param {Object} ctx 全局上下文
          */

+ 2 - 2
app/controller/report_archive_controller.js

@@ -14,7 +14,7 @@ const fsUtil = require('../public/js/fsUtil');
 const auditConst = require('../const/audit');
 
 module.exports = app => {
-    class ReportController extends app.BaseController {
+    class ReportArchiveController extends app.BaseController {
 
         async index(ctx) {
             const tender = ctx.tender;
@@ -270,6 +270,6 @@ module.exports = app => {
         }
 
     }
-    return ReportController;
+    return ReportArchiveController;
 };
 

+ 12 - 0
app/public/js/advance.js

@@ -213,6 +213,18 @@ $(document).ready(function () {
             $('#audit-list').append(historyHTML)
         })
     })
+
+    $('a[data-target="#del-qi"').on('click', function () {
+      const id = $(this).data('id')
+      const order = $(this).data('order') //期数
+      $('#del-qi').find('.modal-body').children()[0].innerText = `确认删除「第${order}期」?`
+      $('#del-qi #del-confirm').click(function() {
+        postData(`${window.location.pathname}/delete`, {id}, (res) => {
+          console.log(res);
+          window.location.reload()
+        })
+      })
+    })
     function formatMoney(s, dot = ',', decimal = 2) {
         if (!s) {
             s = 0;

+ 9 - 0
app/public/report/js/rpt_archive.js

@@ -179,6 +179,7 @@ let rptArchiveObj = {
         //初始化当前报表已经归档的信息
         //ARCHIVE_LIST结构:[{rpt_id, items: [{uuid, update_time, is_common}...最多3个]}...] (当前项目、当前期的所有报表归档信息)
         if (currentNode) {
+            //1. cardArchiveInfo
             let cardArchiveInfo = $('#cardArchiveInfo');
             cardArchiveInfo.empty();
             let auditDate = null;
@@ -217,6 +218,14 @@ let rptArchiveObj = {
                 }
             }
             cardArchiveInfo.append('</div>');
+            //2. selectionArchiveInfo
+            let selectionArchiveInfo = $('#selectionArchiveInfo');
+            selectionArchiveInfo.empty();
+            if (achivedAmt > 0) {
+                for (let idx = 0; idx < achivedItem.items.length; idx++) {
+                    selectionArchiveInfo.append('<a class="dropdown-item" href="javascript: void(0);">#' + (idx + 1) + ' ' + achivedItem.items[idx].updateDate_time + '</a>');
+                }
+            }
         }
     },
     _getCurrentArchives: function (currentNode) {

+ 1 - 0
app/router.js

@@ -133,6 +133,7 @@ module.exports = app => {
     app.get('/tender/:id/advance', sessionAuth, tenderCheck, 'advanceController.index');
     app.get('/tender/:id/advance/material', sessionAuth, tenderCheck, 'advanceController.materialList');
     app.post('/tender/:id/advance/create', sessionAuth, tenderCheck, 'advanceController.create');
+    app.post('/tender/:id/advance/delete', sessionAuth, tenderCheck, 'advanceController.delete');
     app.get('/tender/:id/advance/:order/detail', sessionAuth, tenderCheck, advanceCheck, 'advanceController.detail');
     app.post('/tender/:id/advance/:type/create', sessionAuth, tenderCheck, 'advanceController.create');
     app.post('/tender/:id/advance/:order/audit/add', sessionAuth, tenderCheck, advanceCheck, 'advanceController.addAudit');

+ 7 - 0
app/service/advance.js

@@ -200,7 +200,14 @@ module.exports = app => {
             return await this.update(payload, {
                 id,
             });
+        }
 
+        /**
+         * 删除预付款记录
+         * @param {String} id 预付款id
+         */
+        async deleteAdvance(id) {
+            return await this.deleteById(id);
         }
     }
     return Advance;

+ 2 - 1
app/view/advance/index.ejs

@@ -52,7 +52,7 @@
                             <th class="text-center" width="15%">截止本期金额</th>
                             <th class="text-center">附件</th>
                             <th class="text-center">进度</th>
-                            <th class="text-center" width="100">操作</th>
+                            <th class="text-center" width="150">操作</th>
                         </tr>
                     </thead>
                     <tbody id="advanceList">
@@ -76,6 +76,7 @@
                                 <td>
                                     <% if((item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) && item.uid === ctx.session.sessionUser.accountId) { %>
                                         <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-primary btn-sm">编辑</a>
+                                        <a href="del-qi" class="btn btn-outline-danger btn-sm ml-1" data-toggle="modal" data-target="#del-qi" data-id="<%- item.id %>" data-order="<%- item.order %>">删除</a>
                                     <% } else if(item.status === auditConst.status.checking && item.curAuditor.audit_id === ctx.session.sessionUser.accountId) {%>
                                         <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-success btn-sm">审批</a>
                                     <% } else {%>

+ 17 - 0
app/view/advance/modal.ejs

@@ -60,6 +60,23 @@
         </div>
     </div>
 </div>
+<div class="modal fade" id="del-qi" 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">
+            <h6>确认删除「第3期」?</h6>
+            <h6>删除后,数据无法恢复,请谨慎操作。</h6>
+          </div>
+          <div class="modal-footer">
+            <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            <button type="button" class="btn btn-danger" id="del-confirm">确定删除</button>
+          </div>
+      </div>
+  </div>
+</div>
 <script>
     // 展开历史审核记录
     $('#audit-list').on('click', 'a', function() {

+ 18 - 9
app/view/report/index.ejs

@@ -73,11 +73,7 @@
                                             <button id="btnArchiveList" type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" disabled>
                                                 已归档
                                             </button>
-                                            <div class="dropdown-menu" aria-labelledby="btnGroupDrop1" style="min-width:112px">
-                                                <!--
-                                                <a class="dropdown-item" href="#">#1 2021-03-01</a>
-                                                <a class="dropdown-item" href="#">#2 2021-02-28</a>
-                                                -->
+                                            <div class="dropdown-menu" aria-labelledby="btnGroupDrop1" style="min-width:112px" id="selectionArchiveInfo">
                                             </div>
                                         </div>
                                     </div>
@@ -536,10 +532,23 @@
                 break;
             }
         }
-        buildStageSelection();
-        setupSignature();
-        //还有必要触发报表刷新!
-        zTreeOprObj.onClick(null, null, zTreeOprObj.currentNode);
+        let params = {prjId: PROJECT_ID, stgId: current_stage_id};
+        $.bootstrapLoading.start();
+        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive", params, 10000, true, getCookie('csrfToken_j'),
+            function(result){
+                $.bootstrapLoading.end();
+                ARCHIVE_LIST = result.data;
+                buildStageSelection();
+                setupSignature();
+                //还有必要触发报表刷新!
+                zTreeOprObj.onClick(null, null, zTreeOprObj.currentNode);
+                //console.log(ARCHIVE_LIST);
+            }, function(err){
+                $.bootstrapLoading.end();
+            }, function(ex){
+                $.bootstrapLoading.end();
+            }
+        );
     }
 
     function setupSignature() {

+ 1 - 1
app/view/report/index_archive.ejs

@@ -276,7 +276,7 @@
         //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);
         const params = {prjId: PROJECT_ID, stgId: current_stage_id};
         $.bootstrapLoading.start();
-        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive", params, 10000, true, getCookie('csrfToken'),
+        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive", params, 10000, true, getCookie('csrfToken_j'),
             function(result){
                 $.bootstrapLoading.end();
                 // console.log(result);