From 3bcc12285a4506506f4d40cc6b84052080a9cfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Thu, 4 May 2023 00:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20transfer=20=E5=86=85?= =?UTF-8?q?=E9=83=A8=E6=95=B0=E6=8D=AE=E6=B8=B2=E6=9F=93=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/transfer.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/modules/transfer.js b/src/modules/transfer.js index 70f7c734..aa1adcd5 100644 --- a/src/modules/transfer.js +++ b/src/modules/transfer.js @@ -193,33 +193,35 @@ layui.define(['laytpl', 'form'], function(exports){ that.events(); //事件 }; - //渲染数据 + // 渲染数据 Class.prototype.renderData = function(){ - var that = this - ,options = that.config; + var that = this; + var options = that.config; - //左右穿梭框差异数据 + // 左右穿梭框差异数据 var arr = [{ - checkName: 'layTransferLeftCheck' - ,views: [] + checkName: 'layTransferLeftCheck', + views: [] }, { - checkName: 'layTransferRightCheck' - ,views: [] + checkName: 'layTransferRightCheck', + views: [] }]; - //解析格式 + // 解析格式 that.parseData(function(item){ - //标注为 selected 的为右边的数据 + // 标注为 selected 的为右边的数据 var _index = item.selected ? 1 : 0 - ,listElem = ['
  • ' - ,'' - ,'
  • '].join(''); - //按照options.value顺序排列右侧数据 + var listElem = ['
  • ', + '', + '
  • '].join(''); + // 按照 options.value 顺序排列右侧数据 if(_index){ - for(let key in options.value) { - if(options.value[key] == item.value && item.selected) arr[_index].views[key] = listElem; - } - }else{ + layui.each(options.value, function(i, v){ + if(v == item.value && item.selected){ + arr[_index].views[i] = listElem; + } + }); + } else { arr[_index].views.push(listElem); } delete item.selected; @@ -229,7 +231,7 @@ layui.define(['laytpl', 'form'], function(exports){ that.layData.eq(1).html(arr[1].views.join('')); that.renderCheckBtn(); - } + }; //渲染表单 Class.prototype.renderForm = function(type){