<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-6-23 下午05:35:25  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:view>
        <a:link id="upload_link" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="con_contract_content_init_link" model="cont.CON506.con_contract_content_init" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            function content_and_notarize_detail_return() {
                $('${/parameter/@winid}').close();
            }
            
            
            
            function content_and_notarize_detail_save() {
                $('con_contract_content_sign_information_ds').submit();
            }
            
            
            function on_notarize_load(ds) {
                var records = ds.getAll();
                if (!records.length) {
                    $('con_contract_content_notary_information_grid_id').showEditorByRecord(ds.create());
                }
            }
            
           
            
            function attach_renderer(value, record, name) {
                if (record.get('content_file_id') && record.get('attach_count') > 0) {
                    return '<a href="javascript:open_attach_win(' + record.get('content_file_id') + ')"><div style="color:red">附件</div></a>';
                } else if (record.get('content_file_id')) {
                    return '<a href="javascript:open_attach_win(' + record.get('content_file_id') + ')">附件</a>';
                }
            }
            
            function open_attach_win(content_file_id) {
                new Leaf.Window({
                    id: 'upload_win',
                    url: $('upload_link').getUrl() + '?table_name=CON_CONTRACT_CONTENT_FILE&header_id=' + content_file_id,
                    width: 1000,
                    height: 400
                });
            }
            
            function content_and_notarize_detail_add() {
                $('con_contract_content_sign_information_grid_id').showEditorByRecord($('con_contract_content_sign_information_ds').create());
            }
            
            function content_and_notarize_detail_delete() {
                $('con_contract_content_sign_information_grid_id').remove();
            }
            
            function con_contract_content_sign_information_submitsuccess(ds){
                $('con_contract_content_sign_information_ds').query();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con_contract_content_and_notarize_detail_head_ds" loadData="true" model="cont.CON500.con_contract_v">
                <a:fields>
                    <a:field name="contract_number" readOnly="true"/>
                    <a:field name="contract_name" readOnly="true"/>
                    <a:field name="contract_status_desc" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_content_sign_information_ds" autoQuery="true" model="cont.CON506.con_contract_content_file" queryUrl="${/request/@context_path}/autocrud/cont.CON506.con_contract_content_file/query?contract_id=${/parameter/@contract_id}" selectable="true">
                <a:fields>
                    <a:field name="contract_type" readOnly="true"/>
                    <a:field name="content_number" lovGridHeight="350" lovHeight="500" lovService="cont.CON500.con_contract_content_v?contract_id=${/parameter/@contract_id}" lovWidth="520">
                        <a:mapping>
                            <a:map from="content_number" to="content_number"/>
                            <a:map from="bp_category" to="bp_category"/>
                            <a:map from="bp_category_desc" to="bp_category_desc"/>
                            <a:map from="con_contract_bp_id" to="con_contract_bp_id"/>
                            <a:map from="clause_usage" to="clause_usage"/>
                            <a:map from="clause_usage_name" to="clause_usage_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_category_desc" readOnly="true"/>
                    <a:field name="file_date"/>
                    <a:field name="file_place"/>
                    <a:field name="file_person"/>
                    <a:field name="employee_id_witness_name" lovGridHeight="350" lovHeight="500" lovWidth="500" title="CON506.EMPLOYEE_ID_WITNESS_NAME"/>
                    <a:field name="contract_id" defaultValue="${/parameter/@contract_id}"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="con_contract_content_sign_information_submitsuccess"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="content_and_notarize_detail_return" text="HLS.RETURN"/>
                <a:gridButton click="content_and_notarize_detail_add" text="HLS.NEW"/>
                <a:gridButton click="content_and_notarize_detail_delete" text="HLS.REMOVE"/>
                <a:gridButton click="content_and_notarize_detail_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="3">
                <a:textField name="contract_number" bindTarget="con_contract_content_and_notarize_detail_head_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <a:textField name="contract_name" bindTarget="con_contract_content_and_notarize_detail_head_ds" prompt="HLS.CONTRACT_NAME"/>
                <a:textField name="contract_status_desc" bindTarget="con_contract_content_and_notarize_detail_head_ds" prompt="HLS.CONTRACT_STATUS"/>
            </a:form>
            <a:grid id="con_contract_content_sign_information_grid_id" bindTarget="con_contract_content_sign_information_ds" marginHeight="250" marginWidth="80" navBar="true">
                <a:columns>
                    <a:column name="content_number" editor="sign_information_grid_lov_id" prompt="CON505.CON_CONTENT_NUMBER" width="150"/>
                    <a:column name="clause_usage_name" prompt="HLS.CONTRACT_TYPE"/>
                    <a:column name="bp_category_desc" prompt="商业伙伴类别"/>
                    <a:column name="file_date" editor="sign_information_grid_datepicker_id" prompt="归档时间" renderer="Leaf.formatDate"/>
                    <a:column name="file_place" editor="sign_information_grid_textField_id" prompt="归档地点" width="250"/>
                    <a:column name="file_person" editor="sign_information_grid_textField_id" prompt="归档人"/>
                    <a:column name="description" editor="sign_information_grid_textField_id" prompt="备注" width="200"/>
                    <a:column name="attach" align="center" prompt="附件" renderer="attach_renderer" width="50"/>
                </a:columns>
                <a:editors>
                    <a:lov id="sign_information_grid_lov_id"/>
                    <a:datePicker id="sign_information_grid_datepicker_id"/>
                    <a:textField id="sign_information_grid_textField_id"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        	function init(){
        	    Leaf.request({
        	        url:$('con_contract_content_init_link').getUrl(),
        	        para:{
        	            contract_id:'${/parameter/@contract_id}'
        	        },
        	        scope:this,
        	        success:function(){
        	          $('con_contract_content_sign_information_ds').query();  
        	        },
        	        failure:function(){
        	            
        	        },
        	        error:function(){
        	            
        	        }
        	    });
        	}
        	
        	init();
        ]]></script>
    </a:view>
</a:screen>
