if(layEvent === 'edit'){ // 编辑按钮点击事件 layer.open({ title: '编辑', content: '编辑弹窗的HTML代码', area: ['500px', '300px'], btn: ['保存', '取消'], success: function(layero, index){ var html = '

机构号:
'+ data.institution +'
'; html += '
邮件号:
' + data.mailNumber + '
'; html += '
邮件描述:
' + data.describe + '
';

  // 显示多张图片
  if (data.images.length > 0) {
    html += '<div>图片:</div>';
    for (var i = 0; i < data.images.length; i++) {
      html += '<img src="' + data.images[i] + '" style="width: 100px; height: 100px; margin-right: 10px;" />';
    }
  }

  html += '<div>员工姓名:<div class="info-item">' + data.username + '</div></div>';
  html += '<div>状态(后台编辑):<div class="info-item" contenteditable="true">' + data.state + '</div></div>';
  html += '<div>上传时间:<div class="info-item">' + data.date + '</div></div>';
  $(layero).find('.layui-layer-content').html(html);
},
yes: function(index, layero){
  // 获取编辑后的数据
  var newState = $(layero).find('.info-item[contenteditable="true"]').text();

  // 发送post请求保存数据
  $.ajax({
    url: 'your_post_url',
    method: 'POST',
    data: {state: newState},
    success: function(response){
      // 处理保存成功后的逻辑
      console.log(response);
    },
    error: function(xhr, status, error){
      // 处理请求错误的逻辑
      console.error(error);
    }
  });

  // 关闭弹窗
  layer.close(index);
}

});

iflayEvent === edit 编辑按钮点击事件				 layeropen					title 编辑					content 编辑弹窗的HTML代码					area 500px 300px					btn 保存 取消					success functionlayero index						var html = div机构号div class=info-item+ datains

原文地址: https://www.cveoy.top/t/topic/iYsm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录