在layui layer 彈出層中加載 layui table


 1 layui.use('table', function(){
 2                 var table = layui.table;
 3                 layer.open({
 4                 type : 1,
 5                 area : [ "600px", '430px' ],
 6                 title : "選擇模板",
 7                 maxmin : false,
 8                 content : '<div><table id="templateTable"></table></div>',
 9                 success : function(index, layero) {
10                     
11                       table.render({
12                         elem: '#templateTable'
13                         ,height: 300
14                         ,width:'100%'
15                        ,url: '${ctx}/oa/wzsc/oaWzscTemplate/listJson' //數據接口
16                        
17                         ,page: true //開啟分頁
18                         ,cols: [[ //表頭
19                             {type:'radio'}
20                           ,{field: 'name', title: '模板名稱', width:200, sort: true}
21                           ,{field: 'detail', title: '描述', width:330}
22                            ,{field: 'id', title: 'ID', width:200,hide:true}
23                           
24                         ]]
25                       });
26                     
27                 },
28                 
29                 btn : [ '確定', '關閉' ],
30                 yes : function(index, layero) {
31                         var checkStatus = table.checkStatus('templateTable'); //
32                         var datas = checkStatus.data;//選中的數據
33                         if(datas.length > 0){
34                             var selectData = datas[0];
35                              var tpid = selectData.id;
36                              var tpname = selectData.name;
37                              $('#tpId').val(tpid);
38                              $('#tpName').val(tpname);
39                              try{
40                                  layer.close(index);//關閉對話框.
41                              }catch(e){
42                                  setTimeout(function(){layer.close(index)}, 100);//延時0.1秒,對應360 7.1版本bug
43                              }
44                         }else{
45                             layer.msg('請選擇一個模板!');
46                         }
47                          
48                     }
49                 });
50             });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM