Browse Source

变更bug

laiguoran 5 years ago
parent
commit
41207c4d49
1 changed files with 18 additions and 13 deletions
  1. 18 13
      app/public/js/change_set.js

+ 18 - 13
app/public/js/change_set.js

@@ -49,6 +49,9 @@ $(document).ready(() => {
 
         gclGatherData = gclGatherModel.gatherGclData();
         for (const ggd in gclGatherData) {
+            if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
+                gclGatherData.splice(ggd, 1);
+            }
             gclGatherData[ggd].code = gclGatherData[ggd].b_code;
         }
         // 数组去重
@@ -73,16 +76,18 @@ $(document).ready(() => {
             const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
             let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"': '';
             gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
-            const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? gcl.leafXmjs[0].gcl_id : gcl.id;
-            listHtml += '<tr data-lid="' + lid + '"'+ gclhtml +' data-index="' + list_index + '" data-bwmx="">' +
-                '<td class="text-center">' + list_index + '</td>' +
-                '<td>' + gcl.code + '</td>' +
-                '<td class="text-left">' + gcl.name + '</td>' +
-                '<td class="text-center">' + unit + '</td>' +
-                '<td class="text-right">' + roundnum(unit_price, unitPriceUnit) + '</td>' +
-                '<td class="text-right">' + quantity + '</td>' +
-                '</tr>';
-            list_index++;
+            const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? (gcl.leafXmjs.length !== 0 ? gcl.leafXmjs[0].gcl_id : false) : gcl.id;
+            if (lid) {
+                listHtml += '<tr data-lid="' + lid + '"'+ gclhtml +' data-index="' + list_index + '" data-bwmx="">' +
+                    '<td class="text-center">' + list_index + '</td>' +
+                    '<td>' + gcl.code + '</td>' +
+                    '<td class="text-left">' + gcl.name + '</td>' +
+                    '<td class="text-center">' + unit + '</td>' +
+                    '<td class="text-right">' + roundnum(unit_price, unitPriceUnit) + '</td>' +
+                    '<td class="text-right">' + quantity + '</td>' +
+                    '</tr>';
+                list_index++;
+            }
         }
         $('#table-list-select').html(listHtml);
         tableDataRemake(changeListData);
@@ -242,7 +247,7 @@ $(document).ready(() => {
     });
 
     $('#hideSp').click(function () {
-       $('#sub-sp2').modal('hide');
+        $('#sub-sp2').modal('hide');
     });
 
     // 添加到审批流程中
@@ -546,8 +551,8 @@ $(document).ready(() => {
 
     // 自动编号
     $('.reduction-code').click(function () {
-       const code = $(this).attr('data-code');
-       $('input[name="code"]').val(code);
+        const code = $(this).attr('data-code');
+        $('input[name="code"]').val(code);
     });
 
     // 记录变更信息操作