Browse Source

设置其他流程

MaiXinRong 9 months ago
parent
commit
e444ea66ce
2 changed files with 43 additions and 28 deletions
  1. 24 18
      app/public/js/shenpi.js
  2. 19 10
      app/service/shenpi_audit.js

+ 24 - 18
app/public/js/shenpi.js

@@ -681,30 +681,36 @@ $(document).ready(function () {
     $('body').on('click', '.set-otherShenpi', function () {
         let canSetOther = true;
         const this_code = $(this).data('code');
-        if (['stage', 'change'].indexOf(this_code) !== -1) {
-            const select = $(this).siblings('.lc-show').find('select[class*="audit-type-key"]');
-            select.each((i, s) => {
-                if (s.value !== '1') canSetOther = false;
-            });
-        }
-        if (!canSetOther) {
-            toastr.warning('该流程含有会签或签,不可同步至其他流程');
-            $('#batch2').modal('hide');
-            return;
-        }
+        // if (['stage', 'change'].indexOf(this_code) !== -1) {
+        //     const select = $(this).siblings('.lc-show').find('select[class*="audit-type-key"]');
+        //     select.each((i, s) => {
+        //         if (s.value !== '1') canSetOther = false;
+        //     });
+        // }
+        // if (!canSetOther) {
+        //     toastr.warning('该流程含有会签或签,不可同步至其他流程');
+        //     $('#batch2').modal('hide');
+        //     return;
+        // }
 
         const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
-        const aid_num = $(this).siblings('.lc-show').children('ul').find('.remove-audit').length;
-        const aidList = [];
-        for (let i = 0; i < aid_num; i++) {
-            const aid = parseInt($(this).siblings('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
-            aidList.push(aid);
+        const copyFlow = [];
+        const flow = $('li.d-flex', $(this).siblings('.lc-show'));
+        for (const f of flow) {
+            const audit_type = $('select', f).val();
+            const auditors = $('.remove-audit', f);
+            if (auditors.length === 0) continue;
+            const aid = [];
+            for (const a of auditors) {
+                aid.push(a.getAttribute('data-id'));
+            }
+            copyFlow.push(`${audit_type}:${aid.join(',')}`);
         }
         const html = getShenpiHtml(this_code);
         $('#shenpi-name2').text($(this).data('name'));
         $('#shenpi_code2').val(this_code);
         $('#shenpi_status2').val(this_status);
-        $('#shenpi_auditors2').val(aidList.join(','));
+        $('#shenpi_auditors2').val(copyFlow.join(';'));
         $('#shenpi-list').html(html);
         setTimeout(function () { $("#shenpi-list [data-toggle='tooltip']").tooltip(); },800);
         $('#batch2').modal('show');
@@ -724,7 +730,7 @@ $(document).ready(function () {
             code: $('#shenpi_code2').val(),
         };
         if(data.status !== shenpi_status.gdspl) {
-            data.aidList = $('#shenpi_auditors2').val();
+            data.flowList = $('#shenpi_auditors2').val();
         }
         // 获取已选中的标段
         const shenpiList = [];

+ 19 - 10
app/service/shenpi_audit.js

@@ -291,17 +291,26 @@ module.exports = app => {
                             }
                         }
                         await transaction.delete(this.tableName, { tid: this.ctx.tender.id, sp_type: shenpiConst.sp_type[code], sp_status: shenpiInfo[code] });
-                        for (const aid of data.aidList.split(',')) {
-                            if (aid && parseInt(aid) !== this.ctx.tender.data.user_id || (parseInt(aid) === this.ctx.tender.data.user_id && needYB.indexOf(code) !== -1)) {
-                                const insertData = {
-                                    tid: this.ctx.tender.id,
-                                    sp_type: shenpiConst.sp_type[code],
-                                    sp_status: shenpi_status,
-                                    audit_id: parseInt(aid),
-                                    audit_order: insertList.length + 1,
-                                };
-                                insertList.push(insertData);
+                        const flows = data.flowList.split(';');
+                        let audit_order = 1;
+                        for (const f of flows) {
+                            const audit_type = parseInt(f.split(':')[0]);
+                            const auditTypeInfo = auditType.info[audit_type];
+                            const auditTypeValid = !auditTypeInfo.valid || auditTypeInfo.valid.indexOf(code) >= 0;
+                            const auditIds = f.split(':')[1].split(',').map(x => { return parseInt(x)});
+                            for (const aid of auditIds) {
+                                if (aid !== this.ctx.tender.data.user_id || needYB.indexOf(code) >= 0) {
+                                    insertList.push({
+                                        tid: this.ctx.tender.id,
+                                        sp_type: shenpiConst.sp_type[code], sp_status: shenpi_status,
+                                        audit_id: aid,
+                                        audit_type: auditTypeValid ? audit_type : auditType.key.common,
+                                        audit_order: audit_order,
+                                    });
+                                    if (!auditTypeValid) audit_order++;
+                                }
                             }
+                            if (auditTypeValid) audit_order++;
                         }
                     }
                 }