以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]setAjaxOptions的缺陷能否改进? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102434) |
-- 作者:shenyl0211 -- 发布时间:2017/6/19 22:06:00 -- [求助]setAjaxOptions的缺陷能否改进? 下列函数中,使用setAjaxOptions选择了项目名称,点击提交申请时,一旦判断有数据漏填后,选择完善数据时,项目名称会被清空,但不会清空项目经理,此时必须先选一个错误的项目经理,再选正确的项目经理,然后才能选正确的项目名称。虽然编程人员知道只能这样操作,但确实无法让使用人员理解。 请问狐爸能否改进这个缺陷? (定义公共变量略、其它htm页面和js函数略) Dim e As RequestEventArgs = args(0) Dim rw,rw0,bmmc,nms(),nm,fqr,fqrq,jsr,jsr0 As String Dim dr As DataRow Dim dc As DataCol Dim wb As new WeUI Dim i As Integer dtname="项目借款" If e.PostValues.count = 0 Then wb.AppendHTML("<style>.red{color:red;}</style>", True) wb.AddForm("","form1","增加" & dtname & ".htm") With wb.AddInputGroup("form1","ipg1","基本信息") With .AddInput("申请部门","申请部门","text") .value=department .readonly=True End With .AddInput("收款人","收款人","text") .AddInput("开户银行","开户银行","text") .AddInput("账号","账号","text") With .AddSelect("项目经理","项目经理","|" & DataTables("项目管理").SQLGetComboListString("项目经理","部门名称=\'" & department & "\' and (项目经理=\'" & _username & "\' or 借款人=\'" & _username & "\')")) .Attribute = "on-change=""setAjaxOptions(\'项目名称\',\'项目名称.htm\',\'项目经理\',true)""" End With .Addselect("项目名称","项目名称","").Attribute = "on-change=\'项目信息()\'" .AddInput("合同额","合同额","number") .Readonly=True .AddInput("完成产值","完成产值","number").Readonly=True .AddInput("预算成本","预算成本","number").Readonly=True .AddInput("匹配成本","匹配成本","number").Readonly=True With .AddInput("开累支出","开累支出","number") .Readonly=True .Step="0.01" End With .AddInput("允许借款","允许借款","number").Readonly=True .AddInput("累计到款","累计到款","number").Readonly=True With .AddInput("借款余额","借款余额","number") .Readonly=True .Step="0.01" End With .AddInput("用途","用途","text") With .AddInput("借款金额","借款金额","number") .Placeholder="单位元" .Step = "0.01" End With End With With wb.AddInputGroup("form1","ipg2","备注") With .AddTextArea("备注",5) .Placeholder="100字以内" .class = "red" End With End With With wb.AddInputGroup("form1","ipg3","审批信息") With .AddInput("申请人","申请人","text") .Value = _username .Readonly= True End With With .AddInput("申请日期","申请日期","datetime-local") .value= Format(Date.Now,"yyyy-MM-ddTHH:mm") .readonly=True End With .AddSelect("申请部门会计","申请部门会计",DataTables("字典管理").SQLGetComboListString("财务人员","部门名称=\'" & department & "\'")) .AddSelect("申请部门领导","申请部门领导",DataTables("字典管理").SQLGetComboListString("部门领导","部门名称=\'" & department & "\'")) .AddSelect("财务部领导","财务部领导",DataTables("字典管理").SQLGetComboListString("部门领导","部门名称=\'财务部\'")) .AddSelect("审计部领导","审计部领导",DataTables("字典管理").SQLGetComboListString("部门领导","审批部门=\'审计部\'")) .AddSelect("公司分管领导","公司分管领导",DataTables("字典管理").SQLGetComboListString("分管领导","部门名称=\'" & department & "\'")) .AddSelect("总经理","总经理",DataTables("字典管理").SQLGetComboListString("部门领导","审批部门=\'总经理\'")) .AddSelect("财务部受理","财务部受理",DataTables("字典管理").SQLGetComboListString("财务人员","部门名称=\'" & department & "\'")) End With With wb.AddButtonGroup("form1","btg1",False) .Add("bt1","提交申请","submit") .Add("bt2","取消申请","button","首页.htm") End With Else If CInt(e.PostValues("借款金额")) = 0 Then With wb.AddMsgPage("","msgpage","增加失败","《借款金额》必填!") .icon = "Warn" .AddButton("btn1","完善数据").Attribute = "on-click=\'history-back()\'" .AddButton("btn2","取消申请","首页.htm") End With e.WriteString(wb.Build) Return "" End If If e.PostValues.ContainsKey("备注") AndAlso e.PostValues("备注").Length > 100 Then With wb.AddMsgPage("","msgpage","增加失败","《备注》长度超过100了!") .icon = "Warn" .AddButton("btn1","完善数据").Attribute = "on-click=\'history-back()\'" .AddButton("btn2","取消申请","首页.htm") End With e.WriteString(wb.Build) Return "" End If nms = new String() {"申请部门","收款人","开户银行","账号","项目名称","合同额","用途","项目经理","申请部门会计","申请部门领导","财务部领导","审计部领导","公司分管领导","总经理","财务部受理"} For Each nm In nms If e.PostValues.ContainsKey(nm) = False Then With wb.AddMsgPage("","msgpage","增加失败","请输入《 " & nm & " 》!") .icon = "Warn" .AddButton("btn1","完善内容").Attribute = "on-click=\'history-back()\'" .AddButton("btn2","取消申请","首页.htm") End With e.WriteString(wb.Build) Return "" End If Next dr = DataTables(dtname).AddNew For Each dc In DataTables(dtname).DataCols If dc.name = "借款金额" Then dr(dc.name) = cdbl(e.PostValues(dc.name)) ElseIf e.PostValues.ContainsKey(dc.name) Then dr(dc.name) = e.PostValues(dc.name) Else dr(dc.name)= Nothing End If Next dr.Save() fqr=_username fqrq=Format(Date.now,"yyyy-MM-ddTHH:mm") jsr = "项目经理" jsr0 = dr("项目经理") rw = "请复核!" xxx = "+@|" & dtname & "|" & dr("_Identify") & "|" & jsr0 & "|" & rw dr = DataTables("待批任务").AddNew dr("发送人") = fqr dr("发送时间") = fqrq dr("发送信息") = xxx dr.save() fhs.Add(xxx.SubString(3)) With wb.AddMsgPage("","msgpage","申请完成","已通知 " & jsr & " --> " & jsr0 & " 进行复核") .Icon="success" \'"info","warn" .AddButton("btn1","继续增加","增加" & dtname & ".htm") .AddButton("btn2","返回首页","首页.htm") End With End If wb.AppendHTML("<script src=\'./weui/项目借款.js\'></script>") e.WriteString(wb.Build)
[此贴子已经被作者于2017/6/19 22:14:32编辑过]
|
-- 作者:有点蓝 -- 发布时间:2017/6/19 22:26:00 -- 这里不应该使用“history-back()”,应该重新刷新页面, .AddButton("btn1","完善内容","xxxx.htm") 如果页面内容比较多,建议使用js进行验证 |
-- 作者:shenyl0211 -- 发布时间:2017/6/19 23:03:00 -- 1、刷新页面会导致全部重填,效率更低,还不如用history-back()。 2、我也知道用js函数,但就是希望少用函数,减少流量,提高速度。
|
-- 作者:有点蓝 -- 发布时间:2017/6/19 23:08:00 -- history-back()就这样,没有办法。 有些时候该用的就要用。如果是纯js判断,不可能会产生流量的。而且比您现在history-back()的用法更省流量
|
-- 作者:有点色 -- 发布时间:2017/6/20 9:34:00 -- 你这种,为什么不用 submitAjaxForm ?
http://www.foxtable.com/mobilehelp/scr/0101.htm
|
-- 作者:shenyl0211 -- 发布时间:2017/6/20 21:23:00 -- 经过比较,还是submitAjaxFileds的效果好 |