From 13d295c4210ee589b3e524bd157f85c63bca5a3e Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期四, 30 四月 2026 13:12:08 +0800
Subject: [PATCH] 1.出库单据转历史档有问题 2.新增单据历史档 3.修复入库完成转明细失败

---
 src/main/webapp/static/js/basCrnDepthRule/basCrnDepthRule.js |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/src/main/webapp/static/js/basCrnDepthRule/basCrnDepthRule.js b/src/main/webapp/static/js/basCrnDepthRule/basCrnDepthRule.js
index 8980307..b9959d8 100644
--- a/src/main/webapp/static/js/basCrnDepthRule/basCrnDepthRule.js
+++ b/src/main/webapp/static/js/basCrnDepthRule/basCrnDepthRule.js
@@ -123,7 +123,20 @@
             success: function (layero, dIndex) {
                 form.val('detail', mData || {enabled: 1, layoutType: 2});
                 form.render('select');
+                var detailForm = $(layero).find('#detail');
+                if (!mData) {
+                    detailForm.attr('data-auto-row-fill', 'true');
+                    detailForm.on('input propertychange', '[name="searchRowsCsv"]', function () {
+                        autoFillDepthRows(detailForm);
+                    });
+                    autoFillDepthRows(detailForm);
+                }
                 form.on('submit(editSubmit)', function (data) {
+                    if (!mData) {
+                        var submitForm = $(data.form);
+                        data.field.shallowRowsCsv = submitForm.find('[name="shallowRowsCsv"]').val();
+                        data.field.deepRowsCsv = submitForm.find('[name="deepRowsCsv"]').val();
+                    }
                     $.ajax({
                         url: baseUrl + '/basCrnDepthRule/' + (mData ? 'update' : 'add') + '/auth',
                         headers: {'token': localStorage.getItem('token')},
@@ -148,6 +161,101 @@
         });
     }
 
+    form.on('select(crnDepthLayoutType)', function (data) {
+        autoFillDepthRows($(data.elem).closest('form'));
+    });
+
+    function autoFillDepthRows(formEl) {
+        if (!formEl || formEl.length === 0 || formEl.attr('data-auto-row-fill') !== 'true') {
+            return;
+        }
+        var layoutType = $.trim(formEl.find('[name="layoutType"]').val());
+        var searchRowsCsv = $.trim(formEl.find('[name="searchRowsCsv"]').val());
+        if (layoutType === '1') {
+            formEl.find('[name="shallowRowsCsv"]').val(searchRowsCsv);
+            formEl.find('[name="deepRowsCsv"]').val('');
+            return;
+        }
+        if (layoutType === '2') {
+            var searchRows = parseRows(searchRowsCsv);
+            var shallowRows = [];
+            var deepRows = [];
+            if (searchRows.length > 0) {
+                deepRows.push(searchRows[0]);
+            }
+            if (searchRows.length > 1) {
+                deepRows.push(searchRows[searchRows.length - 1]);
+                shallowRows.push(searchRows[1]);
+            }
+            if (searchRows.length > 2) {
+                shallowRows.push(searchRows[2]);
+            }
+            formEl.find('[name="shallowRowsCsv"]').val(shallowRows.join(','));
+            formEl.find('[name="deepRowsCsv"]').val(deepRows.join(','));
+        }
+    }
+
+    function parseRows(rowsCsv) {
+        var rows = [];
+        if (!rowsCsv) {
+            return rows;
+        }
+        var normalized = rowsCsv.replace(/锛�/g, ',')
+            .replace(/锛�/g, ';')
+            .replace(/銆�/g, ',')
+            .replace(/\s+/g, '');
+        if (!normalized) {
+            return rows;
+        }
+        $.each(normalized.split(/[,;]/), function (_, segment) {
+            if (!segment) {
+                return true;
+            }
+            if (segment.indexOf('-') > -1) {
+                addRangeRows(rows, segment);
+                return true;
+            }
+            addRow(rows, segment);
+            return true;
+        });
+        return rows;
+    }
+
+    function addRangeRows(rows, segment) {
+        var rangeParts = segment.split('-', 2);
+        var startRow = parsePositiveInt(rangeParts[0]);
+        var endRow = parsePositiveInt(rangeParts[1]);
+        if (startRow == null || endRow == null) {
+            return;
+        }
+        var step = startRow <= endRow ? 1 : -1;
+        for (var row = startRow; step > 0 ? row <= endRow : row >= endRow; row += step) {
+            addUniqueRow(rows, row);
+        }
+    }
+
+    function addRow(rows, rowText) {
+        var row = parsePositiveInt(rowText);
+        if (row != null) {
+            addUniqueRow(rows, row);
+        }
+    }
+
+    function parsePositiveInt(value) {
+        var rowText = $.trim(String(value));
+        if (!/^\d+$/.test(rowText)) {
+            return null;
+        }
+        var row = parseInt(rowText, 10);
+        return isNaN(row) || row <= 0 ? null : row;
+    }
+
+    function addUniqueRow(rows, row) {
+        if ($.inArray(row, rows) === -1) {
+            rows.push(row);
+        }
+    }
+
     function openTemplateDialog(generate) {
         admin.open({
             type: 1,

--
Gitblit v1.9.1