From 9afe73a59dcfbf5dac212def62ba92a4b69a005e Mon Sep 17 00:00:00 2001 From: WenG <450292408@qq.com> Date: Sat, 4 Jun 2022 23:14:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8A=9F=E8=83=BD=E5=91=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/assets/js/layui-util.js | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/common/src/main/resources/static/assets/js/layui-util.js b/common/src/main/resources/static/assets/js/layui-util.js index 3621eb18..5de36289 100644 --- a/common/src/main/resources/static/assets/js/layui-util.js +++ b/common/src/main/resources/static/assets/js/layui-util.js @@ -35,12 +35,20 @@ function LayuiUtil(layui, viewer) { var html = ''; for (var i = 0, fileId; fileId = fileIdArray[i++];) { + // 删除按钮 + var deleteBtn = ''; + if(!isShow) { + deleteBtn = [ + '', + ' ', + '' + ].join(''); + } + html += [ '
', ' ', - ' ', - ' ', - ' ', + deleteBtn, '
', ].join(''); } @@ -578,6 +586,7 @@ function LayuiUtil(layui, viewer) { dataForm: opt.dataForm, valueKey: 'dataId', nameKey: 'dataName', + selectedValue: opt.selectedValue, onInit: opt.onInit, onSelect: opt.onSelect }) @@ -600,4 +609,35 @@ function LayuiUtil(layui, viewer) { return null; } + /** + * 禁用表单全部字段 + */ + this.disableFormAllFields = function () { + var doms = $('form').find('input,button,textarea,select'); + doms.attr('disabled', 'disabled'); + doms.attr('lay-verify', ''); + } + + /** + * 禁用字段转div + */ + this.disabledField2Div = function() { + var doms = $('form').find('input,textarea,select'); + $.each(doms, function(index, item) { + if(!item.disabled) { + return; + } + + var value = item.value; + var parent = $(item).parent(); + parent.empty(); + if(item.nodeName === 'INPUT' || item.nodeName === 'SELECT') { + parent.append('
'+ value +'
') + } else if(item.nodeName === 'TEXTAREA') { + parent.append('
'+ value +'
') + + } + }); + } + } \ No newline at end of file