<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        cc.contract_id,
                        cc.contract_number,
                        (select pp.project_number from prj_project pp where pp.project_id=cc.project_id) project_number,
                        ccb.bp_name,
                        (select hm.bp_name from hls_bp_master hm where hm.bp_id = cc.bp_id_agent_level1) bp_id_agent_level1_n,
                        ccb.bp_id,
                        ccb.bp_category,
                        ccb.bp_category_n,
                        ccb.id_card_no
                        --(select ci.license_number from con_contract_lease_item ci where ci.contract_id=cc.contract_id) license_number,
                        --(select ci.item_frame_number from con_contract_lease_item ci where ci.contract_id=cc.contract_id) item_num
                    FROM
                        con_contract cc,
                        con_contract_bp_lv ccb
                    WHERE
   
                        cc.contract_id       = ccb.contract_id(+) AND
                        cc.data_class       = 'NORMAL' AND
                        cc.contract_status IN ('NEW','SIGN','INCEPT','ETING','ADING') AND
                        ccb.bp_category     = 'TENANT'
                    ) v #WHERE_CLAUSE#
                ORDER BY
                    v.contract_number DESC
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="contract_number" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" physicalName="contract_number" prompt="支付表编号"/>
        <bm:field name="project_number" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" physicalName="project_number" prompt="申请编号"/>
        <bm:field name="bp_name" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" physicalName="bp_name" prompt="客户名"/>
        <!--  <bm:field name="license_number" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" physicalName="license_number" prompt="车牌号"/> -->
        <bm:field name="bp_category" databaseType="VARCHAR" datatype="java.lang.String" physicalName="bp_category"/>
        <bm:field name="bp_category_n" databaseType="VARCHAR" datatype="java.lang.String" physicalName="bp_category_n"/>
        <bm:field name="bp_id" databaseType="VARCHAR" datatype="java.lang.String" forDisplay="false" forQuery="false" physicalName="bp_id"/>
        <!-- <bm:field name="contract_number" databaseType="VARCHAR" datatype="java.lang.String" physicalName="contract_number"/> -->
        <bm:field name="id_card_no" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="200" physicalName="id_card_no" prompt="身份证"/>
        <!-- <bm:field name="license_number" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" physicalName="license_number"/> -->
        <!--  <bm:field name="item_num" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="250" forDisplay="true" forQuery="true" physicalName="item_num" prompt="车架号"/> -->
        <bm:field name="bp_id_agent_level1_n" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" prompt="经销商"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="v.contract_number like ${@contract_number}"/>
        <bm:query-field name="project_number" queryExpression="v.project_number like ${@project_number}"/>
        <bm:query-field name="bp_name" queryExpression="v.bp_name like ${@bp_name}"/>
        <bm:query-field name="id_card_no" queryExpression="v.id_card_no like ${@id_card_no}"/>
        <!--    <bm:query-field name="license_number" queryExpression="v.license_number like ${@license_number}"/>
        <bm:query-field name="item_num" queryExpression="v.item_num like ${@item_num}"/> -->
        <bm:query-field name="bp_id_agent_level1_n" queryExpression="v.bp_id_agent_level1_n like ${@bp_id_agent_level1_n}"/>
    </bm:query-fields>
</bm:model>
