以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助] 获取页面  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=149207)

--  作者:cool314156
--  发布时间:2020/4/26 13:27:00
--  [求助] 获取页面

Dim e As RequestEventArgs = args(0)
Dim wb As New weui
\'删除订单明细
If e.GetValues.ContainsKey("deldid") Then
    DataTables("入库").SQLDeleteFor("[_Identify] = " & e.GetValues("deldid"))
End If
\'订单编辑
Dim pr As DataRow \'采购订单 - 父表
Dim srs As List(of DataRow) \'订单明细集合 - 子表
Dim Page As Integer \'页码变量
If e.GetValues.ContainsKey("page") Then  \'如果地址中有page参数
    Integer.TryParse(e.GetValues("page"), page) \'提取page参数
End If
If e.GetValues.ContainsKey("oid") = False Then \'如果没有传递订单编号,则新增与一个订单
    pr = DataTables("采购订单").SQLAddNew() \'
    pr("订单编号") = Functions.Execute("GetOrderID") \'利用自定义函数GetOrderID为新增订单生成编号.
    \'pr("") = Date.Today()
Else \'如果传递了订单编号,则找出此订单进行编辑
    pr = DataTables("采购订单").SQLFind("订单编号=\'" & e.GetValues("oid") & "\'")
    If pr Is Nothing Then \'多用户情况下,必须考虑其他用户删除订单的可能.
        wb.InSertHtml("此订单已被其他用户删除!")
        e.WriteString(wb.Build)
        Return ""  \'必须返回
    End If
    srs =  DataTables("入库").SQLSelect("订单编号=\'" & pr("订单编号")  & "\'") \'获取订单明细
End If
Dim url As String = "edit.htm?page=" & page &  "&oid=" & pr("订单编号")  \'传递页码和订单编号
wb.AddForm("","form1",url)
With wb.AddInputGroup("form1","ipg1",iif(e.GetValues.ContainsKey("oid"),"来货信息",""))
    With .AddInput("订单编号","订单编号","text")
        .Value = pr("订单编号")
        .Readonly = True
    End With
    \'.AddInput("订单编号","订单编号","text").Value = pr("订单编号")
    .AddInput("单位名称","单位名称","text").Value = pr("单位名称")
    .AddInput("验收日期","验收日期","date").Value = pr("验收日期")
    \'.AddInput("验收日期","验收日期","date").Value = pr("验收日期")
    \'\'If e.GetValues.ContainsKey("oid")  Then \'如果是旧采购订单,
    \'Dim qty As Integer
    \'Dim amt As Integer
    \'For Each sr As DataRow In srs
    \'qty = qty + sr("数量")
    \'amt = amt + sr("数量") * sr("单价")
    \'Next
    \'.AddInput("总数量","总数量","number").value = qty
    \'.AddInput("总金额","总金额","number").value = amt
    \'End If
End With
\'订单明细编辑
Dim mr As DataRow \'要编辑的订单明细
Dim IsNew As Boolean \'此变量用于标记是否要新增明细
If e.GetValues.ContainsKey("oid") = False OrElse e.GetValues.ContainsKey("addnext") \'如果是新增订单,或这包括addnext参数
    IsNew = True \'将IsNew参数设置为True,表明需要新增订单明细
ElseIf e.GetValues.ContainsKey("did") Then \'如果传递了订单明细主键
    mr = DataTables("入库").SQLFind("[_Identify]=" & e.GetValues("did")) \'找出此订单明细进行编辑
End If
If IsNew OrElse mr IsNot Nothing  Then
    With wb.AddInputGroup("form1","ipg2",iif(IsNew,"","上架明细"))
        \'.Attribute = "" \'调用js函数,自动计算金额
        If IsNew Then \'如果是新增订单明细
            \'.AddInput("产品","产品","text")    \'AddInput("订单编号","订单编号","text")
            \'.AddInput("通用名","通用名","text")
            \'.AddInput("规格","规格","text")
            \'.AddInput("批号","批号","text")
            \'.AddInput("入库数量","入库数量","number")
            \'.AddInput("单位","单位","text")
            \'.AddInput("货位号","货位号","text")
            \'.AddInput("入库时间","入库时间","date").value  = Date.Today()
            \'
        Else
            .AddHiddenValue("DetailID",mr("_Identify")) \'插入一个隐藏的订单明细主键,此值将随表单数据一并提交到服务器.
            .AddInput("通用名","通用名","text").Value = mr("通用名")
            .AddInput("规格","规格","text").Value = mr("规格")
            .AddInput("批号","批号","text").Value = mr("批号")
            .AddInput("入库数量","入库数量","number").value = mr("入库数量")
            .AddInput("单位","单位","text").Value = mr("单位")
            .AddInput("货位号","货位号","text").Value = mr("货位号")
            .AddInput("入库时间","入库时间","date").value  = Date.Today()
            \'With .AddInput("单价","单价","number")
            \'.Step= "0.01"
            \'.value = mr("单价")
            \'End With
            \'.AddInput("金额","金额","number").value = mr("数量") * mr("单价") \'后台没有金额列,要通过数量和单价计算得出
        End If
    End With
   
    \'Dim msr() As String =  {"入库数量","货位号"} \'重新定义了nms数组,了两列.
    \'For Each ms As String In msr
    \'If e.PostValues.ContainsKey(ms) Then
    \'mr(ms) = e.PostValues(ms)
    \'
    \'End If
    \'Next
