From 3031869ea086f8340150ad0160aafd0bdfbb6c65 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 26 Sep 2021 14:55:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/select-supplier-product-change.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/js/select-supplier-product-change.js b/resources/js/select-supplier-product-change.js index be1ee06..c787d03 100644 --- a/resources/js/select-supplier-product-change.js +++ b/resources/js/select-supplier-product-change.js @@ -18,7 +18,16 @@ $(function () { }; var data = res.data; var forms = $('.has-many-spec-forms'); - forms.html(''); + + //如果是原来数据库已经保存有id,调用click,提交的时候会同时删除数据库,否则直接remove掉,减小HTML体积 + forms.children().each(function () { + if ($(this).find('.field_id').val()) { + $(this).find('.remove.btn').click(); + } else { + $(this).remove(); + } + }); + for (var key in data) { var row = $(template.replace(/new___LA_KEY__/g, key)); for(var key2 in fields) {