以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 怎样重复调用相同的一段代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=191014) |
-- 作者:ycs5801 -- 发布时间:2024/3/21 11:09:00 -- 怎样重复调用相同的一段代码 重复调用相同一段代码,需要怎么操作?官方的微信公众号实例中,我看有这样做的,但是不知道具体调用流程,能不能说下?或者还有没有其它方式? |
-- 作者:有点蓝 -- 发布时间:2024/3/21 11:14:00 -- 上面截图里单元格存储的是json字符串,不是代码。 把代码放到函数里就可以重复调用了:http://www.foxtable.com/webhelp/topics/1486.htm
|
-- 作者:ycs5801 -- 发布时间:2024/3/21 14:32:00 -- Dim e As RequestEventArgs = args(0) Dim wb As New weui \'\'设置分页 Dim dt As DataTable = cmd.ExecuteReader wb.AppendHTML("<link rel=\'stylesheet\' href=\'./weui/exweui.css\'/>", True) \'引入样式2文件 wb.AppendHTML("<script src=\'./weui/exweui.js\' ></script>", True) \'引入框架文件 wb.AddPage("", "page1").Attribute = "style=width:100%;" \'增加1个page Dim p1Div = ExWeUI.WebUI.AddHtmlTag("", "", "div") Dim p1Div1 = ExWeUI.WebUI.AddHtmlTag("", "", "div", , "style=\'display: flex;flex-direction: column;height: 100%;\'") With ExWeUI.WebUI.AddSearchBar("bar01", "关键字") \'添加一个搜索条 .DataFunc = "test" .CancelFunc = "testcancel" p1Div.InnerHtml = p1Div.InnerHtml & .BuildHtml End With p1Div1.InnerHtml = p1Div.buildhtml Dim drs As List(Of DataRow) = dt.Select("") If drs.Count > 0 Then \' messagebox.show(drs.count) With ExWeUI.WebUI.AddListGroup("page1", "lst01", 1) Dim color1 As String = "style=\'background-color:#f69797\'" \'暗红色,未检疫 Dim color2 As String = "style=\'background-color:#d9a738\'" \'淡黄色,正在检疫 Dim color3 As String = "style=\'background-color:#198d65\'" \'淡绿色,已检疫 Dim color As String For Each dr As DataRow In drs If dr("是否离轮") = True or dr("电讯检疫") =true Then \'已检疫 color = color3 ElseIf dr("卫检登轮") = true And dr("是否离轮") <> true Then \'检疫中 color = color2 ElseIf dr("卫检登轮") <> true Then color = color1 End If Dim txt As String = "<p " & color & ">中文船名:" & dr("中文船名") & "<br/>" txt = txt & "入境时间:" & dr("入境时间") & "<br/>" txt = txt & "船  籍:" & dr("船籍") & "<br/>" txt = txt & "IMO号:" & dr("IMO号") & "</p>" Dim s As String = dr("船舶资料") If s.length > 10 Then txt = txt & "<p>船舶资料:" & s.substring(0, 10) & "......" & "</p>" Else txt = txt & "<p>船舶资料:" & dr("船舶资料") & "</p>" End If With .AddList(dr("中文船名") & "(" & dr("检查类别") & ")", "") .TextStyle = "color:red;font-size:20px" \'字体颜色,字体大小 .ImageWidth = 2 \'图片大小 With .LeftFooter .AddFoot(txt).Attribute = "style=\'color:white;background-color:#f69797\';font-size:17px\'" If e.Cookies("用户类别") = "企业" Then .AddFoot("详细信息").Attribute = " & dr("_Identify") & "\'"" style=\'color:blue;font-size:20px\'" Else .AddFoot("详细信息").Attribute = " & dr("_Identify") & "\'"" style=\'color:blue;font-size:20px\'" End If End With With .rightFooter If e.Cookies("用户类别") = "企业" And dr("检查类别") = "进检" Then \' .AddFoot("申报出检").Attribute = " & dr("_Identify") & "\'"" style=\'color:green;font-size:20px\'" .AddFoot("申报出检").Attribute = " & dr("_Identify") & "\'"" style=\'color:green;font-size:20px\'" ElseIf e.Cookies("用户类别") <> "企业" then .AddFoot("拨打电话").Attribute = " & dr("手机号") & "\'"" style=\'color:green;font-size:20px\'" End If End With End With Next p1Div1.InnerHtml = p1Div.InnerHtml & ExWeUI.WebUI.AddHtmlTag("", "p1", "div", .BuildHtml, "class=""exui-scrollview""").buildhtml End With wb.InsertHTML("<div style=\'height:50px\'></div>") wb.InsertHTML("page1", p1Div1.buildhtml) wb.InsertHTML("</div>") wb.InsertHTML("<div style=\'height:50px\'></div>") wb.AddPage("", "page3").Attribute = "style=\'position: fixed;bottom: 0;right: 0;left: 0\'" \'增加两个page With wb.AddButtonGroup("page3", "btg1", False) .Add("btn1", "返回首页", "", "default.htm") If page > 0 Then .Add("btnPrev", "上一页", "", "renamecx.htm?page=" & page - 1) End If If Endrow < count Then .Add("btnNext", "下一页", "", "renamecx.htm?page=" & page + 1) End If .Add("btn2", "清除查询", "button", "Renamecx.htm") End With wb.AppendHTML("<script src=\'./lib/test.js\'></script>") wb.AppendHTML("<script>initExWeUI();</script>") e.WriteString(wb.Build) Else With wb.AddMsgPage("", "msgpage", "查询完成", "没有查询到相关数据!") .icon = "info" \'改变图标"success","info","warn",对应的图标分别是 \' .AddButton("btn1", "返回查询", "renamecx.htm") \' .AddButton("btn22", "返回首页", "default.htm") End With e.WriteString(wb.Build) Return Nothing \'必须返回 End If 假如要把黄色部分做成一个函数 怎么做
|
-- 作者:有点蓝 -- 发布时间:2024/3/21 14:50:00 -- Dim e As RequestEventArgs = args(0) Dim wb As New weui = args(1) Dim drs As List(Of DataRow) = args(2) With ExWeUI.WebUI.AddListGroup("page1", "lst01", 1) Dim color1 As String = "style=\'background-color:#f69797\'" \'暗红色,未检疫 Dim color2 As String = "style=\'background-color:#d9a738\'" \'淡黄色,正在检疫 Dim color3 As String = "style=\'background-color:#198d65\'" \'淡绿色,已检疫 Dim color As String For Each dr As DataRow In drs If dr("是否离轮") = True Or dr("电讯检疫") = True Then \'已检疫 color = color3 ElseIf dr("卫检登轮") = True And dr("是否离轮") <> True Then \'检疫中 color = color2 ElseIf dr("卫检登轮") <> True Then color = color1 End If Dim txt As String = "<p " & color & ">中文船名:" & dr("中文船名") & "<br/>" txt = txt & "入境时间:" & dr("入境时间") & "<br/>" txt = txt & "船  籍:" & dr("船籍") & "<br/>" txt = txt & "IMO号:" & dr("IMO号") & "</p>" Dim s As String = dr("船舶资料") If s.length > 10 Then txt = txt & "<p>船舶资料:" & s.substring(0, 10) & "......" & "</p>" Else txt = txt & "<p>船舶资料:" & dr("船舶资料") & "</p>" End If With .AddList(dr("中文船名") & "(" & dr("检查类别") & ")", "") .TextStyle = "color:red;font-size:20px" \'字体颜色,字体大小 .ImageWidth = 2 \'图片大小 With .LeftFooter .AddFoot(txt).Attribute = "style=\'color:white;background-color:#f69797\';font-size:17px\'" If e.Cookies("用户类别") = "企业" Then .AddFoot("详细信息").Attribute = " & dr("_Identify") & "\'"" style=\'color:blue;font-size:20px\'" Else .AddFoot("详细信息").Attribute = " & dr("_Identify") & "\'"" style=\'color:blue;font-size:20px\'" End If End With With .rightFooter If e.Cookies("用户类别") = "企业" And dr("检查类别") = "进检" Then \' .AddFoot("申报出检").Attribute = " & dr("_Identify") & "\'"" style=\'color:green;font-size:20px\'" .AddFoot("申报出检").Attribute = " & dr("_Identify") & "\'"" style=\'color:green;font-size:20px\'" ElseIf e.Cookies("用户类别") <> "企业" Then .AddFoot("拨打电话").Attribute = " & dr("手机号") & "\'"" style=\'color:green;font-size:20px\'" End If End With End With Next p1Div1.InnerHtml = p1Div.InnerHtml & ExWeUI.WebUI.AddHtmlTag("", "p1", "div",.BuildHtml, "class=""exui-scrollview""").buildhtml End With wb.InsertHTML("<div style=\'height:50px\'></div>") wb.InsertHTML("page1", p1Div1.buildhtml) wb.InsertHTML("</div>") wb.InsertHTML("<div style=\'height:50px\'></div>") wb.AddPage("", "page3").Attribute = "style=\'position: fixed;bottom: 0;right: 0;left: 0\'" \'增加两个page With wb.AddButtonGroup("page3", "btg1", False) .Add("btn1", "返回首页", "", "default.htm") If page > 0 Then .Add("btnPrev", "上一页", "", "renamecx.htm?page=" & page - 1) End If If Endrow < count Then .Add("btnNext", "下一页", "", "renamecx.htm?page=" & page + 1) End If .Add("btn2", "清除查询", "button", "Renamecx.htm") End With
|
-- 作者:ycs5801 -- 发布时间:2024/3/21 16:21:00 -- Functions.Execute("xxx",?,?) 调用的时候怎么写? |
-- 作者:有点蓝 -- 发布时间:2024/3/21 16:41:00 -- Functions.Execute("xxx",e,wb,drs) |
-- 作者:ycs5801 -- 发布时间:2024/3/22 8:45:00 -- Functions.Execute("xxx",e,wb,drs) 不太理解为什么要加入wb和drs这两个参数进去? |
-- 作者:有点蓝 -- 发布时间:2024/3/22 9:05:00 -- 因为里面的代码用到 |