123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>layer iframe 示例</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <link rel="stylesheet" href="../../../../start/layui/css/layui.css" media="all">
- <link rel="stylesheet" href="../../../../dist/style/admin.css" media="all">
- <style>
- body{padding:10px; font-size:14px; background:#fff; width:95%; margin:0 auto; font-size:14px; line-height:20px; }
- p{margin-bottom:10px;}
- input{border:1px solid #999; padding:5px 10px; margin:0 10px 10px 0;}
- </style>
- </head>
- <body>
- <div class="layui-row">
- <div class="layui-card">
- <div class="layui-card-body">
- <div class="layui-tab layui-tab-card">
- <ul class="layui-tab-title">
- <li class="layui-this">本地车辆</li>
- <li>外地车辆</li>
- </ul>
- <div class="layui-tab-content">
- <div class="layui-tab-item layui-show">
- <div class="layui-card-body">
- <table class="layui-hide" id="test-table-radio" lay-filter="test-table-radio"></table>
- <script type="text/html" id="table-submit">
- <div>
- <button class="layui-btn layui-btn-sm" lay-event="getCheckData" >获取数据</button>
- </div>
- </script>
- </div>
- </div>
- <div class="layui-tab-item">
- <div class="layui-card-body">
- <table class="layui-hide" id="test-table-radio-NoLocal" lay-filter="test-table-radio-NoLocal"></table>
- <script type="text/html" id="table-submit-NoLocal">
- <div>
- <button class="layui-btn layui-btn-sm" lay-event="getCheckData" >获取数据</button>
- </div>
- </script>
- </div>
- </div>
- <!--<div class="layui-tab-item">-->
- <!--<input class="layui-input" placeholder="标记" id="LAY_mark">-->
- <!--<div class="layui-btn-container">-->
- <!--<button class="layui-btn layui-btn-primary" data-type="parentPopup">在父层弹出一个层</button>-->
- <!--<button class="layui-btn layui-btn-primary" data-type="setParent">给父页面传值</button>-->
- <!--<button class="layui-btn layui-btn-primary" data-type="close">在内部关闭iframe</button>-->
- <!--</div>-->
- <!--</div>-->
- </div>
- </div>
- </div>
- </div>
- </div>
- <script src="../../../../start/layui/layui.js"></script>
- <script src="../../../../start/layui/lay/modules/element.js"></script>
- <script>
- layui.use(['layer','table'], function(){
- var $ = layui.$
- ,layer = layui.layer
- // ,admin = layui.admin
- ,table = layui.table
- ,index = parent.layer.getFrameIndex(window.name); //获取窗口索引
- $.ajax({
- url:"/charge/waitingList",
- type:'GET',
- data:{},
- success:function (res) {
- //加载本地车牌
- //本地车牌
- table.render({
- elem: '#test-table-radio'
- // ,url: '../../../../start/json/table/user.js'
- // ,url: '/charge/waitingLocal'
- ,data: res.local
- ,height: 400
- ,limit: res.local.length
- ,toolbar: '#table-submit'
- ,cols: [[
- {type:'radio'}
- ,{field:'license', width:180, title: '车牌'}
- ,{field:'type', width:180, title: '类型'}
- ,{field:'time', width:180, title: '时间'}
- ]]
- });
- //加载外地车牌
- //外地车牌
- table.render({
- elem: '#test-table-radio-NoLocal'
- // ,url: '../../../../start/json/table/user.js'
- // ,url: '/charge/waitingNoLocal'
- ,height: 400
- ,limit: res.no_local.length
- ,data: res.no_local
- ,toolbar: '#table-submit-NoLocal'
- ,cols: [[
- {type:'radio'}
- ,{field:'license', width:180, title: '车牌'}
- ,{field:'type', width:180, title: '类型'}
- ,{field:'time', width:180, title: '时间'}
- ]]
- });
- }
- })
- table.on('toolbar(test-table-radio)',function (obj) {
- var checkStatus = table.checkStatus(obj.config.id);
- // console.log(checkStatus.data[0])
- if(obj.event === 'getCheckData'){
- var data = checkStatus.data;
- // layer.alert(JSON.stringify(data));
- parent.layui.$("#LAY_license").val(data[0].license);
- $.ajax({
- url:"/charge/getDetail",
- type:'POST',
- data:data[0],
- success:function (res) {
- parent.layui.$("#LAY_VIN").val(res.车辆识别代号);
- parent.layui.$("#LAY_owner").val(res.所有人);
- }
- });
- parent.layer.close(index)//关闭子页面
- }
- });
- table.on('toolbar(test-table-radio-NoLocal)',function (obj) {
- var checkStatus = table.checkStatus(obj.config.id);
- // console.log(checkStatus.data[0])
- if(obj.event === 'getCheckData'){
- var data = checkStatus.data;
- // layer.alert(JSON.stringify(data));
- parent.layui.$("#LAY_license").val(data[0].license);
- $.ajax({
- url:"/charge/getDetail",
- type:'POST',
- data:data[0],
- success:function (res) {
- parent.layui.$("#LAY_VIN").val(res.车辆识别代号);
- parent.layui.$("#LAY_owner").val(res.所有人);
- }
- })
- parent.layer.close(index)//关闭子页面
- }
- });
- var active = {
- //在父层弹出一个层
- parentPopup: function(){
- parent.layer.msg('Hi, man', {shade: 0.3})
- }
- //给父页面传值
- ,setParent: function(){
- var id = '#LAY_layer_iframe_demo'
- ,mark = $('#LAY_mark')
- ,val = mark.val();
- if(val === ''){
- mark.focus();
- parent.layer.msg('请填写标记');
- return true;
- }
- parent.layer.msg('您将标记 [ ' +val + ' ] 成功传送给了父窗口');
- parent.layui.$(id).text('我被改变了');
- parent.layer.tips('Look here', id, {
- time: 5000
- });
- parent.layer.close(index);
- }
- //在内部关闭iframe
- ,close: function(set){
- parent.layer.close(index);
- }
- }
- $('.layui-btn-container .layui-btn').on('click', function(){
- var othis = $(this)
- ,type = othis.data('type');
- active[type] && active[type].call(this);
- });
- });
- </script>
- </body>
- </html>
|