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,54 +55,59 @@
|
|||||||
"name": "checkcode",
|
"name": "checkcode",
|
||||||
"label": "手机验证码",
|
"label": "手机验证码",
|
||||||
"content": {
|
"content": {
|
||||||
"widgettype": "Form",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"subwidgets": [
|
||||||
"description": "限中国国内手机",
|
{
|
||||||
"fields": [
|
"widgettype": "Form",
|
||||||
{
|
"id": "phone_form",
|
||||||
"name": "cell_no",
|
"options": {
|
||||||
"label": "手机号",
|
"description": "限中国国内手机",
|
||||||
"uitype": "str"
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "cell_no",
|
||||||
|
"label": "手机号",
|
||||||
|
"uitype": "str"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "codeid",
|
||||||
|
"uitype": "hide",
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "check_code",
|
||||||
|
"label": "验证码",
|
||||||
|
"uitype": "str"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
"binds": [
|
||||||
"name": "codeid",
|
|
||||||
"uitype": "hide",
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "check_code",
|
|
||||||
"label": "验证码",
|
|
||||||
"uitype": "str"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"toolbar": {
|
|
||||||
"tools": [
|
|
||||||
{
|
{
|
||||||
"name": "gen_code",
|
"wid": "self",
|
||||||
"label": "发送验证码"
|
"event": "submit",
|
||||||
|
"actiontype": "urlwidget",
|
||||||
|
"target": "self",
|
||||||
|
"options": {
|
||||||
|
"method": "POST",
|
||||||
|
"url": "{{entire_url('code_login.dspy')}}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
|
||||||
"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",
|
"widgettype": "Button",
|
||||||
"event": "submit",
|
"id": "gen_code_btn",
|
||||||
"actiontype": "urlwidget",
|
|
||||||
"target": "self",
|
|
||||||
"options": {
|
"options": {
|
||||||
"method": "POST",
|
"label": "发送验证码"
|
||||||
"url": "{{entire_url('code_login.dspy')}}"
|
},
|
||||||
}
|
"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