首页 > 其他分享 >layui按钮多选数据赋值到OA明细表

layui按钮多选数据赋值到OA明细表

时间:2023-10-17 16:13:46浏览次数:41  
标签:username city layui sex experience 明细表 OA sign id

实际效果:点击全选按钮,选择数据,点击获取选中行数据,自动赋值给明细表

 

因为利用layui生成按钮以及表格,所以需要引入layui。

表格内容为固定数据,如需要实现动态分页数据,自行实现,或者查看我另一篇博客文章:https://www.cnblogs.com/stfzhuang/p/17676056.html

实现JS:

<script>
  
  $("#oTable0").find("tbody").find("tr:eq(1)").find("td:eq(4)").prepend("<button id='selectall' type='button' class='layui-btn layui-btn-xs layui-btn-normal'>全选按钮</button>")
$("#selectall").click( function(event){
        // 在此处输入 layer 的任意代码
        var index1 = layer.open({
          type: 1, // page 层类型
          area: ['800px', '600px'],
          title: '采购订单号',
          shade: 0.6, // 遮罩透明度
          shadeClose: true, // 点击遮罩区域,关闭弹层
          maxmin: true, // 允许全屏最小化
          anim: 0, // 0-6 的动画形式,-1 不开启
          
          
            
          content: "<table class='layui-hide' id='ID-table-demo-search'></table>"
        });
        
        
        layui.use(function(){
          var table = layui.table;
          var form = layui.form;
          var laydate = layui.laydate;
          // 创建表格实例
          table.render({
            elem: '#ID-table-demo-search',
            //url: 'https://layui.dev/static/2.8/json/table/user.json', // 此处为静态模拟数据,实际使用时需换成真实接口
            cols: [[
              //{type: 'radio', title: '?', fixed: true}, // 单选框
              {checkbox: true, title: '?',fixed: true},
              {field:'id', title: 'ID', width:80, sort: true, fixed: true},
              {field:'username', title: '用户名', width:80},
              {field:'sex', title: '性别', width:80, sort: true},
              {field:'city', title: '城市', width:80},
              {field:'sign', title: '签名'},
              {field:'experience', title: '积分', sort: true, width:80}
            ]],
            toolbar: "<div class='layui-btn-container' id='demo-toolbar-setRowChecked'><button class='layui-btn layui-btn-sm' lay-event='getCheckData'>获取选中行数据</button></div>",
            data:[{"id":10000,"username":"user-0","sex":"女","city":"城市-0","sign":"签名-0","experience":255,"logins":24,"words":82830700,"classify":"作家","score":57},{"id":10001,"username":"user-1","sex":"男","city":"城市-1","sign":"签名-1","experience":884,"logins":58,"words":64928690,"classify":"词人","score":70.5},{"id":10002,"username":"user-2","sex":"女","city":"城市-2","sign":"签名-2","experience":650,"logins":77,"words":6298078,"classify":"酱油","score":31},{"id":10003,"username":"user-3","sex":"女","city":"城市-3","sign":"签名-3","experience":362,"logins":157,"words":37117017,"classify":"诗人","score":68},{"id":10004,"username":"user-4","sex":"男","city":"城市-4","sign":"签名-4","experience":807,"logins":51,"words":76263262,"classify":"作家","score":6},{"id":10005,"username":"user-5","sex":"女","city":"城市-5","sign":"签名-5","experience":173,"logins":68,"words":60344147,"classify":"作家","score":87},{"id":10006,"username":"user-6","sex":"女","city":"城市-6","sign":"签名-6","experience":982,"logins":37,"words":57768166,"classify":"作家","score":34},{"id":10007,"username":"user-7","sex":"男","city":"城市-7","sign":"签名-7","experience":727,"logins":150,"words":82030578,"classify":"作家","score":28},{"id":10008,"username":"user-8","sex":"男","city":"城市-8","sign":"签名-8","experience":951,"logins":133,"words":16503371,"classify":"词人","score":14},{"id":10009,"username":"user-9","sex":"女","city":"城市-9","sign":"签名-9","experience":484,"logins":25,"words":86801934,"classify":"词人","score":75},{"id":10009,"username":"user-9","sex":"女","city":"城市-9","sign":"签名-9","experience":484,"logins":25,"words":86801934,"classify":"词人","score":75},{"id":10009,"username":"user-9","sex":"女","city":"城市-9","sign":"签名-9","experience":484,"logins":25,"words":86801934,"classify":"词人","score":75}],
            page: true,
            height: 500
          });
          
          // 头工具栏事件
          table.on('toolbar(ID-table-demo-search)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            switch(obj.event){
              case 'getCheckData':
                var data = checkStatus.data;  // 获取选中行数据
                layer.alert(JSON.stringify(data));  // 显示 - 仅用于演示
                console.log(data);
                for(let i = 0 ; i < data.length; i++){
                    WfForm.addDetailRow("detail_1",{field19394:{value:data[i].id},field19395:{value:data[i].username}});
                }
                
                
              break;
            };
            layer.close(index1);
          });
        });
        
        
          
});
</script>

 

