<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-8-13 上午10:30:25  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:view>
        <!-- <a:link id="con_contract_save_link_id" model="cont.CON543.con_contract_save" modelaction="batch_update"/> -->
        <a:link id="con_content_record_id" url="${/request/@context_path}/modules/cont/CON543/con_contract_content.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_contract_update_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update.lview"/>
        <a:link id="con_contract_query_link_id" url="${/request/@context_path}/modules/cont/CON505/con_contract_query.lview"/>
        <script type="text/javascript"><![CDATA[
            function con543_con_contract_query() {
                $('con543_contract_result_ds').query();
            }
            
            function con543_con_contract_reset() {
                $('con541_contract_query_ds').reset();
            }
            
            function con555_contractMaintainDs_grid_update2(contract_id, cdd_list_id) {
                var url = $('con_content_record_id').getUrl();
                var win = new Leaf.Window({
                    id: 'con_contract_content_window',
                    url: url,
                    params: {
                        contract_id: contract_id,
                        cdd_list_id: cdd_list_id,
                        winId: 'con_contract_content_window'
                    },
                    title: '合同法务审核',
                    fullScreen: true
                });
                win.on('close', function() {                           
                    $('con543_contract_result_ds').query();
                });  
            }
            
            function con543_con_contract_sign() {
                var record = $('con543_contract_result_ds').getCurrentRecord();
                con555_contractMaintainDs_grid_update2(record.get('contract_id'), record.get('cdd_list_id'));
            }
         
            function rendererHandler(val,rec,name){
                var value = addLink(val,rec,name);
                if (name == 'contract_number') {                   
                    return '<a href="javascript:con543_contractMaintainDs_grid_update(' + rec.id + ');">' + value + '</a>';
                }
            }
            
            function con543_param_set_value(param) {
                param['function_code'] = 'CON301_INTER';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_query_link_id');
            }
            
            function con543_contractMaintainDs_grid_update(id) {
                var current_record = $('con543_contract_result_ds').findById(id);
                var param = current_record.data;
                param['document_id'] = current_record.get('contract_id');
                con543_param_set_value(param);
            }
            
            function addLink(val,rec,name){
                if(rec.get('credit_status')=='BACK' || rec.get('credit_status')=='BACK1'){  
                    return '<font color = "RED">'+val+'</font>';
                }else if(rec.get('lease_channel')=='70'){
                    return '<font color = "BLUE">'+val+'</font>';
                }else if(rec.get('credit_status')=='CONFIRM' || rec.get('credit_status')=='SUBMITTED1'){
                    return '<font color = "GREEN">'+val+'</font>';
                }                
                return val;
            }
            
            function con301_param_set_value(param) {

                param['function_code'] = 'CON301_INTER';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_update_link_id');
            }
            
            function con301_contractMaintainDs_grid_update(id) {
                var current_record = $('con543_contract_result_ds').findById(id);
                alert(current_record.get('contract_number'));
                var param = current_record.data;
                param['document_id'] = current_record.get('contract_id');
                con301_param_set_value(param);
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON543"/>
        <a:dataSets>
            <a:dataSet id="con505_division_name_ds" loadData="true" model="basic.hls_division_for_lov"/>
            <a:dataSet id="con505_lease_organization_name_ds" loadData="true" model="basic.hls_lease_organization_for_lov"/>
            <a:dataSet id="con505_unit_name_ds" loadData="true" model="basic.exp_org_unit_name_lov"/>
            <a:dataSet id="con541_lease_channel_name_ds" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="con543_legal_status_ds">
                <a:datas>
                    <a:record value="SUBMIT" value_name="未审批"/>
                    <a:record value="APPROVED" value_name="审批通过"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="con541_contract_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="bp_name" autoComplete="true" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="cont.CON543.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="520" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="legal_status" defaultValue="SUBMIT"/>
                    <a:field name="legal_status_des" defaultValue="未审批" displayField="value_name" options="con543_legal_status_ds" returnField="legal_status" valueField="value"/>
                    <a:field name="division_desc" displayField="description" options="con505_division_name_ds" returnField="division" valueField="division"/>
                    <a:field name="lease_organization_name" displayField="description" options="con505_lease_organization_name_ds" returnField="lease_organization" valueField="lease_organization"/>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="contract_name"/>
                    <a:field name="unit_name" displayField="unit_name" options="con505_unit_name_ds" returnField="unit_id" valueField="unit_id"/>
                    <a:field name="owner_user_id_n" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="basic.sys_user_for_lov" lovWidth="500" title="员工">
                        <a:mapping>
                            <a:map from="user_id" to="owner_user_id"/>
                            <a:map from="description" to="owner_user_id_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="lease_channel_desc" displayField="description" options="con541_lease_channel_name_ds" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="contract_number" typeCase="Upper"/>
                    <a:field name="project_number" typeCase="Upper"/>
                    <a:field name="contract_number_from" 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_number" to="contract_number_from"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number_to" 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_number" to="contract_number_to"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_code" autoComplete="true" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                            <a:map from="bp_name" to="bp_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="down_payment_from"/>
                    <a:field name="down_payment_to"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con543_contract_result_ds" autoPageSize="true" autoQuery="true" queryDataSet="con541_contract_query_ds" queryUrl="${/request/@context_path}/autocrud/cont.CON543.con_contract_for_query/query" selectable="true" selectionModel="single">
                <a:events>
                    <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="con543_con_contract_query" text="HLS.QUERY"/>
                <a:gridButton click="con543_con_contract_reset" text="HLS.RESET"/>
                <a:gridButton click="con543_con_contract_sign" text="法务审核"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" marginWidth="30" title="CON301.CONTRACT_QUERY">
                <a:lov name="contract_number" bindTarget="con541_contract_query_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <a:textField name="contract_name" bindTarget="con541_contract_query_ds" prompt="HLS.CONTRACT_NAME"/>
                <a:lov name="project_number" bindTarget="con541_contract_query_ds" prompt="HLS.PROJECT_NUMBER"/>
                <a:comboBox name="unit_name" bindTarget="con541_contract_query_ds" prompt="供应商"/>
                <a:lov name="bp_code" bindTarget="con541_contract_query_ds" prompt="HLS.TENANT_CODE"/>
                <a:textField name="bp_name" bindTarget="con541_contract_query_ds" prompt="HLS.TENANT_NAME"/>
                <a:lov name="owner_user_id_n" bindTarget="con541_contract_query_ds" prompt="金融经理"/>
                <a:comboBox name="lease_organization_name" bindTarget="con541_contract_query_ds" prompt="HLS.LEASE_ORGANIZATION"/>
                <!-- <a:datePicker name="lease_start_date_from" bindTarget="con541_contract_query_ds" prompt="HLS.LEASE_START_DATE_FROM"/> -->
                <!-- <a:datePicker name="lease_start_date_to" bindTarget="con541_contract_query_ds" prompt="HLS.LEASE_START_DATE_TO"/> -->
                <a:comboBox name="division_desc" bindTarget="con541_contract_query_ds" prompt="HLS.DIVISION_NAME"/>
                <a:comboBox name="lease_channel_desc" bindTarget="con541_contract_query_ds" prompt="HLS.LEASE_CHANNEL_NAME"/>
                <a:comboBox name="legal_status_des" bindTarget="con541_contract_query_ds" prompt="法务审核状态"/>
            </a:form>
            <a:grid bindTarget="con543_contract_result_ds" marginHeight="265" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="HLS.CONTRACT_NUMBER" width="120"/>
                    <a:column name="contract_name" prompt="HLS.CONTRACT_NAME" width="150"/>
                    <!-- <a:column name="lease_start_date" prompt="HLS.LEASE_START_DATE" renderer="Leaf.formatDate" width="80"/> -->
                    <a:column name="project_number" prompt="申请编号"/>
                    <a:column name="unit_name" prompt="供应商"/>
                    <a:column name="bp_name" prompt="HLS.TENANT_NAME" width="150"/>
                    <!--      <a:column name="project_name" prompt="HLS.PROJECT_NAME" width="150"/> -->
                    <a:column name="owner_user_id_n" prompt="金融经理" width="70"/>
                    <a:column name="lease_organization_desc" prompt="HLS.LEASE_ORGANIZATION"/>
                    <a:column name="division_desc" prompt="HLS.DIVISION_NAME" width="70"/>
                    <a:column name="lease_channel_desc" prompt="HLS.LEASE_CHANNEL_NAME" width="70"/>
                    <a:column name="document_type_desc" prompt="HLS.CONTRACT_TYPE" width="90"/>
                    <!-- <a:column name="other_tmpt_clause_desc" prompt="合同模板条件（其它）" width="90"/> -->
                    <a:column name="contract_status_desc" prompt="HLS.CONTRACT_STATUS" width="60"/>
                    <a:column name="legal_status_des" align="center" prompt="法务审核状态" width="100"/>
                </a:columns>
            </a:grid>
            <!--             <p>
                <font color="red"><![CDATA[已退回——红色 ]]></font>
                <font color="blue"><![CDATA[阿里合同——蓝色 ]]></font>
                <font color="green"><![CDATA[信审已确认通过——绿色 ]]></font>
                <font color="#72ACE3"><![CDATA[新建单据——青色 ]]></font>
            </p> -->
        </a:screenBody>
    </a:view>
</a:screen>
