Jelajahi Sumber

清单更改导致变更报错

laiguoran 5 tahun lalu
induk
melakukan
8e5011562a
1 mengubah file dengan 12 tambahan dan 10 penghapusan
  1. 12 10
      app/public/js/change_set.js

+ 12 - 10
app/public/js/change_set.js

@@ -73,16 +73,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);