<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-8-1 下午02:44:52  
    $Revision: 1.0  
    $Purpose: 合同维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="wfl_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="csh539_account_query_link" model="csh.CSH539.account_query" modelaction="execute"/>
        <a:link id="account_journal_link" url="${/request/@context_path}/modules/csh/CSH539/account_query_journal.lview"/>
        <a:link id="account_creation_link" url="${/request/@context_path}/modules/csh/CSH539/account_query_creation.lview"/>


        <script type="text/javascript"><![CDATA[

        function open_journal_win(record_id, ds_id) {
               var record = $(ds_id).findById(record_id);
                  var param = record.data;
                  param['function_usage'] = 'QUERY';
                  param['maintain_type'] = 'QUERY';
                  param['account_id'] = record.get('account_id');
                  param['period_from'] = record.get('period_from');
                  param['period_to'] = record.get('period_to');
                  param['account_type'] = record.get('account_type');
                  param['url_title'] = '科目明细查询';
                  if(record.get('account_type')=='1'){
                       param['function_code'] = 'CSH539J';
                       param['url_title'] = '科目明细查询(按凭证创建日期)';
                      hls_doc_get_layout_code('wfl_con_contract_get_layout_code_link_id', param, 'account_creation_link', ds_id);
                  }else{
                       param['function_code'] = 'CSH539D';
                       param['url_title'] = '科目明细查询(按凭证日期)';
                      hls_doc_get_layout_code('wfl_con_contract_get_layout_code_link_id', param, 'account_journal_link', ds_id);

              }};

            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
                        if (name == 'account_code' && value) {
                            return '<a href="javascript:open_journal_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                        }
                    };


			window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
              Leaf.showConfirm('${l:PROMPT}', '您需要重新按照会计区间统计计算吗?',
              function(){
                var date_from = $('ACCOUNT_QUERY_QUERY__ds').getCurrentRecord().get('accounting_period_from');
                var date_to = $('ACCOUNT_QUERY_QUERY__ds').getCurrentRecord().get('accounting_period_to');
                var account_type = $('ACCOUNT_QUERY_QUERY__ds').getCurrentRecord().get('accounting_type');
                if(!date_from||!date_to){
                    Leaf.showMessage('提示','日期从到不能为空!');
                    return;
                }else if(date_from > date_to){
                    Leaf.showMessage('提示','日期从不能大于日期到!');
                    return;
                }
                if(!account_type){
                    Leaf.showMessage('提示','请选择按照凭证日期查询或者创建日期查询!');
                    return;
                }
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                    Leaf.request({
                        url: $('csh539_account_query_link').getUrl(),
                        para: {
                            date_from: date_from,
                            date_to: date_to,
                            account_type:account_type
                        },
                        success: function() {
							$('ACCOUNT_QUERY_RESULT_account_query_temp_ds').query();
							window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        failure: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        error: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        scope: this
                    });
                    },function(){$('ACCOUNT_QUERY_RESULT_account_query_temp_ds').query();});
            };
            Leaf.onReady(function(){
                //Leaf.center('loginForm');
				//window['${/parameter/@layout_code}_user_button1_layout_dynamic_click']();
            });
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
				$('ACCOUNT_QUERY_RESULT_account_query_temp_layout_grid_id')._export('xls','科目查询报表');
            };


		]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>