标签:username,city,layui,sex,experience,明细表,OA,sign,id
From: https://www.cnblogs.com/stfzhuang/p/17769945.html

相关文章

  • Go - Uploading a File to a Web Application
    Problem: Youwanttouploadafiletoawebapplication. Solution: Usethenet/httppackagetocreateawebapplicationandtheiopackagetoreadthefile. UploadingfilesiscommonlydonethroughHTMLforms.YoulearnedthatHTMLformshaveanencty......
  • pytorch_Tensorboard的使用
     SummaryWriter()将什么写入文件中,如果不指定的话,就写入默认的需要两个方法writer.add_image()wruter.add_scalar() fromtorch.utils.tensorboardimportSummaryWriter#导入tensorboard,再导入SummaryWriter这个类writer=SummaryWriter("logs")#利用OpenC......
  • fastify-autoload + ncc + s3 实现模块的插件化开发加载
    以前简单说明过基于fastify-autoload的插件化加载fastify插件,方便实现开发,但是对于实际生产环境我们可以需要频繁的模块修改,发布以及构建,所以需要我们需要频繁的调整,不是很方便,我们可以基于ncc进行入口的打包,同时对于每个插件也基于ncc打包为独立的文件,这样我们开发的插件只需......
  • 万户OA项目管理开发
    首先修改办理查阅的类。办理查阅EzFLOWDealSearch!initList.actionWEB-INF\classes\struts2\struts-wfdealsearch.xml-> <actionname="EzFLOWDealSearch!*"method="{1}"class="com.whir.ezoffice.monitor.actionsupport.EzFLOWDealSearchAction&quo......
  • fastify-autoload 一个方便的插件动态加载包
    fastify-autoload是一个方便的fastify插件加载工具,我们可以基于路径直接加载开发的插件参考使用配置constFastify=require('fastify')constpath=require("path")constautoLoad=require('@fastify/autoload');constapp=Fastify({logge......
  • 无涯教程-NumPy - broadcast_to函数
    此功能将数组广播为新维度,它返回原始数组的只读视图,如果新维度不符合NumPy的广播规则,则该函数可能会引发ValueError。注意-此功能自版本1.10.0起可用。该函数采用以下参数。numpy.broadcast_to(array,shape,subok)importnumpyasnpa=np.arange(4).reshape(1,4)prin......
  • CF27D Ring Road 2
    好一眼的题,据说出题人给的做法不是2-SAT,因此才会有这样的数据范围,但这个模型yysy实在是太典了啊喂不难发现每条边的取法就是两种,并且内部和外部的边之间绝对不会相交,因此考虑使用2-SAT模型枚举两条边\(i,j\),如果\(i,j\)同时放在一边会产生冲突,就钦定两者的状态必须相异,然后这题......
  • loading效果
    css*{margin:0;padding:0;}#load{width:100%;height:100%;display:block;position:absolute;z-index:1999!important;background-color:rgba(0,0,0,0.5);}#loadmain{......
  • How to fix the bug that the beforeunload event cannot be triggered All In One
    HowtofixthebugthatthebeforeunloadeventcannotbetriggeredAllInOne如何修复beforeunload事件无法触发的bugAllInOnebeforeunloadconstbeforeUnloadHandler=(event)=>{event.preventDefault();//Equivalenttothefollowingle......
  • 订阅计划推送钉钉消息出现"oapi.dingtalk.com: Name or service not known"
    一、问题描述BI系统需要每天将报表推送给钉钉用户,但是偶尔会出现推送失败的情况,提示oapi.dingtalk.com:Nameorservicenotknown,即钉钉域名解析出现错误,后续重新推送又成功了,该情况具有偶然性。可能的原因是:1、钉钉IP地址是一个地址池,域名oapi.dingtalk.com对应多个IP地址,浏......