<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Feng  
    $Date: 2014-1-23 下午9:12:39  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_CONTRACT">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT.CONTRACT_ID"/>
        <bm:field name="data_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DATA_CLASS" prompt="CON_CONTRACT.DATA_CLASS"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="230" forDisplay="true" forQuery="true" physicalName="CONTRACT_NUMBER" prompt="合同编号"/>
        <bm:field name="bp_id_agent_level1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_AGENT_LEVEL1" prompt="CON_CONTRACT.BP_ID_AGENT_LEVEL1"/>
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS" prompt="CON_CONTRACT.CONTRACT_STATUS"/>
        <bm:field name="bp_id_agent_level1_n" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select unit_name from exp_org_unit_v where unit_id = bp_id_agent_level1 and enabled_flag = &apos;Y&apos;)" forInsert="false" forUpdate="false" physicalName="BP_ID_AGENT_LEVEL1_N" prompt="经销商名称"/>
        <bm:field name="bp_tenant_name" displayWidth="230" expression="(select bp_name from hls_bp_master where bp_id = t1.bp_id_tenant)" forDisplay="true" forQuery="true" prompt="承租人"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="contract_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="bp_id_agent_level1_n" queryExpression="exists (select 1 from exp_org_unit_v where unit_id = bp_id_agent_level1 and unit_name like ${@bp_id_agent_level1_n}"/>
        <bm:query-field name="bp_tenant_name" queryExpression="${@bp_tenant_name} like (select bp_name from hls_bp_master where bp_id = t1.bp_id_tenant)"/>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like ${@contract_number}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="data_class" enforceOperations="query" expression="t1.data_class = &apos;NORMAL&apos;"/>
        <bm:data-filter name="contract_status" enforceOperations="query" expression="t1.contract_status IN (&apos;INCEPT&apos;,&apos;SIGN&apos;)"/>
    </bm:data-filters>
</bm:model>
