<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lingfeng.chen
    $Date: 2017-7-14 上午10:06:32
    $Revision: 1.0
    $Purpose: 潜在客户管理
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="basic.hls_sys_time_default_value" rootPath="default_value_path"/>
        <a:model-query model="basic.sys_session_info" rootPath="mainPage_session_record"/>
        <a:model-query defaultWhereClause="t1.role_id=${/session/@role_id} and t1.company_id=${/session/@company_id}" fetchAll="true" model="hls.HLS109.hls_default_parameter" rootPath="hls_default_parameter_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="hls2104_hn_chance_bp_interviews_link" url="${/request/@context_path}/modules/hls/HLS2104/hn_chance_bp_interviews.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CHANCE_BP&amp;function_code=HLS2104"/>
        <script type="text/javascript"><![CDATA[
            function hls2104_grid_editorFunction(record, name) {
                if (name == 'chance_bp_name') {
                    return 'hls2104_grid_textField';
                }
                if (name == 'bp_class_desc') {
                    return 'hls2104_grid_comboBox';
                }
                if (name == 'chance_source_desc') {
                    return 'hls2104_grid_comboBox';
                }
                if (name == 'orgcrdno') {
                    if (record.get('bp_class') == 'ORG') {
                        return 'hls2104_grid_textField_18';
                    }
                }
                if (name == 'id_card_no') {
                    if (record.get('bp_class') == 'NP') {
                        return 'hls2104_grid_textField';
                    }
            
                }
                if (name == 'contact_person') {
                    if (record.get('bp_class') == 'ORG') {
                        return 'hls2104_grid_textField';
                    }
            
                }
                if (name == 'cell_phone') {
                    return 'hls2104_grid_textField';
                }
                if (name == 'enabled_flag') {
                    return 'hls2104_grid_checkBox';
                }
            
                return '';
            }
            
            function hls2104_query() {
                $("hls2104_hn_chance_bp_result_ds").query();
            }
            
            function hls2104_reset() {
                $('hls2104_hn_chance_bp_query_ds').reset();
            }
            
            function hls2104_ds_update_handler(ds, record, name, value, oldvalue) {
                if (name == 'bp_class') {
                    if (value == 'ORG') {
                        record.getField('contact_person').setRequired(true);
                        record.getField('orgcrdno').setRequired(true);
                    }
                    if (value == "NP") {
                        record.getField('contact_person').setRequired(false);
                        record.getField('orgcrdno').setRequired(false);
                    }
                }
            }
            
            function hls2104_open_win(id) {
                var record = $('hls2104_hn_chance_bp_result_ds').findById(id);
                var url = $('hls2104_hn_chance_bp_interviews_link').getUrl();
                var win = new Leaf.Window({
                    id: 'hls2104_hn_chance_bp_interviews_winid',
                    url: url,
                    params: {
                        chance_bp_id: record.get('chance_bp_id'),
                        chance_bp_name: record.get('chance_bp_name'),
                        winid: 'hls2104_hn_chance_bp_interviews_winid'
                    },
                    title: '访谈信息',
                    fullScreen: true
                });
            
            }
            
            function hls2104_detail_renderer(value, record, name) {
            
                if (!record.isNew) {
                    return "<a href='javascript:hls2104_open_win(" + record.id + ")'>访谈信息</a>";
                }
            }
            
            function orgcrdno_validator(record, name, value) {
                if (value  ) {
                    var reg = /^[a-zA-Z0-9]+$/;
                    if (reg.test(value)) {
                        return true;
                    }
                    return '只能包含字母数字';
                }
                return true;
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls211_bp_class_ds" lookupCode="HLS211_BP_CLASS"/>
            <a:dataSet id="lch501_chance_source_ds" lookupCode="LCH501_CHANCE_SOURCE"/>
            <a:dataSet id="hls2104_is_bp_ds" autoCreate="true">
                <a:datas>
                    <a:record name="潜在客户" value="潜在客户"/>
                    <a:record name="商业伙伴" value="商业伙伴"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="hls2104_hn_chance_bp_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="chance_bp_name"/>
                    <a:field name="bp_class_desc" displayField="code_value_name" options="hls211_bp_class_ds" returnField="bp_class" valueField="code_value"/>
                    <a:field name="bp_class"/>
                    <a:field name="is_bp_desc" displayField="name" options="hls2104_is_bp_ds" returnField="is_bp" valueField="value"/>
                    <a:field name="is_bp"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls2104_hn_chance_bp_result_ds" autoPageSize="true" autoQuery="true" model="hls.HLS2104.hn_chance_bp" queryDataSet="hls2104_hn_chance_bp_query_ds">
                <a:fields>
                    <a:field name="bp_class_desc" displayField="code_value_name" options="hls211_bp_class_ds" required="true" returnField="bp_class" valueField="code_value"/>
                    <a:field name="chance_source_desc" displayField="code_value_name" options="lch501_chance_source_ds" required="true" returnField="chance_source" valueField="code_value"/>
                    <a:field name="unit_id" defaultValue="${/model/hls_default_parameter_path/record/@unit_id}"/>
                    <a:field name="unit_id_n" defaultValue="${/model/hls_default_parameter_path/record/@unit_name}"/>
                    <a:field name="owner_user_id_n" defaultValue="${/model/mainPage_session_record/record/@user_desc}"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="chance_bp_name" required="true"/>
                    <a:field name="cell_phone" required="true"/>
                    <a:field name="id_card_no" validator="orgcrdno_validator"/>
                    <a:field name="orgcrdno" validator="orgcrdno_validator"/>
                    <a:field name="creation_date_desc" defaultValue="${/model/default_value_path/record/@now_time}"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="hls2104_ds_update_handler"/>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hls2104_query" text="HLS.QUERY"/>
                <a:gridButton click="hls2104_reset" text="HLS.RESET"/>
                <!-- <a:gridButton bind="hls2104_hn_chance_bp_result_grid" text="新增" type="add"/>
                <a:gridButton bind="hls2104_hn_chance_bp_result_grid" text="HLS.SAVE" type="save"/> -->
            </a:screenTopToolbar>
            <a:form column="3" title="查询条件">
                <a:textField name="chance_bp_name" bindTarget="hls2104_hn_chance_bp_query_ds" prompt="客户名称"/>
                <a:comboBox name="bp_class_desc" bindTarget="hls2104_hn_chance_bp_query_ds" prompt="客户类型"/>
                <a:comboBox name="is_bp_desc" bindTarget="hls2104_hn_chance_bp_query_ds" prompt="客户状态"/>
            </a:form>
            <a:grid id="hls2104_hn_chance_bp_result_grid" bindTarget="hls2104_hn_chance_bp_result_ds" marginHeight="200" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="chance_bp_name" prompt="客户名称" width="200"/>
                    <a:column name="bp_class_desc" prompt="客户类型"/>
                    <!--   <a:column name="chance_source_desc" prompt="客户来源"/> -->
                    <a:column name="orgcrdno" prompt="社会统一信用证代码" width="200"/>
                    <a:column name="id_card_no" prompt="身份证号码" width="150"/>
                    <a:column name="contact_person" prompt="联系人"/>
                    <a:column name="cell_phone" prompt="联系方式"/>
                    <a:column name="unit_id_n" prompt="业务部"/>
                    <a:column name="owner_user_id_n" prompt="创建人"/>
                    <a:column name="creation_date_desc" prompt="创建时间" renderer="Leaf.formatDate"/>
                    <a:column name="hls2104_detail_renderer" align="center" prompt="访谈记录" renderer="hls2104_detail_renderer"/>
                    <a:column name="is_bp" prompt="客户状态"/>
                    <!-- <a:column name="enabled_flag" prompt="启用"/> -->
                </a:columns>
                <a:editors>
                    <a:comboBox id="hls2104_grid_comboBox"/>
                    <a:checkBox id="hls2104_grid_checkBox" checkedValue="Y" uncheckedValue="N"/>
                    <a:datePicker id="hls2104_grid_datePicker"/>
                    <a:lov id="hls2104_grid_lov"/>
                    <a:textField id="hls2104_grid_textField_18" maxLength="18"/>
                    <a:textField id="hls2104_grid_textField"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
