<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hsx
    $Date: 2018年8月8日17:29:18
    $Revision: 1.0  
    $Purpose:罚息减免创建
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="${/parameter/@layout_code}_con_contract_get_layout_code_link_id"
                model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
        <a:link id="${/parameter/@layout_code}_contract_penalty_modify_link"
                url="${/request/@context_path}/modules/cont/CON1020/contract_penalty_reduction_create.lview"/>
        <a:link id="con_penalty_reduction_link_id" url="${/request/@context_path}/modules/cont/CON1021/penalty_reduction_excel.lsc"/>
        <script type="text/javascript"><![CDATA[
        jQuery.noConflict();


        //取消按钮
       /* window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {

            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_case_record');
            var records=$(ds_id).getSelected();
            //只有新建的单据才能够取消操作
            if(records.length<1){
                $L.showInfoMessage("提示",'至少选择一条记录为新建的记录！');
                return ;
            }
            ///
            for (var i=0;i<records.length;i++){

            }


        }*/
        function open_contract_win123() {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_case_record');
            var param = {};
            param['function_code'] = 'CON1021C';
            param['maintain_type'] = 'INSERT';
            param['url_title'] = '罚息减免新建';
            param['winid'] = '${/parameter/@layout_code}_create_win_id'
            hls_doc_get_layout_code('${/parameter/@layout_code}_con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}_contract_penalty_modify_link', ds_id);
        }


        function open_contract_detail_win(ds_id, record_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            if (record.data.status == 'APPROVED' || record.data.status == 'APPROVING'||record.data.status == 'CANCEL'||record.data.status == 'REJECT') {
                param['function_code'] = 'CON1020_C_R';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'QUERY';
                param['status'] = record.data.status;
            } else {
                param['function_code'] = 'CON1021C';
                param['function_usage'] = 'INSERT';
                param['maintain_type'] = 'INSERT';
                param['status'] = record.data.status;
            }
            param['case_status_submit'] = record.data.status;
            param['maintain_type'] = 'INSERT';
            param['record_id'] = record.data.record_id;
            param['url_title'] = '违约金减免维护';
            param['winid'] = '${/parameter/@layout_code}_maintain_win_id'
            hls_doc_get_layout_code('${/parameter/@layout_code}_con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}_contract_penalty_modify_link', ds_id);
        }
        function timeChange(dateStr) {
      date = new Date(dateStr);
     var year = date.getFullYear();
     var month = date.getMonth() + 1;
     var day = date.getDate();
      month = (month < 10 ? "0" + month : month);
       day = (day < 10 ? "0" + day : day);
    var mydate = (year.toString() + '-' + month.toString()+'-'+day.toString());
    return mydate;
    };
        function download_penalty_reduction(){
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_case_record');
            var records = $(ds_id).getAll();
            var query_ds_id = 'CON_PENALTY_REDUCTION_QUERY_F_QUERY__ds';
            var query_record = $(query_ds_id).getCurrentRecord();
            var penalty_batch_number=  query_record.get('penalty_batch_number');
            var created_by_n= query_record.get('created_by_n');
            var status= query_record.get('status');
            var creationdate_from= query_record.get('creationdate_from');
            var creationdate_to= query_record.get('creationdate_to');
            if(!Leaf.isEmpty(creationdate_from)){
                creationdate_from = timeChange(creationdate_from);
            }else{
                creationdate_from ='';
            }
            if(!Leaf.isEmpty(creationdate_to)){
                creationdate_to = timeChange(creationdate_to);

            }else {
                creationdate_to ='';
            }
           // alert(creationdate_from);
           var url_l = $('con_penalty_reduction_link_id').getUrl() + '?penalty_batch_number=' + penalty_batch_number+'&created_by_n='+created_by_n+'&status='+status+'&creationdate_from='+creationdate_from+'&creationdate_to='+creationdate_to;
           var OpenWindow = window.open(href = url_l, target = "_blank");

        }


        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
            open_contract_win123();
        };
        //导出
        window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function () {
            download_penalty_reduction();
        };

        //超链接渲染
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record, bp_seq) {
            var link_function = '';
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            if (name == 'record_detail') {
                link_function = open_contract_detail_win;
                return '<a href="javascript:open_contract_detail_win(\'' + record.ds.id + '\',\'' + record.id + '\');">查看明细</a>';
            }
        };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
