Explorar el Código

other: 尝试增加添加方法,但iframe父子传值还有问题

zhangyuantao hace 1 año
padre
commit
f7569e6247

+ 1 - 0
src/main/java/com/tao/config/WebMVCConfig.java

@@ -21,6 +21,7 @@ public class WebMVCConfig implements WebMvcConfigurer {
     @Override
     public void addViewControllers(ViewControllerRegistry registry) {
         registry.addViewController("/").setViewName("index");
+        registry.addViewController("/addElement").setViewName("add");
     }
 
     @Override

+ 1 - 1
src/main/java/com/tao/listener/StepExecutor.java

@@ -22,7 +22,7 @@ public class StepExecutor implements Runnable {
     public void startStreamTask() {
         try {
             System.out.println("=========> 启动成功!请访问:http://localhost:8085");
-            Runtime.getRuntime().exec("cmd /c start http://localhost:8085");
+//            Runtime.getRuntime().exec("cmd /c start http://localhost:8085");
         } catch (Exception ex) {
             ex.printStackTrace();
         }

+ 1 - 1
src/main/resources/logback.xml

@@ -81,7 +81,7 @@
         <appender-ref ref="file_error"/>
     </root>
 
-    <logger name="com.tao" level="info">
+    <logger name="com.tao" level="debug">
         <appender-ref ref="console"/>
     </logger>
 

+ 19 - 0
src/main/resources/templates/add.html

@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+
+<h1>你好</h1>
+
+</body>
+<script>
+    let pageID = ""
+    function test1(obj1) {
+        pageID = obj1
+    }
+    console.log("子组件" + pageID);
+</script>
+</html>

+ 28 - 7
src/main/resources/templates/index.html

@@ -40,8 +40,10 @@
                     <a href="#">特殊分组</a>
                     <dl class="layui-nav-child">
                         <dd><a class="pageRequest" href="#"
-                               data-param="{&quot;elementType&quot;: &quot;&quot;,&quot;pageID&quot;: &quot;&quot;}">全部数据</a></dd>
-                        <dd><a class="pageRequest" href="#" data-param="{&quot;elementType&quot;: 3,&quot;pageID&quot;: &quot;&quot;}">个人数据</a></dd>
+                               data-param="{&quot;elementType&quot;: &quot;&quot;,&quot;pageID&quot;: &quot;&quot;}">全部数据</a>
+                        </dd>
+                        <dd><a class="pageRequest" href="#"
+                               data-param="{&quot;elementType&quot;: 3,&quot;pageID&quot;: &quot;&quot;}">个人数据</a></dd>
                     </dl>
                 </li>
                 <li class="layui-nav-item">
@@ -79,7 +81,8 @@
                     <div class="layui-inline" style="display: inline">
                         <label class="layui-form-label" style="width: 90px;">Android</label>
                         <div class="layui-input-inline" style="width: 18%;">
-                            <input type="text" name="elementAndroidLocate" class="layui-input" placeholder="请输入Android定位关键值">
+                            <input type="text" name="elementAndroidLocate" class="layui-input"
+                                   placeholder="请输入Android定位关键值">
                         </div>
                     </div>
                     <div class="layui-inline" style="display: inline">
@@ -95,7 +98,9 @@
                         </div>
                     </div>
                     <div class="layui-inline" style="display: inline">
-                        <button type="button" class="layui-btn mgl-20" lay-submit lay-filter="search"><i class="layui-icon">&#xe615;</i>查询</button>
+                        <button type="button" class="layui-btn mgl-20" lay-submit lay-filter="search"><i
+                                class="layui-icon">&#xe615;</i>查询
+                        </button>
                         <button class="layui-btn layui-btn-primary" type="reset" lay-active="reset">重置</button>
                     </div>
                 </div>
@@ -141,6 +146,7 @@
             </script>
             <script type="text/html" id="toolbar">
                 <a class="layui-btn layui-btn-sm" lay-event="clearFilter">清除所有筛选条件</a>
+                <a class="layui-btn layui-btn-sm" lay-event="addElement">添加</a>
             </script>
             <script type="text/html" id="elementTypeTpl">
                 {{# if(d.elementType === 0){ }}
@@ -277,11 +283,11 @@
 
         //处理属性 为 lay-active 的所有元素事件
         util.event('lay-active', {
-            reset: function(othis){
+            reset: function (othis) {
                 table.reload('myTable', {
                     where: {
-                        elementType : elementType,
-                        pageID : pageID
+                        elementType: elementType,
+                        pageID: pageID
                     }
                 })
             }
@@ -333,6 +339,21 @@
                 // 清除所有筛选条件并重载表格
                 // 参数: tableId
                 soulTable.clearFilter('myTable')
+            } else if (obj.event === 'addElement') {
+                layer.open({
+                    type: 2,
+                    area: ['700px', '450px'],
+                    fixed: false, //不固定
+                    maxmin: true,
+                    resizing: false,
+                    content: 'addElement',
+                    success: function (layero, index) {
+                        let iframe = window['layui-layer-iframe' + index];
+                        console.log(iframe);
+                        // console.log("父组件" + pageID);
+                        iframe.test1("123123");
+                    }
+                });
             }
         });