有需求是
编辑条件,进行对条件的路由拼接,进行展示对应报表
在原生的 domain widget 效果不是很理想,并想展示只是编辑条件以及展示条件,并不能满足。所以继承开发并另命名widget
代码如下:
js 修改
在原有代码基础上复制进行修改
export class XCDomainField extends Component {static template = "iframe_manage.XCDomainField";xxxx...}
export const xcdomainField = {component: XCDomainField,xxxx...}
registry.category("fields").add("xcdomain", xcdomainField);
xml 修改
在原有代码基础上复制进行修改
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve"><t t-name="iframe_manage.XCDomainField"><div t-att-class="{ o_inline_mode: !props.editInDialog }"><t t-set="resModel" t-value="getResModel()"/><t t-if="resModel"><t t-if="props.isFoldable and state.folded and state.isValid"><button class="btn btn-primary o_field_domain_dialog_button"t-on-click.prevent="onEditDialogBtnClick">编辑条件</button><t t-foreach="state.facets" t-as="facet" t-key="facet_index"><small class="o_facet_value" t-esc="facet" style="margin-right:5px;"/></t></t><t t-else=""><div class="d-flex"><DomainSelectorresModel="resModel"domain="getDomain()"readonly="props.readonly or props.editInDialog"update.bind="update"isDebugMode="!!env.debug"className="props.readonly ? 'o_read_mode' : 'o_edit_mode'"/></div><div class="o_field_domain_panel d-flex align-items-center gap-2 mt-1"><t t-if="state.isValid === null and state.recordCount === null"><i class="fa fa-circle-o-notch fa-spin ms-2" role="img" aria-label="Loading"title="Loading"/></t><t t-else=""><t t-if="state.isValid"></t><t t-else=""><span class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning"title="Warning"/>Invalid domain</span></t><t t-if="!!env.debug and !props.readonly"><buttonclass="btn btn-sm btn-icon fa fa-refresh o_refresh_count"role="img"aria-label="Refresh"title="Refresh"t-on-click="() => this.checkProps()"/></t></t><t t-if="props.editInDialog and !props.readonly"><button class="btn btn-sm btn-primary o_field_domain_dialog_button"t-on-click.prevent="onEditDialogBtnClick">Edit Domain</button></t></div></t></t><t t-else=""><div>Select a model to add a filter.</div></t></div></t></templates>
效果如下
另附资料