<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Harry  
    $Date: 2017-1-9 下午01:13:07  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_BP_MASTER_V">
    <bm:fields>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID" prompt="HLS_BP_MASTER_V.BP_ID"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="120" forDisplay="true" forQuery="true" physicalName="BP_CODE" prompt="经销商编码"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="210" forDisplay="true" forQuery="true" physicalName="BP_NAME" prompt="经销商名称"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="HLS_BP_MASTER_V.COMPANY_ID"/>
        <bm:field name="company_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_CODE" prompt="HLS_BP_MASTER_V.COMPANY_CODE"/>
        <bm:field name="company_short_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_SHORT_NAME" prompt="HLS_BP_MASTER_V.COMPANY_SHORT_NAME"/>
        <bm:field name="company_full_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_FULL_NAME" prompt="HLS_BP_MASTER_V.COMPANY_FULL_NAME"/>
        <bm:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY"/>
        <bm:field name="bp_category_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY_NAME"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS"/>
        <bm:field name="bp_class_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS_NAME"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="bp_id" queryOperator="="/>
        <bm:query-field field="bp_code" queryOperator="like"/>
        <bm:query-field field="bp_name" queryExpression="t1.bp_name like &apos;%&apos;||${@bp_name}||&apos;%&apos;"/>
        <bm:query-field field="bp_category" queryExpression="(t1.bp_category = ${@bp_category} or exists(select 1 from hls_bp_master_role br where br.bp_id = t1.bp_id     and br.bp_category = ${@bp_category} and br.bp_type = ${@bp_category}))"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="query" expression="(t1.enabled_flag=&apos;Y&apos;)"/>
        <bm:data-filter name="bp_category" expression="t1.bp_category = &apos;AGENT&apos;"/>
    </bm:data-filters>
</bm:model>
