<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:ZLF  
    $Date: 2014-11-7
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query model="cont.CON555.con555_get_info" rootPath="con555_get_info"/>
        <a:model-execute model="db.prj_cdd_item_pkg.prj_cdd_item_extra_save"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con555_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="con555_cdd_download_id" url="${/request/@context_path}/atm_download.lsc"/>
        <a:link id="con555_cdd_query_link" url="${/request/@context_path}/autocrud/cont.CON541.con_content_query_detail/query"/>
        <a:link id="con_contract_sign_link_id" model="cont.CON541.con_contract_save" modelaction="batch_update"/>
        <a:link id="contract_credit_submit_link" model="cont.CON541.contract_credit_submit_execute" modelaction="execute"/>
        <a:script><![CDATA[
        
            
            function con555_cdd_editorFunction(record, name) {
                if (record.get('sys_flag') == 'N' ) {
                    return 'con555_cdd_tf_id';
                }
                return '';
            }
            
            function con555_cdd_editorFunction1(record, name){
                var credit_status = $('con555_detail_ds').getCurrentRecord().get('credit_status');
                if(credit_status == 'BACK1' || record.get('sys_flag') == 'Y'){
                    return '';
                }
                else return 'con555_cdd_tf_id1'
            }
            
            function con555_cdd_selectFunc(record) {
                if (record.get('sys_flag') == 'Y') {
                    return false;
                }
                return true;
            }
            
            function con555_cdd_attachment_render(value, record, name) {
                var credit_status = $('con555_detail_ds').getCurrentRecord().get('credit_status');
                var check_id = record.get('check_id');
                var file_name = record.get('file_name');
                var record_id = record.id;
                //&& credit_status != 'BACK1'
                if (!record.isNew && check_id && credit_status != 'BACK1') {
                    return '<a href="javascript:con555_cdd_attachtment_upload(' + record.get('check_id') + ',\'' + file_name + '\',' + record_id + ')">${l:HLS.ATTACHMENT}</a>';
                }
            }
            
            function con555_cdd_attachment_render_fw (value, record, name) {
                var check_id = record.get('check_id');
                var file_name = record.get('file_name');
                var record_id = record.id;
                //&& credit_status != 'BACK1'
                if (!record.isNew && check_id ) {
                    return '<a href="javascript:con555_cdd_attachtment_upload(' + record.get('check_id') + ',\'' + file_name + '\',' + record_id + ')">${l:HLS.ATTACHMENT}</a>';
                }
            }
            
            function con555_link_render(value, record, name)  {
                if (value != null) {
                    var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                    var str = value.split(';;');
                    var url = '';
                    for (var i = 0;i < str.length;i++) {
                        var temp = str[i].split('--');
                        if (!Leaf.isEmpty(temp[0])) {
                            url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                        }
                    }
                    return url; 
                }
            }
            
            function con555_cdd_attachtment_upload(check_id, file_name, record_id) {
                var url = $('con555_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + check_id;
                var record = $('con555_detail_result_ds').getCurrentRecord();
                var oldvalue = file_name ? file_name : null;
                var contract_id = ${/parameter/@contract_id};
                paras = {
                    'contract_id': contract_id
                };
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'con555_cdd_uploadFile_screen_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {
                    //
                    Leaf.request({
                        url: $('con555_cdd_query_link').getUrl(),
                        para: paras,
                        success: function(data) {
                            //
                            $('con555_detail_result_ds').query();
                            $('con555_detail_result1_ds').query();
            
                            //var newvalue = $('con555_detail_result_ds').findById(record_id).get('file_name');
                        },
                        sync: true
                    });           
                });
            }
            
            function con555_cdd_required_render(value, record, name) {
                var project_required_flag = record.get('project_required_flag');
                if (project_required_flag == 'Y') {
                    return '<pan style="color:red">' + value + '</pan>';
                } else {
                    return value;
                }
            }
          
            window['con555_attach_load'] = function(ds) {
                var records = ds.getAll();
                if (records.length) {
                    for (var i = 0;i < records.length;i++) {
                        var record = records[i];
                        if (Ext.isEmpty(record.get('check_id'))) {
                            record.dirty = true;
                        }
                    }
                }
            };
                       
            function con555_con_contract_back()
            {
                $('con_contract_content_window').close();
            }
            
            
        ]]></a:script>
        <a:dataSets>
            <a:dataSet id="con555_detail_ds" autoQuery="true" fetchAll="true" model="csh.CSH506.con_contract_for_query" queryUrl="${/request/@context_path}/autocrud/csh.CSH506.con_contract_for_query/query?contract_id=${/parameter/@contract_id}">
                <a:fields>
                    <a:field name="contract_id"/>
                    <a:field name="contract_number" readOnly="true"/>
                    <a:field name="bp_name" readOnly="true"/>
                    <!--<a:field name="zero_times_date" required="true"/>-->
                    <a:field name="signing_date" required="true"/>
                    <a:field name="signing_location" required="true"/>
                    <a:field name="contract_status_desc" readOnly="true"/>
                    <a:field name="ebank_id_n" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON541.csh_bank_lov" lovWidth="500" title="银行">
                        <a:mapping>
                            <a:map from="bank_id" to="ebank_id"/>
                            <a:map from="bank_short_name" to="ebank_id_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="credit_status"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con555_detail_result_ds" autoQuery="true" model="cont.CON541.con_content_query_detail" pageSize="10" queryUrl="${/request/@context_path}/autocrud/cont.CON541.con_content_query_detail/query?contract_id=${/parameter/@contract_id}" selectFunction="con555_cdd_selectFunc" selectable="true">
                <a:fields>
                    <a:field name="document_table" defaultValue="CON_CONTRACT"/>
                    <a:field name="paper_required" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="sign_required_flag" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="paper_required" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="attachment_required" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="sys_flag" defaultValue="N"/>
                    <a:field name="document_id" defaultValue="${/parameter/@contract_id}"/>
                    <a:field name="cdd_list_id" defaultValue="${/parameter/@cdd_list_id}"/>
                    <a:field name="note"/>
                    <a:field name="note2"/>
                    <a:field name="note3"/>
                    <a:field name="note4"/>
                    <a:field name="note5"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con555_detail_result1_ds" autoQuery="true" model="cont.CON541.con_content_query_detail_1" pageSize="10" queryUrl="${/request/@context_path}/autocrud/cont.CON543.con_content_query_detail/query?contract_id=${/parameter/@contract_id}" selectFunction="con555_cdd_selectFunc" selectable="true">
                <a:fields>
                    <a:field name="document_table" defaultValue="CON_CONTRACT_CREDIT"/>
                    <a:field name="paper_required" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="sign_required_flag" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="paper_required" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="attachment_required" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="sys_flag" defaultValue="N"/>
                    <a:field name="document_id" defaultValue="${/parameter/@contract_id}"/>
                    <a:field name="cdd_list_id" defaultValue="${/parameter/@cdd_list_id}"/>
                    <a:field name="note"/>
                    <a:field name="note2"/>
                    <a:field name="note3"/>
                    <a:field name="note4"/>
                    <a:field name="note5"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con555_con_contract_back" text="返回"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" title="基础信息" width="1300">
                <a:textField name="contract_number" bindTarget="con555_detail_ds" prompt="合同编号"/>
                <a:lov name="bp_name" bindTarget="con555_detail_ds" prompt="承租人名称"/>
                <!-- <a:datePicker name="signing_date" bindTarget="con555_detail_ds" prompt="签约时间"/>
                <a:textField name="signing_location" bindTarget="con555_detail_ds" prompt="签约地点"/>
                <a:lov name="ebank_id_n" bindTarget="con555_detail_ds" prompt="代扣银行"/>
                <a:comboBox name="ebank_type_n" bindTarget="con555_detail_ds" prompt="代扣账户类型"/>
                <a:textField name="ebank_account_name" bindTarget="con555_detail_ds" prompt="代扣账户名"/>
                <a:textField name="ebank_account_num" bindTarget="con555_detail_ds" prompt="代扣账号"/> -->
            </a:form>
            <a:tabPanel width="1300">
                <a:tabs>
                    <a:tab prompt="附件">
                        <a:grid bindTarget="con555_detail_result1_ds" height="350" navBar="true" width="1295">
                            <a:columns>
                                <a:column name="description" editorFunction="con555_cdd_editorFunction1" lock="true" prompt="HLS.DOCUMENT_NAME" renderer="con555_cdd_required_render" width="200"/>
                                <a:column name="attachment" align="center" lock="true" prompt="附件" renderer="con555_cdd_attachment_render" width="60"/>
                                <a:column name="file_name" align="center" lock="true" prompt="附件名" renderer="con555_link_render" width="400"/>
                                <a:column name="note" prompt="审核意见1" width="200"/>
                                <a:column name="note2" prompt="审核意见2" width="200"/>
                                <a:column name="note3" prompt="审核意见3" width="200"/>
                                <a:column name="note4" prompt="审核意见4" width="200"/>
                                <a:column name="note5" prompt="审核意见5" width="200"/>
                            </a:columns>
                            <a:editors>
                                <a:textField id="con555_cdd_tf_id1"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
        </a:screenBody>
    </a:view>
</a:screen>