<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
          trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="prj.PRJ500D.user_agent_description" rootPath="user_agent_description"/>
    </a:init-procedure>
    <a:view>
        <a:link id="contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>


        <script type="text/javascript"><![CDATA[
        function getNextDate(date,day) {
            var dd = new Date(date);
            dd.setDate(dd.getDate() + day);
            var y = dd.getFullYear();
            var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
            var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
            return y + "-" + m + "-" + d;
        };

        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {

            var query_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            var grid_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
          var period_name=$(query_ds_id).getAt(0).get('period_name');
          var contract_number = $(query_ds_id).getAt(0).get('contract_number');
          var rest_unpayment_amount_from = $(query_ds_id).getAt(0).get('rest_unpayment_amount_from');
          var rest_unpayment_amount_to  =$(query_ds_id).getAt(0).get('rest_unpayment_amount_to');
          if(!period_name){
              $L.showInfoMessage("提示",'请选择期间进行查询!');
              return;
          }
          //拆分成三个
            //月初
            var start_calc_date=period_name+'-01';
            var temp_date = new Date(start_calc_date.replace(/-/g, '/')); // "2010/08/01";
            var  last_month_date=getNextDate(temp_date,-1);

          //查询数据
            $(grid_ds_id).setQueryUrl("${/request/@context_path}/autocrud/cont.CON3600.contract_lease_report/query");
            $(grid_ds_id).setQueryParameter('period_name',period_name);
            $(grid_ds_id).setQueryParameter('start_calc_date',start_calc_date);
            $(grid_ds_id).setQueryParameter('last_month_date',last_month_date);
            $(grid_ds_id).setQueryParameter('contract_number',contract_number);
            $(grid_ds_id).setQueryParameter('rest_unpayment_amount_from',rest_unpayment_amount_from);
            $(grid_ds_id).setQueryParameter('rest_unpayment_amount_to',rest_unpayment_amount_to);

            $(grid_ds_id).query();
        }

        //页面加载事件
        Leaf.onReady(function() {
            var bp_code='${/model/user_agent_description/record/@bp_code}';

            // if (!Ext.isEmpty(bp_code)&&bp_code!== 'C00010168') {
            //     $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('branch_code_n');
            //     $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('branch_code');
            // }
            // if (!Ext.isEmpty(bp_code)) {
            //     if (bp_code == 'C00010168' || bp_code == 'C00010198' || bp_code == 'C00010170') {
            //         $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').showColumn('large_balance_n');
            //         $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').showColumn('large_balance');
            //     }else {
            //         $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('large_balance_n');
            //         $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('large_balance');
            //     }
            // }



            if (!Ext.isEmpty(bp_code)&&bp_code!== 'D00010001'&&bp_code!=='D00000009') {
                $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('branch_code_n');
                $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('branch_code');
            }
            if (!Ext.isEmpty(bp_code)) {
                if (bp_code == 'D00000041' || bp_code == 'D00010001' || bp_code == 'D00000026') {
                 $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').showColumn('large_balance_n');
                    $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').showColumn('large_balance');
                }else {
                    $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('large_balance_n');
                    $('CONTRACT_DEBIT_MONTH_G_CONTRACT_RESULT_hls_bp_master_layout_grid_id').hideColumn('large_balance');
                }
            }
        });

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