fix: 参数名改用mkt_id避免与行数据marketing_id字段冲突,照抄产品明细params_mapping模式
This commit is contained in:
parent
e311a42e99
commit
0144129ec1
@ -77,8 +77,22 @@
|
|||||||
{
|
{
|
||||||
"wid": "self",
|
"wid": "self",
|
||||||
"event": "gen_promo",
|
"event": "gen_promo",
|
||||||
"actiontype": "script",
|
"actiontype": "urlwidget",
|
||||||
"script": "(function(){var id='${id}$';if(!id||id==='${id}$'){alert('未获取到方案ID,请先选中一行。');return;}var x=new XMLHttpRequest();x.open('POST','{{entire_url('../api/gen_promo_from_mkt.dspy')}}',true);x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');x.onload=function(){try{var d=JSON.parse(x.responseText);if(d.widgettype==='Message'){var m=new bricks.Message(d.options);m.show();}else{alert(d.options.message||x.responseText);}}catch(e){alert(x.responseText);}};x.send('marketing_id='+encodeURIComponent(id));})();"
|
"target": "PopupWindow",
|
||||||
|
"popup_options": {
|
||||||
|
"title": "生成促销码",
|
||||||
|
"cwidth": 16,
|
||||||
|
"cheight": 10
|
||||||
|
},
|
||||||
|
"params_mapping": {
|
||||||
|
"mapping": {
|
||||||
|
"id": "mkt_id"
|
||||||
|
},
|
||||||
|
"need_other": false
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"url": "{{entire_url('../api/gen_promo_from_mkt.dspy')}}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"new_data_url": "{{entire_url('/discount/api/marketing_create.dspy')}}",
|
"new_data_url": "{{entire_url('/discount/api/marketing_create.dspy')}}",
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
# 从营销方案直接生成促销码(toolbar 工具按钮调用)
|
# 从营销方案直接生成促销码(toolbar 工具按钮调用)
|
||||||
marketing_id = params_kw.get('marketing_id', '')
|
# 参数 mkt_id = 选中行的 id 字段(params_mapping: id → mkt_id)
|
||||||
if not marketing_id:
|
mkt_id = params_kw.get('mkt_id', '')
|
||||||
|
if not mkt_id:
|
||||||
return {"widgettype": "Error", "options": {"title": "操作失败", "message": "缺少方案ID", "cwidth": 16, "cheight": 9, "timeout": 3}}
|
return {"widgettype": "Error", "options": {"title": "操作失败", "message": "缺少方案ID", "cwidth": 16, "cheight": 9, "timeout": 3}}
|
||||||
|
|
||||||
result = await generate_promo_code(request, {"marketing_id": marketing_id})
|
result = await generate_promo_code(request, {"marketing_id": mkt_id})
|
||||||
if result.get("status") == "success":
|
if result.get("status") == "success":
|
||||||
return {
|
return {
|
||||||
"widgettype": "Message",
|
"widgettype": "Message",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user