From 95d9421574d9122597b717b36b8b8884032d4666 Mon Sep 17 00:00:00 2001 From: "hi34753357@aliyun.com" <44069836@qq.com> Date: Thu, 30 Dec 2021 17:39:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20fieldlist=20key=20?= =?UTF-8?q?=E4=B8=BA=E6=95=B0=E5=AD=97=E4=B8=8D=E8=83=BD=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-form.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/public/assets/js/require-form.js b/public/assets/js/require-form.js index df7abd322..9b570e55f 100755 --- a/public/assets/js/require-form.js +++ b/public/assets/js/require-form.js @@ -287,6 +287,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio //绑定fieldlist if ($(".fieldlist", form).size() > 0) { require(['dragsort', 'template'], function (undefined, Template) { + var prefix='~*orderByKey*~'; //刷新隐藏textarea的值 var refresh = function (name) { var data = {}; @@ -309,14 +310,14 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio if (j) { if (!template) { if (j.key != '') { - result[j.key] = j.value; + result[prefix + j.key] = j.value; } } else { result.push(j); } } }); - textarea.val(JSON.stringify(result)); + textarea.val(JSON.stringify(result).replaceAll(prefix,'')); }; //监听文本框改变事件 $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () { @@ -367,9 +368,15 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio var json = {}; try { json = JSON.parse($(this).val()); + if(!Array.isArray(json)){ + json = JSON.parse($(this).val().replaceAll('":',prefix+'":')); + } } catch (e) { } $.each(json, function (i, j) { + if (typeof j == 'string') { + i = i.replaceAll(prefix,''); + } $(".btn-append,.append", container).trigger('click', template ? j : { key: i, value: j }); -- Gitee