<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: trd
    $Date: 2012-12-6 上午11:18:39
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
      </a:init-procedure>
    <a:view>
        <a:link id="hls_journal_import_create_link_id" url="${/request/@context_path}/modules/hls/HLS536/hls_journal_import_create.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="journal_attachment_uploadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>

         <script><![CDATA[
         Leaf.onReady(function () {
               $('hls_journal_header_result_ds').setQueryParameter('journal_submit_batch_id','${/parameter/@journal_submit_batch_id}');
         })
        //查询按钮

        function hls536_journal_query() {
            $('hls_journal_header_result_ds').setQueryParameter('journal_submit_batch_id','${/parameter/@journal_submit_batch_id}');
            $('hls_journal_header_result_ds').query();
        }
        //重置按钮

        function hls536_journal_reset() {
            $('hls_journal_header_query').reset();
        }

        //  审批流程中，叶唯吟节点可编辑页面
        function hls536_link_dynamic(reocrd_id, journal_header_id) {
            var record = $('hls_journal_header_result_ds').findById(reocrd_id);
            var param = record.data;
            param['currency'] = param['currency_code'];
            param['function_code'] = 'HLS536';
            param['document_id'] = journal_header_id;
            param['document_category'] = 'JE';
            var edit_flag = '${/parameter/@edit_flag}';
            if(edit_flag == 'Y' ){
                param['function_usage'] = 'MODIFY';
                param['maintain_type'] = 'UPDATE';
            }else {
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
            }
            param['url_title'] = '${l:HLS530.JOURNAL_LINE_MODIFY}';
            hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_journal_import_create_link_id');
        }

         function hls536_journal_num_render(value, record, name) {
             return '<a href="javascript:hls536_link_dynamic(' + record.id + ',' + record.get('journal_header_id') + ');">' + value + '</a>';
         }

         function receipt_attachment_upload(val,rec,name){
             return '<a href=javascript:open_upload_window('+rec.get('journal_header_id')+')>附件</a>';
         }

         function open_upload_window(record_id){
             var url = $('journal_attachment_uploadFile_id').getUrl() + '?table_name=HLS_JOURNAL_HEADER_IMP&header_id=' + record_id;
             var win = new Leaf.Window({
                 url: url,
                 title: '${l:HLS.SUPPORTING_DOCUMENT}',
                 id: 'attachment_uploadFile_id',
                 width: 850,
                 height: 400
             });
             win.on('close', function() {
                 $('hls_journal_header_result_ds').query();
             });
         }

         function attachment_upload(val,rec,name){
          return '<a href=javascript:open_other_attachment_download('+rec.get('journal_header_id')+')>其它附件</a>';
                   }

          //其它附件下载
              function open_other_attachment_download(record_id){
                       var url = $('journal_attachment_uploadFile_id').getUrl() + '?table_name=HLS_JOURNAL_DETAIL_IMP&header_id=' + record_id;
                         var win = new Leaf.Window({
                          url: url,
                          title: '${l:HLS.SUPPORTING_DOCUMENT}',
                          id: 'other_attachment_uploadFile_id',
                          width: 850,
                          height: 400
                      });
                      win.on('close', function() {
                          $('hls_journal_header_result_ds').query();
                      });
                  }
         ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="hls536_wfl_status_ds" lookupCode="HLS536_WFL_STATUS"/>
            <a:dataSet id="hls_journal_header_query">
                <a:fields>
                    <a:field name="journal_num"/>
                    <a:field name="journal_date_from"/>
                    <a:field name="journal_date_to"/>
                    <a:field name="total_amount_dr_from"/>
                    <a:field name="total_amount_dr_to"/>
                    <a:field name="description"/>
                    <a:field name="wfl_status_n" displayField="code_value_name" options="hls536_wfl_status_ds" returnField="wfl_status" valueField="code_value"/>
                    <a:field name="wfl_status" />
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls_journal_header_result_ds" autoPageSize="true" autoQuery="true" model="hls.HLS536.hls_journal_import_reverse_wfl" queryDataSet="hls_journal_header_query"  selectable="true" queryUrl="${/request/@context_path}/autocrud/hls.HLS536.hls_journal_import_reverse_wfl/query?journal_reverse_batch_id=${/parameter/@journal_submit_batch_id}">
>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:toolbarButton click="hls536_journal_query" text="HLS.QUERY"/>
                <a:toolbarButton click="hls536_journal_reset" text="HLS.RESET"/>
            </a:screenTopToolbar>
            <a:form column="5" labelSeparator=" " labelWidth="100" marginWidth="40" title="HAP_QUERY_TITLE">
                <a:textField name="journal_num" bindTarget="hls_journal_header_query" prompt="凭证编号"/>
                <a:datePicker name="journal_date_from" bindTarget="hls_journal_header_query" prompt="凭证日期从"/>
                <a:datePicker name="journal_date_to" bindTarget="hls_journal_header_query" prompt="凭证日期到"/>
                <a:numberField name="total_amount_dr_from" allowFormat="true" bindTarget="hls_journal_header_query" prompt="金额从"/>
                <a:numberField name="total_amount_dr_to" allowFormat="true" bindTarget="hls_journal_header_query" prompt="金额到"/>
                <a:textField name="description" bindTarget="hls_journal_header_query" prompt="凭证摘要"/>
                <a:comboBox name="wfl_status_n" bindTarget="hls_journal_header_query" prompt="凭证导入状态"/>
            </a:form>
            <a:grid id="hls_journal_headers_grid" bindTarget="hls_journal_header_result_ds" marginHeight="250" marginWidth="40" navBar="true">
                <a:columns>
                    <a:column name="journal_num" lock="true" prompt="凭证编号" renderer="hls536_journal_num_render" width="120"/>
                    <a:column name="js_company_short_name" prompt="记账公司" width="90"/>
                    <a:column name="period_name" align="center" prompt="期间" width="80"/>
                    <a:column name="journal_date" align="center" prompt="凭证日期" renderer="Leaf.formatDate" width="90"/>
                    <a:column name="currency_desc" align="center" prompt="币种" width="80"/>
                    <a:column name="total_amount_fuc_dr" align="right" prompt="金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="description" prompt="凭证摘要" width="220"/>
                    <a:column name="je_detail_count" prompt="凭证行数量" width="50"/>
                    <!--<a:column name="wfl_status_n" prompt="凭证导入状态" width="100"/>-->
                    <a:column name="reverse_wfl_status_n" prompt="凭证反冲状态" width="100"/>
                     <a:column name="other_attachment_file"  prompt="其它附件" width="120" renderer="attachment_upload" align="center"/>
                    <!--<a:column name="error_message" prompt="错误信息" width="150"/>-->
                    <!--<a:column name="attachment_file"  prompt="附件" width="120" renderer="receipt_attachment_upload" align="center"/>-->
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
