fix: 手机验证码tab改用VBox+独立Button,避免toolbar tool触发submit导致tab跳转
根因:Form toolbar tool点击会同时触发Form的submit事件, submit的urlwidget替换Form后TabPanel重置到第一个tab。 改为VBox包裹Form和独立Button,Button通过bricks.getWidgetById 读取Form值,fetch加_webbricks_=1确保返回纯JSON。
This commit is contained in:
parent
7200ee43a0
commit
92627c9c96
@ -55,7 +55,11 @@
|
||||
"name": "checkcode",
|
||||
"label": "手机验证码",
|
||||
"content": {
|
||||
"widgettype": "VBox",
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "Form",
|
||||
"id": "phone_form",
|
||||
"options": {
|
||||
"description": "限中国国内手机",
|
||||
"fields": [
|
||||
@ -74,26 +78,9 @@
|
||||
"label": "验证码",
|
||||
"uitype": "str"
|
||||
}
|
||||
],
|
||||
"toolbar": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "gen_code",
|
||||
"label": "发送验证码"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "gen_code",
|
||||
"actiontype": "script",
|
||||
"datawidget": "self",
|
||||
"datamethod": "getValue",
|
||||
"target": "self",
|
||||
"script": "var cell=params.cell_no;if(!cell){alert('请输入手机号');return;}fetch(bricks.app.baseUrl+'/rbac/gen_sms_code.dspy?cellphone='+encodeURIComponent(cell)).then(function(r){return r.json()}).then(function(d){if(d.status==='ok'){this.setValue({codeid:d.data.key});alert('验证码已发送')}else{alert(d.data.message)}}.bind(this)).catch(function(e){alert('发送失败:'+e)})"
|
||||
},
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "submit",
|
||||
@ -105,6 +92,24 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
"id": "gen_code_btn",
|
||||
"options": {
|
||||
"label": "发送验证码"
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var form=bricks.getWidgetById('phone_form',bricks.app);if(!form){alert('form not found');return;}var vals=form.getValue();var cell=vals.cell_no;if(!cell){alert('请输入手机号');return;}this.options.label='发送中...';this.el&&(this.el.disabled=true);fetch(bricks.app.baseUrl+'/rbac/gen_sms_code.dspy?_webbricks_=1&cellphone='+encodeURIComponent(cell)).then(function(r){return r.json()}).then(function(d){var btn=bricks.getWidgetById('gen_code_btn',bricks.app);if(d.status==='ok'){form.setValue({codeid:d.data.key});if(btn){btn.options.label='已发送';btn.el&&(btn.el.disabled=false)}}else{alert(d.data.message);if(btn){btn.options.label='发送验证码';btn.el&&(btn.el.disabled=false)}}}).catch(function(e){alert('发送失败:'+e);var btn=bricks.getWidgetById('gen_code_btn',bricks.app);if(btn){btn.options.label='发送验证码';btn.el&&(btn.el.disabled=false)}})"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user