<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2016-5-19 上午9:49:33  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="prj811d_project_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="prj811d_project_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_create_tree_n.lview"/>
        <a:link id="bgfl_csh_payment_conditions_uploadfile_link_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="bgfl_csh_payment_conditions_downloadfile_link_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="prj811d_create_project_side_update_link_id" model="prj.PRJ811.hn_create_project_side" modelaction="update"/>
        <a:link id="prj811d_create_project_side_submit_link_id" model="prj.PRJ811.hn_create_project_side" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
            function prj811_side_detail_exit() {
                $('${/parameter/@winid}').close();
            }
            
            function open_project_info_win() {

                var record = $('prj_project_base_info_ds').getAt(0);
                var param = record.data;
                maintain_type = 'READONLY';
                function_usage = 'QUERY';
                function_code = 'PRJ505';
                param['document_id'] = record.get('project_id');
                param['function_code'] = function_code;
                param['function_usage'] = function_usage;
                param['maintain_type'] = maintain_type;
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                //param['layout_debugger_flag']='Y';
                param['cond_para2'] = record.get('hn_industry_classification');
                param['wf_function_code'] = '${/parameter/@function_code}';
                hls_doc_get_layout_code('prj811d_project_get_layout_code_link_id', param, 'prj811d_project_modify_link');
            }
            
            function onSubmitSuccess_doc(dataSet, datas, rec) {
                $('prj811_detail_result_ds').query();
            }
            
            
            function bgfl_doc(record, name) {
                var query_flag = '${/parameter/@query_flag}';
                if (name === 'description' || name === 'note') {
                    if (record.isNew || (query_flag != 'Y' && !record.isNew)) {
                        return 'grid_ts_id';
                    }
                }
                return '';
            }
            
            function open_attachment_window(condiction_id, url) {
                new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    params: {
                        'table_name': 'PRJ_CDD_ITEM_CHECK',
                        'header_id': condiction_id
                    },
                    width: 850,
                    height: 400
                }).on('close',function (){
                	$('prj811_detail_result_ds').query();
                });
            }
            
            function bgfl_doc_render_func(value, record, name) {
                if (name === 'attachments') {

                    var query_flag = '${/parameter/@query_flag}';
                    var check_id = record.get('check_id');
                    var url;
                    var text;
                    //保存之后才能生成
                    if (query_flag != 'Y' && !record.isNew && check_id !== undefined) {
                        url = $('bgfl_csh_payment_conditions_uploadfile_link_id').getUrl();
            
                        text = '上传/删除';
                    } else if (!record.isNew && query_flag === 'Y') {
                        url = $('bgfl_csh_payment_conditions_downloadfile_link_id').getUrl();
                        text = '下载';
                    } else {
                        text = '';
                    }
                    return '<a href="javascript:open_attachment_window(' + record.get('check_id') + ',\'' + url + '\')">' + text + '</a>';
                }
                if (name=='attachment_name'){
                    var file_name=record.get('attachment_name');
                    if (file_name != null) {
                        var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                        var str = file_name.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 prj811_project_control_select_func(record) {
            // var project_submit_flag = record.get('project_submit_flag');
            // if (record.isNew) {
            // return true;
            // } else if (!record.isNew && project_submit_flag === 'Y') {
            // return false;
            // } else {
            // return true;
            // }
            
            // }
            
            function onSubmitSuccess_copyDs(dataSet, datas, rec) {
                $('prj811_csh_payment_conditions_result_ds').query();
            }
            
            //保存
            
            function prj811_side_detail_save() {
            
                if ($('prj_project_base_info_ds').validate()) {
                    Leaf.Masker.mask($('${/parameter/@winid}').wrap, '正在执行...');
                    var record = $('prj_project_base_info_ds').getAt(0);
                    Leaf.request({
                        url: $('prj811d_create_project_side_update_link_id').getUrl(),
                        para: {
                            prj_side_id: '${/parameter/@prj_side_id}',
                            project_id: '${/parameter/@project_id}',
                            side_note: record.get('side_note'),
                            side_item: record.get('side_item')
                        },
                        success: function() {
                            $('prj811_detail_result_ds').submit();
            
                            Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
            
                        },
                        failure: function() {
                            Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                        },
                        error: function() {
                            Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                        },
                        scope: this
                    });
                }
            
            }
            //提交审批
            
            function prj811_side_detail_submit() {
                if ($('prj_project_base_info_ds').validate()) {
                    Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交审批吗?', function() {
                        Leaf.Masker.mask($('${/parameter/@winid}').wrap, '正在执行');
                        $('prj811_detail_result_ds').submit();
                        var record = $('prj_project_base_info_ds').getAt(0);
                        Leaf.request({
                            url: $('prj811d_create_project_side_submit_link_id').getUrl(),
                            para: {
                                prj_side_id: '${/parameter/@prj_side_id}',
                                project_id: '${/parameter/@project_id}',
                                side_note: record.get('side_note'),
                                side_item: record.get('side_item')
                            },
                            success: function() {
                                Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                                $('${/parameter/@winid}').close();
            
                            },
                            failure: function() {
                                Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                            },
                            error: function() {
                                Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                            },
                            scope: this
                        });
                    });
                }
            }
            
            
            function on_base_info_load_check(ds) {
                if ('${/parameter/@query_flag}' == 'Y') {
                    var record = ds.getCurrentRecord();
                    record.getField('side_note').setReadOnly(true);
                    record.getField('side_note').setRequired(false);
                    record.getField('side_item').setReadOnly(true);
                    record.getField('side_item').setRequired(false);
                }
                if ('${/parameter/@query_flag}' == 'W') {
                    var record = ds.getCurrentRecord();
                    record.getField('side_note').setReadOnly(true);
                    record.getField('side_note').setRequired(false);
                    record.getField('side_item').setReadOnly(true);
                    record.getField('side_item').setRequired(false);
                }
            };
        ]]></script>
        <a:dataSets>
            <a:dataSet id="prj_project_base_info_ds" autoQuery="true" model="prj.PRJ811.hn_create_project_side" queryUrl="${/request/@context_path}/autocrud/prj.PRJ811.hn_create_project_side/query?project_id=${/parameter/@project_id}&amp;prj_side_id=${/parameter/@prj_side_id}">
                <a:fields>
                    <a:field name="project_number" readOnly="true"/>
                    <a:field name="project_name" readOnly="true"/>
                    <a:field name="chance_source_n" readOnly="true"/>
                    <a:field name="employee_id_n" readOnly="true"/>
                    <a:field name="lease_organization_n" readOnly="true"/>
                    <a:field name="business_type_n" readOnly="true"/>
                    <a:field name="lease_form_n" readOnly="true"/>
                    <a:field name="division_n" readOnly="true"/>
                    <a:field name="pre_rental_business_n" readOnly="true"/>
                    <a:field name="lease_item_amount" readOnly="true"/>
                    <a:field name="lease_term" readOnly="true"/>
                    <a:field name="int_rate" readOnly="true"/>
                    <a:field name="int_rate_fixing_way_n" readOnly="true"/>
                    <a:field name="int_rate_fixing_range" readOnly="true"/>
                    <a:field name="side_item" required="true"/>
                    <a:field name="side_note" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="on_base_info_load_check"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="prj811_detail_result_ds" autoQuery="true" model="prj.PRJ811.hn_prj_project_doc_cdd_item" pageSize="11" queryUrl="${/request/@context_path}/autocrud/prj.PRJ811.hn_prj_project_doc_cdd_item/query?document_id=${/parameter/@prj_side_id}&amp;document_table=HN_PRJ_PROJECT_SIDE" selectable="true">
                <a:fields>
                    <a:field name="document_table" defaultValue="HN_PRJ_PROJECT_SIDE"/>
                    <a:field name="document_id" defaultValue="${/parameter/@prj_side_id}"/>
                    <a:field name="note"/>
                    <a:field name="description" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="submitSuccess" handler="onSubmitSuccess_doc"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:switch test="/parameter/@query_flag">
                <a:case value="N">
                    <a:screenTopToolbar>
                        <a:screenTitle/>
                        <a:gridButton click="prj811_side_detail_exit" text="HLS.EXIT"/>
                        <a:gridButton click="prj811_side_detail_save" text="保存"/>
                        <a:gridButton click="prj811_side_detail_submit" text="提交审批"/>
                    </a:screenTopToolbar>
                </a:case>
                <!--             <a:case value="N">
               
            </a:case> -->
            </a:switch>
            <a:tabPanel id="side" marginHeight="260" marginWidth="50">
                <a:tabs>
                    <a:tab id="project_base_info_tab_id" disabled="false" marginHeight="270" prompt="基本信息" selected="true" width="120">
                        <a:form column="4" labelWidth="120" style="margin-left:10px;margin-top:10px;" title="基本信息">
                            <a:textField name="project_number" bindTarget="prj_project_base_info_ds" prompt="项目编号"/>
                            <a:textField name="project_name" bindTarget="prj_project_base_info_ds" colspan="2" prompt="项目名称" width="428"/>
                            <a:textField name="chance_source_n" bindTarget="prj_project_base_info_ds" prompt="项目来源"/>
                            <a:textField name="employee_id_n" bindTarget="prj_project_base_info_ds" prompt="项目经理"/>
                            <a:textField name="lease_organization_n" bindTarget="prj_project_base_info_ds" prompt="业务部"/>
                            <a:textField name="business_type_n" bindTarget="prj_project_base_info_ds" prompt="租赁业务类型"/>
                            <a:textField name="lease_form_n" bindTarget="prj_project_base_info_ds" prompt="租赁形式"/>
                            <a:textField name="division_n" bindTarget="prj_project_base_info_ds" prompt="产品线"/>
                            <a:textField name="pre_rental_business_n" bindTarget="prj_project_base_info_ds" prompt="租前期项目"/>
                            <a:numberField name="lease_item_amount" allowFormat="true" bindTarget="prj_project_base_info_ds" decimalPrecision="2" prompt="融资金额"/>
                            <a:textField name="lease_term" bindTarget="prj_project_base_info_ds" prompt="租赁期限"/>
                            <a:percentField name="int_rate" bindTarget="prj_project_base_info_ds" prompt="租赁利率"/>
                            <a:textField name="int_rate_fixing_way_n" bindTarget="prj_project_base_info_ds" prompt="利率浮动方式"/>
                            <a:percentField name="int_rate_fixing_range" bindTarget="prj_project_base_info_ds" prompt="浮动幅度"/>
                            <a href="javascript:open_project_info_win()"><![CDATA[项目详细信息]]></a>
                            <a:textField name="side_item" bindTarget="prj_project_base_info_ds" colspan="4" prompt="审议事项" width="1000"/>
                            <a:textArea name="side_note" bindTarget="prj_project_base_info_ds" colspan="4" height="100" prompt="变更说明" width="1000"/>
                        </a:form>
                    </a:tab>
                    <a:tab id="project_app_attch_tab_id" prompt="支撑性文件" width="120">
                        <a:switch test="/parameter/@query_flag">
                            <a:case value="Y">
                                <a:grid bindTarget="prj811_detail_result_ds" marginHeight="400" marginWidth="100" navBar="true" style="margin-left:10px;margin-top:10px;">
                                    <a:columns>
                                        <a:column name="description" editorFunction="bgfl_doc" lock="true" prompt="HLS.DOCUMENT_NAME" width="300"/>
                                        <a:column name="attachments" align="center" prompt="附件上传" renderer="bgfl_doc_render_func" width="100"/>
                                        <a:column name="attachment_name" prompt="文件名" renderer="bgfl_doc_render_func" width="400"/>
                                        <a:column name="note" editor="con555_cdd_tf_id" editorFunction="bgfl_doc" prompt="备注" width="500"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:textField id="grid_ts_id"/>
                                    </a:editors>
                                </a:grid>
                            </a:case>
                            <a:case value="N">
                                <a:grid bindTarget="prj811_detail_result_ds" marginHeight="400" marginWidth="100" navBar="true" style="margin-left:10px;margin-top:10px;">
                                    <a:toolBar>
                                        <a:button type="add"/>
                                        <a:button type="delete"/>
                                        <a:button type="save"/>
                                    </a:toolBar>
                                    <a:columns>
                                        <a:column name="description" editorFunction="bgfl_doc" lock="true" prompt="HLS.DOCUMENT_NAME" width="300"/>
                                        <a:column name="attachments" align="center" prompt="附件上传" renderer="bgfl_doc_render_func" width="100"/>
                                        <a:column name="attachment_name" prompt="文件名" renderer="bgfl_doc_render_func" width="400"/>
                                        <a:column name="note" editor="con555_cdd_tf_id" editorFunction="bgfl_doc" prompt="备注" width="500"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:textField id="grid_ts_id"/>
                                    </a:editors>
                                </a:grid>
                            </a:case>
                            <a:case value="W">
                                <a:grid bindTarget="prj811_detail_result_ds" marginHeight="400" marginWidth="100" navBar="true" style="margin-left:10px;margin-top:10px;">
                                    <a:toolBar>
                                        <a:button type="add"/>
                                        <a:button type="delete"/>
                                        <a:button type="save"/>
                                    </a:toolBar>
                                    <a:columns>
                                        <a:column name="description" editorFunction="bgfl_doc" lock="true" prompt="HLS.DOCUMENT_NAME" width="300"/>
                                        <a:column name="attachments" align="center" prompt="附件上传" renderer="bgfl_doc_render_func" width="100"/>
                                        <a:column name="attachment_name" prompt="文件名" renderer="bgfl_doc_render_func" width="400"/>
                                        <a:column name="note" editor="con555_cdd_tf_id" editorFunction="bgfl_doc" prompt="备注" width="500"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:textField id="grid_ts_id"/>
                                    </a:editors>
                                </a:grid>
                            </a:case>
                        </a:switch>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
            <script type="text/javascript"><![CDATA[
                
            ]]></script>
        </a:screenBody>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>