<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm
    $Date: 2013-12-28 下午1:24:13
    $Revision: 1.0
    $Purpose:
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query model="rsc.RSC510.workflow_info" defaultWhereClause="instance_id=${/parameter/@instance_id}" rootPath="wolkflow_path"></a:model-query>
    </a:init-procedure>
    <a:view>
        <a:link id="hls_attachment_uploadFile_wfl_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="hls_attachment_uploadonlyFile_wfl_id" url="${/request/@context_path}/downloadFile.lview"/>
<!--        <a:link id="hls_month_end_print_id"-->
<!--                url="${/request/@context_path}/modules/cus_deposit/CUS_DEPOSIT106/hls_month_end_print.lsc"/>-->

        <a:link id="hls_month_end_print_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_con_req_history_pdf_print.lsc"/>
        <script><![CDATA[
       //add  by gzj
        function detail_upload_window(record_id) {

                if('${/model/wolkflow_path/record/@current_seq}' == '5'){
                    var url = $('hls_attachment_uploadFile_wfl_id').getUrl() + '?table_name=BUSINESS_REPORT&header_id=' + record_id;
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'hls_month_downloadFile_id',
                        width: 850,
                        height: 400
                    });
                    win.on('close', function() {
                        $('month_report_wfl_ds').query();
                    });
                }else{
                    var url = $('hls_attachment_uploadonlyFile_wfl_id').getUrl() + '?table_name=BUSINESS_REPORT&header_id=' + record_id;
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'month_downloadFile_id',
                        width: 850,
                        height: 400
                    });
                    win.on('close', function() {
                        $('month_report_wfl_ds').query();
                    });
                }


        }
        function attachment_upload(val,rec,name) {
            return '<a href=javascript:detail_upload_window('+rec.get('tab_id')+')>附件上传</a>';
        }
        function sbo_detail_upload_window(record_id) {

                if('${/model/wolkflow_path/record/@current_seq}' == '5'){
                    var url = $('hls_attachment_uploadFile_wfl_id').getUrl() + '?table_name=SBO_REPORT&header_id=' + record_id;
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'hls_sbo_month_downloadFile_id',
                        width: 850,
                        height: 400
                    });
                    win.on('close', function() {
                        $('month_report_wfl_ds').query();
                    });
                }else{
                    var url = $('hls_attachment_uploadonlyFile_wfl_id').getUrl() + '?table_name=SBO_REPORT&header_id=' + record_id;
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'sbo_month_downloadFile_id',
                        width: 850,
                        height: 400
                    });
                    win.on('close', function() {
                        $('month_report_wfl_ds').query();
                    });
                }

        }
        function sbo_attachment_upload(val,rec,name) {
            return '<a href=javascript:sbo_detail_upload_window('+rec.get('tab_id')+')>附件上传</a>';
        }
        //审批通过打印审批记录
        function month_approved_print() {
            debugger;
            var headers_ds = $('month_report_wfl_ds');
            var record = headers_ds.getAt(0);
            // var year = record.get('year');
            // var month = record.get('month');
            var  year = "${/parameter/@month_date}".substring(0, 4);
            var  month = "${/parameter/@month_date}".substring(4, 6);
            var date  = year+month;
            var wfl_instance_id = '${/parameter/@instance_id}';
            // var record = $('csh_transaction_return_wfl_ds').getCurrentRecord();
            // var return_id = record.get('return_id');
            var file_name =  year+'年'+ month + "月月结资料审批记录打印";
           var url_l = $('hls_month_end_print_id').getUrl() + '?document_id=' + wfl_instance_id + '&file_name=' + encodeURI(file_name) + '&document_table=HLS_MONTH_END&batch_flag=Y&source_type=COMMON';
            var OpenWindow = window.open(href = url_l, target = "_blank");


        }

        ]]></script>
        <a:dataSets>
            <a:dataSet id="unearned_finance_income_query_wfl_ds" autoCreate="true"  >
                <a:fields>
                <a:field name="month_date" defaultValue="${/parameter/@month_date}"/>
                <a:field name="year"/>
                <a:field name="month"/>
                <a:field name="batch_num" defaultValue="${/parameter/@batch_num}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="report_name_wfl_ds" lookupCode="HLS_REPORT_NAME"/>
            <a:dataSet id="month_report_wfl_ds" autoQuery="true" fetchAll="true" model="hls.HLS801.con_monthly_statement_wfl"
                       queryDataSet="unearned_finance_income_query_wfl_ds">
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton id="month_approved_print_id" click="month_approved_print" text="月结报表审批记录打印"/>
            </a:screenTopToolbar>
            <a:form column="1" marginWidth="80" style="margin-left:3px" title="HLS.QUERY_TITLE">
                <a:box column="3" labelWidth="150" style="margin-left:-80px">
                    <a:textField name="year" bindTarget="unearned_finance_income_query_wfl_ds"
                                 prompt="HLS801.YEAR" readOnly="true"/>
                    <a:textField name="month" bindTarget="unearned_finance_income_query_wfl_ds"
                                 prompt="HLS801.MONTH" readOnly="true"/>
                </a:box>
            </a:form>
            <a:grid id="month_report_wfl_id" bindTarget="month_report_wfl_ds" marginHeight="300"
                    marginWidth="150">
                <a:columns>
                    <a:column name="report_name" align="center" prompt="报表名称"
                    width="100" />
                    <a:column name="sbo_attachment_upload" align="center" prompt="SB0报表" renderer="sbo_attachment_upload" width="80"/>
                    <a:column name="sbo_file_name" align="center" prompt="附件名称"
                              width="100" />
                    <a:column name="attachment_upload" align="center" prompt="业务系统报表" renderer="attachment_upload" width="80"/>
                    <a:column name="business_file_name" align="center" prompt="附件名称"
                              width="100" />
                </a:columns>
            </a:grid>
        </a:screenBody>
        <script>
            Leaf.onReady(function () {
                Leaf.onReady(init);
                function init() {
                    var record = $('unearned_finance_income_query_wfl_ds').getCurrentRecord();
                   var  year = "${/parameter/@month_date}".substring(0, 4);
                   var  month = "${/parameter/@month_date}".substring(4, 6);
                    record.set('year',year);
                    record.set('month',month);
                    if ('${/model/wolkflow_path/record/@current_seq}' == '5'||'${/model/wolkflow_path/record/@current_seq}' == '10') {
                        document.getElementById("month_approved_print_id").style.display = "none";
                    }
                    $('month_report_wfl_ds').query();
                }
            })
        </script>
    </a:view>

</a:screen>