Pārlūkot izejas kodu

会签或签,设置其他标段

MaiXinRong 2 gadi atpakaļ
vecāks
revīzija
a132644efa
2 mainītis faili ar 30 papildinājumiem un 17 dzēšanām
  1. 15 8
      app/public/js/shenpi.js
  2. 15 9
      app/service/shenpi_audit.js

+ 15 - 8
app/public/js/shenpi.js

@@ -632,17 +632,24 @@ $(document).ready(function () {
     $('.set-otherTender').on('click', function () {
         const this_code = $(this).data('code');
         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 lis = $(this).siblings('.lc-show').find('li');
+        const auditList = [], aidList = [];
+        lis.each((i, li) => {
+            const removes = $(li).find('.remove-audit');
+            if (removes.length === 0) return;
+
+            const select = $(li).find('select');
+            const audit_type = select.length > 0 ? parseInt(select.val()) : 1;
+            for (const remove of removes) {
+                auditList.push({ audit_id: parseInt(remove.getAttribute('data-id')), audit_type, audit_order: i + 1 });
+                aidList.push(parseInt(remove.getAttribute('data-id')));
+            }
+        });
         const html = getTenderTreeHtml(this_code, this_status, aidList);
         $('#shenpi-name').text($(this).data('name'));
         $('#shenpi_code').val(this_code);
         $('#shenpi_status').val(this_status);
-        $('#shenpi_auditors').val(aidList.join(','));
+        $('#shenpi_auditors').val(JSON.stringify(auditList));
         $('#tender-list').html(html);
         $('#search-audit').val('');
         $('#search-result').text('0/0');
@@ -664,7 +671,7 @@ $(document).ready(function () {
             code: $('#shenpi_code').val(),
         };
         if(data.status !== shenpi_status.gdspl) {
-            data.aidList = $('#shenpi_auditors').val();
+            data.auditList = JSON.parse($('#shenpi_auditors').val());
         }
         // 获取已选中的标段
         const tenderList = [];

+ 15 - 9
app/service/shenpi_audit.js

@@ -159,16 +159,22 @@ module.exports = app => {
                 for (const t of tenders) {
                     if (shenpi_status !== shenpiConst.sp_status.sqspr) {
                         await transaction.delete(this.tableName, { tid: t.id, sp_type: shenpiConst.sp_type[data.code], sp_status: shenpi_status });
-                        for (const aid of data.aidList.split(',')) {
-                            if (aid && parseInt(aid) !== t.user_id || (parseInt(aid) === t.user_id && canYB)) {
-                                const insertData = {
-                                    tid: t.id,
-                                    sp_type: shenpiConst.sp_type[data.code],
-                                    sp_status: shenpi_status,
-                                    audit_id: parseInt(aid),
-                                };
-                                insertList.push(insertData);
+                        const sourceList = data.auditList.filter(x => { return x.audit_id && (x.audit_id !== t.user_id || canYB) });
+                        sourceList.sort((a, b) => { return a.audit_order - b.audit_order; });
+                        let audit_order = 0, curAuditOrder = 0;
+                        for (const s of sourceList) {
+                            if (s.audit_order !== curAuditOrder) {
+                                curAuditOrder = s.audit_order;
+                                audit_order = audit_order + 1;
                             }
+                            insertList.push({
+                                tid: t.id,
+                                sp_type: shenpiConst.sp_type[data.code],
+                                sp_status: shenpi_status,
+                                audit_id: s.audit_id,
+                                audit_type: s.audit_type,
+                                audit_order: audit_order,
+                            });
                         }
                     }
                 }