getCarInfo.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>layer iframe 示例</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  9. <link rel="stylesheet" href="../../../../start/layui/css/layui.css" media="all">
  10. <link rel="stylesheet" href="../../../../dist/style/admin.css" media="all">
  11. <style>
  12. body{padding:10px; font-size:14px; background:#fff; width:95%; margin:0 auto; font-size:14px; line-height:20px; }
  13. p{margin-bottom:10px;}
  14. input{border:1px solid #999; padding:5px 10px; margin:0 10px 10px 0;}
  15. </style>
  16. </head>
  17. <body>
  18. <div class="layui-row">
  19. <div class="layui-card">
  20. <div class="layui-card-body">
  21. <div class="layui-tab layui-tab-card">
  22. <ul class="layui-tab-title">
  23. <li class="layui-this">本地车辆</li>
  24. <li>外地车辆</li>
  25. </ul>
  26. <div class="layui-tab-content">
  27. <div class="layui-tab-item layui-show">
  28. <div class="layui-card-body">
  29. <table class="layui-hide" id="test-table-radio" lay-filter="test-table-radio"></table>
  30. <script type="text/html" id="table-submit">
  31. <div>
  32. <button class="layui-btn layui-btn-sm" lay-event="getCheckData" >获取数据</button>
  33. </div>
  34. </script>
  35. </div>
  36. </div>
  37. <div class="layui-tab-item">
  38. <div class="layui-card-body">
  39. <table class="layui-hide" id="test-table-radio-NoLocal" lay-filter="test-table-radio-NoLocal"></table>
  40. <script type="text/html" id="table-submit-NoLocal">
  41. <div>
  42. <button class="layui-btn layui-btn-sm" lay-event="getCheckData" >获取数据</button>
  43. </div>
  44. </script>
  45. </div>
  46. </div>
  47. <!--<div class="layui-tab-item">-->
  48. <!--<input class="layui-input" placeholder="标记" id="LAY_mark">-->
  49. <!--<div class="layui-btn-container">-->
  50. <!--<button class="layui-btn layui-btn-primary" data-type="parentPopup">在父层弹出一个层</button>-->
  51. <!--<button class="layui-btn layui-btn-primary" data-type="setParent">给父页面传值</button>-->
  52. <!--<button class="layui-btn layui-btn-primary" data-type="close">在内部关闭iframe</button>-->
  53. <!--</div>-->
  54. <!--</div>-->
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <script src="../../../../start/layui/layui.js"></script>
  61. <script src="../../../../start/layui/lay/modules/element.js"></script>
  62. <script>
  63. layui.use(['layer','table'], function(){
  64. var $ = layui.$
  65. ,layer = layui.layer
  66. // ,admin = layui.admin
  67. ,table = layui.table
  68. ,index = parent.layer.getFrameIndex(window.name); //获取窗口索引
  69. $.ajax({
  70. url:"/charge/waitingList",
  71. type:'GET',
  72. data:{},
  73. success:function (res) {
  74. //加载本地车牌
  75. //本地车牌
  76. table.render({
  77. elem: '#test-table-radio'
  78. // ,url: '../../../../start/json/table/user.js'
  79. // ,url: '/charge/waitingLocal'
  80. ,data: res.local
  81. ,height: 400
  82. ,limit: res.local.length
  83. ,toolbar: '#table-submit'
  84. ,cols: [[
  85. {type:'radio'}
  86. ,{field:'license', width:180, title: '车牌'}
  87. ,{field:'type', width:180, title: '类型'}
  88. ,{field:'time', width:180, title: '时间'}
  89. ]]
  90. });
  91. //加载外地车牌
  92. //外地车牌
  93. table.render({
  94. elem: '#test-table-radio-NoLocal'
  95. // ,url: '../../../../start/json/table/user.js'
  96. // ,url: '/charge/waitingNoLocal'
  97. ,height: 400
  98. ,limit: res.no_local.length
  99. ,data: res.no_local
  100. ,toolbar: '#table-submit-NoLocal'
  101. ,cols: [[
  102. {type:'radio'}
  103. ,{field:'license', width:180, title: '车牌'}
  104. ,{field:'type', width:180, title: '类型'}
  105. ,{field:'time', width:180, title: '时间'}
  106. ]]
  107. });
  108. }
  109. })
  110. table.on('toolbar(test-table-radio)',function (obj) {
  111. var checkStatus = table.checkStatus(obj.config.id);
  112. // console.log(checkStatus.data[0])
  113. if(obj.event === 'getCheckData'){
  114. var data = checkStatus.data;
  115. // layer.alert(JSON.stringify(data));
  116. parent.layui.$("#LAY_license").val(data[0].license);
  117. $.ajax({
  118. url:"/charge/getDetail",
  119. type:'POST',
  120. data:data[0],
  121. success:function (res) {
  122. parent.layui.$("#LAY_VIN").val(res.车辆识别代号);
  123. parent.layui.$("#LAY_owner").val(res.所有人);
  124. }
  125. });
  126. parent.layer.close(index)//关闭子页面
  127. }
  128. });
  129. table.on('toolbar(test-table-radio-NoLocal)',function (obj) {
  130. var checkStatus = table.checkStatus(obj.config.id);
  131. // console.log(checkStatus.data[0])
  132. if(obj.event === 'getCheckData'){
  133. var data = checkStatus.data;
  134. // layer.alert(JSON.stringify(data));
  135. parent.layui.$("#LAY_license").val(data[0].license);
  136. $.ajax({
  137. url:"/charge/getDetail",
  138. type:'POST',
  139. data:data[0],
  140. success:function (res) {
  141. parent.layui.$("#LAY_VIN").val(res.车辆识别代号);
  142. parent.layui.$("#LAY_owner").val(res.所有人);
  143. }
  144. })
  145. parent.layer.close(index)//关闭子页面
  146. }
  147. });
  148. var active = {
  149. //在父层弹出一个层
  150. parentPopup: function(){
  151. parent.layer.msg('Hi, man', {shade: 0.3})
  152. }
  153. //给父页面传值
  154. ,setParent: function(){
  155. var id = '#LAY_layer_iframe_demo'
  156. ,mark = $('#LAY_mark')
  157. ,val = mark.val();
  158. if(val === ''){
  159. mark.focus();
  160. parent.layer.msg('请填写标记');
  161. return true;
  162. }
  163. parent.layer.msg('您将标记 [ ' +val + ' ] 成功传送给了父窗口');
  164. parent.layui.$(id).text('我被改变了');
  165. parent.layer.tips('Look here', id, {
  166. time: 5000
  167. });
  168. parent.layer.close(index);
  169. }
  170. //在内部关闭iframe
  171. ,close: function(set){
  172. parent.layer.close(index);
  173. }
  174. }
  175. $('.layui-btn-container .layui-btn').on('click', function(){
  176. var othis = $(this)
  177. ,type = othis.data('type');
  178. active[type] && active[type].call(this);
  179. });
  180. });
  181. </script>
  182. </body>
  183. </html>