End If


\'生成订单明细表格
If e.GetValues.ContainsKey("oid") AndAlso  srs.count > 0 Then \'如果不是新增订单,且订单明细行数大于0,则生成入库明细表格.
    With wb.AddTable("form1","detailTable") \'为了区分,明细表的名字设为detailTable
        .head.AddRow("通用名","规格","批号","入库数量","单位","货位号")
        .ActiveSheet = "menu" \'指定菜单
        For Each sr As DataRow In srs
            With .Body.AddRow(sr("通用名"),sr("规格"),sr("批号"),sr("入库数量"),sr("单位"),sr("货位号"))
                \'.AddCell(sr("数量") * sr("单价"))
                .Primarykey = sr("_Identify") \'为此行指定主键值
            End With
        Next
    End With
    \'设计菜单
    With wb.AddActionSheet("","menu")
        \'.Add("mnudAdd", "新增明细").Attribute="" \'调用js函数
        .Add("mnuEdit", "编辑明细").Attribute =""
        .Add("mnuDelete", "删除明细").Attribute ="""
        .Add("mnuCancel","取消","",True)
    End With
End If
With wb.AddDialog("","dlg1", "删除确认","您确定要删除当前明细吗?")
    .AddButton("btnCancel","取消").Kind = 1
    .AddButton("btnOK","确定").Attribute = ""
End With
With wb.AddButtonGroup("form1","btg1",False)
    \'.Add("btn4", "新增明细", "submit").Attribute =""  \'加上addnext参数,表示保存后进入增加明细状态
    .Add("btn1", "编辑明细", "submit").FormAction = url & "&did=" detailtable.primarykey
    .Add("btn2", "保存", "submit") \'正常提交,保存后进入编辑状态
   
   
    If  e.GetValues.ContainsKey("oid") = False Then \'如过是新增订单
        .Add("btn3", "取消", "button","list.htm?page=" & page & "&deloid=" & pr("订单编号")) \'删除新增订单后返回列表
    ElseIf IsNew OrElse mr IsNot Nothing  Then \'如果在给旧订单新增或修改明细,则直接返回编辑状态
        .Add("btn3", "取消", "button",url) \'返回编辑状态
    Else
        .Add("btn3", "返回", "button","list.htm?page=" & page) \'返回列表
    End If
End With
pr.Save() \'必须保存,而且必须在最后保存,因为SQLAddNew增加的行,保存之后就会销毁,无法再调用
If e.PostValues.Count > 0 Then \'如果是通过提交按钮访问,则给一个已经保存的提示给用户,时长500毫秒
    wb.AddToast("","t1", "已经保存",0).Msec= 500
End If
wb.AppendHTML("<script src=\'./lib/order.js\'></script>") \'引入脚本文件
e.WriteString(wb.Build) \'生成网页

 

求教下,蓝色字体的这段代码 会出现报错,要怎么写才能点击编辑明细时获取正确的网页

[此贴子已经被作者于2020/4/26 13:27:03编辑过]

--  作者:有点蓝
--  发布时间:2020/4/26 13:53:00
--  
必须使用js处理:http://www.foxtable.com/mobilehelp/topics/0129.htmhttp://www.foxtable.com/mobilehelp/topics/0128.htm

在目录"d:\\web\\lib"新建一个文本文件"order.js",内容为:

function edit(){
   location="edit.htm?page=" + 
detailTable.pagenumber + "&oid=" + detailTable.primarykey + ; 
}


.Add("btn1", "编辑明细", "button").Attribute ="onclick=\'edit()\'"

--  作者:cool314156
--  发布时间:2020/4/26 14:14:00
--  

谢谢老师了


--  作者:cool314156
--  发布时间:2020/4/26 15:13:00
--  
老师,我用你改代码试了试,好像还是不可以啊
--  作者:有点蓝
--  发布时间:2020/4/26 15:17:00
--  
打开浏览器开发者工具自己调试一下。如果不会就上传实例测试