소스 검색

task#3418

TonyKang 4 년 전
부모
커밋
d403631ef5
5개의 변경된 파일61개의 추가작업 그리고 56개의 파일을 삭제
  1. 24 18
      app/controller/report_controller.js
  2. 4 1
      app/controller/signature_controller.js
  3. 12 12
      app/public/report/js/rpt_signature.js
  4. 19 23
      app/service/role_rpt_rel.js
  5. 2 2
      app/view/report/rpt_all_popup.ejs

+ 24 - 18
app/controller/report_controller.js

@@ -814,7 +814,9 @@ async function getAllPagesCommon(ctx, rptTpl, params, option, outputType, baseDi
         }
         const dftOption = params.option || JV.PAGING_OPTION_NORMAL;
         printCom.initialize(rptTpl);
-        // ctx.helper
+        // 在ctx.helper里夹带私货,增加当前期status及times
+        // ctx.helper.current_stage_status = params.stage_status;
+        // ctx.helper.current_stage_times = params.stage_times;
         printCom.analyzeData(ctx.helper, rptTpl, tplData, defProperties, dftOption, outputType, customSelect);
         // console.log(JSON.stringify(rptTpl));
         const maxPages = printCom.totalPages;
@@ -1191,27 +1193,31 @@ function fillWaterMark(pageRstArray) {
 async function encodeSignatureDataUri(roleRel, baseDir) {
     if (roleRel) {
         for (const singleRoleRel of roleRel) {
-            const roleRelContent = JSON.parse(singleRoleRel.rel_content);
-            for (const role of roleRelContent) {
-                // console.log(role);
-                if (role.sign_path !== '') {
-                    const filePath = baseDir + '/app' + role.sign_path;
-                    try {
-                        const res = await isFileExisted(filePath);
-                        if (res) {
-                            const bData = fs.readFileSync(filePath);
-                            const base64Str = bData.toString('base64');
-                            const datauri = 'data:image/png;base64,' + base64Str;
-                            role.sign_pic = datauri;
-                        } else {
-                            console.log('文件不存在:' + filePath);
+            if (singleRoleRel.rel_content !== null && singleRoleRel.rel_content !== undefined && singleRoleRel.rel_content !== '') {
+                const roleRelContent = JSON.parse(singleRoleRel.rel_content);
+                for (const role of roleRelContent) {
+                    // console.log(role);
+                    if (role.sign_path !== '') {
+                        const filePath = baseDir + '/app' + role.sign_path;
+                        try {
+                            const res = await isFileExisted(filePath);
+                            if (res) {
+                                const bData = fs.readFileSync(filePath);
+                                const base64Str = bData.toString('base64');
+                                const datauri = 'data:image/png;base64,' + base64Str;
+                                role.sign_pic = datauri;
+                            } else {
+                                console.log('文件不存在:' + filePath);
+                            }
+                        } catch (err) {
+                            console.error(err);
                         }
-                    } catch (err) {
-                        console.error(err);
                     }
                 }
+                singleRoleRel.rel_content = JSON.stringify(roleRelContent);
+            } else {
+                singleRoleRel.rel_content = [];
             }
-            singleRoleRel.rel_content = JSON.stringify(roleRelContent);
         }
     }
 }

+ 4 - 1
app/controller/signature_controller.js

@@ -77,8 +77,11 @@ module.exports = app => {
         async updateCrossTendersRoleRelationship(ctx) {
             const params = JSON.parse(ctx.request.body.params);
             const conParams = params.selectedTenders;
-            const roleRel = params.originalRoleRelList;
+            // conParams.push([params.tender_id, params.stage_id, params.rpt_id]); // 传过来的数据是额外项目的,还需要加上自己一个
+            const roleRel = params.rel_content;
             // updateMultiRoleRelationship
+            // console.log(params.rel_content);
+            await ctx.service.roleRptRel.updateRoleRelationship(params.id, params.tender_id, params.rpt_id, params.stage_id, params.rel_content); // 传过来的数据是额外项目的,还需要单独处理当前的
             const rst = await ctx.service.roleRptRel.updateMultiRoleRelationship(conParams, roleRel);
             ctx.body = { data: rst };
             ctx.status = 201;

+ 12 - 12
app/public/report/js/rpt_signature.js

@@ -435,18 +435,18 @@ let rptSignatureHelper = {
         params.rel_content = ROLE_REL_LIST;
         params.selectedTenders = selectedTenders;
         rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
-        // CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken'),
-        //     function(result){
-        //         console.log(result);
-        //         if (result.data && result.data.insertId > 0) {
-        //             CURRENT_ROLE_REL_ID = result.data.insertId;
-        //         }
-        //     }, function(err){
-        //         // hintBox.unWaitBox();
-        //     }, function(ex){
-        //         // hintBox.unWaitBox();
-        //     }
-        // );
+        CommonAjax.postXsrfEx("/tender/report_api/updateMultiRoleRelationship", params, 10000, true, getCookie('csrfToken'),
+            function(result){
+                console.log(result);
+                if (result.data && result.data.insertId > 0) {
+                    CURRENT_ROLE_REL_ID = result.data.insertId;
+                }
+            }, function(err){
+                // hintBox.unWaitBox();
+            }, function(ex){
+                // hintBox.unWaitBox();
+            }
+        );
     },
     setupAfterSelectSignature: function () {
         //0. 签名日期

+ 19 - 23
app/service/role_rpt_rel.js

@@ -110,11 +110,12 @@ module.exports = app => {
             this.transaction = await this.db.beginTransaction();
             try {
                 const data = {
-                    tender_id: tender_id,
-                    rpt_id: rpt_id,
-                    sid: sid,
+                    tender_id,
+                    rpt_id,
+                    sid,
                     rel_content: JSON.stringify(relArr),
                 };
+                // console.log(data);
                 rst = await this.transaction.insert(this.tableName, data);
                 await this.transaction.commit();
             } catch (ex) {
@@ -153,13 +154,13 @@ module.exports = app => {
         async updateRoleRelationship(id, tender_id, rpt_id, sid, relArr) {
             let rst = null;
             if (id < 0) {
-                rst = this.createRoleRelationship(tender_id, rpt_id, sid, relArr);
+                rst = await this.createRoleRelationship(tender_id, rpt_id, sid, relArr);
             } else {
                 this.transaction = await this.db.beginTransaction();
                 try {
-                    const data = { id: id, tender_id: tender_id, rpt_id: rpt_id, sid: sid, rel_content: JSON.stringify(relArr) };
+                    const data = { id, tender_id, rpt_id, sid, rel_content: JSON.stringify(relArr) };
                     rst = await this.transaction.update(this.tableName, data);
-                    this.transaction.commit();
+                    await this.transaction.commit();
                 } catch (ex) {
                     console.log(ex);
                     // 回滚
@@ -170,26 +171,21 @@ module.exports = app => {
         }
 
         async updateMultiRoleRelationship(orgParams, newRelArr) {
-            let rst = false;
-            this.transaction = await this.db.beginTransaction();
-            try {
-                // const data = { id: id, tender_id: tender_id, rpt_id: rpt_id, sid: sid, rel_content: JSON.stringify(relArr) };
-                // rst = await this.transaction.update(this.tableName, data);
-                // this.transaction.commit();
-                for (let idx = 0; idx < orgParams.length; idx++) {
-                    const param = orgParams[idx];
-                    const data = { tender_id: param[0], sid: param[1], rpt_id: param[2] };
+            for (let idx = 0; idx < orgParams.length; idx++) {
+                const param = orgParams[idx];
+                const data = { tender_id: param[0], sid: param[1], rpt_id: param[2] };
+                this.transaction = await this.db.beginTransaction();
+                try {
                     await this.transaction.delete(this.tableName, data);
-                    this.createRoleRelationship(param[0], param[2], param[0], newRelArr);
+                    this.transaction.commit();
+                    await this.createRoleRelationship(param[0], param[2], param[1], newRelArr);
+                } catch (ex) {
+                    console.log(ex.toString());
+                    // 回滚
+                    await this.transaction.rollback();
                 }
-                rst = true;
-                this.transaction.commit();
-            } catch (ex) {
-                console.log(ex.toString());
-                // 回滚
-                await this.transaction.rollback();
             }
-            return rst;
+            return true;
         }
     }
     return RoleRptRel;

+ 2 - 2
app/view/report/rpt_all_popup.ejs

@@ -203,8 +203,8 @@
             <div class="modal-body" id="eSignatureBodyDiv">
             </div>
             <div class="modal-footer">
-                <!--
                 <button type="button" id="btn_cross_tender" class="btn btn-sm btn-link float-left" data-dismiss="modal" data-toggle="modal" data-target="#batch-eSignature" id="batch-setupProjSignature" onclick="rptSignatureHelper.resetESignature(zTreeOprObj.currentRptPageRst, 'batch-eSignatureBodyDiv'); buildTendersTree();">批量设置其他标段</button>
+                <!--
 
                 <button type="button" class="btn btn-sm btn-link float-left" data-toggle="modal" data-target="#batch-eSignature" id="hidden_show_batch_eSignature" style="display:none"></button>
                 <button type="button" class="btn btn-sm btn-link float-left" data-dismiss="modal" onclick="setTimeout(function(){$('#hidden_show_batch_eSignature').trigger('click');}, 50);">批量设置其他标段</button>
@@ -236,7 +236,7 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
-                <a href="javascript:void(0);" onclick="rptSignatureHelper.setupAfterSelectMultiTenders(SELECTED_TENDERS)" class="btn btn-sm btn-primary">确定</a>
+                <a href="javascript:void(0);" onclick="rptSignatureHelper.setupAfterSelectMultiTenders(SELECTED_TENDERS)" class="btn btn-sm btn-primary" data-dismiss="modal">确定</a>
             </div>
         </div>
     </div>