<?xml version="1.0" encoding="UTF-8"?>
<!--
   create by xuls 
    for prj&con ata sign
    2014-10-15
 -->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="con544_batch_down_link" url="${/request/@context_path}/modules/batch_download/lease_atm_batch_dl.lsc"/>
        <a:link id="con544_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            function con544_detail_close() {
                $('con544_sign_detail_id').close();
            }
            
            function con544_detail_save() {
                $('con544_sign_atm_detail_ds').submit();
            }
            
            function con544_detail_submit() {
                alert('此功能等待开发');
            }
            function con544_sign_atm_detail_query(){
                $('con544_sign_atm_detail_ds').query();
            }
            
            /*
             附件批量下载
             */
            function con44_batch_down() {
                var document_id = ${/parameter/@document_id};
                var document_table = '${/parameter/@document_table}';
                var document_number ='${/parameter/@document_number}';
                var url = $('con544_batch_down_link').getUrl()+'?table_name='+document_table+'&table_pk_value=' + document_id + '&doc_code=' + document_number;
                window.open(url);
            }
            function con544_cdd_editorFunction(record, name) {
                if (record.get('sys_flag') == 'N') {
                    return 'con544_cdd_tf_id';
                }
                return '';
            }
            
           function con544_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;
                }
            }
            function con544_cdd_attachtment_upload(check_id, file_name, record_id) {
                //
                var url = $('con544_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + check_id;
                
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'con544_cdd_uploadFile_screen_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {
                	con544_sign_atm_detail_query();           
                });
            }
            function con544_cdd_attachment_render(value, record, name) {
                //
                var check_id = record.get('check_id');
                var file_name = record.get('file_name');
                var record_id = record.id;
                if (!record.isNew && check_id) {
                    return '<a href="javascript:window[\'con544_cdd_attachtment_upload\'](\'' + record.get('check_id') + '\',\'' + file_name + '\',\'' + record_id + '\')">${l:HLS.ATTACHMENT}</a>';
                }
            }
            
             function con544_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 con544_detail_add(){
                 $('con544_sign_detail_gd').showEditorByRecord($('con544_sign_atm_detail_ds').create());
            }
            function con544_detail_delete(){
                 $('con544_sign_detail_gd').remove();
            }
            function con544_cdd_selectFunc(record) {
                if (record.get('sys_flag') == 'Y') {
                    return false;
                }
                return true;
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con544_sign_atm_header_ds" autoCreate="true"/>
            <a:dataSet id="con544_sign_atm_detail_ds" autoPageSize="true" autoQuery="true" model="cont.CON544.con_sign_atm_detail" queryUrl="${/request/@context_path}/autocrud/cont.CON544.con_sign_atm_detail/query?document_id=${/parameter/@document_id}&amp;document_table=${/parameter/@document_table}&amp;cdd_list_id=${/parameter/@cdd_list_id}" selectFunction="con544_cdd_selectFunc" selectable="true">
                <a:fields>
                    <a:field name="document_table" defaultValue="${/parameter/@document_table}"/>
                    <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/@document_id}"/>
                    <a:field name="cdd_list_id" defaultValue="${/parameter/@cdd_list_id}"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="con544_detail_close" text="HLS.CLOSE"/>
                <a:gridButton click="con544_detail_add" text="HLS.NEW"/>
                <a:gridButton click="con544_detail_save" text="HLS.SAVE"/>
                <a:gridButton click="con544_detail_delete" text="HLS.REMOVE"/>
                <a:gridButton click="con544_detail_submit" text="HLS.SUBMIT"/>
                <a:gridButton click="con44_batch_down" text="附件批量下载"/>
            </a:screenTopToolbar>
            <a:form marginWidth="30" title="附件信息">
                <a:grid id="con544_sign_detail_gd" bindTarget="con544_sign_atm_detail_ds" marginHeight="250" marginWidth="38" navBar="true">
                    <a:columns>
                        <a:column name="description" editorFunction="con544_cdd_editorFunction" lock="true" prompt="HLS.DOCUMENT_NAME" renderer="con544_cdd_required_render" width="200"/>
                        <a:column name="attachment" align="center" lock="true" prompt="附件" renderer="con544_cdd_attachment_render" width="60"/>
                        <a:column name="file_name" align="center" lock="true" prompt="附件名" renderer="con544_link_render" width="400"/>
                        <a:column name="note" editor="con544_cdd_tf_id" prompt="审核意见" width="300"/>
                    </a:columns>
                    <a:editors>
                        <a:checkBox id="con544_cdd_ck_id"/>
                        <a:textField id="con544_cdd_tf_id"/>
                    </a:editors>
                </a:grid>
            </a:form>
        </a:screenBody>
    </a:view>
</a:screen>
