t-on-click 传递参数
xml:
<button class="btn btn-outline-primary m-1" t-on-click="()=>this.runtask('MM离线文件')">MM离线文件</button>
js
/** @odoo-module **/ import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; import { getDefaultConfig } from "@web/views/view"; import { useService } from "@web/core/utils/hooks"; const { Component, useSubEnv, useState } = owl; class SAPBOTSupportView extends Component { "use strict"; setup(){ useSubEnv({ config: { ...getDefaultConfig(), ...this.env.config, }, }); this.rpc = useService("rpc"); this.action = useService('action'); this.display = { controlPanel: { "top-right": false, "bottom-right": false }, }; } async runtask(y){ var x = this.rpc('/runtask', {name: y}); if(x){ this.action.doAction({ type: 'ir.actions.client', tag: 'display_notification', params:{ 'title': "提醒", 'message':"等待一小会儿, 会收到任务邮件.", 'sticky': false,}}) ; }else{ this.action.doAction({ type: 'ir.actions.client', tag: 'display_notification', params:{ 'title': "提醒", 'message':"执行失败, 请联系Grant.", 'sticky': false, }} ); } } } SAPBOTSupportView.components = { Layout }; SAPBOTSupportView.template = "saobot_support_template"; registry.category("actions").add("sapbot.sapbot_support_view", SAPBOTSupportView);