<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-9-12 下午04:40:13  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.fc_estimate_id=${/parameter/@fc_estimate_id}" model="rsc.RSC501.rsc_fc_estimate" rootPath="rsc501_fc_estimate_path"/>
        <a:model-query model="basic.sys_session_info" rootPath="rsc501_get_sysdate_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="rsc501_fc_estimate_result_dtl_link" url="${/request/@context_path}/modules/rsc/RSC501/rsc_fc_estimate_result_dtl.lview"/>
        <script type="text/javascript"><![CDATA[
            function rsc501_fc_estimate_result_query_ds_onUpdate(ds, record, name, value, oldValue) {
                if (name == 'estimate_date_f') {
                    if (Leaf.isEmpty(record.get('estimate_date_t'))) {
                        record.set('estimate_date_t', value);
                    }
                }
            }
            
            function rsc501_fc_estimate_result_close() {
                $('rsc501_fc_estimate_result_window').close();
            }
            
            function rsc501_fc_estimate_result_query() {
                $('rsc501_fc_estimate_result_ds').query();
            }
            
            function fnd714_sc_score_result_dtl_open(record_id) {
                var record = $('rsc501_fc_estimate_result_ds').findById(record_id);
                new Leaf.Window({
                    id: 'rsc501_fc_estimate_result_dtl_window',
                    url: $('rsc501_fc_estimate_result_dtl_link').getUrl(),
                    params: {
                        result_id: record.get('result_id'),
                        fc_estimate_id: '${/parameter/@fc_estimate_id}',
                        bp_id: record.get('bp_id'),
                        contract_id: record.get('contract_id'),
                        five_class_plan: '${/parameter/@five_class_plan}'
                    },
                    title: '${l:RSC501.FIVE_CLASS_TARGET_DETAIL}',
                    fullScreen: true
                });
            }
            
            function rsc501_fc_estimate_result_grid_render(value, record, name) {
                if (!record.isNew) {
                    return '<a href="javascript:fnd714_sc_score_result_dtl_open(' + record.id + ');">' + '${l:RSC501.FIVE_CLASS_TARGET_DETAIL}' + '</a>';
                }
                return '';
            }
            
            function rsc501_fc_estimate_result_grid_editorFunc(record, name) {
                if (record.isNew) {
                    if (name == 'contract_number') {
                        return 'rsc501_fc_estimate_result_grid_lov';
                    }
                }
                return '';
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="rsc501_fc_estimate_head_ds">
                <a:datas dataSource="/model/rsc501_fc_estimate_path"/>
                <a:fields>
                    <a:field name="estimate_num" readOnly="true"/>
                    <a:field name="five_class_plan_name" readOnly="true"/>
                    <a:field name="internal_period_num" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="rsc501_five_class_status_ds" lookupCode="RSC_FIVE_CLASS_REMOVAL_APPROVAL_STATUS"/>
            <a:dataSet id="rsc501_fc_estimate_result_query_ds">
                <a:fields>
                    <a:field name="fc_estimate_id" defaultValue="${/parameter/@fc_estimate_id}"/>
                    <a:field name="contract_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON500.con_contract_number_lov" lovWidth="500" title="HLS.CONTRACT_NUMBER">
                        <a:mapping>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="contract_number" to="contract_number"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="status_name" displayField="code_value_name" options="rsc501_five_class_status_ds" returnField="status" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="rsc501_fc_estimate_result_query_ds_onUpdate"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="rsc501_fc_estimate_result_ds" autoPageSize="true" autoQuery="true" model="rsc.RSC501.rsc_fc_estimate_result" queryDataSet="rsc501_fc_estimate_result_query_ds" selectable="true" submitUrl="${/request/@context_path}/modules/rsc/RSC501/rsc_fc_estimate_result.lsc">
                <a:fields>
                    <a:field name="five_class_plan" defaultValue="${/parameter/@five_class_plan}"/>
                    <a:field name="fc_estimate_id" defaultValue="${/parameter/@fc_estimate_id}"/>
                    <a:field name="contract_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON500.con_contract_number_lov" lovWidth="500" title="HLS.CONTRACT_NUMBER">
                        <a:mapping>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="bp_id_tenant" to="bp_id"/>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="estimate_date" defaultValue="${/model/rsc501_get_sysdate_path/record/@today}"/>
                    <a:field name="status" defaultValue="NEW"/>
                    <a:field name="status_name" displayField="code_value_name" options="rsc501_five_class_status_ds" required="true" returnField="status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="rsc501_fc_estimate_result_close" text="HLS.CLOSE"/>
                <a:gridButton click="rsc501_fc_estimate_result_query" text="HLS.QUERY"/>
                <a:gridButton bind="rsc501_fc_estimate_result_grid" type="add"/>
                <a:gridButton bind="rsc501_fc_estimate_result_grid" type="delete"/>
                <a:gridButton bind="rsc501_fc_estimate_result_grid" type="save"/>
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="100">
                <a:textField name="estimate_num" bindTarget="rsc501_fc_estimate_head_ds" prompt="RSC501.ESTIMATE_NUM" typeCase="upper"/>
                <a:comboBox name="five_class_plan_name" bindTarget="rsc501_fc_estimate_head_ds" prompt="RSC501.FIVE_CLASS_PLAN_NAME"/>
                <a:textField name="internal_period_num" bindTarget="rsc501_fc_estimate_head_ds" prompt="RSC501.INTERNAL_PERIOD_NUM"/>
                <a:comboBox name="status_name" bindTarget="rsc501_fc_estimate_result_query_ds" prompt="RSC501.STATUS"/>
                <a:lov name="contract_number" bindTarget="rsc501_fc_estimate_result_query_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <a:textField name="contract_name" bindTarget="rsc501_fc_estimate_result_query_ds" prompt="HLS.CONTRACT_NAME"/>
                <a:datePicker name="estimate_date_f" bindTarget="rsc501_fc_estimate_result_query_ds" prompt="RSC501.ESTIMATE_DATE_F"/>
                <a:datePicker name="estimate_date_t" bindTarget="rsc501_fc_estimate_result_query_ds" prompt="RSC501.ESTIMATE_DATE_T"/>
            </a:form>
            <a:grid id="rsc501_fc_estimate_result_grid" bindTarget="rsc501_fc_estimate_result_ds" marginHeight="200" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" editorFunction="rsc501_fc_estimate_result_grid_editorFunc" prompt="HLS.CONTRACT_NUMBER" width="120"/>
                    <a:column name="contract_name" prompt="HLS.CONTRACT_NAME" width="200"/>
                    <a:column name="five_class_name" prompt="RSC501.FIVE_CLASS_CODE" width="100"/>
                    <a:column name="lamp_color_name" prompt="RSC501.LAMP_COLOR" width="100"/>
                    <a:column name="estimate_date" prompt="RSC501.ESTIMATE_DATE" width="120"/>
                    <a:column name="description" editor="rsc501_fc_estimate_result_grid_tf" prompt="RSC501.DESCRIPTION" width="220"/>
                    <a:column name="status_name" prompt="RSC501.STATUS" width="120"/>
                    <a:column name="detail" align="center" prompt="RSC501.FIVE_CLASS_TARGET_DETAIL" renderer="rsc501_fc_estimate_result_grid_render" width="100"/>
                </a:columns>
                <a:editors>
                    <a:textField id="rsc501_fc_estimate_result_grid_tf"/>
                    <a:comboBox id="rsc501_fc_estimate_result_grid_cb"/>
                    <a:lov id="rsc501_fc_estimate_result_grid_lov"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>